* [PATCH v2] net/hns3: fix L4 checksum incorrect for tunnel packets
@ 2026-05-09 6:47 Xingui Yang
2026-05-09 7:18 ` fengchengwen
2026-05-18 3:30 ` Stephen Hemminger
0 siblings, 2 replies; 3+ messages in thread
From: Xingui Yang @ 2026-05-09 6:47 UTC (permalink / raw)
To: dev
Cc: stephen, david.marchand, fengchengwen, lihuisong, liuyonglong,
kangfenglong
In HIP09 simple BD mode, the driver incorrectly calculates L4_START
position for tunnel packets. The current implementation only uses
l2_len + l3_len without considering outer header lengths (outer_l2_len
and outer_l3_len), causing hardware to calculate checksum from wrong
offset.
For a typical NvGRE tunnel packet with structure:
Outer Eth(14) + Outer IPv6(40) + NvGRE(8) + Inner Eth(14) +
Inner IPv6(40) + TCP(20)
Expected L4_START: 116 bytes (from packet start to inner TCP header)
Actual calculation: 62 bytes (missing outer headers)
This results in incorrect TCP/UDP checksum for all tunnel packets when
using simple BD mode, including NvGRE, VxLAN, GRE, GENEVE tunnels.
Fix by adding outer_l2_len and outer_l3_len to L4_START calculation
when RTE_MBUF_F_TX_TUNNEL_MASK flag is set.
Fixes: 6393fc0b823c ("net/hns3: simplify hardware checksum offloading")
Cc: stable@dpdk.org
Signed-off-by: Xingui Yang <yangxingui@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 573604b0cd..4d48cbdc11 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -3982,6 +3982,7 @@ hns3_handle_simple_bd(struct hns3_tx_queue *txq, struct hns3_desc *desc,
{
#define HNS3_TCP_CSUM_OFFSET 16
#define HNS3_UDP_CSUM_OFFSET 6
+ uint32_t l4_start;
/*
* In HIP09, NIC HW support Tx simple BD mode that the HW will
@@ -4003,9 +4004,13 @@ hns3_handle_simple_bd(struct hns3_tx_queue *txq, struct hns3_desc *desc,
((m->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_TCP_CKSUM ||
(m->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_UDP_CKSUM)) {
/* set checksum start and offset, defined in 2 Bytes */
+ l4_start = m->l2_len + m->l3_len;
+ if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
+ l4_start += m->outer_l2_len + m->outer_l3_len;
+
hns3_set_field(desc->tx.type_cs_vlan_tso_len,
HNS3_TXD_L4_START_M, HNS3_TXD_L4_START_S,
- (m->l2_len + m->l3_len) >> HNS3_SIMPLE_BD_UNIT);
+ l4_start >> HNS3_SIMPLE_BD_UNIT);
hns3_set_field(desc->tx.ol_type_vlan_len_msec,
HNS3_TXD_L4_CKS_OFFSET_M, HNS3_TXD_L4_CKS_OFFSET_S,
(m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
--
2.33.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net/hns3: fix L4 checksum incorrect for tunnel packets
2026-05-09 6:47 [PATCH v2] net/hns3: fix L4 checksum incorrect for tunnel packets Xingui Yang
@ 2026-05-09 7:18 ` fengchengwen
2026-05-18 3:30 ` Stephen Hemminger
1 sibling, 0 replies; 3+ messages in thread
From: fengchengwen @ 2026-05-09 7:18 UTC (permalink / raw)
To: Xingui Yang, dev
Cc: stephen, david.marchand, lihuisong, liuyonglong, kangfenglong
Reviewed-by: Chengwen Feng <fengchengwen@huawei.com>
On 5/9/2026 2:47 PM, Xingui Yang wrote:
> In HIP09 simple BD mode, the driver incorrectly calculates L4_START
> position for tunnel packets. The current implementation only uses
> l2_len + l3_len without considering outer header lengths (outer_l2_len
> and outer_l3_len), causing hardware to calculate checksum from wrong
> offset.
>
> For a typical NvGRE tunnel packet with structure:
> Outer Eth(14) + Outer IPv6(40) + NvGRE(8) + Inner Eth(14) +
> Inner IPv6(40) + TCP(20)
>
> Expected L4_START: 116 bytes (from packet start to inner TCP header)
> Actual calculation: 62 bytes (missing outer headers)
>
> This results in incorrect TCP/UDP checksum for all tunnel packets when
> using simple BD mode, including NvGRE, VxLAN, GRE, GENEVE tunnels.
>
> Fix by adding outer_l2_len and outer_l3_len to L4_START calculation
> when RTE_MBUF_F_TX_TUNNEL_MASK flag is set.
>
> Fixes: 6393fc0b823c ("net/hns3: simplify hardware checksum offloading")
> Cc: stable@dpdk.org
>
> Signed-off-by: Xingui Yang <yangxingui@huawei.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net/hns3: fix L4 checksum incorrect for tunnel packets
2026-05-09 6:47 [PATCH v2] net/hns3: fix L4 checksum incorrect for tunnel packets Xingui Yang
2026-05-09 7:18 ` fengchengwen
@ 2026-05-18 3:30 ` Stephen Hemminger
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2026-05-18 3:30 UTC (permalink / raw)
To: Xingui Yang
Cc: dev, david.marchand, fengchengwen, lihuisong, liuyonglong,
kangfenglong
On Sat, 9 May 2026 14:47:53 +0800
Xingui Yang <yangxingui@huawei.com> wrote:
> In HIP09 simple BD mode, the driver incorrectly calculates L4_START
> position for tunnel packets. The current implementation only uses
> l2_len + l3_len without considering outer header lengths (outer_l2_len
> and outer_l3_len), causing hardware to calculate checksum from wrong
> offset.
>
> For a typical NvGRE tunnel packet with structure:
> Outer Eth(14) + Outer IPv6(40) + NvGRE(8) + Inner Eth(14) +
> Inner IPv6(40) + TCP(20)
>
> Expected L4_START: 116 bytes (from packet start to inner TCP header)
> Actual calculation: 62 bytes (missing outer headers)
>
> This results in incorrect TCP/UDP checksum for all tunnel packets when
> using simple BD mode, including NvGRE, VxLAN, GRE, GENEVE tunnels.
>
> Fix by adding outer_l2_len and outer_l3_len to L4_START calculation
> when RTE_MBUF_F_TX_TUNNEL_MASK flag is set.
>
> Fixes: 6393fc0b823c ("net/hns3: simplify hardware checksum offloading")
> Cc: stable@dpdk.org
>
> Signed-off-by: Xingui Yang <yangxingui@huawei.com>
> ---
> drivers/net/hns3/hns3_rxtx.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
> index 573604b0cd..4d48cbdc11 100644
> --- a/drivers/net/hns3/hns3_rxtx.c
> +++ b/drivers/net/hns3/hns3_rxtx.c
> @@ -3982,6 +3982,7 @@ hns3_handle_simple_bd(struct hns3_tx_queue *txq, struct hns3_desc *desc,
> {
> #define HNS3_TCP_CSUM_OFFSET 16
> #define HNS3_UDP_CSUM_OFFSET 6
> + uint32_t l4_start;
>
> /*
> * In HIP09, NIC HW support Tx simple BD mode that the HW will
> @@ -4003,9 +4004,13 @@ hns3_handle_simple_bd(struct hns3_tx_queue *txq, struct hns3_desc *desc,
> ((m->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_TCP_CKSUM ||
> (m->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_UDP_CKSUM)) {
> /* set checksum start and offset, defined in 2 Bytes */
> + l4_start = m->l2_len + m->l3_len;
Applied to next-net; moved declaration of l4_start into that basic block.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-18 3:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-09 6:47 [PATCH v2] net/hns3: fix L4 checksum incorrect for tunnel packets Xingui Yang
2026-05-09 7:18 ` fengchengwen
2026-05-18 3:30 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox