virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 net-next  0/3] virtio_net: Implement VIRTIO_NET_F_OUT_NET_HEADER from virtio spec 1.4
@ 2025-09-23 20:22 Kommula Shiva Shankar
  2025-09-23 20:22 ` [PATCH v1 net-next 1/3] net: implement virtio helper to handle outer nw offset Kommula Shiva Shankar
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Kommula Shiva Shankar @ 2025-09-23 20:22 UTC (permalink / raw)
  To: netdev, mst, jasowang, pabeni, xuanzhuo
  Cc: virtualization, parav, jerinj, ndabilpuram, sburla, schalla

This series implements the VIRTIO_NET_F_OUT_NET_HEADER feature which was introduced in the virtio specification 1.4 recently. 
With this change, segmentation offload functionality now propagates outer IP header offset information to the device/apps running on NIC. 

The virtio 1.4 spec introduced VIRTIO_NET_F_OUT_NET_HEADER feature[1] to address the performance issue caused by reading packet data 
to determine outer network header offset and to support Inline IPSec functionality,
where vendor hardware devices need to know the outer network header offset for Inline IPSec acceleration.

Currently, devices must parse through packet headers to determine the outer network header which impacts performance. 
This patch series implements the outer_nh_offset field in virtio_net_hdr to avoid parsing overhead. 

This series was tested on ARM platform with virtio-net driver where ~4% performance improvement was measured
for device applications.

[1] https://lore.kernel.org/virtio-comment/20250401195655.486230-1-kshankar@marvell.com/

Kommula Shiva Shankar (3):
  net: implement virtio helper to handle outer nw offset
  virtio_net: enable outer nw header offset support.
  vhost/net: enable outer nw header offset support.

 drivers/net/virtio_net.c        | 23 +++++++++++++++----
 drivers/vhost/net.c             |  4 ++++
 include/linux/virtio_net.h      | 40 +++++++++++++++++++++++++++++++++
 include/uapi/linux/virtio_net.h |  8 +++++++
 4 files changed, 71 insertions(+), 4 deletions(-)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v1 net-next  1/3] net: implement virtio helper to handle outer nw offset
  2025-09-23 20:22 [PATCH v1 net-next 0/3] virtio_net: Implement VIRTIO_NET_F_OUT_NET_HEADER from virtio spec 1.4 Kommula Shiva Shankar
@ 2025-09-23 20:22 ` Kommula Shiva Shankar
  2025-09-24  0:51   ` Jason Wang
  2025-09-23 20:22 ` [PATCH v1 net-next 2/3] virtio_net: enable outer nw header offset support Kommula Shiva Shankar
  2025-09-23 20:22 ` [PATCH v1 net-next 3/3] vhost/net: " Kommula Shiva Shankar
  2 siblings, 1 reply; 9+ messages in thread
From: Kommula Shiva Shankar @ 2025-09-23 20:22 UTC (permalink / raw)
  To: netdev, mst, jasowang, pabeni, xuanzhuo
  Cc: virtualization, parav, jerinj, ndabilpuram, sburla, schalla

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..e6153e9106d3 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 = __virtio16_to_cpu(little_endian, 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))
+		vhdr->outer_nh_offset = __cpu_to_virtio16(little_endian,
+							  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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 net-next  2/3] virtio_net: enable outer nw header offset support.
  2025-09-23 20:22 [PATCH v1 net-next 0/3] virtio_net: Implement VIRTIO_NET_F_OUT_NET_HEADER from virtio spec 1.4 Kommula Shiva Shankar
  2025-09-23 20:22 ` [PATCH v1 net-next 1/3] net: implement virtio helper to handle outer nw offset Kommula Shiva Shankar
@ 2025-09-23 20:22 ` Kommula Shiva Shankar
  2025-09-25  1:07   ` kernel test robot
  2025-09-23 20:22 ` [PATCH v1 net-next 3/3] vhost/net: " Kommula Shiva Shankar
  2 siblings, 1 reply; 9+ messages in thread
From: Kommula Shiva Shankar @ 2025-09-23 20:22 UTC (permalink / raw)
  To: netdev, mst, jasowang, pabeni, xuanzhuo
  Cc: virtualization, parav, jerinj, ndabilpuram, sburla, schalla

If outer network header feature is set, update header offset
in ingress and egress path.

If feature is not set, reset header offset to zero.

Signed-off-by: Kommula Shiva Shankar <kshankar@marvell.com>
---
 drivers/net/virtio_net.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 7da5a37917e9..0b60cbbb3d33 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -451,6 +451,9 @@ struct virtnet_info {
 
 	bool rx_tnl_csum;
 
+	/* Outer network header support */
+	bool out_net_hdr_negotiated;
+
 	/* Is delayed refill enabled? */
 	bool refill_enabled;
 
@@ -511,6 +514,7 @@ struct virtio_net_common_hdr {
 		struct virtio_net_hdr_mrg_rxbuf	mrg_hdr;
 		struct virtio_net_hdr_v1_hash hash_v1_hdr;
 		struct virtio_net_hdr_v1_hash_tunnel tnl_hdr;
+		struct virtio_net_hdr_v1_hash_tunnel_out_net_hdr out_net_hdr;
 	};
 };
 
@@ -2576,8 +2580,8 @@ static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue *
 	hdr->hdr.flags = flags;
 	if (virtio_net_handle_csum_offload(skb, &hdr->hdr, vi->rx_tnl_csum)) {
 		net_warn_ratelimited("%s: bad csum: flags: %x, gso_type: %x rx_tnl_csum %d\n",
-				     dev->name, hdr->hdr.flags,
-				     hdr->hdr.gso_type, vi->rx_tnl_csum);
+				dev->name, hdr->hdr.flags,
+				hdr->hdr.gso_type, vi->rx_tnl_csum);
 		goto frame_err;
 	}
 
@@ -2591,6 +2595,8 @@ static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue *
 		goto frame_err;
 	}
 
+	virtio_net_out_net_header_to_skb(skb, &hdr->out_net_hdr, vi->out_net_hdr_negotiated,
+					 virtio_is_little_endian(vi->vdev));
 	skb_record_rx_queue(skb, vq2rxq(rq->vq));
 	skb->protocol = eth_type_trans(skb, dev);
 	pr_debug("Receiving skb proto 0x%04x len %i type %i\n",
@@ -3317,6 +3323,9 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb, bool orphan)
 	else
 		hdr = &skb_vnet_common_hdr(skb)->tnl_hdr;
 
+	virtio_net_out_net_header_from_skb(skb, &skb_vnet_common_hdr(skb)->out_net_hdr,
+					   vi->out_net_hdr_negotiated,
+					   virtio_is_little_endian(vi->vdev));
 	if (virtio_net_hdr_tnl_from_skb(skb, hdr, vi->tx_tnl,
 					virtio_is_little_endian(vi->vdev), 0))
 		return -EPROTO;
@@ -6915,8 +6924,10 @@ static int virtnet_probe(struct virtio_device *vdev)
 		dev->xdp_metadata_ops = &virtnet_xdp_metadata_ops;
 	}
 
-	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO) ||
-	    virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO))
+	if (virtio_has_feature(vdev, VIRTIO_NET_F_OUT_NET_HEADER))
+		vi->hdr_len = sizeof(struct virtio_net_hdr_v1_hash_tunnel_out_net_hdr);
+	else if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO) ||
+		 virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO))
 		vi->hdr_len = sizeof(struct virtio_net_hdr_v1_hash_tunnel);
 	else if (vi->has_rss_hash_report)
 		vi->hdr_len = sizeof(struct virtio_net_hdr_v1_hash);
@@ -6933,6 +6944,9 @@ static int virtnet_probe(struct virtio_device *vdev)
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO))
 		vi->tx_tnl = true;
 
+	if (virtio_has_feature(vdev, VIRTIO_NET_F_OUT_NET_HEADER))
+		vi->out_net_hdr_negotiated = true;
+
 	if (virtio_has_feature(vdev, VIRTIO_F_ANY_LAYOUT) ||
 	    virtio_has_feature(vdev, VIRTIO_F_VERSION_1))
 		vi->any_header_sg = true;
@@ -7247,6 +7261,7 @@ static unsigned int features[] = {
 	VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM,
 	VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO,
 	VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM,
+	VIRTIO_NET_F_OUT_NET_HEADER,
 };
 
 static unsigned int features_legacy[] = {
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 net-next  3/3] vhost/net: enable outer nw header offset support.
  2025-09-23 20:22 [PATCH v1 net-next 0/3] virtio_net: Implement VIRTIO_NET_F_OUT_NET_HEADER from virtio spec 1.4 Kommula Shiva Shankar
  2025-09-23 20:22 ` [PATCH v1 net-next 1/3] net: implement virtio helper to handle outer nw offset Kommula Shiva Shankar
  2025-09-23 20:22 ` [PATCH v1 net-next 2/3] virtio_net: enable outer nw header offset support Kommula Shiva Shankar
@ 2025-09-23 20:22 ` Kommula Shiva Shankar
  2025-09-24 15:44   ` kernel test robot
  2 siblings, 1 reply; 9+ messages in thread
From: Kommula Shiva Shankar @ 2025-09-23 20:22 UTC (permalink / raw)
  To: netdev, mst, jasowang, pabeni, xuanzhuo
  Cc: virtualization, parav, jerinj, ndabilpuram, sburla, schalla

apprise vhost net about the virtio net header size.

Signed-off-by: Kommula Shiva Shankar <kshankar@marvell.com>
---
 drivers/vhost/net.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index c6508fe0d5c8..a5c56af555f9 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -78,6 +78,7 @@ static const u64 vhost_net_features[VIRTIO_FEATURES_DWORDS] = {
 	(1ULL << VIRTIO_F_IN_ORDER),
 	VIRTIO_BIT(VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO) |
 	VIRTIO_BIT(VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO),
+	VIRTIO_BIT(VIRTIO_NET_F_OUT_NET_HEADER),
 };
 
 enum {
@@ -1661,6 +1662,9 @@ static int vhost_net_set_features(struct vhost_net *n, const u64 *features)
 		  sizeof(struct virtio_net_hdr_mrg_rxbuf) :
 		  sizeof(struct virtio_net_hdr);
 
+	if (virtio_features_test_bit(features,
+				     VIRTIO_NET_F_OUT_NET_HEADER))
+		hdr_len = sizeof(struct virtio_net_hdr_v1_hash_tunnel_out_net_hdr);
 	if (virtio_features_test_bit(features,
 				     VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO) ||
 	    virtio_features_test_bit(features,
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 net-next 1/3] net: implement virtio helper to handle outer nw offset
  2025-09-23 20:22 ` [PATCH v1 net-next 1/3] net: implement virtio helper to handle outer nw offset Kommula Shiva Shankar
