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 04/17] net/hns3: add max number of segs compatibility
Date: Tue, 22 Sep 2020 20:03:16 +0800
Message-ID: <20200922120329.21185-5-huwei013@chinasoftinc.com> (raw)
In-Reply-To: <20200922120329.21185-1-huwei013@chinasoftinc.com>

From: Hongbo Zheng <zhenghongbo3@huawei.com>

Kunpeng 920 supports the maximum nb_segs of non-tso packet is 8 in Tx
direction, kunpeng 930 expands this limit value to 18, this patch sets
the corresponding value by querying the maximum number of non-tso nb_segs
supported by the device during initialization.

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_vf.c |  2 +-
 drivers/net/hns3/hns3_rxtx.c      | 30 ++++++++++++++++++++----------
 drivers/net/hns3/hns3_rxtx.h      |  1 +
 4 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index abc1742..3922df5 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2514,7 +2514,7 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
 		.nb_min = HNS3_MIN_RING_DESC,
 		.nb_align = HNS3_ALIGN_RING_DESC,
 		.nb_seg_max = HNS3_MAX_TSO_BD_PER_PKT,
-		.nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT,
+		.nb_mtu_seg_max = hw->max_non_tso_bd_num,
 	};
 
 	info->default_rxconf = (struct rte_eth_rxconf) {
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 037a5be..c39edf5 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -966,7 +966,7 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
 		.nb_min = HNS3_MIN_RING_DESC,
 		.nb_align = HNS3_ALIGN_RING_DESC,
 		.nb_seg_max = HNS3_MAX_TSO_BD_PER_PKT,
-		.nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT,
+		.nb_mtu_seg_max = hw->max_non_tso_bd_num,
 	};
 
 	info->default_rxconf = (struct rte_eth_rxconf) {
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 6d02bad..7c7b9de 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -2181,6 +2181,7 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,
 					HNS3_PORT_BASE_VLAN_ENABLE;
 	else
 		txq->pvid_sw_shift_en = false;
+	txq->max_non_tso_bd_num = hw->max_non_tso_bd_num;
 	txq->configured = true;
 	txq->io_base = (void *)((char *)hw->io_base + HNS3_TQP_REG_OFFSET +
 				idx * HNS3_TQP_REG_SIZE);
@@ -2438,7 +2439,8 @@ hns3_pktmbuf_copy_hdr(struct rte_mbuf *new_pkt, struct rte_mbuf *old_pkt)
 }
 
 static int
