105 lines
3.8 KiB
Diff
105 lines
3.8 KiB
Diff
From 1ae2ad1afcb032dc933104da5ad922173961caf8 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
|
|
Date: Mon, 14 Mar 2022 18:34:46 +0100
|
|
Subject: [PATCH] vdpa: adapt vhost_ops callbacks to svq
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
First half of the buffers forwarding part, preparing vhost-vdpa
|
|
callbacks to SVQ to offer it. QEMU cannot enable it at this moment, so
|
|
this is effectively dead code at the moment, but it helps to reduce
|
|
patch size.
|
|
|
|
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
|
Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
|
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
|
---
|
|
hw/virtio/vhost-vdpa.c | 48 ++++++++++++++++++++++++++++++++++++------
|
|
1 file changed, 41 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
|
|
index 8ee63933a8..2f0e6a9bef 100644
|
|
--- a/hw/virtio/vhost-vdpa.c
|
|
+++ b/hw/virtio/vhost-vdpa.c
|
|
@@ -735,6 +735,13 @@ static int vhost_vdpa_get_config(struct vhost_dev *dev, uint8_t *config,
|
|
return ret;
|
|
}
|
|
|
|
+static int vhost_vdpa_set_dev_vring_base(struct vhost_dev *dev,
|
|
+ struct vhost_vring_state *ring)
|
|
+{
|
|
+ trace_vhost_vdpa_set_vring_base(dev, ring->index, ring->num);
|
|
+ return vhost_vdpa_call(dev, VHOST_SET_VRING_BASE, ring);
|
|
+}
|
|
+
|
|
static int vhost_vdpa_set_vring_dev_kick(struct vhost_dev *dev,
|
|
struct vhost_vring_file *file)
|
|
{
|
|
@@ -749,6 +756,18 @@ static int vhost_vdpa_set_vring_dev_call(struct vhost_dev *dev,
|
|
return vhost_vdpa_call(dev, VHOST_SET_VRING_CALL, file);
|
|
}
|
|
|
|
+static int vhost_vdpa_set_vring_dev_addr(struct vhost_dev *dev,
|
|
+ struct vhost_vring_addr *addr)
|
|
+{
|
|
+ trace_vhost_vdpa_set_vring_addr(dev, addr->index, addr->flags,
|
|
+ addr->desc_user_addr, addr->used_user_addr,
|
|
+ addr->avail_user_addr,
|
|
+ addr->log_guest_addr);
|
|
+
|
|
+ return vhost_vdpa_call(dev, VHOST_SET_VRING_ADDR, addr);
|
|
+
|
|
+}
|
|
+
|
|
/**
|
|
* Set the shadow virtqueue descriptors to the device
|
|
*
|
|
@@ -858,11 +877,17 @@ static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base,
|
|
static int vhost_vdpa_set_vring_addr(struct vhost_dev *dev,
|
|
struct vhost_vring_addr *addr)
|
|
{
|
|
- trace_vhost_vdpa_set_vring_addr(dev, addr->index, addr->flags,
|
|
- addr->desc_user_addr, addr->used_user_addr,
|
|
- addr->avail_user_addr,
|
|
- addr->log_guest_addr);
|
|
- return vhost_vdpa_call(dev, VHOST_SET_VRING_ADDR, addr);
|
|
+ struct vhost_vdpa *v = dev->opaque;
|
|
+
|
|
+ if (v->shadow_vqs_enabled) {
|
|
+ /*
|
|
+ * Device vring addr was set at device start. SVQ base is handled by
|
|
+ * VirtQueue code.
|
|
+ */
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ return vhost_vdpa_set_vring_dev_addr(dev, addr);
|
|
}
|
|
|
|
static int vhost_vdpa_set_vring_num(struct vhost_dev *dev,
|
|
@@ -875,8 +900,17 @@ static int vhost_vdpa_set_vring_num(struct vhost_dev *dev,
|
|
static int vhost_vdpa_set_vring_base(struct vhost_dev *dev,
|
|
struct vhost_vring_state *ring)
|
|
{
|
|
- trace_vhost_vdpa_set_vring_base(dev, ring->index, ring->num);
|
|
- return vhost_vdpa_call(dev, VHOST_SET_VRING_BASE, ring);
|
|
+ struct vhost_vdpa *v = dev->opaque;
|
|
+
|
|
+ if (v->shadow_vqs_enabled) {
|
|
+ /*
|
|
+ * Device vring base was set at device start. SVQ base is handled by
|
|
+ * VirtQueue code.
|
|
+ */
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ return vhost_vdpa_set_dev_vring_base(dev, ring);
|
|
}
|
|
|
|
static int vhost_vdpa_get_vring_base(struct vhost_dev *dev,
|
|
--
|
|
2.27.0
|
|
|