DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wei Hu (Xavier)" <huwei013@chinasoftinc.com>
To: <dev@dpdk.org>
Cc: <xavier.huwei@huawei.com>
Subject: [dpdk-dev] [PATCH v2 05/17] net/hns3: add TSO pseudo header calculation compatibility
Date: Tue, 22 Sep 2020 20:03:17 +0800
Message-ID: <20200922120329.21185-6-huwei013@chinasoftinc.com> (raw)
In-Reply-To: <20200922120329.21185-1-huwei013@chinasoftinc.com>

From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>

In kunpeng 920, when process pkts which need TSO, the network driver
need to erase the L4 len value of the TCP TSO pseudo header and
recalculate the pseudo header checksum. kunpeng930 support not need
to erase the L4 len value of the TCP TSO pseudo header.

Signed-off-by: Hongbo Zheng <zhenghongbo3@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c    |  2 +
 drivers/net/hns3/hns3_ethdev.h    | 21 +++++++++-
 drivers/net/hns3/hns3_ethdev_vf.c |  2 +
 drivers/net/hns3/hns3_rxtx.c      | 82 ++++++++++++++++++++++++---------------
 drivers/net/hns3/hns3_rxtx.h      | 17 ++++++++
 5 files changed, 92 insertions(+), 32 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 3922df5..10cfc5d 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2916,6 +2916,7 @@ hns3_get_capability(struct hns3_hw *hw)
 		hw->intr.mapping_mode = HNS3_INTR_MAPPING_VEC_RSV_ONE;
 		hw->intr.coalesce_mode = HNS3_INTR_COALESCE_NON_QL;
 		hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_2US;
+		hw->tso_mode = HNS3_TSO_SW_CAL_PSEUDO_H_CSUM;
 		hw->vlan_mode = HNS3_SW_SHIFT_AND_DISCARD_MODE;
 		hw->min_tx_pkt_len = HNS3_HIP08_MIN_TX_PKT_LEN;
 		return 0;
@@ -2932,6 +2933,7 @@ hns3_get_capability(struct hns3_hw *hw)
 	hw->intr.mapping_mode = HNS3_INTR_MAPPING_VEC_ALL;
 	hw->intr.coalesce_mode = HNS3_INTR_COALESCE_QL;
 	hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_1US;
+	hw->tso_mode = HNS3_TSO_HW_CAL_PSEUDO_H_CSUM;
 	hw->vlan_mode = HNS3_HW_SHIFT_AND_DISCARD_MODE;
 	hw->min_tx_pkt_len = HNS3_HIP09_MIN_TX_PKT_LEN;
 
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index a70223f..f170df9 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -416,6 +416,9 @@ struct hns3_queue_intr {
 	uint8_t gl_unit;
 };
 
