Skip to content

Commit c8068d9

Browse files
siwliu-kernelmstsirkin
authored andcommitted
vhost-vdpa: uAPI to get dedicated descriptor group id
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 <[email protected]> Acked-by: Eugenio Pérez <[email protected]> Acked-by: Jason Wang <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Si-Wei Liu <[email protected]> Tested-by: Si-Wei Liu <[email protected]> Tested-by: Lei Yang <[email protected]>
1 parent 7db0d60 commit c8068d9

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

drivers/vhost/vdpa.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,16 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
613613
else if (copy_to_user(argp, &s, sizeof(s)))
614614
return -EFAULT;
615615
return 0;
616+
case VHOST_VDPA_GET_VRING_DESC_GROUP:
617+
if (!vhost_vdpa_has_desc_group(v))
618+
return -EOPNOTSUPP;
619+
s.index = idx;
620+
s.num = ops->get_vq_desc_group(vdpa, idx);
621+
if (s.num >= vdpa->ngroups)
622+
return -EIO;
623+
else if (copy_to_user(argp, &s, sizeof(s)))
624+
return -EFAULT;
625+
return 0;
616626
case VHOST_VDPA_SET_GROUP_ASID:
617627
if (copy_from_user(&s, argp, sizeof(s)))
618628
return -EFAULT;

include/uapi/linux/vhost.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,12 @@
219219
*/
220220
#define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E)
221221

222+
/* Get the group for the descriptor table including driver & device areas
223+
* of a virtqueue: read index, write group in num.
224+
* The virtqueue index is stored in the index field of vhost_vring_state.
225+
* The group ID of the descriptor table for this specific virtqueue
226+
* is returned via num field of vhost_vring_state.
227+
*/
228+
#define VHOST_VDPA_GET_VRING_DESC_GROUP _IOWR(VHOST_VIRTIO, 0x7F, \
229+
struct vhost_vring_state)
222230
#endif

0 commit comments

Comments
 (0)