[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/15] vdpa: adapt vhost_ops callbacks to svq
|
From: |
Jason Wang |
|
Subject: |
[PULL 07/15] vdpa: adapt vhost_ops callbacks to svq |
|
Date: |
Tue, 8 Mar 2022 21:34:43 +0800 |
From: Eugenio Pérez <eperezma@redhat.com>
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.
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.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 77ad56e..6a7575f 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -732,6 +732,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)
{
@@ -746,6 +753,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
*
@@ -856,11 +875,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,
@@ -873,8 +898,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.7.4
- [PULL 00/15] Net patches, Jason Wang, 2022/03/08
- [PULL 01/15] virtio-net: fix map leaking on error during receive, Jason Wang, 2022/03/08
- [PULL 02/15] vhost: Add VhostShadowVirtqueue, Jason Wang, 2022/03/08
- [PULL 03/15] vhost: Add Shadow VirtQueue kick forwarding capabilities, Jason Wang, 2022/03/08
- [PULL 04/15] vhost: Add Shadow VirtQueue call forwarding capabilities, Jason Wang, 2022/03/08
- [PULL 06/15] virtio: Add vhost_svq_get_vring_addr, Jason Wang, 2022/03/08
- [PULL 05/15] vhost: Add vhost_svq_valid_features to shadow vq, Jason Wang, 2022/03/08
- [PULL 07/15] vdpa: adapt vhost_ops callbacks to svq,
Jason Wang <=
- [PULL 08/15] vhost: Shadow virtqueue buffers forwarding, Jason Wang, 2022/03/08
- [PULL 09/15] util: Add iova_tree_alloc_map, Jason Wang, 2022/03/08
- [PULL 10/15] util: add iova_tree_find_iova, Jason Wang, 2022/03/08
- [PULL 12/15] vdpa: Add custom IOTLB translations to SVQ, Jason Wang, 2022/03/08
- [PULL 11/15] vhost: Add VhostIOVATree, Jason Wang, 2022/03/08
- [PULL 13/15] vdpa: Adapt vhost_vdpa_get_vring_base to SVQ, Jason Wang, 2022/03/08
- [PULL 14/15] vdpa: Never set log_base addr if SVQ is enabled, Jason Wang, 2022/03/08
- [PULL 15/15] vdpa: Expose VHOST_F_LOG_ALL on SVQ, Jason Wang, 2022/03/08
- Re: [PULL 00/15] Net patches, Peter Maydell, 2022/03/09