[RFC 4/4] vduse: update the vq_info in ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Your Name <you@xxxxxxxxxxx>

in VDUSE_VQ_GET_INFO, driver will sync the last_avail_idx
with reconnect info, I have olny test the split mode, so
only use this here, will add more information later

Signed-off-by: Cindy Lu <lulu@xxxxxxxxxx>
---
 drivers/vdpa/vdpa_user/vduse_dev.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index 3df1256eccb4..b8e453eac0ce 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -141,6 +141,11 @@ static u32 allowed_device_id[] = {
 	VIRTIO_ID_NET,
 };
 
+struct vhost_reconnect_vring {
+	uint16_t last_avail_idx;
+	bool avail_wrap_counter;
+};
+
 static inline struct vduse_dev *vdpa_to_vduse(struct vdpa_device *vdpa)
 {
 	struct vduse_vdpa *vdev = container_of(vdpa, struct vduse_vdpa, vdpa);
@@ -1176,6 +1181,17 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
 				vq->state.split.avail_index;
 
 		vq_info.ready = vq->ready;
+		struct vdpa_reconnect_info *area;
+
+		area = &dev->reconnect_info[index];
+		struct vhost_reconnect_vring *log_reconnect;
+
+		log_reconnect = (struct vhost_reconnect_vring *)area->vaddr;
+		if (log_reconnect->last_avail_idx !=
+		    vq_info.split.avail_index) {
+			vq_info.split.avail_index =
+				log_reconnect->last_avail_idx;
+		}
 
 		ret = -EFAULT;
 		if (copy_to_user(argp, &vq_info, sizeof(vq_info)))
-- 
2.34.3




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux