[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 44/81] virtio-net: support queue_enable
From: |
Michael S. Tsirkin |
Subject: |
[PULL v3 44/81] virtio-net: support queue_enable |
Date: |
Sat, 5 Nov 2022 13:17:35 -0400 |
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>
Message-Id: <20221017092558.111082-14-xuanzhuo@linux.alibaba.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@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 34fb4b1423..e68daf51bb 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);
@@ -3845,6 +3865,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;
--
MST
- Re: [PULL v3 49/81] acpi: pc: vga: use AcpiDevAmlIf interface to build VGA device descriptors, (continued)
[PULL v3 51/81] acpi: pc/q35: drop ad-hoc PCI-ISA bridge AML routines and let bus ennumeration generate AML, Michael S. Tsirkin, 2022/11/05
[PULL v3 59/81] tests: acpi: update expected blobs, Michael S. Tsirkin, 2022/11/05
[PULL v3 36/81] virtio-pci: support queue reset, Michael S. Tsirkin, 2022/11/05
[PULL v3 43/81] virtio-net: support queue reset, Michael S. Tsirkin, 2022/11/05
[PULL v3 47/81] virtio-rng-pci: Allow setting nvectors, so we can use MSI-X, Michael S. Tsirkin, 2022/11/05
[PULL v3 48/81] vhost-user: Fix out of order vring host notification handling, Michael S. Tsirkin, 2022/11/05
[PULL v3 68/81] tests: acpi: add and whitelist *.hmat-noinitiator expected blobs, Michael S. Tsirkin, 2022/11/05
[PULL v3 44/81] virtio-net: support queue_enable,
Michael S. Tsirkin <=
[PULL v3 53/81] tests: acpi: whitelist DSDT before generating ICH9_SMB AML automatically, Michael S. Tsirkin, 2022/11/05
[PULL v3 61/81] MAINTAINERS: Add qapi/virtio.json to section "virtio", Michael S. Tsirkin, 2022/11/05
[PULL v3 64/81] hw/i386/acpi-build: Remove unused struct, Michael S. Tsirkin, 2022/11/05
[PULL v3 60/81] hw/acpi/erst.c: Fix memory handling issues, Michael S. Tsirkin, 2022/11/05
[PULL v3 65/81] hw/i386/acpi-build: Resolve redundant attribute, Michael S. Tsirkin, 2022/11/05
[PULL v3 39/81] vhost: expose vhost_virtqueue_stop(), Michael S. Tsirkin, 2022/11/05
[PULL v3 35/81] virtio: core: vq reset feature negotation support, Michael S. Tsirkin, 2022/11/05
[PULL v3 37/81] virtio-pci: support queue enable, Michael S. Tsirkin, 2022/11/05
[PULL v3 40/81] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_reset(), Michael S. Tsirkin, 2022/11/05
[PULL v3 46/81] virtio-net: enable vq reset feature, Michael S. Tsirkin, 2022/11/05