All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Eugenio Pérez" <eperezma@redhat.com>
To: qemu-devel@nongnu.org
Cc: yvugenfi@redhat.com, "Eugenio Pérez" <eperezma@redhat.com>,
	si-wei.liu@oracle.com, "Jason Wang" <jasowang@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Dragos Tatulea" <dtatulea@nvidia.com>,
	"Shannon Nelson" <snelson@pensando.io>
Subject: [RFC PATCH 08/12] vdpa: add vhost_vdpa_svq_start
Date: Thu, 20 Jul 2023 20:14:55 +0200	[thread overview]
Message-ID: <20230720181459.607008-9-eperezma@redhat.com> (raw)
In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com>

To split each SVQ in its own initialization routine let's us to restart
a VQ individually, and to keep future vhost_vdpa_restart_queue
symmetrical with vhost_vdpa_reset_queue.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 hw/virtio/vhost-vdpa.c | 67 ++++++++++++++++++++++++++----------------
 1 file changed, 41 insertions(+), 26 deletions(-)

diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index df2515a247..7248072989 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -1223,6 +1223,46 @@ static bool vhost_vdpa_svq_setup(struct vhost_dev *dev,
     return r == 0;
 }
 
+static bool vhost_vdpa_svq_start(struct vhost_dev *dev, unsigned i,
+                                 Error **errp)
+{
+    struct vhost_vdpa *v = dev->opaque;
+    VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
+    VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
+    struct vhost_vring_addr addr = {
+        .index = dev->vq_index + i,
+    };
+    int r;
+    bool ok = vhost_vdpa_svq_setup(dev, svq, i, errp);
+    if (unlikely(!ok)) {
+        goto err;
+    }
+
+    vhost_svq_start(svq, dev->vdev, vq, v->iova_tree);
+    ok = vhost_vdpa_svq_map_rings(dev, svq, &addr, errp);
+    if (unlikely(!ok)) {
+        goto err_map;
+    }
+
+    /* Override vring GPA set by vhost subsystem */
+    r = vhost_vdpa_set_vring_dev_addr(dev, &addr);
+    if (unlikely(r != 0)) {
+        error_setg_errno(errp, -r, "Cannot set device address");
+        goto err_set_addr;
+    }
+
+    return true;
+
+err_set_addr:
+    vhost_vdpa_svq_unmap_rings(dev, g_ptr_array_index(v->shadow_vqs, i));
+
+err_map:
+    vhost_svq_stop(g_ptr_array_index(v->shadow_vqs, i));
+
+err:
+    return false;
+}
+
 static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
 {
     struct vhost_vdpa *v = dev->opaque;
@@ -1234,39 +1274,14 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
     }
 
     for (i = 0; i < v->shadow_vqs->len; ++i) {
-        VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
-        VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
-        struct vhost_vring_addr addr = {
-            .index = dev->vq_index + i,
-        };
-        int r;
-        bool ok = vhost_vdpa_svq_setup(dev, svq, i, &err);
+        bool ok = vhost_vdpa_svq_start(dev, i, &err);
         if (unlikely(!ok)) {
             goto err;
         }
-
-        vhost_svq_start(svq, dev->vdev, vq, v->iova_tree);
-        ok = vhost_vdpa_svq_map_rings(dev, svq, &addr, &err);
-        if (unlikely(!ok)) {
-            goto err_map;
-        }
-
-        /* Override vring GPA set by vhost subsystem */
-        r = vhost_vdpa_set_vring_dev_addr(dev, &addr);
-        if (unlikely(r != 0)) {
-            error_setg_errno(&err, -r, "Cannot set device address");
-            goto err_set_addr;
-        }
     }
 
     return true;
 
-err_set_addr:
-    vhost_vdpa_svq_unmap_rings(dev, g_ptr_array_index(v->shadow_vqs, i));
-
-err_map:
-    vhost_svq_stop(g_ptr_array_index(v->shadow_vqs, i));
-
 err:
     error_reportf_err(err, "Cannot setup SVQ %u: ", i);
     for (unsigned j = 0; j < i; ++j) {
-- 
2.39.3



  parent reply	other threads:[~2023-07-20 18:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20 18:14 [RFC PATCH 00/12] Prefer to use SVQ to stall dataplane at NIC state restore through CVQ Eugenio Pérez
2023-07-20 18:14 ` [RFC PATCH 01/12] vhost: add vhost_reset_queue_op Eugenio Pérez
2023-07-20 18:14 ` [RFC PATCH 02/12] vhost: add vhost_restart_queue_op Eugenio Pérez
2023-07-20 18:14 ` [RFC PATCH 03/12] vhost_net: Use ops->vhost_restart_queue in vhost_net_virtqueue_restart Eugenio Pérez
2023-07-25  7:07   ` Jason Wang
2023-07-20 18:14 ` [RFC PATCH 04/12] vhost_net: Use ops->vhost_reset_queue in vhost_net_virtqueue_reset Eugenio Pérez
2023-07-25  7:08   ` Jason Wang
2023-07-20 18:14 ` [RFC PATCH 05/12] vdpa: add vhost_vdpa_set_vring_ready_internal Eugenio Pérez
2023-07-20 18:14 ` [RFC PATCH 06/12] vdpa: add vhost_vdpa_svq_stop Eugenio Pérez
2023-07-20 18:14 ` [RFC PATCH 07/12] vdpa: add vhost_vdpa_reset_queue Eugenio Pérez
2023-07-21 21:56   ` Si-Wei Liu
2023-07-24 16:35     ` Eugenio Perez Martin
2023-07-20 18:14 ` Eugenio Pérez [this message]
2023-07-20 18:14 ` [RFC PATCH 09/12] vdpa: add vhost_vdpa_restart_queue Eugenio Pérez
2023-07-20 18:14 ` [RFC PATCH 10/12] vdpa: enable all vqs if the device support RING_RESET feature Eugenio Pérez
2023-07-20 18:14 ` [RFC PATCH 11/12] vdpa: use SVQ to stall dataplane while NIC state is being restored Eugenio Pérez
2023-07-21 22:58   ` Si-Wei Liu
2023-07-24 19:59     ` Eugenio Perez Martin
2023-07-25  3:48       ` Jason Wang
2023-07-20 18:14 ` [RFC PATCH 12/12] vhost: Allow _F_RING_RESET with shadow virtqueue Eugenio Pérez
2023-07-21  6:48 ` [RFC PATCH 00/12] Prefer to use SVQ to stall dataplane at NIC state restore through CVQ Eugenio Perez Martin
2023-07-25  7:15   ` Jason Wang
2023-07-27 12:53     ` Eugenio Perez Martin
2023-07-27 13:05   ` Michael S. Tsirkin
2023-07-27 15:23     ` Eugenio Perez Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230720181459.607008-9-eperezma@redhat.com \
    --to=eperezma@redhat.com \
    --cc=dtatulea@nvidia.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=si-wei.liu@oracle.com \
    --cc=snelson@pensando.io \
    --cc=yvugenfi@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.