-hns3_reassemble_tx_pkts(struct rte_mbuf *tx_pkt, struct rte_mbuf **new_pkt)
+hns3_reassemble_tx_pkts(struct rte_mbuf *tx_pkt, struct rte_mbuf **new_pkt,
+				  uint8_t max_non_tso_bd_num)
 {
 	struct rte_mempool *mb_pool;
 	struct rte_mbuf *new_mbuf;
@@ -2458,7 +2460,7 @@ hns3_reassemble_tx_pkts(struct rte_mbuf *tx_pkt, struct rte_mbuf **new_pkt)
 	mb_pool = tx_pkt->pool;
 	buf_size = tx_pkt->buf_len - RTE_PKTMBUF_HEADROOM;
 	nb_new_buf = (rte_pktmbuf_pkt_len(tx_pkt) - 1) / buf_size + 1;
-	if (nb_new_buf > HNS3_MAX_NON_TSO_BD_PER_PKT)
+	if (nb_new_buf > max_non_tso_bd_num)
 		return -EINVAL;
 
 	last_buf_len = rte_pktmbuf_pkt_len(tx_pkt) % buf_size;
@@ -2690,7 +2692,8 @@ hns3_txd_enable_checksum(struct hns3_tx_queue *txq, uint16_t tx_desc_id,
 }
 
 static bool
-hns3_pkt_need_linearized(struct rte_mbuf *tx_pkts, uint32_t bd_num)
+hns3_pkt_need_linearized(struct rte_mbuf *tx_pkts, uint32_t bd_num,
+				 uint32_t max_non_tso_bd_num)
 {
 	struct rte_mbuf *m_first = tx_pkts;
 	struct rte_mbuf *m_last = tx_pkts;
@@ -2705,10 +2708,10 @@ hns3_pkt_need_linearized(struct rte_mbuf *tx_pkts, uint32_t bd_num)
 	 * frags greater than gso header len + mss, and the remaining 7
 	 * consecutive frags greater than MSS except the last 7 frags.
 	 */
-	if (bd_num <= HNS3_MAX_NON_TSO_BD_PER_PKT)
+	if (bd_num <= max_non_tso_bd_num)
 		return false;
 
-	for (i = 0; m_last && i < HNS3_MAX_NON_TSO_BD_PER_PKT - 1;
+	for (i = 0; m_last && i < max_non_tso_bd_num - 1;
 	     i++, m_last = m_last->next)
 		tot_len += m_last->data_len;
 
@@ -2726,7 +2729,7 @@ hns3_pkt_need_linearized(struct rte_mbuf *tx_pkts, uint32_t bd_num)
 	 * ensure the sum of the data length of every 7 consecutive buffer
 	 * is greater than mss except the last one.
 	 */
-	for (i = 0; m_last && i < bd_num - HNS3_MAX_NON_TSO_BD_PER_PKT; i++) {
+	for (i = 0; m_last && i < bd_num - max_non_tso_bd_num; i++) {
 		tot_len -= m_first->data_len;
 		tot_len += m_last->data_len;
 
@@ -2859,15 +2862,19 @@ uint16_t
 hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 	       uint16_t nb_pkts)
 {
+	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];
 
 		if (hns3_pkt_is_tso(m) &&
-		    (hns3_pkt_need_linearized(m, m->nb_segs) ||
+		    (hns3_pkt_need_linearized(m, m->nb_segs,
+					      txq->max_non_tso_bd_num) ||
 		     hns3_check_tso_pkt_valid(m))) {
 			rte_errno = EINVAL;
 			return i;
@@ -2880,7 +2887,7 @@ hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 			return i;
 		}
 
-		if (hns3_vld_vlan_chk(tx_queue, m)) {
+		if (hns3_vld_vlan_chk(txq, m)) {
 			rte_errno = EINVAL;
 			return i;
 		}
@@ -2921,6 +2928,7 @@ static int
 hns3_check_non_tso_pkt(uint16_t nb_buf, struct rte_mbuf **m_seg,
 		      struct rte_mbuf *tx_pkt, struct hns3_tx_queue *txq)
 {
+	uint8_t max_non_tso_bd_num;
 	struct rte_mbuf *new_pkt;
 	int ret;
 
@@ -2936,9 +2944,11 @@ hns3_check_non_tso_pkt(uint16_t nb_buf, struct rte_mbuf **m_seg,
 		return -EINVAL;
 	}
 
-	if (unlikely(nb_buf > HNS3_MAX_NON_TSO_BD_PER_PKT)) {
+	max_non_tso_bd_num = txq->max_non_tso_bd_num;
+	if (unlikely(nb_buf > max_non_tso_bd_num)) {
 		txq->exceed_limit_bd_pkt_cnt++;
-		ret = hns3_reassemble_tx_pkts(tx_pkt, &new_pkt);
+		ret = hns3_reassemble_tx_pkts(tx_pkt, &new_pkt,
+					      max_non_tso_bd_num);
 		if (ret) {
 			txq->exceed_limit_bd_reassem_fail++;
 			return ret;
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index 476cfc2..5ffe30e 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -372,6 +372,7 @@ struct hns3_tx_queue {
 	 */
 	uint32_t min_tx_pkt_len;
 
+	uint8_t max_non_tso_bd_num; /* max BD number of one non-TSO packet */
 	bool tx_deferred_start; /* don't start this queue in dev start */
 	bool configured;        /* indicate if tx queue has been configured */
 	/*
-- 
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   ` Wei Hu (Xavier) [this message]
2020-09-22 12:03   ` [dpdk-dev] [PATCH v2 05/17] net/hns3: add TSO pseudo header calculation compatibility Wei Hu (Xavier)
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-5-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