+#define HNS3_TSO_SW_CAL_PSEUDO_H_CSUM		0
+#define HNS3_TSO_HW_CAL_PSEUDO_H_CSUM		1
+
 struct hns3_hw {
 	struct rte_eth_dev_data *data;
 	void *io_base;
@@ -476,7 +479,23 @@ struct hns3_hw {
 	uint32_t min_tx_pkt_len;
 
 	struct hns3_queue_intr intr;
-
+	/*
+	 * tso mode.
+	 * value range:
+	 *      HNS3_TSO_SW_CAL_PSEUDO_H_CSUM/HNS3_TSO_HW_CAL_PSEUDO_H_CSUM
+	 *
+	 *  - HNS3_TSO_SW_CAL_PSEUDO_H_CSUM
+	 *     In this mode, because of the hardware constraint, network driver
+	 *     software need erase the L4 len value of the TCP pseudo header
+	 *     and recalculate the TCP pseudo header checksum of packets that
+	 *     need TSO.
+	 *
+	 *  - HNS3_TSO_HW_CAL_PSEUDO_H_CSUM
+	 *     In this mode, hardware support recalculate the TCP pseudo header
+	 *     checksum of packets that need TSO, so network driver software
+	 *     not need to recalculate it.
+	 */
+	uint8_t tso_mode;
 	/*
 	 * vlan mode.
 	 * value range:
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index c39edf5..565cf60 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1165,6 +1165,7 @@ hns3vf_get_capability(struct hns3_hw *hw)
 		hw->intr.mapping_mode = HNS3_INTR_MAPPING_VEC_RSV_ONE;
 		hw->intr.coalesce_mode = HNS3_INTR_COALESCE_NON_QL;
 		hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_2US;
+		hw->tso_mode = HNS3_TSO_SW_CAL_PSEUDO_H_CSUM;
 		hw->min_tx_pkt_len = HNS3_HIP08_MIN_TX_PKT_LEN;
 		return 0;
 	}
@@ -1180,6 +1181,7 @@ hns3vf_get_capability(struct hns3_hw *hw)
 	hw->intr.mapping_mode = HNS3_INTR_MAPPING_VEC_ALL;
 	hw->intr.coalesce_mode = HNS3_INTR_COALESCE_QL;
 	hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_1US;
+	hw->tso_mode = HNS3_TSO_HW_CAL_PSEUDO_H_CSUM;
 	hw->min_tx_pkt_len = HNS3_HIP09_MIN_TX_PKT_LEN;
 
 	return 0;
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 7c7b9de..930aa28 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -2188,6 +2188,7 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,
 	txq->io_tail_reg = (volatile void *)((char *)txq->io_base +
 					     HNS3_RING_TX_TAIL_REG);
 	txq->min_tx_pkt_len = hw->min_tx_pkt_len;
+	txq->tso_mode = hw->tso_mode;
 	txq->over_length_pkt_cnt = 0;
 	txq->exceed_limit_bd_pkt_cnt = 0;
 	txq->exceed_limit_bd_reassem_fail = 0;
@@ -2858,47 +2859,66 @@ hns3_vld_vlan_chk(struct hns3_tx_queue *txq, struct rte_mbuf *m)
 }
 #endif
 
-uint16_t
-hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
-	       uint16_t nb_pkts)
+static int
+hns3_prep_pkt_proc(struct hns3_tx_queue *tx_queue, struct rte_mbuf *m)
 {
-	struct hns3_tx_queue *txq;
-	struct rte_mbuf *m;
-	uint16_t i;
 	int ret;
 
-	txq = (struct hns3_tx_queue *)tx_queue;
-
-	for (i = 0; i < nb_pkts; i++) {
-		m = tx_pkts[i];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	ret = rte_validate_tx_offload(m);
+	if (ret != 0) {
+		rte_errno = -ret;
+		return ret;
+	}
 
-		if (hns3_pkt_is_tso(m) &&
-		    (hns3_pkt_need_linearized(m, m->nb_segs,
-					      txq->max_non_tso_bd_num) ||
-		     hns3_check_tso_pkt_valid(m))) {
+	ret = hns3_vld_vlan_chk(tx_queue, m);
+	if (ret != 0) {
+		rte_errno = EINVAL;
+		return ret;
+	}
+#endif
+	if (hns3_pkt_is_tso(m)) {
+		if (hns3_pkt_need_linearized(m, m->nb_segs,
+					     tx_queue->max_non_tso_bd_num) ||
+		    hns3_check_tso_pkt_valid(m)) {
 			rte_errno = EINVAL;
-			return i;
+			return -EINVAL;
 		}
 
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-		ret = rte_validate_tx_offload(m);
-		if (ret != 0) {
-			rte_errno = -ret;
-			return i;
+		if (tx_queue->tso_mode != HNS3_TSO_SW_CAL_PSEUDO_H_CSUM) {
+			/*
+			 * (tso mode != HNS3_TSO_SW_CAL_PSEUDO_H_CSUM) means
+			 * hardware support recalculate the TCP pseudo header
+			 * checksum of packets that need TSO, so network driver
+			 * software not need to recalculate it.
+			 */
+			hns3_outer_header_cksum_prepare(m);
+			return 0;
 		}
+	}
 
-		if (hns3_vld_vlan_chk(txq, m)) {
-			rte_errno = EINVAL;
-			return i;
-		}
-#endif
-		ret = rte_net_intel_cksum_prepare(m);
-		if (ret != 0) {
-			rte_errno = -ret;
-			return i;
-		}
+	ret = rte_net_intel_cksum_prepare(m);
+	if (ret != 0) {
+		rte_errno = -ret;
+		return ret;
+	}
+
+	hns3_outer_header_cksum_prepare(m);
+
+	return 0;
+}
 
