qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Eugenio Pérez" <eperezma@redhat.com>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>, Cindy Lu <lulu@redhat.com>,
	si-wei.liu@oracle.com, Stefano Garzarella <sgarzare@redhat.com>,
	Shannon Nelson <snelson@pensando.io>,
	Gautam Dawar <gdawar@xilinx.com>,
	Jason Wang <jasowang@redhat.com>,
	Harpreet Singh Anand <hanand@xilinx.com>,
	Parav Pandit <parav@mellanox.com>,
	Dragos Tatulea <dtatulea@nvidia.com>,
	Zhu Lingshan <lingshan.zhu@intel.com>,
	Lei Yang <leiyang@redhat.com>
Subject: [RFC PATCH 5/6] vdpa: delay enable of data vqs
Date: Thu,  6 Jul 2023 21:12:26 +0200	[thread overview]
Message-ID: <20230706191227.835526-6-eperezma@redhat.com> (raw)
In-Reply-To: <20230706191227.835526-1-eperezma@redhat.com>

To restore the device at the destination of a live migration we send
the commands through control virtqueue.  For a device to read CVQ it
must have received the DRIVER_OK status bit.

However this opens a window where the device could start receiving
packets in rx queue 0 before it receives the RSS configuration.  To
avoid that, we do not send vring_enable until all configuration is used
by the device.

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

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 536bab8613..d5970e9f06 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -739,6 +739,13 @@ static int vhost_vdpa_net_load(NetClientState *nc)
         return r;
     }
 
+    for (int i = 0; i < v->dev->vq_index; ++i) {
+        r = vhost_vdpa_set_vring_ready(v, i);
+        if (unlikely(r)) {
+            return r;
+        }
+    }
+
     return 0;
 }
 
@@ -826,9 +833,25 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops = {
     .avail_handler = vhost_vdpa_net_handle_ctrl_avail,
 };
 
+/**
+ * Check if a vhost_vdpa device should enable before DRIVER_OK
+ *
+ * CVQ must always start first if we want to restore the state safely. Do not
+ * start data vqs if the device has CVQ.
+ */
 static bool vhost_vdpa_should_enable(const struct vhost_vdpa *v)
 {
-    return true;
+    struct vhost_dev *dev = v->dev;
+
+    if (!dev->vq_index_end % 2) {
+        /* vDPA device does not have CVQ */
+        return true;
+    }
+
+    /*
+     * We're evaluating CVQ, enable to send control cmds to load device state.
+     */
+    return dev->vq_index + 1 == dev->vq_index_end;
 }
 
 static const VhostVDPAVirtIOOps vhost_vdpa_virtio_net_ops = {
-- 
2.39.3



  parent reply	other threads:[~2023-07-06 19:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06 19:12 [RFC PATCH 0/6] Enable vdpa net migration with features depending on CVQ Eugenio Pérez
2023-07-06 19:12 ` [RFC PATCH 1/6] vdpa: export vhost_vdpa_set_vring_ready Eugenio Pérez
2023-07-10  3:19   ` Jason Wang
2023-07-10  8:43     ` Eugenio Perez Martin
2023-07-06 19:12 ` [RFC PATCH 2/6] vdpa: add should_enable op Eugenio Pérez
2023-07-10  3:46   ` Jason Wang
2023-07-06 19:12 ` [RFC PATCH 3/6] vdpa: use virtio_ops->should_enable at vhost_vdpa_set_vrings_ready Eugenio Pérez
2023-07-06 19:12 ` [RFC PATCH 4/6] vdpa: add stub vhost_vdpa_should_enable Eugenio Pérez
2023-07-06 19:12 ` Eugenio Pérez [this message]
2023-07-06 19:12 ` [RFC PATCH 6/6] vdpa: remove net cvq migration blocker Eugenio Pérez
2023-07-10  3:53   ` Jason Wang
2023-07-10  7:37     ` Eugenio Perez Martin
2023-07-20  8:17       ` Eugenio Perez Martin
2023-07-20  8:23         ` Jason Wang
2023-07-06 20:02 ` [RFC PATCH 0/6] Enable vdpa net migration with features depending on CVQ Michael S. Tsirkin
2023-07-07  6:21   ` 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=20230706191227.835526-6-eperezma@redhat.com \
    --to=eperezma@redhat.com \
    --cc=dtatulea@nvidia.com \
    --cc=gdawar@xilinx.com \
    --cc=hanand@xilinx.com \
    --cc=jasowang@redhat.com \
    --cc=leiyang@redhat.com \
    --cc=lingshan.zhu@intel.com \
    --cc=lulu@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=parav@mellanox.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=si-wei.liu@oracle.com \
    --cc=snelson@pensando.io \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).