[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 13/15] virtio-net: support queue_enable
From: |
Xuan Zhuo |
Subject: |
[PATCH v6 13/15] virtio-net: support queue_enable |
Date: |
Mon, 17 Oct 2022 17:25:56 +0800 |
From: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Support queue_enable in vhost-kernel scenario. It can be called when
a vq reset operation has been performed and the vq is restared.
It should be noted that we can restart the vq when the vhost has
already started. When launching a new vhost device, the vhost is not
started and all vqs are not initalized until VIRTIO_PCI_COMMON_STATUS
is written. Thus, we should use vhost_started to differentiate the
two cases: vq reset and device start.
Currently it only supports vhost-kernel.
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
hw/net/virtio-net.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 8feeb032b4..f5adba45d5 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -563,6 +563,26 @@ static void virtio_net_queue_reset(VirtIODevice *vdev,
uint32_t queue_index)
flush_or_purge_queued_packets(nc);
}
+static void virtio_net_queue_enable(VirtIODevice *vdev, uint32_t queue_index)
+{
+ VirtIONet *n = VIRTIO_NET(vdev);
+ NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(queue_index));
+ int r;
+
+ if (!nc->peer || !vdev->vhost_started) {
+ return;
+ }
+
+ if (get_vhost_net(nc->peer) &&
+ nc->peer->info->type == NET_CLIENT_DRIVER_TAP) {
+ r = vhost_net_virtqueue_restart(vdev, nc, queue_index);
+ if (r < 0) {
+ error_report("unable to restart vhost net virtqueue: %d, "
+ "when resetting the queue", queue_index);
+ }
+ }
+}
+
static void virtio_net_reset(VirtIODevice *vdev)
{
VirtIONet *n = VIRTIO_NET(vdev);
@@ -3802,6 +3822,7 @@ static void virtio_net_class_init(ObjectClass *klass,
void *data)
vdc->bad_features = virtio_net_bad_features;
vdc->reset = virtio_net_reset;
vdc->queue_reset = virtio_net_queue_reset;
+ vdc->queue_enable = virtio_net_queue_enable;
vdc->set_status = virtio_net_set_status;
vdc->guest_notifier_mask = virtio_net_guest_notifier_mask;
vdc->guest_notifier_pending = virtio_net_guest_notifier_pending;
--
2.32.0.3.g01195cf9f
- [PATCH v6 01/15] virtio: introduce __virtio_queue_reset(), (continued)
- [PATCH v6 01/15] virtio: introduce __virtio_queue_reset(), Xuan Zhuo, 2022/10/17
- [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 <=
- [PATCH v6 06/15] virtio-pci: support queue enable, Xuan Zhuo, 2022/10/17
- [PATCH v6 09/15] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_reset(), Xuan Zhuo, 2022/10/17
- [PATCH v6 05/15] virtio-pci: support queue reset, Xuan Zhuo, 2022/10/17