[PATCH 02/40] vdpa: add vhost_vdpa_get_vring_desc_group

Si-Wei Liu posted 40 patches 11 months, 3 weeks ago
[PATCH 02/40] vdpa: add vhost_vdpa_get_vring_desc_group
Posted by Si-Wei Liu 11 months, 3 weeks ago
Internal API to get the descriptor group index for a specific virtqueue
through the VHOST_VDPA_GET_VRING_DESC_GROUP ioctl.

Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
---
 net/vhost-vdpa.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 90f4128..887c329 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -471,6 +471,25 @@ static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index,
     return state.num;
 }
 
+static int64_t vhost_vdpa_get_vring_desc_group(int device_fd,
+                                               unsigned vq_index,
+                                               Error **errp)
+{
+    struct vhost_vring_state state = {
+        .index = vq_index,
+    };
+    int r = ioctl(device_fd, VHOST_VDPA_GET_VRING_DESC_GROUP, &state);
+
+    if (unlikely(r < 0)) {
+        r = -errno;
+        error_setg_errno(errp, errno, "Cannot get VQ %u descriptor group",
+                         vq_index);
+        return r;
+    }
+
+    return state.num;
+}
+
 static int vhost_vdpa_set_address_space_id(struct vhost_vdpa *v,
                                            unsigned vq_group,
                                            unsigned asid_num)
-- 
1.8.3.1
Re: [PATCH 02/40] vdpa: add vhost_vdpa_get_vring_desc_group
Posted by Jason Wang 10 months, 2 weeks ago
On Fri, Dec 8, 2023 at 2:50 AM Si-Wei Liu <si-wei.liu@oracle.com> wrote:
>
> Internal API to get the descriptor group index for a specific virtqueue
> through the VHOST_VDPA_GET_VRING_DESC_GROUP ioctl.
>
> Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>

Acked-by: Jason Wang <jasowang@redhat.com>

Thanks

> ---
>  net/vhost-vdpa.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index 90f4128..887c329 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -471,6 +471,25 @@ static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index,
>      return state.num;
>  }
>
> +static int64_t vhost_vdpa_get_vring_desc_group(int device_fd,
> +                                               unsigned vq_index,
> +                                               Error **errp)
> +{
> +    struct vhost_vring_state state = {
> +        .index = vq_index,
> +    };
> +    int r = ioctl(device_fd, VHOST_VDPA_GET_VRING_DESC_GROUP, &state);
> +
> +    if (unlikely(r < 0)) {
> +        r = -errno;
> +        error_setg_errno(errp, errno, "Cannot get VQ %u descriptor group",
> +                         vq_index);
> +        return r;
> +    }
> +
> +    return state.num;
> +}
> +
>  static int vhost_vdpa_set_address_space_id(struct vhost_vdpa *v,
>                                             unsigned vq_group,
>                                             unsigned asid_num)
> --
> 1.8.3.1
>