[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACGkMEtfzcCzdCCFWKup2d417_OtpBgiWRf2bu1Qh=SQnD7Jcw@mail.gmail.com>
Date: Mon, 26 May 2025 09:01:21 +0800
From: Jason Wang <jasowang@...hat.com>
To: Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org, Willem de Bruijn <willemdebruijn.kernel@...il.com>,
Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
"Michael S. Tsirkin" <mst@...hat.com>, Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Eugenio Pérez <eperezma@...hat.com>
Subject: Re: [PATCH net-next 4/8] virtio_net: add supports for extended offloads
On Wed, May 21, 2025 at 6:33 PM Paolo Abeni <pabeni@...hat.com> wrote:
>
> The virtio_net driver needs it to implement GSO over UDP tunnel
> offload.
>
> The only missing piece is mapping them to/from the extended
> features.
>
> Signed-off-by: Paolo Abeni <pabeni@...hat.com>
> ---
> drivers/net/virtio_net.c | 31 +++++++++++++++++++++++++++++--
> 1 file changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index e53ba600605a5..71a972f20f19b 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -35,6 +35,29 @@ module_param(csum, bool, 0444);
> module_param(gso, bool, 0444);
> module_param(napi_tx, bool, 0644);
>
> +#define VIRTIO_OFFLOAD_MAP_MIN 46
> +#define VIRTIO_OFFLOAD_MAP_MAX 49
> +#define VIRTIO_FEATURES_MAP_MIN 65
> +#define VIRTIO_O2F_DELTA (VIRTIO_FEATURES_MAP_MIN - VIRTIO_OFFLOAD_MAP_MIN)
Instead of doing this, I wonder if it's simple to just have an array
for the mapping from all guest offload features to guest controllable
offload bits?
> +
> +static bool virtio_is_mapped_offload(unsigned int obit)
> +{
> + return obit >= VIRTIO_OFFLOAD_MAP_MIN &&
> + obit <= VIRTIO_OFFLOAD_MAP_MAX;
> +}
> +
> +#define VIRTIO_FEATURE_TO_OFFLOAD(fbit) \
> + ({ \
> + unsigned int __f = fbit; \
> + __f >= VIRTIO_FEATURES_MAP_MIN ? __f - VIRTIO_O2F_DELTA : __f; \
> + })
> +#define VIRTIO_OFFLOAD_TO_FEATURE(obit) \
> + ({ \
> + unsigned int __o = obit; \
> + virtio_is_mapped_offload(__o) ? __o + VIRTIO_O2F_DELTA :\
> + __o; \
> + })
> +
> /* FIXME: MTU in config. */
> #define GOOD_PACKET_LEN (ETH_HLEN + VLAN_HLEN + ETH_DATA_LEN)
> #define GOOD_COPY_LEN 128
> @@ -7037,9 +7060,13 @@ static int virtnet_probe(struct virtio_device *vdev)
> netif_carrier_on(dev);
> }
>
> - for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
> - if (virtio_has_feature(vi->vdev, guest_offloads[i]))
> + for (i = 0; i < ARRAY_SIZE(guest_offloads); i++) {
> + unsigned int fbit;
> +
> + fbit = VIRTIO_OFFLOAD_TO_FEATURE(guest_offloads[i]);
> + if (virtio_has_feature(vi->vdev, fbit))
> set_bit(guest_offloads[i], &vi->guest_offloads);
> + }
> vi->guest_offloads_capable = vi->guest_offloads;
>
> rtnl_unlock();
> --
> 2.49.0
>
Thanks
Powered by blists - more mailing lists