-		hns3_outer_header_cksum_prepare(m);
+uint16_t
+hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
+	       uint16_t nb_pkts)
+{
+	struct rte_mbuf *m;
+	uint16_t i;
+
+	for (i = 0; i < nb_pkts; i++) {
+		m = tx_pkts[i];
+		if (hns3_prep_pkt_proc(tx_queue, m))
+			return i;
 	}
 
 	return i;
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index 5ffe30e..d7d70f6 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -367,6 +367,23 @@ struct hns3_tx_queue {
 	struct rte_mbuf **free;
 
 	/*
+	 * tso mode.
+	 * value range:
+	 *      HNS3_TSO_SW_CAL_PSEUDO_H_CSUM/HNS3_TSO_HW_CAL_PSEUDO_H_CSUM
+	 *
+	 *  - HNS3_TSO_SW_CAL_PSEUDO_H_CSUM
+	 *     In this mode, because of the hardware constraint, network driver
+	 *     software need erase the L4 len value of the TCP pseudo header
+	 *     and recalculate the TCP pseudo header checksum of packets that
+	 *     need TSO.
+	 *
+	 *  - HNS3_TSO_HW_CAL_PSEUDO_H_CSUM
+	 *     In this mode, hardware support recalculate the TCP pseudo header
+	 *     checksum of packets that need TSO, so network driver software
+	 *     not need to recalculate it.
+	 */
+	uint8_t tso_mode;
+	/*
 	 * The minimum length of the packet supported by hardware in the Tx
 	 * direction.
 	 */
-- 
2.9.5


  parent reply	other threads:[~2020-09-22 12:04 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22  8:53 [dpdk-dev] [PATCH 00/17] updates for hns3 PMD driver Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 01/17] net/hns3: add VLAN configuration compatibility Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 02/17] net/hns3: fix default VLAN won't be deleted when set PF PVID Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 03/17] net/hns3: add default branch to switch in Rx VLAN processing Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 04/17] net/hns3: add max number of segs compatibility Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 05/17] net/hns3: add TSO pseudo header calculation compatibility Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 06/17] net/hns3: avoid accessing nonexistent VF reg when PF in FLR Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 07/17] net/hns3: add default branch to switch when parsing fd tuple Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 08/17] net/hns3: add break to exit loop when err stat item found Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 09/17] net/hns3: support flow action of queue region Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 10/17] net/hns3: support querying RSS flow rule Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 11/17] net/hns3: check input RSS type when creating flow with RSS Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 12/17] net/hns3: set RSS hash type input configuration Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 13/17] net/hns3: fix config when creating RSS rule after flush Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 14/17] net/hns3: fix flow RSS queue num with 0 Wei Hu (Xavier)
2020-09-22  8:53 ` [dpdk-dev] [PATCH 15/17] net/hns3: fix flushing RSS rule Wei Hu (Xavier)
2020-09-22  8:54 ` [dpdk-dev] [PATCH 16/17] net/hns3: fix configuring device with RSS is enabled Wei Hu (Xavier)
2020-09-22  8:54 ` [dpdk-dev] [PATCH 17/17] net/hns3: fix storing RSS info when creating flow action Wei Hu (Xavier)
2020-09-22 12:03 ` [dpdk-dev] [PATCH v2 00/17] updates for hns3 PMD driver Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 01/17] net/hns3: add VLAN configuration compatibility Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 02/17] net/hns3: fix default VLAN won't be deleted when set PF PVID Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 03/17] net/hns3: add default branch to switch in Rx VLAN processing Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 04/17] net/hns3: add max number of segs compatibility Wei Hu (Xavier)
2020-09-22 12:03   ` Wei Hu (Xavier) [this message]
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 06/17] net/hns3: avoid accessing nonexistent VF reg when PF in FLR Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 07/17] net/hns3: add default branch to switch when parsing fd tuple Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 08/17] net/hns3: add break to exit loop when err stat item found Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 09/17] net/hns3: support flow action of queue region Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 10/17] net/hns3: support querying RSS flow rule Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 11/17] net/hns3: check input RSS type when creating flow with RSS Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 12/17] net/hns3: set RSS hash type input configuration Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 13/17] net/hns3: fix config when creating RSS rule after flush Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 14/17] net/hns3: fix flow RSS queue num with 0 Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 15/17] net/hns3: fix flushing RSS rule Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 16/17] net/hns3: fix configuring device with RSS is enabled Wei Hu (Xavier)
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 17/17] net/hns3: fix storing RSS info when creating flow action Wei Hu (Xavier)
2020-09-28 13:29   ` [dpdk-dev] [PATCH v2 00/17] updates for hns3 PMD driver Ferruh Yigit

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=20200922120329.21185-6-huwei013@chinasoftinc.com \
    --to=huwei013@chinasoftinc.com \
    --cc=dev@dpdk.org \
    --cc=xavier.huwei@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