From patchwork Wed Jul 27 10:36:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 114270 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A0595A00C4; Wed, 27 Jul 2022 12:37:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F15694114A; Wed, 27 Jul 2022 12:37:12 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id D1445400D7; Wed, 27 Jul 2022 12:37:11 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lt9Bj4h3TzkXW4; Wed, 27 Jul 2022 18:34:37 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 18:37:10 +0800 From: Dongdong Liu To: , , , CC: , Chengwen Feng , Dongdong Liu , Yisen Zhuang , Lijun Ou , "Min Hu (Connor)" Subject: [PATCH 1/8] net/hns3: fix segment fault when using SVE xmit Date: Wed, 27 Jul 2022 18:36:09 +0800 Message-ID: <20220727103616.18596-2-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220727103616.18596-1-liudongdong3@huawei.com> References: <20220727103616.18596-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500017.china.huawei.com (7.221.188.110) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Chengwen Feng Currently, the number of Tx send bytes is obtained by accumulating the length of the batch 'mbuf' packets of the current loop cycle. Unfortunately, it uses svcntd (which means all lane, regardless of whether the corresponding lane is valid) which may lead to overflow, and thus refers to an invalid mbuf. Because the SVE xmit algorithm applies only to a single mbuf, the mbuf's data_len is equal pkt_len, so this patch fixes it by using svaddv_u64(svbool_t pg, svuint64_t data_len) which only adds valid lanes. Fixes: fdcd6a3e0246 ("net/hns3: add bytes stats") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_rxtx_vec_sve.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c index be1fdbcdf0..b0dfb052bb 100644 --- a/drivers/net/hns3/hns3_rxtx_vec_sve.c +++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c @@ -435,9 +435,8 @@ hns3_tx_fill_hw_ring_sve(struct hns3_tx_queue *txq, offsets, svdup_n_u64(valid_bit)); /* Increment bytes counter */ - uint32_t idx; - for (idx = 0; idx < svcntd(); idx++) - txq->basic_stats.bytes += pkts[idx]->pkt_len; + txq->basic_stats.bytes += + (svaddv_u64(pg, data_len) >> HNS3_UINT16_BIT); /* update index for next loop */ i += svcntd(); From patchwork Wed Jul 27 10:36:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 114271 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EC6B2A00C4; Wed, 27 Jul 2022 12:37:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 275294282E; Wed, 27 Jul 2022 12:37:16 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 5D7D14282E; Wed, 27 Jul 2022 12:37:14 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lt9Cb0L7tzmVCx; Wed, 27 Jul 2022 18:35:23 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 18:37:12 +0800 From: Dongdong Liu To: , , , CC: , Chengwen Feng , Dongdong Liu , Yisen Zhuang , "Wei Hu (Xavier)" , Huisong Li Subject: [PATCH 2/8] net/hns3: fix next-to-use overflow when using SVE xmit Date: Wed, 27 Jul 2022 18:36:10 +0800 Message-ID: <20220727103616.18596-3-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220727103616.18596-1-liudongdong3@huawei.com> References: <20220727103616.18596-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500017.china.huawei.com (7.221.188.110) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Chengwen Feng If txq's next-to-use plus nb_pkts equal txq's nb_tx_desc when using SVE xmit algorithm, the txq's next-to-use will equal nb_tx_desc after the xmit, this does not cause Tx exceptions, but may affect other ops that depend on this field, such as tx_descriptor_status. This patch fixes it. Fixes: f0c243a6cb6f ("net/hns3: support SVE Tx") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_rxtx_vec_sve.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c index b0dfb052bb..f09a81dbd5 100644 --- a/drivers/net/hns3/hns3_rxtx_vec_sve.c +++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c @@ -464,14 +464,16 @@ hns3_xmit_fixed_burst_vec_sve(void *__restrict tx_queue, return 0; } - if (txq->next_to_use + nb_pkts > txq->nb_tx_desc) { + if (txq->next_to_use + nb_pkts >= txq->nb_tx_desc) { nb_tx = txq->nb_tx_desc - txq->next_to_use; hns3_tx_fill_hw_ring_sve(txq, tx_pkts, nb_tx); txq->next_to_use = 0; } - hns3_tx_fill_hw_ring_sve(txq, tx_pkts + nb_tx, nb_pkts - nb_tx); - txq->next_to_use += nb_pkts - nb_tx; + if (nb_pkts > nb_tx) { + hns3_tx_fill_hw_ring_sve(txq, tx_pkts + nb_tx, nb_pkts - nb_tx); + txq->next_to_use += nb_pkts - nb_tx; + } txq->tx_bd_ready -= nb_pkts; hns3_write_txq_tail_reg(txq, nb_pkts); From patchwork Wed Jul 27 10:36:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 114272 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0B230A00C4; Wed, 27 Jul 2022 12:37:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2168441147; Wed, 27 Jul 2022 12:37:18 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 7428040141; Wed, 27 Jul 2022 12:37:16 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lt9Bp0pFTzkXFw; Wed, 27 Jul 2022 18:34:42 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 18:37:14 +0800 From: Dongdong Liu To: , , , CC: , Chengwen Feng , Dongdong Liu , Yisen Zhuang , "Wei Hu (Xavier)" , Huisong Li Subject: [PATCH 3/8] net/hns3: fix next-to-use overflow when using simple xmit Date: Wed, 27 Jul 2022 18:36:11 +0800 Message-ID: <20220727103616.18596-4-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220727103616.18596-1-liudongdong3@huawei.com> References: <20220727103616.18596-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500017.china.huawei.com (7.221.188.110) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Chengwen Feng If txq's next-to-use plus nb_pkts equal txq's nb_tx_desc when using simple xmit algorithm, the txq's next-to-use will equal nb_tx_desc fter the xmit, this does not cause Tx exceptions, but may affect other ops that depend on this field, such as tx_descriptor_status. This patch fixes it. Fixes: 7ef933908f04 ("net/hns3: add simple Tx path") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_rxtx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 95f711e7eb..bb06038848 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -4126,14 +4126,16 @@ hns3_xmit_pkts_simple(void *tx_queue, } txq->tx_bd_ready -= nb_pkts; - if (txq->next_to_use + nb_pkts > txq->nb_tx_desc) { + if (txq->next_to_use + nb_pkts >= txq->nb_tx_desc) { nb_tx = txq->nb_tx_desc - txq->next_to_use; hns3_tx_fill_hw_ring(txq, tx_pkts, nb_tx); txq->next_to_use = 0; } - hns3_tx_fill_hw_ring(txq, tx_pkts + nb_tx, nb_pkts - nb_tx); - txq->next_to_use += nb_pkts - nb_tx; + if (nb_pkts > nb_tx) { + hns3_tx_fill_hw_ring(txq, tx_pkts + nb_tx, nb_pkts - nb_tx); + txq->next_to_use += nb_pkts - nb_tx; + } hns3_write_txq_tail_reg(txq, nb_pkts); From patchwork Wed Jul 27 10:36:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 114273 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 38C25A00C4; Wed, 27 Jul 2022 12:37:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4963C42B74; Wed, 27 Jul 2022 12:37:20 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 6B83042826; Wed, 27 Jul 2022 12:37:18 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lt9Cg2J0wzmVD4; Wed, 27 Jul 2022 18:35:27 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 18:37:16 +0800 From: Dongdong Liu To: , , , CC: , Chengwen Feng , Dongdong Liu , Yisen Zhuang Subject: [PATCH 4/8] net/hns3: optimize SVE xmit performance Date: Wed, 27 Jul 2022 18:36:12 +0800 Message-ID: <20220727103616.18596-5-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220727103616.18596-1-liudongdong3@huawei.com> References: <20220727103616.18596-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500017.china.huawei.com (7.221.188.110) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Chengwen Feng This patch optimize SVE xmit algorithm performance, will get about 1%+ performance gain under 64B macfwd. Cc: stable@dpdk.org Signed-off-by: Chengwen Feng --- drivers/net/hns3/hns3_rxtx_vec_sve.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c index f09a81dbd5..6f23ba674d 100644 --- a/drivers/net/hns3/hns3_rxtx_vec_sve.c +++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c @@ -389,10 +389,12 @@ hns3_tx_fill_hw_ring_sve(struct hns3_tx_queue *txq, HNS3_UINT32_BIT; svuint64_t base_addr, buf_iova, data_off, data_len, addr; svuint64_t offsets = svindex_u64(0, BD_SIZE); - uint32_t i = 0; - svbool_t pg = svwhilelt_b64_u32(i, nb_pkts); + uint32_t cnt = svcntd(); + svbool_t pg; + uint32_t i; - do { + for (i = 0; i < nb_pkts; /* i is updated in the inner loop */) { + pg = svwhilelt_b64_u32(i, nb_pkts); base_addr = svld1_u64(pg, (uint64_t *)pkts); /* calc mbuf's field buf_iova address */ buf_iova = svadd_n_u64_z(pg, base_addr, @@ -439,12 +441,11 @@ hns3_tx_fill_hw_ring_sve(struct hns3_tx_queue *txq, (svaddv_u64(pg, data_len) >> HNS3_UINT16_BIT); /* update index for next loop */ - i += svcntd(); - pkts += svcntd(); - txdp += svcntd(); - tx_entry += svcntd(); - pg = svwhilelt_b64_u32(i, nb_pkts); - } while (svptest_any(svptrue_b64(), pg)); + i += cnt; + pkts += cnt; + txdp += cnt; + tx_entry += cnt; + } } static uint16_t From patchwork Wed Jul 27 10:36:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 114274 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0B182A00C4; Wed, 27 Jul 2022 12:37:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C3CD42B70; Wed, 27 Jul 2022 12:37:28 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 772FD40F19; Wed, 27 Jul 2022 12:37:26 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Lt9Bb59lMz1M8Gb; Wed, 27 Jul 2022 18:34:31 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 18:37:24 +0800 From: Dongdong Liu To: , , , CC: , Chengwen Feng , Dongdong Liu , Yisen Zhuang , Anatoly Burakov , Ferruh Yigit , Huisong Li , "Wei Hu (Xavier)" , Hao Chen , "Min Hu (Connor)" Subject: [PATCH 5/8] net/hns3: fix segment fault when secondary process access FW Date: Wed, 27 Jul 2022 18:36:13 +0800 Message-ID: <20220727103616.18596-6-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220727103616.18596-1-liudongdong3@huawei.com> References: <20220727103616.18596-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500017.china.huawei.com (7.221.188.110) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Chengwen Feng Currently, to prevent missing reporting of reset interrupts and quickly identify reset interrupts, the following logic is designed in the FW (firmware) command interface hns3_cmd_send: if an unprocessed interrupt exist (by checking reset registers), related reset task is scheduled. The secondary process may invoke the hns3_cmd_send interface (e.g. using proc-info query some stats). Unfortunately, the secondary process does not support reset processing, and a segment fault may occur if it schedules reset task. This patch fixes it by limit the checking and scheduling of reset under only primary process. Fixes: 2790c6464725 ("net/hns3: support device reset") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_ethdev.c | 10 +++++++++- drivers/net/hns3/hns3_ethdev_vf.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 6b1d1a5fb1..aedd17ef26 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -5601,7 +5601,15 @@ hns3_is_reset_pending(struct hns3_adapter *hns) struct hns3_hw *hw = &hns->hw; enum hns3_reset_level reset; - hns3_check_event_cause(hns, NULL); + /* + * Check the registers to confirm whether there is reset pending. + * Note: This check may lead to schedule reset task, but only primary + * process can process the reset event. Therefore, limit the + * checking under only primary process. + */ + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + hns3_check_event_cause(hns, NULL); + reset = hns3_get_reset_level(hns, &hw->reset.pending); if (reset != HNS3_NONE_RESET && hw->reset.level != HNS3_NONE_RESET && hw->reset.level < reset) { diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 18504e6926..f3167523cf 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1863,8 +1863,15 @@ hns3vf_is_reset_pending(struct hns3_adapter *hns) if (hw->reset.level == HNS3_VF_FULL_RESET) return false; - /* Check the registers to confirm whether there is reset pending */ - hns3vf_check_event_cause(hns, NULL); + /* + * Check the registers to confirm whether there is reset pending. + * Note: This check may lead to schedule reset task, but only primary + * process can process the reset event. Therefore, limit the + * checking under only primary process. + */ + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + hns3vf_check_event_cause(hns, NULL); + reset = hns3vf_get_reset_level(hw, &hw->reset.pending); if (hw->reset.level != HNS3_NONE_RESET && reset != HNS3_NONE_RESET && hw->reset.level < reset) { From patchwork Wed Jul 27 10:36:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 114275 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C2232A00C4; Wed, 27 Jul 2022 12:37:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5462F42B79; Wed, 27 Jul 2022 12:37:30 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id B4F5142B72; Wed, 27 Jul 2022 12:37:28 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Lt9Dc40XCz9sxH; Wed, 27 Jul 2022 18:36:16 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 18:37:26 +0800 From: Dongdong Liu To: , , , CC: , Huisong Li , Dongdong Liu , Yisen Zhuang , Chunsong Feng , Ferruh Yigit , Hao Chen , "Min Hu (Connor)" Subject: [PATCH 6/8] net/hns3: delete rte unused tag Date: Wed, 27 Jul 2022 18:36:14 +0800 Message-ID: <20220727103616.18596-7-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220727103616.18596-1-liudongdong3@huawei.com> References: <20220727103616.18596-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500017.china.huawei.com (7.221.188.110) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Huisong Li The '__rte_unused' tag in the input parameter of 'hns3_mac_stats_reset' is redundant. This patch remove this tag. In addition, this function is aimed to clear MAC statics. So using 'struct hns3_hw' as input parameter is better than 'struct rte_eth_dev', and it also facilitates the call of this function. Fixes: 8839c5e202f3 ("net/hns3: support device stats") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_stats.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c index 4ec0911522..2ec7a9635e 100644 --- a/drivers/net/hns3/hns3_stats.c +++ b/drivers/net/hns3/hns3_stats.c @@ -406,15 +406,6 @@ hns3_query_mac_stats_reg_num(struct hns3_hw *hw) return 0; } -static int -hns3_query_update_mac_stats(struct rte_eth_dev *dev) -{ - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; - - return hns3_update_mac_stats(hw); -} - static int hns3_update_port_rpu_drop_stats(struct hns3_hw *hw) { @@ -763,14 +754,13 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) } static int -hns3_mac_stats_reset(__rte_unused struct rte_eth_dev *dev) +hns3_mac_stats_reset(struct hns3_hw *hw) { - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; struct hns3_mac_stats *mac_stats = &hw->mac_stats; int ret; - ret = hns3_query_update_mac_stats(dev); + /* Clear hardware MAC statistics by reading it. */ + ret = hns3_update_mac_stats(hw); if (ret) { hns3_err(hw, "Clear Mac stats fail : %d", ret); return ret; @@ -1063,8 +1053,7 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, hns3_tqp_basic_stats_get(dev, xstats, &count); if (!hns->is_vf) { - /* Update Mac stats */ - ret = hns3_query_update_mac_stats(dev); + ret = hns3_update_mac_stats(hw); if (ret < 0) { hns3_err(hw, "Update Mac stats fail : %d", ret); rte_spinlock_unlock(&hw->stats_lock); @@ -1482,8 +1471,7 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev) if (hns->is_vf) goto out; - /* HW registers are cleared on read */ - ret = hns3_mac_stats_reset(dev); + ret = hns3_mac_stats_reset(hw); out: rte_spinlock_unlock(&hw->stats_lock); From patchwork Wed Jul 27 10:36:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 114276 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 76806A00C4; Wed, 27 Jul 2022 12:37:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7ED4F42B72; Wed, 27 Jul 2022 12:37:33 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 13AB0427E9; Wed, 27 Jul 2022 12:37:32 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lt9C562x4zkXFw; Wed, 27 Jul 2022 18:34:57 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 18:37:30 +0800 From: Dongdong Liu To: , , , CC: , Huisong Li , Dongdong Liu , Yisen Zhuang , "Min Hu (Connor)" , Ferruh Yigit , Hao Chen , Chunsong Feng Subject: [PATCH 7/8] net/hns3: fix uncleared hardware MAC statistics Date: Wed, 27 Jul 2022 18:36:15 +0800 Message-ID: <20220727103616.18596-8-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220727103616.18596-1-liudongdong3@huawei.com> References: <20220727103616.18596-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500017.china.huawei.com (7.221.188.110) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Huisong Li In the situation that the driver hns3 exits abnormally during packets sending and receiving, the hardware statistics are not cleared when the driver hns3 is reloaded. It need to be cleared during driver hns3 initialization that hardware MAC statistics. Fixes: 8839c5e202f3 ("net/hns3: support device stats") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_stats.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c index 2ec7a9635e..bad65fcbed 100644 --- a/drivers/net/hns3/hns3_stats.c +++ b/drivers/net/hns3/hns3_stats.c @@ -1528,6 +1528,7 @@ hns3_tqp_stats_clear(struct hns3_hw *hw) int hns3_stats_init(struct hns3_hw *hw) { + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); int ret; rte_spinlock_init(&hw->stats_lock); @@ -1538,6 +1539,9 @@ hns3_stats_init(struct hns3_hw *hw) return ret; } + if (!hns->is_vf) + hns3_mac_stats_reset(hw); + return hns3_tqp_stats_init(hw); } From patchwork Wed Jul 27 10:36:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 114277 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5DC2EA00C4; Wed, 27 Jul 2022 12:38:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1F85742B8B; Wed, 27 Jul 2022 12:37:37 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id A749142B75; Wed, 27 Jul 2022 12:37:34 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lt9Cz4mXWzmVCP; Wed, 27 Jul 2022 18:35:43 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 18:37:32 +0800 From: Dongdong Liu To: , , , CC: , Chengwen Feng , Dongdong Liu , Yisen Zhuang , "Min Hu (Connor)" Subject: [PATCH 8/8] net/hns3: revert optimize Tx performance Date: Wed, 27 Jul 2022 18:36:16 +0800 Message-ID: <20220727103616.18596-9-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220727103616.18596-1-liudongdong3@huawei.com> References: <20220727103616.18596-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500017.china.huawei.com (7.221.188.110) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Chengwen Feng The Tx performance deteriorates in the case of larger packets size and larger burst. It may take a long time to optimize in these scenarios, so this commit reverts commit 0b77e8f3d364 ("net/hns3: optimize Tx performance") Fixes: 0b77e8f3d364 ("net/hns3: optimize Tx performance") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_rxtx.c | 115 ++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index bb06038848..169c058c95 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -3072,51 +3072,40 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, return 0; } -static int +static void hns3_tx_free_useless_buffer(struct hns3_tx_queue *txq) { uint16_t tx_next_clean = txq->next_to_clean; - uint16_t tx_next_use = txq->next_to_use; - struct hns3_entry *tx_entry = &txq->sw_ring[tx_next_clean]; + uint16_t tx_next_use = txq->next_to_use; + uint16_t tx_bd_ready = txq->tx_bd_ready; + uint16_t tx_bd_max = txq->nb_tx_desc; + struct hns3_entry *tx_bak_pkt = &txq->sw_ring[tx_next_clean]; struct hns3_desc *desc = &txq->tx_ring[tx_next_clean]; - uint16_t i; - - if (tx_next_use >= tx_next_clean && - tx_next_use < tx_next_clean + txq->tx_rs_thresh) - return -1; + struct rte_mbuf *mbuf; - /* - * All mbufs can be released only when the VLD bits of all - * descriptors in a batch are cleared. - */ - for (i = 0; i < txq->tx_rs_thresh; i++) { - if (desc[i].tx.tp_fe_sc_vld_ra_ri & - rte_le_to_cpu_16(BIT(HNS3_TXD_VLD_B))) - return -1; - } + while ((!(desc->tx.tp_fe_sc_vld_ra_ri & + rte_cpu_to_le_16(BIT(HNS3_TXD_VLD_B)))) && + tx_next_use != tx_next_clean) { + mbuf = tx_bak_pkt->mbuf; + if (mbuf) { + rte_pktmbuf_free_seg(mbuf); + tx_bak_pkt->mbuf = NULL; + } - for (i = 0; i < txq->tx_rs_thresh; i++) { - rte_pktmbuf_free_seg(tx_entry[i].mbuf); - tx_entry[i].mbuf = NULL; + desc++; + tx_bak_pkt++; + tx_next_clean++; + tx_bd_ready++; + + if (tx_next_clean >= tx_bd_max) { + tx_next_clean = 0; + desc = txq->tx_ring; + tx_bak_pkt = txq->sw_ring; + } } - /* Update numbers of available descriptor due to buffer freed */ - txq->tx_bd_ready += txq->tx_rs_thresh; - txq->next_to_clean += txq->tx_rs_thresh; - if (txq->next_to_clean >= txq->nb_tx_desc) - txq->next_to_clean = 0; - - return 0; -} - -static inline int -hns3_tx_free_required_buffer(struct hns3_tx_queue *txq, uint16_t required_bds) -{ - while (required_bds > txq->tx_bd_ready) { - if (hns3_tx_free_useless_buffer(txq) != 0) - return -1; - } - return 0; + txq->next_to_clean = tx_next_clean; + txq->tx_bd_ready = tx_bd_ready; } int @@ -4159,8 +4148,7 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) uint16_t nb_tx; uint16_t i; - if (txq->tx_bd_ready < txq->tx_free_thresh) - (void)hns3_tx_free_useless_buffer(txq); + hns3_tx_free_useless_buffer(txq); tx_next_use = txq->next_to_use; tx_bd_max = txq->nb_tx_desc; @@ -4175,14 +4163,10 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) nb_buf = tx_pkt->nb_segs; if (nb_buf > txq->tx_bd_ready) { - /* Try to release the required MBUF, but avoid releasing - * all MBUFs, otherwise, the MBUFs will be released for - * a long time and may cause jitter. - */ - if (hns3_tx_free_required_buffer(txq, nb_buf) != 0) { - txq->dfx_stats.queue_full_cnt++; - goto end_of_tx; - } + txq->dfx_stats.queue_full_cnt++; + if (nb_tx == 0) + return 0; + goto end_of_tx; } /* @@ -4598,22 +4582,43 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) static int hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt) { - uint16_t round_cnt; + uint16_t next_to_clean = txq->next_to_clean; + uint16_t next_to_use = txq->next_to_use; + uint16_t tx_bd_ready = txq->tx_bd_ready; + struct hns3_entry *tx_pkt = &txq->sw_ring[next_to_clean]; + struct hns3_desc *desc = &txq->tx_ring[next_to_clean]; uint32_t idx; if (free_cnt == 0 || free_cnt > txq->nb_tx_desc) free_cnt = txq->nb_tx_desc; - if (txq->tx_rs_thresh == 0) - return 0; - - round_cnt = rounddown(free_cnt, txq->tx_rs_thresh); - for (idx = 0; idx < round_cnt; idx += txq->tx_rs_thresh) { - if (hns3_tx_free_useless_buffer(txq) != 0) + for (idx = 0; idx < free_cnt; idx++) { + if (next_to_clean == next_to_use) + break; + if (desc->tx.tp_fe_sc_vld_ra_ri & + rte_cpu_to_le_16(BIT(HNS3_TXD_VLD_B))) break; + if (tx_pkt->mbuf != NULL) { + rte_pktmbuf_free_seg(tx_pkt->mbuf); + tx_pkt->mbuf = NULL; + } + next_to_clean++; + tx_bd_ready++; + tx_pkt++; + desc++; + if (next_to_clean == txq->nb_tx_desc) { + tx_pkt = txq->sw_ring; + desc = txq->tx_ring; + next_to_clean = 0; + } + } + + if (idx > 0) { + txq->next_to_clean = next_to_clean; + txq->tx_bd_ready = tx_bd_ready; } - return idx; + return (int)idx; } int