From: Kommula Shiva Shankar <kshankar@marvell.com>
To: <netdev@vger.kernel.org>, <mst@redhat.com>, <jasowang@redhat.com>,
<pabeni@redhat.com>, <xuanzhuo@linux.alibaba.com>
Cc: <virtualization@lists.linux.dev>, <parav@nvidia.com>,
<jerinj@marvell.com>, <ndabilpuram@marvell.com>,
<sburla@marvell.com>, <schalla@marvell.com>
Subject: [PATCH v2 net-next 1/3] net: implement virtio helper to handle outer nw offset
Date: Wed, 8 Oct 2025 16:30:02 +0530 [thread overview]
Message-ID: <20251008110004.2933101-2-kshankar@marvell.com> (raw)
In-Reply-To: <20251008110004.2933101-1-kshankar@marvell.com>
virtio specification introduced support for outer network
header offset broadcast.
This patch implements the needed defines and virtio header
parsing capabilities.
Signed-off-by: Kommula Shiva Shankar <kshankar@marvell.com>
---
include/linux/virtio_net.h | 40 +++++++++++++++++++++++++++++++++
include/uapi/linux/virtio_net.h | 8 +++++++
2 files changed, 48 insertions(+)
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index 20e0584db1dd..7ab872a11a21 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -374,6 +374,46 @@ static inline int virtio_net_handle_csum_offload(struct sk_buff *skb,
return 0;
}
+static inline int
+virtio_net_out_net_header_to_skb(struct sk_buff *skb,
+ struct virtio_net_hdr_v1_hash_tunnel_out_net_hdr *vhdr,
+ bool out_net_hdr_negotiated,
+ bool little_endian)
+{
+ unsigned int out_net_hdr_off;
+
+ if (!out_net_hdr_negotiated)
+ return 0;
+
+ if (vhdr->outer_nh_offset) {
+ out_net_hdr_off = le16_to_cpu(vhdr->outer_nh_offset);
+ skb_set_network_header(skb, out_net_hdr_off);
+ }
+
+ return 0;
+}
+
+static inline int
+virtio_net_out_net_header_from_skb(const struct sk_buff *skb,
+ struct virtio_net_hdr_v1_hash_tunnel_out_net_hdr *vhdr,
+ bool out_net_hdr_negotiated,
+ bool little_endian)
+{
+ unsigned int out_net_hdr_off;
+
+ if (!out_net_hdr_negotiated) {
+ vhdr->outer_nh_offset = 0;
+ return 0;
+ }
+
+ out_net_hdr_off = skb_network_offset(skb);
+ if (out_net_hdr_off && (skb->protocol == htons(ETH_P_IP) ||
+ skb->protocol == htons(ETH_P_IPV6)))
+ vhdr->outer_nh_offset = cpu_to_le16(out_net_hdr_off);
+
+ return 0;
+}
+
/*
* vlan_hlen always refers to the outermost MAC header. That also
* means it refers to the only MAC header, if the packet does not carry
diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
index 8bf27ab8bcb4..6032b9e443bb 100644
--- a/include/uapi/linux/virtio_net.h
+++ b/include/uapi/linux/virtio_net.h
@@ -86,6 +86,7 @@
* packets with partial csum
* for the outer header
*/
+#define VIRTIO_NET_F_OUT_NET_HEADER 69 /* Outer network header offset */
/* Offloads bits corresponding to VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO{,_CSUM}
* features
@@ -214,6 +215,13 @@ struct virtio_net_hdr_v1_hash_tunnel {
__le16 inner_nh_offset;
};
+/* outer network header */
+struct virtio_net_hdr_v1_hash_tunnel_out_net_hdr {
+ struct virtio_net_hdr_v1_hash_tunnel tnl_hdr;
+ __le16 outer_nh_offset;
+ __u8 padding_reserved_2[6];
+};
+
#ifndef VIRTIO_NET_NO_LEGACY
/* This header comes first in the scatter-gather list.
* For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must
--
2.48.1
next prev parent reply other threads:[~2025-10-08 11:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-08 11:00 [PATCH v2 net-next 0/3] virtio_net: Implement VIRTIO_NET_F_OUT_NET_HEADER from virtio spec 1.4 Kommula Shiva Shankar
2025-10-08 11:00 ` Kommula Shiva Shankar [this message]
2025-10-08 11:00 ` [PATCH v2 net-next 2/3] virtio_net: enable outer nw header offset support Kommula Shiva Shankar
2025-10-08 11:00 ` [PATCH v2 net-next 3/3] vhost/net: " Kommula Shiva Shankar
2025-10-09 9:44 ` Paolo Abeni
2025-10-09 10:31 ` Michael S. Tsirkin
2025-10-08 11:26 ` [PATCH v2 net-next 0/3] virtio_net: Implement VIRTIO_NET_F_OUT_NET_HEADER from virtio spec 1.4 Parav Pandit
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=20251008110004.2933101-2-kshankar@marvell.com \
--to=kshankar@marvell.com \
--cc=jasowang@redhat.com \
--cc=jerinj@marvell.com \
--cc=mst@redhat.com \
--cc=ndabilpuram@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parav@nvidia.com \
--cc=sburla@marvell.com \
--cc=schalla@marvell.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.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).