@ 2025-09-24  0:51   ` Jason Wang
  2025-09-24  1:11     ` Jason Wang
  0 siblings, 1 reply; 9+ messages in thread
From: Jason Wang @ 2025-09-24  0:51 UTC (permalink / raw)
  To: Kommula Shiva Shankar
  Cc: netdev, mst, pabeni, xuanzhuo, virtualization, parav, jerinj,
	ndabilpuram, sburla, schalla

On Wed, Sep 24, 2025 at 4:23 AM Kommula Shiva Shankar
<kshankar@marvell.com> wrote:
>
> 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..e6153e9106d3 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 = __virtio16_to_cpu(little_endian, 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))
> +               vhdr->outer_nh_offset = __cpu_to_virtio16(little_endian,
> +                                                         out_net_hdr_off);

I'd expect this to work for IPV6 as well.

Thanks


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 net-next 1/3] net: implement virtio helper to handle outer nw offset
  2025-09-24  0:51   ` Jason Wang
@ 2025-09-24  1:11     ` Jason Wang
  2025-10-03 11:06       ` [EXTERNAL] " Shiva Shankar Kommula
  0 siblings, 1 reply; 9+ messages in thread
From: Jason Wang @ 2025-09-24  1:11 UTC (permalink / raw)
  To: Kommula Shiva Shankar
  Cc: netdev, mst, pabeni, xuanzhuo, virtualization, parav, jerinj,
	ndabilpuram, sburla, schalla

On Wed, Sep 24, 2025 at 8:51 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Wed, Sep 24, 2025 at 4:23 AM Kommula Shiva Shankar
> <kshankar@marvell.com> wrote:
> >
> > 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..e6153e9106d3 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 = __virtio16_to_cpu(little_endian, 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))
> > +               vhdr->outer_nh_offset = __cpu_to_virtio16(little_endian,
> > +                                                         out_net_hdr_off);
>
> I'd expect this to work for IPV6 as well.

Or why it only works for IP/IPV6.

>
> Thanks

Thanks


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 net-next  3/3] vhost/net: enable outer nw header offset support.
  2025-09-23 20:22 ` [PATCH v1 net-next 3/3] vhost/net: " Kommula Shiva Shankar
