[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 43/82] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_r
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 43/82] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_reset() |
Date: |
Wed, 2 Nov 2022 12:10:21 -0400 |
From: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Introduce vhost_virtqueue_reset(), which can reset the specific
virtqueue in the device. Then it will unmap vrings and the desc
of the virtqueue.
Here we do not reuse the vhost_net_stop_one() or vhost_dev_stop(),
because they work at queue pair level. We do not use
vhost_virtqueue_stop() because it may stop the device in the
backend.
This patch only considers the case of vhost-kernel, when
NetClientDriver is NET_CLIENT_DRIVER_TAP.
Furthermore, we do not need net->nc->info->poll() because
it enables userspace datapath and we want to stop all
datapaths for this reset virtqueue here.
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-10-xuanzhuo@linux.alibaba.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/net/vhost_net.h | 2 ++
hw/net/vhost_net-stub.c | 6 ++++++
hw/net/vhost_net.c | 25 +++++++++++++++++++++++++
3 files changed, 33 insertions(+)
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
index 387e913e4e..85d85a4957 100644
--- a/include/net/vhost_net.h
+++ b/include/net/vhost_net.h
@@ -48,4 +48,6 @@ uint64_t vhost_net_get_acked_features(VHostNetState *net);
int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu);
+void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc,
+ int vq_index);
#endif
diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c
index 89d71cfb8e..2d745e359c 100644
--- a/hw/net/vhost_net-stub.c
+++ b/hw/net/vhost_net-stub.c
@@ -101,3 +101,9 @@ int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu)
{
return 0;
}
+
+void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc,
+ int vq_index)
+{
+
+}
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index d6924f5e57..519dced899 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -531,3 +531,28 @@ int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu)
return vhost_ops->vhost_net_set_mtu(&net->dev, mtu);
}
+
+void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc,
+ int vq_index)
+{
+ VHostNetState *net = get_vhost_net(nc->peer);
+ const VhostOps *vhost_ops = net->dev.vhost_ops;
+ struct vhost_vring_file file = { .fd = -1 };
+ int idx;
+
+ /* should only be called after backend is connected */
+ assert(vhost_ops);
+
+ idx = vhost_ops->vhost_get_vq_index(&net->dev, vq_index);
+
+ if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
+ file.index = idx;
+ int r = vhost_net_set_backend(&net->dev, &file);
+ assert(r >= 0);
+ }
+
+ vhost_virtqueue_stop(&net->dev,
+ vdev,
+ net->dev.vqs + idx,
+ net->dev.vq_index + idx);
+}
--
MST
- [PULL v2 34/82] virtio: re-order vm_running and use_started checks, (continued)
- [PULL v2 34/82] virtio: re-order vm_running and use_started checks, Michael S. Tsirkin, 2022/11/02
- [PULL v2 35/82] virtio: introduce __virtio_queue_reset(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 33/82] hw/virtio/virtio-iommu-pci: Enforce the device is plugged on the root bus, Michael S. Tsirkin, 2022/11/02
- [PULL v2 37/82] virtio: introduce virtio_queue_enable(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 38/82] virtio: core: vq reset feature negotation support, Michael S. Tsirkin, 2022/11/02
- [PULL v2 36/82] virtio: introduce virtio_queue_reset(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 40/82] virtio-pci: support queue enable, Michael S. Tsirkin, 2022/11/02
- [PULL v2 42/82] vhost: expose vhost_virtqueue_stop(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 39/82] virtio-pci: support queue reset, Michael S. Tsirkin, 2022/11/02
- [PULL v2 41/82] vhost: expose vhost_virtqueue_start(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 43/82] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_reset(),
Michael S. Tsirkin <=
- [PULL v2 44/82] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_restart(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 45/82] virtio-net: introduce flush_or_purge_queued_packets(), Michael S. Tsirkin, 2022/11/02
- [PULL v2 47/82] virtio-net: support queue_enable, Michael S. Tsirkin, 2022/11/02
- [PULL v2 46/82] virtio-net: support queue reset, Michael S. Tsirkin, 2022/11/02
- [PULL v2 50/82] virtio-rng-pci: Allow setting nvectors, so we can use MSI-X, Michael S. Tsirkin, 2022/11/02
- [PULL v2 48/82] vhost: vhost-kernel: enable vq reset feature, Michael S. Tsirkin, 2022/11/02
- [PULL v2 51/82] vhost-user: Fix out of order vring host notification handling, Michael S. Tsirkin, 2022/11/02
- [PULL v2 49/82] virtio-net: enable vq reset feature, Michael S. Tsirkin, 2022/11/02
- [PULL v2 53/82] tests: acpi: whitelist DSDT before generating PCI-ISA bridge AML automatically, Michael S. Tsirkin, 2022/11/02
- [PULL v2 52/82] acpi: pc: vga: use AcpiDevAmlIf interface to build VGA device descriptors, Michael S. Tsirkin, 2022/11/02