qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH v9 21/23] vdpa: Add vhost_vdpa_start_control_svq


From: Jason Wang
Subject: Re: [RFC PATCH v9 21/23] vdpa: Add vhost_vdpa_start_control_svq
Date: Tue, 12 Jul 2022 15:26:28 +0800
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0


在 2022/7/7 02:40, Eugenio Pérez 写道:
As a first step we only enable CVQ first than others. Future patches add
state restore.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
  net/vhost-vdpa.c | 19 +++++++++++++++++++
  1 file changed, 19 insertions(+)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index e415cc8de5..77d013833f 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -370,6 +370,24 @@ static CVQElement 
*vhost_vdpa_cvq_alloc_elem(VhostVDPAState *s,
      return g_steal_pointer(&cvq_elem);
  }
+static int vhost_vdpa_start_control_svq(VhostShadowVirtqueue *svq,
+                                        void *opaque)
+{
+    struct vhost_vring_state state = {
+        .index = virtio_get_queue_index(svq->vq),
+        .num = 1,
+    };
+    VhostVDPAState *s = opaque;
+    struct vhost_dev *dev = s->vhost_vdpa.dev;
+    struct vhost_vdpa *v = dev->opaque;
+    int r;
+
+    assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_VDPA);
+
+    r = ioctl(v->device_fd, VHOST_VDPA_SET_VRING_ENABLE, &state);
+    return r < 0 ? -errno : r;
+}
+
  /**
   * iov_size with an upper limit. It's assumed UINT64_MAX is an invalid
   * iov_size.
@@ -554,6 +572,7 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops 
= {
      .avail_handler = vhost_vdpa_net_handle_ctrl_avail,
      .used_handler = vhost_vdpa_net_handle_ctrl_used,
      .detach_handler = vhost_vdpa_net_handle_ctrl_detach,
+    .start = vhost_vdpa_start_control_svq,
  };


I wonder if vhost_net_start() is something better than here. It knows all virtqueues and it can do whatever it wants, we just need to make shadow virtqueue visible there?

Thanks


static NetClientState *net_vhost_vdpa_init(NetClientState *peer,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]