[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 3/3] virtio-net: pass Device-TLB enable/disable events to vhos
|
From: |
Viktor Prutyanov |
|
Subject: |
[PATCH v3 3/3] virtio-net: pass Device-TLB enable/disable events to vhost |
|
Date: |
Fri, 12 May 2023 16:51:22 +0300 |
If vhost is enabled for virtio-net, Device-TLB enable/disable events
must be passed to vhost for proper IOMMU unmap flag selection.
Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
---
hw/net/vhost_net.c | 11 +++++++++++
hw/net/virtio-net.c | 7 +++++++
include/net/vhost_net.h | 2 ++
3 files changed, 20 insertions(+)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index c4eecc6f36..df5c312993 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -552,6 +552,17 @@ 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_toggle_device_iotlb(struct vhost_dev *dev)
+{
+ const VhostOps *vhost_ops = dev->vhost_ops;
+
+ if (!vhost_ops->vhost_toggle_device_iotlb) {
+ return;
+ }
+
+ vhost_ops->vhost_toggle_device_iotlb(dev);
+}
+
void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc,
int vq_index)
{
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 447f669921..faba810db1 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3844,6 +3844,12 @@ static struct vhost_dev
*virtio_net_get_vhost(VirtIODevice *vdev)
return &net->dev;
}
+static void virtio_net_toggle_device_iotlb(VirtIODevice *vdev)
+{
+ if (vdev->vhost_started)
+ vhost_net_toggle_device_iotlb(virtio_net_get_vhost(vdev));
+}
+
static const VMStateDescription vmstate_virtio_net = {
.name = "virtio-net",
.minimum_version_id = VIRTIO_NET_VM_VERSION,
@@ -3949,6 +3955,7 @@ static void virtio_net_class_init(ObjectClass *klass,
void *data)
vdc->vmsd = &vmstate_virtio_net_device;
vdc->primary_unplug_pending = primary_unplug_pending;
vdc->get_vhost = virtio_net_get_vhost;
+ vdc->toggle_device_iotlb = virtio_net_toggle_device_iotlb;
}
static const TypeInfo virtio_net_info = {
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
index c37aba35e6..28d93ea8c5 100644
--- a/include/net/vhost_net.h
+++ b/include/net/vhost_net.h
@@ -56,4 +56,6 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev,
NetClientState *nc,
int vq_index);
void vhost_net_save_acked_features(NetClientState *nc);
+
+void vhost_net_toggle_device_iotlb(struct vhost_dev *dev);
#endif
--
2.35.1
[PATCH v3 3/3] virtio-net: pass Device-TLB enable/disable events to vhost,
Viktor Prutyanov <=