[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 20/24] virtio-net: introduce flush_or_purge_queued_packets()
From: |
Kangjie Xu |
Subject: |
[PATCH v2 20/24] virtio-net: introduce flush_or_purge_queued_packets() |
Date: |
Tue, 16 Aug 2022 09:06:32 +0800 |
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>
---
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 dd0d056fde..27b59c0ad6 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -118,6 +118,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.
*/
@@ -560,12 +570,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));
}
}
--
2.32.0
- [PATCH v2 08/24] vhost: extract the logic of unmapping the vrings and desc, (continued)
[PATCH v2 20/24] virtio-net: introduce flush_or_purge_queued_packets(),
Kangjie Xu <=
[PATCH v2 22/24] virtio-net: support queue_enable, Kangjie Xu, 2022/08/15
[PATCH v2 24/24] vhost: vhost-user: enable vq reset feature, Kangjie Xu, 2022/08/15
[PATCH v2 19/24] vhost-net: vhost-user: update vhost_net_virtqueue_restart(), Kangjie Xu, 2022/08/15
Re: [PATCH 00/24] Support VIRTIO_F_RING_RESET for virtio-net, vhost-user, vhost-kernel in virtio pci-modern, Michael S. Tsirkin, 2022/08/16
- Re: [PATCH 00/24] Support VIRTIO_F_RING_RESET for virtio-net, vhost-user, vhost-kernel in virtio pci-modern, Xuan Zhuo, 2022/08/16
- Re: [PATCH 00/24] Support VIRTIO_F_RING_RESET for virtio-net, vhost-user, vhost-kernel in virtio pci-modern, Michael S. Tsirkin, 2022/08/16
- Re: [PATCH 00/24] Support VIRTIO_F_RING_RESET for virtio-net, vhost-user, vhost-kernel in virtio pci-modern, Xuan Zhuo, 2022/08/16
- Re: [PATCH 00/24] Support VIRTIO_F_RING_RESET for virtio-net, vhost-user, vhost-kernel in virtio pci-modern, Kangjie Xu, 2022/08/17
Re: [PATCH 00/24] Support VIRTIO_F_RING_RESET for virtio-net, vhost-user, vhost-kernel in virtio pci-modern, Kangjie Xu, 2022/08/22