[dpdk-stable] [PATCH 19.11.6 12/13] net/hns3: fix Tx checksum outer header prepare

Lijun Ou oulijun at huawei.com
Fri Nov 13 14:37:09 CET 2020


From: Chengchang Tang <tangchengchang at huawei.com>

[ upstream commit f9edada6515213d3c58180d564a0743a4ebbe153 ]

Currently, there are two mistakes in Tx checksum outer header prepare.
1) Check whether the packet outer header is IPV4 based on PKT_TX_IPV4
   which is incorrect.
2) For HIP08, the outer UDP cksum could not be offloaded. And driver
   should ensure the outer udp cksum filed set to 0. In current code,
   PKT_TX_UDP_CKSUM is used to determine whether the outer layer of
   the packet is a UDP header. Actually, for tunnel TSO, the flag will
   never be set.

For the first mistake, it is fixed by replacing PKT_TX_IPV4 with
PKT_TX_OUTER_IPV4. And the protocol number in L3 header is used to check
whether the outer L4 header is UDP.

Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations")
Fixes: 6dca716c9e1d ("net/hns3: support TSO")
Cc: stable at dpdk.org

Signed-off-by: Chengchang Tang <tangchengchang at huawei.com>
Signed-off-by: Lijun Ou <oulijun at huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 2bb0c46..e8c85c6 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -2365,26 +2365,29 @@ static void
 hns3_outer_header_cksum_prepare(struct rte_mbuf *m)
 {
 	uint64_t ol_flags = m->ol_flags;
-	struct rte_ipv4_hdr *ipv4_hdr;
-	struct rte_udp_hdr *udp_hdr;
-	uint32_t paylen, hdr_len;
+	uint32_t paylen, hdr_len, l4_proto;
 
 	if (!(ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6)))
 		return;
 
-	if (ol_flags & PKT_TX_IPV4) {
+	if (ol_flags & PKT_TX_OUTER_IPV4) {
+		struct rte_ipv4_hdr *ipv4_hdr;
 		ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
 						   m->outer_l2_len);
-
-		if (ol_flags & PKT_TX_IP_CKSUM)
+		l4_proto = ipv4_hdr->next_proto_id;
+		if (ol_flags & PKT_TX_OUTER_IP_CKSUM)
 			ipv4_hdr->hdr_checksum = 0;
+	} else {
+		struct rte_ipv6_hdr *ipv6_hdr;
+		ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *,
+						   m->outer_l2_len);
+		l4_proto = ipv6_hdr->proto;
 	}
-
-	if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM &&
-	    ol_flags & PKT_TX_TCP_SEG) {
+	/* driver should ensure the outer udp cksum is 0 for TUNNEL TSO */
+	if (l4_proto == IPPROTO_UDP && (ol_flags & PKT_TX_TCP_SEG)) {
+		struct rte_udp_hdr *udp_hdr;
 		hdr_len = m->l2_len + m->l3_len + m->l4_len;
-		hdr_len += (ol_flags & PKT_TX_TUNNEL_MASK) ?
-				m->outer_l2_len + m->outer_l3_len : 0;
+		hdr_len += m->outer_l2_len + m->outer_l3_len;
 		paylen = m->pkt_len - hdr_len;
 		if (paylen <= m->tso_segsz)
 			return;
-- 
2.7.4



More information about the stable mailing list