[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/16] virtio: introduce __virtio_queue_reset()
From: |
Kangjie Xu |
Subject: |
[PATCH 04/16] virtio: introduce __virtio_queue_reset() |
Date: |
Mon, 18 Jul 2022 19:17:01 +0800 |
From: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Separate the logic of vq reset. This logic will be called directly
later.
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
hw/virtio/virtio.c | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 5d607aeaa0..67d54832a9 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2019,6 +2019,26 @@ static enum virtio_device_endian
virtio_current_cpu_endian(void)
}
}
+static void __virtio_queue_reset(VirtIODevice *vdev, uint32_t i)
+{
+ vdev->vq[i].vring.desc = 0;
+ vdev->vq[i].vring.avail = 0;
+ vdev->vq[i].vring.used = 0;
+ vdev->vq[i].last_avail_idx = 0;
+ vdev->vq[i].shadow_avail_idx = 0;
+ vdev->vq[i].used_idx = 0;
+ vdev->vq[i].last_avail_wrap_counter = true;
+ vdev->vq[i].shadow_avail_wrap_counter = true;
+ vdev->vq[i].used_wrap_counter = true;
+ virtio_queue_set_vector(vdev, i, VIRTIO_NO_VECTOR);
+ vdev->vq[i].signalled_used = 0;
+ vdev->vq[i].signalled_used_valid = false;
+ vdev->vq[i].notification = true;
+ vdev->vq[i].vring.num = vdev->vq[i].vring.num_default;
+ vdev->vq[i].inuse = 0;
+ virtio_virtqueue_reset_region_cache(&vdev->vq[i]);
+}
+
void virtio_reset(void *opaque)
{
VirtIODevice *vdev = opaque;
@@ -2050,22 +2070,7 @@ void virtio_reset(void *opaque)
virtio_notify_vector(vdev, vdev->config_vector);
for(i = 0; i < VIRTIO_QUEUE_MAX; i++) {
- vdev->vq[i].vring.desc = 0;
- vdev->vq[i].vring.avail = 0;
- vdev->vq[i].vring.used = 0;
- vdev->vq[i].last_avail_idx = 0;
- vdev->vq[i].shadow_avail_idx = 0;
- vdev->vq[i].used_idx = 0;
- vdev->vq[i].last_avail_wrap_counter = true;
- vdev->vq[i].shadow_avail_wrap_counter = true;
- vdev->vq[i].used_wrap_counter = true;
- virtio_queue_set_vector(vdev, i, VIRTIO_NO_VECTOR);
- vdev->vq[i].signalled_used = 0;
- vdev->vq[i].signalled_used_valid = false;
- vdev->vq[i].notification = true;
- vdev->vq[i].vring.num = vdev->vq[i].vring.num_default;
- vdev->vq[i].inuse = 0;
- virtio_virtqueue_reset_region_cache(&vdev->vq[i]);
+ __virtio_queue_reset(vdev, i);
}
}
--
2.32.0
- [PATCH 13/16] virtio: introduce queue_enable in virtio, (continued)
- [PATCH 13/16] virtio: introduce queue_enable in virtio, Kangjie Xu, 2022/07/18
- [PATCH 08/16] vhost: add op to enable or disable a single vring, Kangjie Xu, 2022/07/18
- Re: [PATCH 08/16] vhost: add op to enable or disable a single vring, Jason Wang, 2022/07/25
- Re: [PATCH 08/16] vhost: add op to enable or disable a single vring, Kangjie Xu, 2022/07/26
- Re: [PATCH 08/16] vhost: add op to enable or disable a single vring, Jason Wang, 2022/07/27
- Re: [PATCH 08/16] vhost: add op to enable or disable a single vring, Kangjie Xu, 2022/07/27
- Re: [PATCH 08/16] vhost: add op to enable or disable a single vring, Jason Wang, 2022/07/27
- Re: [PATCH 08/16] vhost: add op to enable or disable a single vring, Kangjie Xu, 2022/07/28
[PATCH 04/16] virtio: introduce __virtio_queue_reset(),
Kangjie Xu <=
[PATCH 15/16] virtio-net: support queue_reset for vhost-user, Kangjie Xu, 2022/07/18
[PATCH 06/16] virtio-pci: support queue reset, Kangjie Xu, 2022/07/18
[PATCH 12/16] vhost-net: introduce restart and stop for vhost_net's vqs, Kangjie Xu, 2022/07/18
[PATCH 03/16] virtio: pci: virtio_pci_common_cfg add queue_reset, Kangjie Xu, 2022/07/18
[PATCH 09/16] vhost-user: enable/disable a single vring, Kangjie Xu, 2022/07/18