Skip to contentSkip to conversation

vdpa: Allow vDPA to work on big-endian machine

PATCH Superseded Konstantin Shkolnyy 4 participants 6 messages Feb 21, 2025 – Mar 17, 2025 Networking

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 vdpa: Allow vDPA to work on big-endian machine

Add .set_vnet_le() function that always returns success, assuming that vDPA h/w always implements LE data format. Otherwise, QEMU disables vDPA and outputs the message:
"backend does not support LE vnet headers; falling back on userspace virtio"

---
Changes in V2: Add code comment.

 net/vhost-vdpa.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
net/vhost-vdpa.c +13 -0
index 231b45246c..6e7cec4d45 100644
@@ -270,6 +270,18 @@ static bool vhost_vdpa_has_ufo(NetClientState *nc)
 
 }
 
+/*
+ * FIXME: vhost_vdpa doesn't have an API to "set h/w endianness". But it's
+ * reasonable to assume that h/w is LE by default, because LE is what
+ * virtio 1.0 and later ask for. So, this function just says "yes, the h/w is
+ * LE". Otherwise, on a BE machine, higher-level code would mistakely think
+ * the h/w is BE and can't support VDPA for a virtio 1.0 client.
+ */
+static int vhost_vdpa_set_vnet_le(NetClientState *nc, bool enable)
+{
+    return 0;
+}
+
 static bool vhost_vdpa_check_peer_type(NetClientState *nc, ObjectClass *oc,
                                        Error **errp)
 {
@@ -437,6 +449,7 @@ static NetClientInfo net_vhost_vdpa_info = {
         .cleanup = vhost_vdpa_cleanup,
         .has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
         .has_ufo = vhost_vdpa_has_ufo,
+        .set_vnet_le = vhost_vdpa_set_vnet_le,
         .check_peer_type = vhost_vdpa_check_peer_type,
         .set_steering_ebpf = vhost_vdpa_set_steering_ebpf,
 };
Signature · 1 line
2.34.1
Acked-by on v2 1/1
#1 lore raw
Quoted 10 lines · Konstantin Shkolnyy

Add .set_vnet_le() function that always returns success, assuming that vDPA h/w always implements LE data format. Otherwise, QEMU disables vDPA and outputs the message:
"backend does not support LE vnet headers; falling back on userspace virtio"

---
Changes in V2: Add code comment.

Thanks

#2 lore raw
Quoted 7 lines · Jason Wang
Quoted 6 lines · Konstantin Shkolnyy

Add .set_vnet_le() function that always returns success, assuming that vDPA h/w always implements LE data format. Otherwise, QEMU disables vDPA and outputs the message:
"backend does not support LE vnet headers; falling back on userspace virtio"

Quoted 6 lines
Quoted 4 lines

---
Changes in V2: Add code comment.

Is this patch all set to be eventually integrated, or more review is needed?

Acked-by on v2 1/1
#5 lore raw
In reply to Konstantin Shkolnyy
Quoted 6 lines · Konstantin Shkolnyy

Add .set_vnet_le() function that always returns success, assuming that vDPA h/w always implements LE data format. Otherwise, QEMU disables vDPA and outputs the message:
"backend does not support LE vnet headers; falling back on userspace virtio"

Quoted 41 lines

---
Changes in V2: Add code comment.

 net/vhost-vdpa.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
net/vhost-vdpa.c +13 -1
index 231b45246c..6e7cec4d45 100644
@@ -270,6 +270,18 @@ static bool vhost_vdpa_has_ufo(NetClientState *nc)
 
 }
 
+/*
+ * FIXME: vhost_vdpa doesn't have an API to "set h/w endianness". But it's
+ * reasonable to assume that h/w is LE by default, because LE is what
+ * virtio 1.0 and later ask for. So, this function just says "yes, the h/w is
+ * LE". Otherwise, on a BE machine, higher-level code would mistakely think
+ * the h/w is BE and can't support VDPA for a virtio 1.0 client.
+ */
+static int vhost_vdpa_set_vnet_le(NetClientState *nc, bool enable)
+{
+    return 0;
+}
+
 static bool vhost_vdpa_check_peer_type(NetClientState *nc, ObjectClass *oc,
                                        Error **errp)
 {
@@ -437,6 +449,7 @@ static NetClientInfo net_vhost_vdpa_info = {
         .cleanup = vhost_vdpa_cleanup,
         .has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
         .has_ufo = vhost_vdpa_has_ufo,
+        .set_vnet_le = vhost_vdpa_set_vnet_le,
         .check_peer_type = vhost_vdpa_check_peer_type,
         .set_steering_ebpf = vhost_vdpa_set_steering_ebpf,
 };
--

2.34.1

#3 lore raw
In reply to Konstantin Shkolnyy
Quoted 9 lines · Konstantin Shkolnyy
Quoted 7 lines · Jason Wang
Quoted 6 lines · Konstantin Shkolnyy

Add .set_vnet_le() function that always returns success, assuming that vDPA h/w always implements LE data format. Otherwise, QEMU disables vDPA and outputs the message:
"backend does not support LE vnet headers; falling back on userspace virtio"

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

---
Changes in V2: Add code comment.

Is this patch all set to be eventually integrated, or more review is needed?

Michael, do you want to queue this or can I do that?

Thanks

Reviewed-by
#4 lore raw
Quoted 15 lines · Jason Wang
Quoted 14 lines · Konstantin Shkolnyy
Quoted 12 lines · Jason Wang
Quoted 10 lines · Konstantin Shkolnyy

Add .set_vnet_le() function that always returns success, assuming that vDPA h/w always implements LE data format. Otherwise, QEMU disables vDPA and outputs the message:
"backend does not support LE vnet headers; falling back on userspace virtio"

---
Changes in V2: Add code comment.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Is this patch all set to be eventually integrated, or more review is needed?

Michael, do you want to queue this or can I do that?

Thanks

Go ahead.