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 85C03A04E1; Tue, 22 Sep 2020 11:02:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 36FC21DBDD; Tue, 22 Sep 2020 10:55:04 +0200 (CEST) Received: from incedge.chinasoftinc.com (unknown [114.113.233.8]) by dpdk.org (Postfix) with ESMTP id 5EACC1DAFF for ; Tue, 22 Sep 2020 10:54:56 +0200 (CEST) X-ASG-Debug-ID: 1600764894-149d111bae19b030001-TfluYd Received: from mail.chinasoftinc.com ([10.168.0.51]) by incedge.chinasoftinc.com with ESMTP id L32AhJ0oQYAU6wc8 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2020 16:54:54 +0800 (CST) X-Barracuda-Envelope-From: huwei013@chinasoftinc.com X-Barracuda-RBL-Trusted-Forwarder: 10.168.0.51 X-ASG-Whitelist: Client Received: from localhost.localdomain (120.133.139.157) by INCCAS001.ito.icss (10.168.0.60) with Microsoft SMTP Server id 14.3.487.0; Tue, 22 Sep 2020 16:54:53 +0800 From: "Wei Hu (Xavier)" X-Barracuda-RBL-Trusted-Forwarder: 10.168.0.60 To: CC: Date: Tue, 22 Sep 2020 16:53:48 +0800 X-ASG-Orig-Subj: [PATCH 04/17] net/hns3: add max number of segs compatibility Message-ID: <20200922085401.12272-5-huwei013@chinasoftinc.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200922085401.12272-1-huwei013@chinasoftinc.com> References: <20200922085401.12272-1-huwei013@chinasoftinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [120.133.139.157] X-Barracuda-Connect: UNKNOWN[10.168.0.51] X-Barracuda-Start-Time: 1600764894 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA X-Barracuda-URL: https://incspam.chinasofti.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at chinasoftinc.com X-Barracuda-Scan-Msg-Size: 6614 Subject: [dpdk-dev] [PATCH 04/17] net/hns3: add max number of segs compatibility X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Hongbo Zheng 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 Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chengchang Tang --- 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 9ce382a..ed4273b 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