[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 01/15] virtio: introduce __virtio_queue_reset()
From: |
Xuan Zhuo |
Subject: |
[PATCH v6 01/15] virtio: introduce __virtio_queue_reset() |
Date: |
Mon, 17 Oct 2022 17:25:44 +0800 |
Separate the logic of vq reset. This logic will be called directly
later.
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Acked-by: Jason Wang <jasowang@redhat.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 808446b4c9..6f42fcadd7 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2464,6 +2464,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;
@@ -2495,22 +2515,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.3.g01195cf9f
- [PATCH v6 00/15] Support VIRTIO_F_RING_RESET for virtio-net, vhost-net kernel in virtio pci-modern, Xuan Zhuo, 2022/10/17
- [PATCH v6 02/15] virtio: introduce virtio_queue_reset(), Xuan Zhuo, 2022/10/17
- [PATCH v6 01/15] virtio: introduce __virtio_queue_reset(),
Xuan Zhuo <=
- [PATCH v6 08/15] vhost: expose vhost_virtqueue_stop(), Xuan Zhuo, 2022/10/17
- [PATCH v6 07/15] vhost: expose vhost_virtqueue_start(), Xuan Zhuo, 2022/10/17
- [PATCH v6 11/15] virtio-net: introduce flush_or_purge_queued_packets(), Xuan Zhuo, 2022/10/17
- [PATCH v6 03/15] virtio: introduce virtio_queue_enable(), Xuan Zhuo, 2022/10/17
- [PATCH v6 12/15] virtio-net: support queue reset, Xuan Zhuo, 2022/10/17
- [PATCH v6 04/15] virtio: core: vq reset feature negotation support, Xuan Zhuo, 2022/10/17
- [PATCH v6 14/15] vhost: vhost-kernel: enable vq reset feature, Xuan Zhuo, 2022/10/17
- [PATCH v6 15/15] virtio-net: enable vq reset feature, Xuan Zhuo, 2022/10/17
- [PATCH v6 10/15] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_restart(), Xuan Zhuo, 2022/10/17
- [PATCH v6 13/15] virtio-net: support queue_enable, Xuan Zhuo, 2022/10/17