From: Paolo Abeni <pabeni@redhat.com>
To: netdev@vger.kernel.org
Cc: "Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
"Jason Wang" <jasowang@redhat.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Yuri Benditovich" <yuri.benditovich@daynix.com>,
"Akihiko Odaki" <akihiko.odaki@daynix.com>,
"Jonathan Corbet" <corbet@lwn.net>,
kvm@vger.kernel.org, linux-doc@vger.kernel.org
Subject: [PATCH v7 net-next 5/9] virtio_net: add supports for extended offloads
Date: Tue, 8 Jul 2025 09:09:01 +0200 [thread overview]
Message-ID: <82a5589e753192a82c69d74ec32938e385a44680.1751874094.git.pabeni@redhat.com> (raw)
In-Reply-To: <cover.1751874094.git.pabeni@redhat.com>
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.
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
v4 -> v5:
- avoid lines longer than 80 chars
v2 -> v3:
- offload to feature conversion is now an inline function
v1 -> v2:
- drop unused macro
- restrict the offload remap range as per latest spec update
---
drivers/net/virtio_net.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 9f6e0153ed2d..6f86a8edc981 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -35,6 +35,23 @@ 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 47
+#define VIRTIO_FEATURES_MAP_MIN 65
+#define VIRTIO_O2F_DELTA (VIRTIO_FEATURES_MAP_MIN - \
+ VIRTIO_OFFLOAD_MAP_MIN)
+
+static bool virtio_is_mapped_offload(unsigned int obit)
+{
+ return obit >= VIRTIO_OFFLOAD_MAP_MIN &&
+ obit <= VIRTIO_OFFLOAD_MAP_MAX;
+}
+
+static unsigned int virtio_offload_to_feature(unsigned int obit)
+{
+ return virtio_is_mapped_offload(obit) ? obit + VIRTIO_O2F_DELTA : obit;
+}
+
/* FIXME: MTU in config. */
#define GOOD_PACKET_LEN (ETH_HLEN + VLAN_HLEN + ETH_DATA_LEN)
#define GOOD_COPY_LEN 128
@@ -7055,9 +7072,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
next prev parent reply other threads:[~2025-07-08 7:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 7:08 [PATCH v7 net-next 0/9] virtio: introduce GSO over UDP tunnel Paolo Abeni
2025-07-08 7:08 ` [PATCH v7 net-next 1/9] scripts/kernel_doc.py: properly handle VIRTIO_DECLARE_FEATURES Paolo Abeni
2025-07-08 7:08 ` [PATCH v7 net-next 2/9] virtio: introduce extended features Paolo Abeni
2025-07-08 7:08 ` [PATCH v7 net-next 3/9] virtio_pci_modern: allow configuring " Paolo Abeni
2025-07-08 7:09 ` [PATCH v7 net-next 4/9] vhost-net: " Paolo Abeni
2025-07-08 7:09 ` Paolo Abeni [this message]
2025-07-08 7:09 ` [PATCH v7 net-next 6/9] net: implement virtio helpers to handle UDP GSO tunneling Paolo Abeni
2025-07-08 7:09 ` [PATCH v7 net-next 7/9] virtio_net: enable gso over UDP tunnel support Paolo Abeni
2025-07-08 7:09 ` [PATCH v7 net-next 8/9] tun: " Paolo Abeni
2025-07-08 7:09 ` [PATCH v7 net-next 9/9] vhost/net: " Paolo Abeni
2025-07-08 15:01 ` [PATCH v7 net-next 0/9] virtio: introduce GSO over UDP tunnel Michael S. Tsirkin
2025-07-08 15:24 ` Jakub Kicinski
2025-07-08 16:00 ` Michael S. Tsirkin
2025-07-08 16:43 ` Paolo Abeni
2025-07-08 17:00 ` Paolo Abeni
2025-07-08 19:50 ` Michael S. Tsirkin
2025-07-08 18:23 ` Michael S. Tsirkin
2025-07-09 9:02 ` Paolo Abeni
2025-07-10 20:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=82a5589e753192a82c69d74ec32938e385a44680.1751874094.git.pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=akihiko.odaki@daynix.com \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xuanzhuo@linux.alibaba.com \
--cc=yuri.benditovich@daynix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).