qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vdpa: Allow vDPA to work on big-endian machine
@ 2025-02-11 16:19 Konstantin Shkolnyy
  2025-02-12 13:38 ` Eugenio Perez Martin
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Konstantin Shkolnyy @ 2025-02-11 16:19 UTC (permalink / raw)
  To: eperezma; +Cc: mst, sgarzare, mjrosato, qemu-devel, 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"

Signed-off-by: Konstantin Shkolnyy <kshk@linux.ibm.com>
---
 net/vhost-vdpa.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 231b45246c..7219aa2eee 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -270,6 +270,11 @@ static bool vhost_vdpa_has_ufo(NetClientState *nc)
 
 }
 
+static int vhost_vdpa_set_vnet_le(NetClientState *nc, bool is_le)
+{
+    return 0;
+}
+
 static bool vhost_vdpa_check_peer_type(NetClientState *nc, ObjectClass *oc,
                                        Error **errp)
 {
@@ -437,6 +442,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



^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH] vdpa: Allow VDPA to work on big-endian machine
@ 2025-06-14 22:44 Konstantin Shkolnyy
  2025-06-16  2:49 ` Jason Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Konstantin Shkolnyy @ 2025-06-14 22:44 UTC (permalink / raw)
  To: jasowang, akihiko.odaki; +Cc: qemu-devel, mjrosato, Konstantin Shkolnyy

After commit 0caed25cd171 vhost_vdpa_net_load_vlan() started seeing
VIRTIO_NET_F_CTRL_VLAN flag and making 4096 calls to the kernel with
VIRTIO_NET_CTRL_VLAN_ADD command. However, it forgot to convert the
16-bit VLAN IDs to LE format. On BE machine, the kernel calls failed
when they saw "VLAN IDs" greater than 4095, and QEMU then said:
"unable to start vhost net: 5: falling back on userspace virtio", and
VDPA became disabled.

Convert the VLAN ID to LE before putting it into virtio queue.

Signed-off-by: Konstantin Shkolnyy <kshk@linux.ibm.com>
---
 net/vhost-vdpa.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 58d738945d..99c9eb42b9 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -1173,9 +1173,10 @@ static int vhost_vdpa_net_load_single_vlan(VhostVDPAState *s,
                                            struct iovec *in_cursor,
                                            uint16_t vid)
 {
+    __le16 vid_le = cpu_to_le16(vid);
     const struct iovec data = {
-        .iov_base = &vid,
-        .iov_len = sizeof(vid),
+        .iov_base = &vid_le,
+        .iov_len = sizeof(vid_le),
     };
     ssize_t r = vhost_vdpa_net_load_cmd(s, out_cursor, in_cursor,
                                         VIRTIO_NET_CTRL_VLAN,
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2025-06-16  8:57 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-11 16:19 [PATCH] vdpa: Allow vDPA to work on big-endian machine Konstantin Shkolnyy
2025-02-12 13:38 ` Eugenio Perez Martin
2025-02-12 14:47   ` Konstantin Shkolnyy
2025-02-12 14:52 ` Philippe Mathieu-Daudé
2025-02-12 17:24   ` Konstantin Shkolnyy
2025-02-12 18:07     ` Philippe Mathieu-Daudé
2025-02-12 20:01       ` Konstantin Shkolnyy
2025-02-18 13:27         ` Konstantin Shkolnyy
2025-02-18 14:02           ` Philippe Mathieu-Daudé
2025-02-19  0:29             ` Jason Wang
2025-02-20 15:57 ` Michael S. Tsirkin
2025-02-21  3:40   ` Konstantin Shkolnyy
  -- strict thread matches above, loose matches on Subject: below --
2025-06-14 22:44 [PATCH] vdpa: Allow VDPA " Konstantin Shkolnyy
2025-06-16  2:49 ` Jason Wang
2025-06-16  6:19 ` Eugenio Perez Martin
2025-06-16  8:56 ` Akihiko Odaki

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).