@ 2025-09-24 15:44   ` kernel test robot
  0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-09-24 15:44 UTC (permalink / raw)
  To: Kommula Shiva Shankar, netdev, mst, jasowang, pabeni, xuanzhuo
  Cc: oe-kbuild-all, virtualization, parav, jerinj, ndabilpuram, sburla,
	schalla

Hi Kommula,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Kommula-Shiva-Shankar/net-implement-virtio-helper-to-handle-outer-nw-offset/20250924-042602
base:   net-next/main
patch link:    https://lore.kernel.org/r/20250923202258.2738717-4-kshankar%40marvell.com
patch subject: [PATCH v1 net-next  3/3] vhost/net: enable outer nw header offset support.
config: arc-randconfig-r071-20250924 (https://download.01.org/0day-ci/archive/20250924/202509242332.EMhAL1a2-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 13.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250924/202509242332.EMhAL1a2-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509242332.EMhAL1a2-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from include/linux/bits.h:5,
                    from include/linux/bitops.h:6,
                    from include/linux/log2.h:12,
                    from include/asm-generic/div64.h:55,
                    from ./arch/arc/include/generated/asm/div64.h:1,
                    from include/linux/math.h:6,
                    from include/linux/math64.h:6,
                    from include/linux/time.h:6,
                    from include/linux/compat.h:10,
                    from drivers/vhost/net.c:8:
>> include/vdso/bits.h:8:33: warning: excess elements in array initializer
       8 | #define BIT_ULL(nr)             (ULL(1) << (nr))
         |                                 ^
   include/linux/virtio_features.h:10:33: note: in expansion of macro 'BIT_ULL'
      10 | #define VIRTIO_BIT(b)           BIT_ULL((b) & 0x3f)
         |                                 ^~~~~~~
   drivers/vhost/net.c:81:9: note: in expansion of macro 'VIRTIO_BIT'
      81 |         VIRTIO_BIT(VIRTIO_NET_F_OUT_NET_HEADER),
         |         ^~~~~~~~~~
   include/vdso/bits.h:8:33: note: (near initialization for 'vhost_net_features')
       8 | #define BIT_ULL(nr)             (ULL(1) << (nr))
         |                                 ^
   include/linux/virtio_features.h:10:33: note: in expansion of macro 'BIT_ULL'
      10 | #define VIRTIO_BIT(b)           BIT_ULL((b) & 0x3f)
         |                                 ^~~~~~~
   drivers/vhost/net.c:81:9: note: in expansion of macro 'VIRTIO_BIT'
      81 |         VIRTIO_BIT(VIRTIO_NET_F_OUT_NET_HEADER),
         |         ^~~~~~~~~~


vim +8 include/vdso/bits.h

3945ff37d2f48d Vincenzo Frascino 2020-03-20  6  
3945ff37d2f48d Vincenzo Frascino 2020-03-20  7  #define BIT(nr)			(UL(1) << (nr))
cbdb1f163af2bb Andy Shevchenko   2022-11-28 @8  #define BIT_ULL(nr)		(ULL(1) << (nr))
3945ff37d2f48d Vincenzo Frascino 2020-03-20  9  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 net-next  2/3] virtio_net: enable outer nw header offset support.
  2025-09-23 20:22 ` [PATCH v1 net-next 2/3] virtio_net: enable outer nw header offset support Kommula Shiva Shankar
