[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 42/81] virtio-net: introduce flush_or_purge_queued_packets()
From: |
Michael S. Tsirkin |
Subject: |
[PULL v3 42/81] virtio-net: introduce flush_or_purge_queued_packets() |
Date: |
Sat, 5 Nov 2022 13:17:29 -0400 |
From: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Introduce the fucntion flush_or_purge_queued_packets(), it will be
used in device reset and virtqueue reset. Therefore, we extract the
common logic as a new function.
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-12-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 | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index b6903aea54..038a6fba7c 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -124,6 +124,16 @@ static int vq2q(int queue_index)
return queue_index / 2;
}
+static void flush_or_purge_queued_packets(NetClientState *nc)
+{
+ if (!nc->peer) {
+ return;
+ }
+
+ qemu_flush_or_purge_queued_packets(nc->peer, true);
+ assert(!virtio_net_get_subqueue(nc)->async_tx.elem);
+}
+
/* TODO
* - we could suppress RX interrupt if we were so inclined.
*/
@@ -566,12 +576,7 @@ static void virtio_net_reset(VirtIODevice *vdev)
/* Flush any async TX */
for (i = 0; i < n->max_queue_pairs; i++) {
- NetClientState *nc = qemu_get_subqueue(n->nic, i);
-
- if (nc->peer) {
- qemu_flush_or_purge_queued_packets(nc->peer, true);
- assert(!virtio_net_get_subqueue(nc)->async_tx.elem);
- }
+ flush_or_purge_queued_packets(qemu_get_subqueue(n->nic, i));
}
}
--
MST
- [PULL v3 63/81] hw/i386/pc.c: CXL Fixed Memory Window should not reserve e820 in bios, (continued)
- [PULL v3 63/81] hw/i386/pc.c: CXL Fixed Memory Window should not reserve e820 in bios, Michael S. Tsirkin, 2022/11/05
- [PULL v3 66/81] hw/i386/acpi-build: Resolve north rather than south bridges, Michael S. Tsirkin, 2022/11/05
- [PULL v3 70/81] tests: acpi: q35: update expected blobs *.hmat-noinitiators expected HMAT:, Michael S. Tsirkin, 2022/11/05
- [PULL v3 76/81] intel-iommu: don't warn guest errors when getting rid2pasid entry, Michael S. Tsirkin, 2022/11/05
- [PULL v3 80/81] vhost: Change the sequence of device start, Michael S. Tsirkin, 2022/11/05
- [PULL v3 41/81] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_restart(), Michael S. Tsirkin, 2022/11/05
- [PULL v3 50/81] tests: acpi: whitelist DSDT before generating PCI-ISA bridge AML automatically, Michael S. Tsirkin, 2022/11/05
- [PULL v3 42/81] virtio-net: introduce flush_or_purge_queued_packets(),
Michael S. Tsirkin <=
- [PULL v3 56/81] tests: acpi: update expected blobs, Michael S. Tsirkin, 2022/11/05
- [PULL v3 57/81] tests: acpi: pc/q35 whitelist DSDT before \_GPE cleanup, Michael S. Tsirkin, 2022/11/05
- [PULL v3 28/81] hw/cxl/cdat: CXL CDAT Data Object Exchange implementation, Michael S. Tsirkin, 2022/11/05
- [PULL v3 72/81] hw/arm/virt: Enable HMAT on arm virt machine, Michael S. Tsirkin, 2022/11/05
- [PULL v3 73/81] tests: acpi: aarch64/virt: add a test for hmat nodes with no initiators, Michael S. Tsirkin, 2022/11/05
- [PULL v3 74/81] tests: virt: Update expected *.acpihmatvirt tables, Michael S. Tsirkin, 2022/11/05
- [PULL v3 79/81] intel-iommu: PASID support, Michael S. Tsirkin, 2022/11/05
- [PULL v3 62/81] msix: Assert that specified vector is in range, Michael S. Tsirkin, 2022/11/05
- [PULL v3 67/81] hmat acpi: Don't require initiator value in -numa, Michael S. Tsirkin, 2022/11/05
- [PULL v3 69/81] tests: acpi: q35: add test for hmat nodes without initiators, Michael S. Tsirkin, 2022/11/05