DPDK patches and discussions
 help / color / mirror / Atom feed
From: Lijun Ou <oulijun@huawei.com>
To: <ferruh.yigit@intel.com>
Cc: <dev@dpdk.org>, <linuxarm@huawei.com>
Subject: [dpdk-dev] [PATCH 2/8] net/hns3: fix Tx cksum outer header prepare
Date: Mon, 2 Nov 2020 22:38:13 +0800
Message-ID: <1604327899-60126-3-git-send-email-oulijun@huawei.com> (raw)
In-Reply-To: <1604327899-60126-1-git-send-email-oulijun@huawei.com>

From: Chengchang Tang <tangchengchang@huawei.com>

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 <tangchengchang@huawei.com>
Signed-off-by: Lijun Ou <oulijun@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 2988a4b..9cd728b 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -3151,26 +3151,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


  parent reply	other threads:[~2020-11-02 14:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-02 14:38 [dpdk-dev] [PATCH 0/8] misc fixes for hns3 Lijun Ou
2020-11-02 14:38 ` [dpdk-dev] [PATCH 1/8] net/hns3: add limit promisc mode to VF Lijun Ou
2020-11-02 14:38 ` Lijun Ou [this message]
2020-11-02 14:38 ` [dpdk-dev] [PATCH 3/8] net/hns3: fix Tx checksum with fix header length Lijun Ou
2020-11-02 14:38 ` [dpdk-dev] [PATCH 4/8] net/hns3: add VXLAN-GPE packets TSO and checksum support Lijun Ou
2020-11-02 14:38 ` [dpdk-dev] [PATCH 5/8] net/hns3: fix configurations of port-level scheduling rate Lijun Ou
2020-11-02 14:38 ` [dpdk-dev] [PATCH 6/8] net/hns3: fix visit unsupported QL register error Lijun Ou
2020-11-02 14:38 ` [dpdk-dev] [PATCH 7/8] net/hns3: fix some static check errors by coverity Lijun Ou
2020-11-03 11:41   ` Ferruh Yigit
2020-11-03 12:11     ` oulijun
2020-11-03 12:18       ` Ferruh Yigit
2020-11-02 14:38 ` [dpdk-dev] [PATCH 8/8] net/hns3: adjust some header files location Lijun Ou
2020-11-03 12:15 ` [dpdk-dev] [PATCH 0/8] misc fixes for hns3 Ferruh Yigit
2020-11-04  8:34   ` oulijun

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=1604327899-60126-3-git-send-email-oulijun@huawei.com \
    --to=oulijun@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=linuxarm@huawei.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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git