[PATCH v2] vdpa: Allow vDPA to work on big-endian machine

Konstantin Shkolnyy posted 1 patch 11 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250221190733.490308-1-kshk@linux.ibm.com
Maintainers: Jason Wang <jasowang@redhat.com>
net/vhost-vdpa.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
[PATCH v2] vdpa: Allow vDPA to work on big-endian machine
Posted by Konstantin Shkolnyy 11 months, 2 weeks ago
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
Re: [PATCH v2] vdpa: Allow vDPA to work on big-endian machine
Posted by Eugenio Perez Martin 10 months, 4 weeks ago
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
>
Re: [PATCH v2] vdpa: Allow vDPA to work on big-endian machine
Posted by Jason Wang 11 months, 2 weeks ago
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
Re: [PATCH v2] vdpa: Allow vDPA to work on big-endian machine
Posted by Konstantin Shkolnyy 11 months ago
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?

Re: [PATCH v2] vdpa: Allow vDPA to work on big-endian machine
Posted by Jason Wang 10 months, 3 weeks ago
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
Re: [PATCH v2] vdpa: Allow vDPA to work on big-endian machine
Posted by Michael S. Tsirkin 10 months, 3 weeks ago
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>