* [PATCH v2] vdpa: Allow vDPA to work on big-endian machine
@ 2025-02-21 19:07 Konstantin Shkolnyy
2025-02-24 1:57 ` Jason Wang
2025-03-14 11:36 ` Eugenio Perez Martin
0 siblings, 2 replies; 8+ messages in thread
From: Konstantin Shkolnyy @ 2025-02-21 19:07 UTC (permalink / raw)
To: jasowang, mst
Cc: eperezma, 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>
---
Changes in V2: Add code comment.
net/vhost-vdpa.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 231b45246c..6e7cec4d45 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] vdpa: Allow vDPA to work on big-endian machine
2025-02-21 19:07 [PATCH v2] vdpa: Allow vDPA " Konstantin Shkolnyy
@ 2025-02-24 1:57 ` Jason Wang
2025-03-13 15:13 ` Konstantin Shkolnyy
2025-03-14 11:36 ` Eugenio Perez Martin
1 sibling, 1 reply; 8+ messages in thread
From: Jason Wang @ 2025-02-24 1:57 UTC (permalink / raw)
To: Konstantin Shkolnyy; +Cc: mst, eperezma, sgarzare, mjrosato, qemu-devel
On Sat, Feb 22, 2025 at 3:08 AM Konstantin Shkolnyy <kshk@linux.ibm.com> wrote:
>
> 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>
> ---
> Changes in V2: Add code comment.
>
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] vdpa: Allow vDPA to work on big-endian machine
2025-02-24 1:57 ` Jason Wang
@ 2025-03-13 15:13 ` Konstantin Shkolnyy
2025-03-17 0:26 ` Jason Wang
0 siblings, 1 reply; 8+ messages in thread
From: Konstantin Shkolnyy @ 2025-03-13 15:13 UTC (permalink / raw)
To: Jason Wang; +Cc: mst, eperezma, sgarzare, mjrosato, qemu-devel
On 2/23/2025 19:57, Jason Wang wrote:
> On Sat, Feb 22, 2025 at 3:08 AM Konstantin Shkolnyy <kshk@linux.ibm.com> wrote:
>>
>> 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>
>> ---
>> Changes in V2: Add code comment.
>>
>
> Acked-by: Jason Wang <jasowang@redhat.com>
Is this patch all set to be eventually integrated, or more review is needed?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] vdpa: Allow vDPA to work on big-endian machine
2025-02-21 19:07 [PATCH v2] vdpa: Allow vDPA " Konstantin Shkolnyy
2025-02-24 1:57 ` Jason Wang
@ 2025-03-14 11:36 ` Eugenio Perez Martin
1 sibling, 0 replies; 8+ messages in thread
From: Eugenio Perez Martin @ 2025-03-14 11:36 UTC (permalink / raw)
To: Konstantin Shkolnyy; +Cc: jasowang, mst, sgarzare, mjrosato, qemu-devel
On Fri, Feb 21, 2025 at 8:08 PM Konstantin Shkolnyy <kshk@linux.ibm.com> wrote:
>
> 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"
>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
> Signed-off-by: Konstantin Shkolnyy <kshk@linux.ibm.com>
> ---
> Changes in V2: Add code comment.
>
> net/vhost-vdpa.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index 231b45246c..6e7cec4d45 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -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
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] vdpa: Allow vDPA to work on big-endian machine
2025-03-13 15:13 ` Konstantin Shkolnyy
@ 2025-03-17 0:26 ` Jason Wang
2025-03-17 0:36 ` Michael S. Tsirkin
0 siblings, 1 reply; 8+ messages in thread
From: Jason Wang @ 2025-03-17 0:26 UTC (permalink / raw)
To: Konstantin Shkolnyy; +Cc: mst, eperezma, sgarzare, mjrosato, qemu-devel
On Thu, Mar 13, 2025 at 11:14 PM Konstantin Shkolnyy <kshk@linux.ibm.com> wrote:
>
> On 2/23/2025 19:57, Jason Wang wrote:
> > On Sat, Feb 22, 2025 at 3:08 AM Konstantin Shkolnyy <kshk@linux.ibm.com> wrote:
> >>
> >> 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>
> >> ---
> >> Changes in V2: Add code comment.
> >>
> >
> > Acked-by: Jason Wang <jasowang@redhat.com>
>
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] vdpa: Allow vDPA to work on big-endian machine
2025-03-17 0:26 ` Jason Wang
@ 2025-03-17 0:36 ` Michael S. Tsirkin
0 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2025-03-17 0:36 UTC (permalink / raw)
To: Jason Wang; +Cc: Konstantin Shkolnyy, eperezma, sgarzare, mjrosato, qemu-devel
On Mon, Mar 17, 2025 at 08:26:37AM +0800, Jason Wang wrote:
> On Thu, Mar 13, 2025 at 11:14 PM Konstantin Shkolnyy <kshk@linux.ibm.com> wrote:
> >
> > On 2/23/2025 19:57, Jason Wang wrote:
> > > On Sat, Feb 22, 2025 at 3:08 AM Konstantin Shkolnyy <kshk@linux.ibm.com> wrote:
> > >>
> > >> 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>
> > >> ---
> > >> Changes in V2: Add code comment.
> > >>
> > >
> > > Acked-by: Jason Wang <jasowang@redhat.com>
> >
> > 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.
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] vdpa: Allow VDPA to work on big-endian machine
@ 2025-06-16 13:36 Konstantin Shkolnyy
2025-06-21 5:52 ` Akihiko Odaki
0 siblings, 1 reply; 8+ messages in thread
From: Konstantin Shkolnyy @ 2025-06-16 13:36 UTC (permalink / raw)
To: jasowang, akihiko.odaki, yin31149
Cc: qemu-devel, mjrosato, Konstantin Shkolnyy, Eugenio Pérez
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.
Fixes: 8f7e9967484d ("vdpa: Restore vlan filtering state")
Signed-off-by: Konstantin Shkolnyy <kshk@linux.ibm.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
---
Changes in v2:
- Replace __le16 with uint16_t.
- Add "Fixes:" tag.
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..bd5c37305d 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)
{
+ uint16_t 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] 8+ messages in thread
* Re: [PATCH v2] vdpa: Allow VDPA to work on big-endian machine
2025-06-16 13:36 [PATCH v2] vdpa: Allow VDPA to work on big-endian machine Konstantin Shkolnyy
@ 2025-06-21 5:52 ` Akihiko Odaki
0 siblings, 0 replies; 8+ messages in thread
From: Akihiko Odaki @ 2025-06-21 5:52 UTC (permalink / raw)
To: Konstantin Shkolnyy, jasowang, yin31149
Cc: qemu-devel, mjrosato, Eugenio Pérez
On 2025/06/16 22:36, Konstantin Shkolnyy wrote:
> 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.
>
> Fixes: 8f7e9967484d ("vdpa: Restore vlan filtering state")
> Signed-off-by: Konstantin Shkolnyy <kshk@linux.ibm.com>
> Acked-by: Jason Wang <jasowang@redhat.com>
> Acked-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-06-21 5:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-16 13:36 [PATCH v2] vdpa: Allow VDPA to work on big-endian machine Konstantin Shkolnyy
2025-06-21 5:52 ` Akihiko Odaki
-- strict thread matches above, loose matches on Subject: below --
2025-02-21 19:07 [PATCH v2] vdpa: Allow vDPA " Konstantin Shkolnyy
2025-02-24 1:57 ` Jason Wang
2025-03-13 15:13 ` Konstantin Shkolnyy
2025-03-17 0:26 ` Jason Wang
2025-03-17 0:36 ` Michael S. Tsirkin
2025-03-14 11:36 ` Eugenio Perez Martin
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).