@ 2025-09-25  1:07   ` kernel test robot
  0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-09-25  1:07 UTC (permalink / raw)
  To: Kommula Shiva Shankar, netdev, mst, jasowang, pabeni, xuanzhuo
  Cc: oe-kbuild-all, virtualization, parav, jerinj, ndabilpuram, sburla,
	schalla

Hi Kommula,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Kommula-Shiva-Shankar/net-implement-virtio-helper-to-handle-outer-nw-offset/20250924-042602
base:   net-next/main
patch link:    https://lore.kernel.org/r/20250923202258.2738717-3-kshankar%40marvell.com
patch subject: [PATCH v1 net-next  2/3] virtio_net: enable outer nw header offset support.
config: x86_64-randconfig-122-20250924 (https://download.01.org/0day-ci/archive/20250925/202509250856.HoVMjFzw-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250925/202509250856.HoVMjFzw-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509250856.HoVMjFzw-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   drivers/net/virtio_net.c: note: in included file:
>> include/linux/virtio_net.h:389:72: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __virtio16 [usertype] val @@     got restricted __le16 [usertype] outer_nh_offset @@
   include/linux/virtio_net.h:389:72: sparse:     expected restricted __virtio16 [usertype] val
   include/linux/virtio_net.h:389:72: sparse:     got restricted __le16 [usertype] outer_nh_offset
>> include/linux/virtio_net.h:411:39: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __le16 [usertype] outer_nh_offset @@     got restricted __virtio16 @@
   include/linux/virtio_net.h:411:39: sparse:     expected restricted __le16 [usertype] outer_nh_offset
   include/linux/virtio_net.h:411:39: sparse:     got restricted __virtio16

vim +389 include/linux/virtio_net.h

a2fb4bc4e2a6a0 Paolo Abeni           2025-07-08  376  
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  377  static inline int
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  378  virtio_net_out_net_header_to_skb(struct sk_buff *skb,
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  379  				 struct virtio_net_hdr_v1_hash_tunnel_out_net_hdr *vhdr,
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  380  				 bool out_net_hdr_negotiated,
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  381  				 bool little_endian)
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  382  {
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  383  	unsigned int out_net_hdr_off;
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  384  
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  385  	if (!out_net_hdr_negotiated)
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  386  		return 0;
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  387  
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  388  	if (vhdr->outer_nh_offset) {
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24 @389  		out_net_hdr_off = __virtio16_to_cpu(little_endian, vhdr->outer_nh_offset);
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  390  		skb_set_network_header(skb, out_net_hdr_off);
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  391  	}
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  392  
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  393  	return 0;
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  394  }
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  395  
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  396  static inline int
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  397  virtio_net_out_net_header_from_skb(const struct sk_buff *skb,
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  398  				   struct virtio_net_hdr_v1_hash_tunnel_out_net_hdr *vhdr,
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  399  				   bool out_net_hdr_negotiated,
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  400  				   bool little_endian)
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  401  {
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  402  	unsigned int out_net_hdr_off;
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  403  
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  404  	if (!out_net_hdr_negotiated) {
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  405  		vhdr->outer_nh_offset = 0;
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  406  		return 0;
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  407  	}
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  408  
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  409  	out_net_hdr_off = skb_network_offset(skb);
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  410  	if (out_net_hdr_off && skb->protocol == htons(ETH_P_IP))
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24 @411  		vhdr->outer_nh_offset = __cpu_to_virtio16(little_endian,
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  412  							  out_net_hdr_off);
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  413  
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  414  	return 0;
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  415  }
1dc49efaeaa4c1 Kommula Shiva Shankar 2025-09-24  416  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [EXTERNAL] Re: [PATCH v1 net-next 1/3] net: implement virtio helper to handle outer nw offset
  2025-09-24  1:11     ` Jason Wang
