Skip to contentSkip to conversation

net/vhost-vdpa: enable vqs before DRIVER_OK if no cvq

PATCH In review Eugenio Pérez 2 participants 4 messages Mar 4 – Mar 10 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/vhost-vdpa: enable vqs before DRIVER_OK if no cvq

VDUSE do not forward the enable message to the userland device at the moment, leaving the dataplane disabled. As there is no functional difference if the device have no CVQ, enable them before DRIVER_OK in that case.

For devices with a control vq, keep the enabling of the dataplane after CVQ so QEMU can restore the device configuration.

Fixes 6c4825476a43 ("vdpa: move vhost_vdpa_set_vring_ready to the caller")
---
 net/vhost-vdpa.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)
net/vhost-vdpa.c +10 -20
index 3df6091274e5..ee7eb1a4db28 100644
@@ -397,6 +397,7 @@ static int vhost_vdpa_net_data_start(NetClientState *nc)
 {
     VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
     struct vhost_vdpa *v = &s->vhost_vdpa;
+    bool has_cvq = v->dev->vq_index_end % 2;
 
     assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA);
 
@@ -406,6 +407,15 @@ static int vhost_vdpa_net_data_start(NetClientState *nc)
         v->shadow_vqs_enabled = false;
     }
 
+    if (!has_cvq) {
+        for (int i = 0; i < v->dev->nvqs; ++i) {
+            int ret = vhost_vdpa_set_vring_ready(v, i + v->dev->vq_index);
+            if (ret < 0) {
+                return ret;
+            }
+        }
+    }
+
     if (v->index == 0) {
         v->shared->shadow_data = v->shadow_vqs_enabled;
         vhost_vdpa_net_data_start_first(s);
@@ -415,25 +425,6 @@ static int vhost_vdpa_net_data_start(NetClientState *nc)
     return 0;
 }
 
-static int vhost_vdpa_net_data_load(NetClientState *nc)
-{
-    VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
-    struct vhost_vdpa *v = &s->vhost_vdpa;
-    bool has_cvq = v->dev->vq_index_end % 2;
-
-    if (has_cvq) {
-        return 0;
-    }
-
-    for (int i = 0; i < v->dev->nvqs; ++i) {
-        int ret = vhost_vdpa_set_vring_ready(v, i + v->dev->vq_index);
-        if (ret < 0) {
-            return ret;
-        }
-    }
-    return 0;
-}
-
 static void vhost_vdpa_net_client_stop(NetClientState *nc)
 {
     VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
@@ -450,7 +441,6 @@ static NetClientInfo net_vhost_vdpa_info = {
         .size = sizeof(VhostVDPAState),
         .receive = vhost_vdpa_receive,
         .start = vhost_vdpa_net_data_start,
-        .load = vhost_vdpa_net_data_load,
         .stop = vhost_vdpa_net_client_stop,
         .cleanup = vhost_vdpa_cleanup,
         .has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
Signature · 1 line
2.53.0
#1 lore raw
Quoted 11 lines · Eugenio Pérez

VDUSE do not forward the enable message to the userland device at the moment, leaving the dataplane disabled. As there is no functional difference if the device have no CVQ, enable them before DRIVER_OK in that case.

For devices with a control vq, keep the enabling of the dataplane after CVQ so QEMU can restore the device configuration.

Fixes 6c4825476a43 ("vdpa: move vhost_vdpa_set_vring_ready to the caller")

Once we add cvq in the future, it looks like we need to bring this back?

Thanks

#2 lore raw
Quoted 8 lines · Jason Wang
Quoted 6 lines · Eugenio Pérez

VDUSE do not forward the enable message to the userland device at the moment, leaving the dataplane disabled. As there is no functional difference if the device have no CVQ, enable them before DRIVER_OK in that case.

Quoted 8 lines
Quoted 5 lines

For devices with a control vq, keep the enabling of the dataplane after CVQ so QEMU can restore the device configuration.

Fixes 6c4825476a43 ("vdpa: move vhost_vdpa_set_vring_ready to the caller")

Once we add cvq in the future, it looks like we need to bring this back?

Do you mean when we add CVQ in VDUSE? I'd prefer to handle this as a patch independent from the vdpa backend, as I'm not sure if any other device in the wild supports the current behavior.

Considering the conversations about adding this ioctl in vhost_vdpa, and the patch vdpa_blk needed to restore ENABLE before DRIVER_OK, I prefer to view this as "Restore the original QEMU behavior from before introducing CVQ shadowing." This way, no device sees a breaking change from previous QEMU versions or even standard VirtIO. In other words, the behavior after merging this patch is guaranteed to be supported by all the devices, but we have seen that some devices do not support the initialization that happens in QEMU master.

But yes, the main use case I'm testing is VDUSE+DPDK.

Acked-by
#3 lore raw
Quoted 16 lines · Eugenio Perez Martin
Quoted 14 lines · Jason Wang
Quoted 11 lines · Eugenio Pérez

VDUSE do not forward the enable message to the userland device at the moment, leaving the dataplane disabled. As there is no functional difference if the device have no CVQ, enable them before DRIVER_OK in that case.

For devices with a control vq, keep the enabling of the dataplane after CVQ so QEMU can restore the device configuration.

Fixes 6c4825476a43 ("vdpa: move vhost_vdpa_set_vring_ready to the caller")
Quoted 6 lines
Quoted 2 lines

Once we add cvq in the future, it looks like we need to bring this back?

Do you mean when we add CVQ in VDUSE? I'd prefer to handle this as a patch independent from the vdpa backend, as I'm not sure if any other device in the wild supports the current behavior.

Yes.

Quoted 11 lines

Considering the conversations about adding this ioctl in vhost_vdpa, and the patch vdpa_blk needed to restore ENABLE before DRIVER_OK, I prefer to view this as "Restore the original QEMU behavior from before introducing CVQ shadowing." This way, no device sees a breaking change from previous QEMU versions or even standard VirtIO. In other words, the behavior after merging this patch is guaranteed to be supported by all the devices, but we have seen that some devices do not support the initialization that happens in QEMU master.

But yes, the main use case I'm testing is VDUSE+DPDK.

Ok.

So,

Thanks

Quoted 1 line