[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 21/24] virtio-net: support queue reset
From: |
Kangjie Xu |
Subject: |
[PATCH v2 21/24] virtio-net: support queue reset |
Date: |
Tue, 16 Aug 2022 09:06:33 +0800 |
From: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
virtio-net, vhost-kernel, vhost-user implement queue reset.
Queued packets in the corresponding queue pair are flushed
or purged.
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
---
hw/net/virtio-net.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 27b59c0ad6..e2989487ec 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -540,6 +540,24 @@ 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) ||
+ (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER))) {
+ vhost_net_virtqueue_stop(vdev, nc, queue_index);
+ }
+
+ flush_or_purge_queued_packets(nc);
+}
+
static void virtio_net_reset(VirtIODevice *vdev)
{
VirtIONet *n = VIRTIO_NET(vdev);
@@ -3784,6 +3802,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;
--
2.32.0
- Re: [PATCH v2 12/24] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_restart(), (continued)
[PATCH v2 13/24] docs: vhost-user: add VHOST_USER_RESET_VRING message, Kangjie Xu, 2022/08/15
[PATCH v2 15/24] vhost-user: add op to enable or disable a single vring, Kangjie Xu, 2022/08/15
[PATCH v2 23/24] vhost: vhost-kernel: enable vq reset feature, Kangjie Xu, 2022/08/15
[PATCH v2 21/24] virtio-net: support queue reset,
Kangjie Xu <=
[PATCH v2 16/24] vhost: vhost-user: update vhost_dev_virtqueue_stop(), Kangjie Xu, 2022/08/15
[PATCH v2 08/24] vhost: extract the logic of unmapping the vrings and desc, Kangjie Xu, 2022/08/15
[PATCH v2 17/24] vhost: vhost-user: update vhost_dev_virtqueue_restart(), Kangjie Xu, 2022/08/15
[PATCH v2 18/24] vhost-net: vhost-user: update vhost_net_virtqueue_stop(), Kangjie Xu, 2022/08/15