aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangjie Xu <kangjie.xu@linux.alibaba.com>2022-10-17 17:25:54 +0800
committerMichael S. Tsirkin <mst@redhat.com>2022-11-07 13:12:20 -0500
commit4fdf69ab691e513280a3b5529de997d95a29f358 (patch)
treeaa56f76a877a8dd7be69bcf47c33e54cd2d3df1e
parent10f8a115a862045a836932c5d519a848dda5d461 (diff)
downloadqemu-4fdf69ab691e513280a3b5529de997d95a29f358.zip
qemu-4fdf69ab691e513280a3b5529de997d95a29f358.tar.gz
qemu-4fdf69ab691e513280a3b5529de997d95a29f358.tar.bz2
virtio-net: introduce flush_or_purge_queued_packets()
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>
-rw-r--r--hw/net/virtio-net.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index b6903ae..038a6fb 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));
}
}