[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 22/24] virtio-net: support queue_enable
From: |
Kangjie Xu |
Subject: |
[PATCH v2 22/24] virtio-net: support queue_enable |
Date: |
Tue, 16 Aug 2022 09:06:34 +0800 |
virtio-net: support queue_enable for vhost
Support queue_enable in vhost scenario. It can be called when
a vq reset operation is performed and the vq will be restared.
It should be noted that we can restart the vq when the vhost has
already started. When launching a new vhost-user device, the vhost
is not started and all vqs are not initalized until
VIRTIO_PCI_COMMON_STATUS is written. Thus, we should use vhost_started
to differentiate the two cases: vq reset and device start.
Currently it only supports vhost-user and vhost-kernel.
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
hw/net/virtio-net.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index e2989487ec..ba216f7b84 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -558,6 +558,27 @@ static void virtio_net_queue_reset(VirtIODevice *vdev,
uint32_t queue_index)
flush_or_purge_queued_packets(nc);
}
+static void virtio_net_queue_enable(VirtIODevice *vdev, uint32_t queue_index)
+{
+ VirtIONet *n = VIRTIO_NET(vdev);
+ NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(queue_index));
+ int r;
+
+ if (!nc->peer || !vdev->vhost_started) {
+ return;
+ }
+
+ if (get_vhost_net(nc->peer) &&
+ ((nc->peer->info->type == NET_CLIENT_DRIVER_TAP) ||
+ (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER))) {
+ r = vhost_net_virtqueue_restart(vdev, nc, queue_index);
+ if (r < 0) {
+ error_report("unable to restart vhost net virtqueue: %d, "
+ "when resetting the queue", queue_index);
+ }
+ }
+}
+
static void virtio_net_reset(VirtIODevice *vdev)
{
VirtIONet *n = VIRTIO_NET(vdev);
@@ -3803,6 +3824,7 @@ static void virtio_net_class_init(ObjectClass *klass,
void *data)
vdc->bad_features = virtio_net_bad_features;
vdc->reset = virtio_net_reset;
vdc->queue_reset = virtio_net_queue_reset;
+ vdc->queue_enable = virtio_net_queue_enable;
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 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, 2022/08/15
[PATCH v2 22/24] virtio-net: support queue_enable,
Kangjie Xu <=
[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
Re: [PATCH 00/24] Support VIRTIO_F_RING_RESET for virtio-net, vhost-user, vhost-kernel in virtio pci-modern, Jason Wang, 2022/08/24