diff mbox series

[RFC,09/12] vdpa: add vhost_vdpa_restart_queue

Message ID 20230720181459.607008-10-eperezma@redhat.com
State New
Headers show
Series Prefer to use SVQ to stall dataplane at NIC state restore through CVQ | expand

Commit Message

Eugenio Perez Martin July 20, 2023, 6:14 p.m. UTC
Split out vq restart operation in its own function, as it may be called
with ring reset.

Signed-off-by: Eugenio PĂ©rez <eperezma@redhat.com>
---
 hw/virtio/vhost-vdpa.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
diff mbox series

Patch

diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 7248072989..7b24fa3e12 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -562,6 +562,29 @@  static void vhost_vdpa_reset_queue(struct vhost_dev *dev, int idx)
     }
 }
 
+/* TODO: Properly reorder static functions */
+static bool vhost_vdpa_svq_start(struct vhost_dev *dev, unsigned i,
+                                 Error **errp);
+static int vhost_vdpa_restart_queue(struct vhost_dev *dev, int idx)
+{
+    struct vhost_vdpa *v = dev->opaque;
+
+    if (v->shadow_vqs_enabled) {
+        Error *err = NULL;
+        bool ok = vhost_vdpa_svq_start(dev, idx, &err);
+        if (unlikely(!ok)) {
+            error_report_err(err);
+            return -1;
+        }
+    }
+
+    if (dev->features & VIRTIO_F_RING_RESET) {
+        return vhost_vdpa_set_vring_ready_internal(v, idx, true);
+    }
+
+    return 0;
+}
+
 /*
  * The use of this function is for requests that only need to be
  * applied once. Typically such request occurs at the beginning
@@ -1574,4 +1597,5 @@  const VhostOps vdpa_ops = {
         .vhost_set_config_call = vhost_vdpa_set_config_call,
         .vhost_reset_status = vhost_vdpa_reset_status,
         .vhost_reset_queue = vhost_vdpa_reset_queue,
+        .vhost_restart_queue = vhost_vdpa_restart_queue,
 };