]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
vhost-vdpa: uAPI to get dedicated descriptor group id
authorSi-Wei Liu <si-wei.liu@oracle.com>
Wed, 18 Oct 2023 17:14:43 +0000 (20:14 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 1 Nov 2023 13:19:55 +0000 (09:19 -0400)
With _F_DESC_ASID backend feature, the device can now support the
VHOST_VDPA_GET_VRING_DESC_GROUP ioctl, and it may expose the descriptor
table (including avail and used ring) in a different group than the
buffers it contains. This new uAPI will fetch the group ID of the
descriptor table.

Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20231018171456.1624030-6-dtatulea@nvidia.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Si-Wei Liu <si-wei.liu@oracle.com>
Tested-by: Si-Wei Liu <si-wei.liu@oracle.com>
Tested-by: Lei Yang <leiyang@redhat.com>
drivers/vhost/vdpa.c
include/uapi/linux/vhost.h

index 2f21798a37ee01ce505523a167e91ede72609f08..851535f57b958937c64fdcf2465afcc2ae51bdbf 100644 (file)
@@ -613,6 +613,16 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
                else if (copy_to_user(argp, &s, sizeof(s)))
                        return -EFAULT;
                return 0;
+       case VHOST_VDPA_GET_VRING_DESC_GROUP:
+               if (!vhost_vdpa_has_desc_group(v))
+                       return -EOPNOTSUPP;
+               s.index = idx;
+               s.num = ops->get_vq_desc_group(vdpa, idx);
+               if (s.num >= vdpa->ngroups)
+                       return -EIO;
+               else if (copy_to_user(argp, &s, sizeof(s)))
+                       return -EFAULT;
+               return 0;
        case VHOST_VDPA_SET_GROUP_ASID:
                if (copy_from_user(&s, argp, sizeof(s)))
                        return -EFAULT;
index f5c48b61ab62244104bbf1b2100d3db7286f8c82..649560c685f13b73feaafb96b64c351b6eec2c25 100644 (file)
  */
 #define VHOST_VDPA_RESUME              _IO(VHOST_VIRTIO, 0x7E)
 
+/* Get the group for the descriptor table including driver & device areas
+ * of a virtqueue: read index, write group in num.
+ * The virtqueue index is stored in the index field of vhost_vring_state.
+ * The group ID of the descriptor table for this specific virtqueue
+ * is returned via num field of vhost_vring_state.
+ */
+#define VHOST_VDPA_GET_VRING_DESC_GROUP        _IOWR(VHOST_VIRTIO, 0x7F,       \
+                                             struct vhost_vring_state)
 #endif