[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 46/82] virtio-net: support queue reset
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 46/82] virtio-net: support queue reset |
Date: |
Wed, 2 Nov 2022 12:10:29 -0400 |
From: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
virtio-net and vhost-kernel implement queue reset.
Queued packets in the corresponding queue pair are flushed
or purged.
For virtio-net, userspace datapath will be disabled later in
__virtio_queue_reset(). It will set addr of vring to 0 and idx to 0.
Thus, virtio_net_receive() and virtio_net_flush_tx() will not receive
or send packets.
For vhost-net, the datapath will be disabled in vhost_net_virtqueue_reset().
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20221017092558.111082-13-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 | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 038a6fba7c..34fb4b1423 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -546,6 +546,23 @@ static RxFilterInfo
*virtio_net_query_rxfilter(NetClientState *nc)
return info;
}
+static void virtio_net_queue_reset(VirtIODevice *vdev, uint32_t queue_index)
+{
+ VirtIONet *n = VIRTIO_NET(vdev);
+ NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(queue_index));
+
+ if (!nc->peer) {
+ return;
+ }
+
+ if (get_vhost_net(nc->peer) &&
+ nc->peer->info->type == NET_CLIENT_DRIVER_TAP) {
+ vhost_net_virtqueue_reset(vdev, nc, queue_index);
+ }
+
+ flush_or_purge_queued_packets(nc);
+}
+
static void virtio_net_reset(VirtIODevice *vdev)
{
VirtIONet *n = VIRTIO_NET(vdev);
@@ -3827,6 +3844,7 @@ static void virtio_net_class_init(ObjectClass *klass,
void *data)
vdc->set_features = virtio_net_set_features;
vdc->bad_features = virtio_net_bad_features;
vdc->reset = virtio_net_reset;
+ vdc->queue_reset = virtio_net_queue_reset;
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
- [PULL v2 38/82] virtio: core: vq reset feature negotation support, (continued)
- [PULL v2 38/82] virtio: core: vq reset feature negotation support, Michael S. Tsirkin, 2022/11/02
- [PULL v2 36/82] virtio: introduce virtio_queue_reset(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 40/82] virtio-pci: support queue enable, Michael S. Tsirkin, 2022/11/02
- [PULL v2 42/82] vhost: expose vhost_virtqueue_stop(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 39/82] virtio-pci: support queue reset, Michael S. Tsirkin, 2022/11/02
- [PULL v2 41/82] vhost: expose vhost_virtqueue_start(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 43/82] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_reset(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 44/82] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_restart(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 45/82] virtio-net: introduce flush_or_purge_queued_packets(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 47/82] virtio-net: support queue_enable, Michael S. Tsirkin, 2022/11/02
- [PULL v2 46/82] virtio-net: support queue reset,
Michael S. Tsirkin <=
- [PULL v2 50/82] virtio-rng-pci: Allow setting nvectors, so we can use MSI-X, Michael S. Tsirkin, 2022/11/02
- [PULL v2 48/82] vhost: vhost-kernel: enable vq reset feature, Michael S. Tsirkin, 2022/11/02
- [PULL v2 51/82] vhost-user: Fix out of order vring host notification handling, Michael S. Tsirkin, 2022/11/02
- [PULL v2 49/82] virtio-net: enable vq reset feature, Michael S. Tsirkin, 2022/11/02
- [PULL v2 53/82] tests: acpi: whitelist DSDT before generating PCI-ISA bridge AML automatically, Michael S. Tsirkin, 2022/11/02
- [PULL v2 52/82] acpi: pc: vga: use AcpiDevAmlIf interface to build VGA device descriptors, Michael S. Tsirkin, 2022/11/02
- [PULL v2 56/82] tests: acpi: whitelist DSDT before generating ICH9_SMB AML automatically, Michael S. Tsirkin, 2022/11/02
- [PULL v2 55/82] tests: acpi: update expected DSDT after ISA bridge is moved directly under PCI host bridge, Michael S. Tsirkin, 2022/11/02
- [PULL v2 54/82] acpi: pc/q35: drop ad-hoc PCI-ISA bridge AML routines and let bus ennumeration generate AML, Michael S. Tsirkin, 2022/11/02
- [PULL v2 60/82] tests: acpi: pc/q35 whitelist DSDT before \_GPE cleanup, Michael S. Tsirkin, 2022/11/02