From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CB526A09E0 for ; Fri, 13 Nov 2020 14:37:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6BA1BC8A8; Fri, 13 Nov 2020 14:37:03 +0100 (CET) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id 77C6FC8BC for ; Fri, 13 Nov 2020 14:37:00 +0100 (CET) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CXfdW0hg4z72bS for ; Fri, 13 Nov 2020 21:36:47 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Fri, 13 Nov 2020 21:36:47 +0800 From: Lijun Ou To: , CC: Date: Fri, 13 Nov 2020 21:37:09 +0800 Message-ID: <1605274630-23414-13-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605274630-23414-1-git-send-email-oulijun@huawei.com> References: <1605274630-23414-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-stable] [PATCH 19.11.6 12/13] net/hns3: fix Tx checksum outer header prepare X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Chengchang Tang [ 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@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Lijun Ou --- 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