@ 2025-10-03 11:06       ` Shiva Shankar Kommula
  0 siblings, 0 replies; 9+ messages in thread
From: Shiva Shankar Kommula @ 2025-10-03 11:06 UTC (permalink / raw)
  To: Jason Wang
  Cc: netdev@vger.kernel.org, mst@redhat.com, pabeni@redhat.com,
	xuanzhuo@linux.alibaba.com, virtualization@lists.linux.dev,
	parav@nvidia.com, Jerin Jacob, Nithin Kumar Dabilpuram,
	Satananda Burla, Srujana Challa



> -----Original Message-----
> From: Jason Wang <jasowang@redhat.com>
> Sent: Wednesday, September 24, 2025 6:42 AM
> To: Shiva Shankar Kommula <kshankar@marvell.com>
> Cc: netdev@vger.kernel.org; mst@redhat.com; pabeni@redhat.com;
> xuanzhuo@linux.alibaba.com; virtualization@lists.linux.dev;
> parav@nvidia.com; Jerin Jacob <jerinj@marvell.com>; Nithin Kumar
> Dabilpuram <ndabilpuram@marvell.com>; Satananda Burla
> <sburla@marvell.com>; Srujana Challa <schalla@marvell.com>
> Subject: [EXTERNAL] Re: [PATCH v1 net-next 1/3] net: implement virtio helper
> to handle outer nw offset
> 
> On Wed, Sep 24, 2025 at 8: 51 AM Jason Wang <jasowang@ redhat. com>
> wrote: > > On Wed, Sep 24, 2025 at 4: 23 AM Kommula Shiva Shankar >
> <kshankar@ marvell. com> wrote: > > > > virtio specification introduced
> support ZjQcmQRYFpfptBannerStart Prioritize security for external emails:
> Confirm sender and content safety before clicking links or opening
> attachments <https://us-phishalarm-
> ewt.proofpoint.com/EWT/v1/CRVmXkqW!uK3X-
> 9E6SRp0XGTVtj3VIQ_zyUMjHsJk-qBfNXNYwQ-
> KaaNi0OVbkFRQlH6dtJYLMJxB4nt7OedRALLt3Wbol5OAgy2sLOiZzMfXrW0fM
> e51aGMKTCrL4Ni4Ink$>
> Report Suspicious
> 
> ZjQcmQRYFpfptBannerEnd
> On Wed, Sep 24, 2025 at 8:51 AM Jason Wang <jasowang@redhat.com>
> wrote:
> >
> > On Wed, Sep 24, 2025 at 4:23 AM Kommula Shiva Shankar
> > <kshankar@marvell.com> wrote:
> > >
> > > 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..e6153e9106d3 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 = __virtio16_to_cpu(little_endian, 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))
> > > +               vhdr->outer_nh_offset = __cpu_to_virtio16(little_endian,
> > > +
> > > + out_net_hdr_off);
> >
> > I'd expect this to work for IPV6 as well.
This feature could be extended to both IPv4 and IPv6 as they both used in GSO. 
I will send v2 with IPv6 support.
> 
> Or why it only works for IP/IPV6.
AFAIK,  virtio device acceleration features are optimized for the IP protocol 
and transport layers like TCP/UDP. 
Although other protocols like IPX uses similar checksum algo used in IP checksum, they are not 
utilized in device offloading. 
> 
> >
> > Thanks
> 
> Thanks


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-10-03 11:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23 20:22 [PATCH v1 net-next 0/3] virtio_net: Implement VIRTIO_NET_F_OUT_NET_HEADER from virtio spec 1.4 Kommula Shiva Shankar
2025-09-23 20:22 ` [PATCH v1 net-next 1/3] net: implement virtio helper to handle outer nw offset Kommula Shiva Shankar
2025-09-24  0:51   ` Jason Wang
2025-09-24  1:11     ` Jason Wang
2025-10-03 11:06       ` [EXTERNAL] " Shiva Shankar Kommula
2025-09-23 20:22 ` [PATCH v1 net-next 2/3] virtio_net: enable outer nw header offset support Kommula Shiva Shankar
2025-09-25  1:07   ` kernel test robot
2025-09-23 20:22 ` [PATCH v1 net-next 3/3] vhost/net: " Kommula Shiva Shankar
2025-09-24 15:44   ` kernel test robot

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).