From patchwork Sun Dec 13 08:02:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 85043 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 93029A04B5; Sun, 13 Dec 2020 09:04:31 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 22006C9A6; Sun, 13 Dec 2020 09:03:19 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by dpdk.org (Postfix) with ESMTP id 6A669C96A for ; Sun, 13 Dec 2020 09:03:13 +0100 (CET) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Ctxnz2tkTz15cDC for ; Sun, 13 Dec 2020 16:02:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Sun, 13 Dec 2020 16:02:58 +0800 From: Lijun Ou To: CC: , Date: Sun, 13 Dec 2020 16:02:59 +0800 Message-ID: <1607846585-2381-2-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1607846585-2381-1-git-send-email-oulijun@huawei.com> References: <1607846585-2381-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 1/7] net/hns3: fix incorrect interception with filter director 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" The rte_fdir_conf structure has deprecated and users need to use the specified rule parameters of rte_flow structure when configure a flow rule. As a result, it is incorrectly used in the rte_flow API. Fixes: fcba820d9b9e ("net/hns3: support flow director") Cc: stable@dpdk.org Signed-off-by: Lijun Ou --- drivers/net/hns3/hns3_flow.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index ee6ec15..f303df4 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1208,11 +1208,6 @@ hns3_parse_fdir_filter(struct rte_eth_dev *dev, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "Fdir not supported in VF"); - if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_HANDLE, NULL, - "fdir_conf.mode isn't perfect"); - step_mngr.items = first_items; step_mngr.count = ARRAY_SIZE(first_items); for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) { From patchwork Sun Dec 13 08:03:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 85045 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8C131A04B5; Sun, 13 Dec 2020 09:05:05 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CE917C9BE; Sun, 13 Dec 2020 09:03:21 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by dpdk.org (Postfix) with ESMTP id 0351BC97C for ; Sun, 13 Dec 2020 09:03:16 +0100 (CET) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Ctxnz3P2rz15cD1 for ; Sun, 13 Dec 2020 16:02:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Sun, 13 Dec 2020 16:02:58 +0800 From: Lijun Ou To: CC: , Date: Sun, 13 Dec 2020 16:03:00 +0800 Message-ID: <1607846585-2381-3-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1607846585-2381-1-git-send-email-oulijun@huawei.com> References: <1607846585-2381-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 2/7] net/hns3: fix xstats statistics with id 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: Huisong Li Number of xstats item in rte_eth_xstats_get_by_id is obtained by the eth_dev_get_xstats_count API, and the xstats_get_by_id ops of the driver only needs to report the corresponding stats item result. However, a redundant code for reporting the number of stats items in the hns3_dev_xstats_get_by_id API causes a problem. Namely, if the ID range of the xstats stats item does not include the basic stats item, the app can not obtain the corresponding xstats statistics in hns3_dev_xstats_get_by_id. Fixes: 8839c5e202f3 ("net/hns3: support device stats") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Lijun Ou --- drivers/net/hns3/hns3_stats.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c index 91168ac..b43143b 100644 --- a/drivers/net/hns3/hns3_stats.c +++ b/drivers/net/hns3/hns3_stats.c @@ -933,9 +933,6 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, uint32_t i; int ret; - if (ids == NULL || size < cnt_stats) - return cnt_stats; - /* Update tqp stats by read register */ ret = hns3_update_tqp_stats(hw); if (ret) { From patchwork Sun Dec 13 08:03:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 85044 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 81CA6A04B5; Sun, 13 Dec 2020 09:04:48 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B8402C9B2; Sun, 13 Dec 2020 09:03:20 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by dpdk.org (Postfix) with ESMTP id 33EF7C974 for ; Sun, 13 Dec 2020 09:03:15 +0100 (CET) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Ctxnz3GgMz15Zr0 for ; Sun, 13 Dec 2020 16:02:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Sun, 13 Dec 2020 16:02:58 +0800 From: Lijun Ou To: CC: , Date: Sun, 13 Dec 2020 16:03:01 +0800 Message-ID: <1607846585-2381-4-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1607846585-2381-1-git-send-email-oulijun@huawei.com> References: <1607846585-2381-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 3/7] net/hns3: fix abnormal return value in xstats 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: Huisong Li The ethdev API has processed the failure to obtain xstats statistics. Therefore, driver should return an error code instead of 0 in 'hns3_dev_xstats_get' API. Fixes: 8839c5e202f3 ("net/hns3: support device stats") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Lijun Ou --- drivers/net/hns3/hns3_stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c index b43143b..94d34bc 100644 --- a/drivers/net/hns3/hns3_stats.c +++ b/drivers/net/hns3/hns3_stats.c @@ -739,9 +739,9 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, if (!hns->is_vf) { /* Update Mac stats */ ret = hns3_query_update_mac_stats(dev); - if (ret) { + if (ret < 0) { hns3_err(hw, "Update Mac stats fail : %d", ret); - return 0; + return ret; } /* Get MAC stats from hw->hw_xstats.mac_stats struct */ From patchwork Sun Dec 13 08:03:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 85042 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3A8E6A04B5; Sun, 13 Dec 2020 09:04:13 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 86BF5C996; Sun, 13 Dec 2020 09:03:17 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by dpdk.org (Postfix) with ESMTP id 858293257 for ; Sun, 13 Dec 2020 09:03:11 +0100 (CET) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Ctxnz2dMDz15cD5 for ; Sun, 13 Dec 2020 16:02:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Sun, 13 Dec 2020 16:02:59 +0800 From: Lijun Ou To: CC: , Date: Sun, 13 Dec 2020 16:03:02 +0800 Message-ID: <1607846585-2381-5-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1607846585-2381-1-git-send-email-oulijun@huawei.com> References: <1607846585-2381-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 4/7] net/hns3: fix Rx/Tx abnormal errors stats 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: Huisong Li Abnormal errors stats in Rx/Tx datapath are statistics items in driver, and displayed in xstats. They should be cleared by the rte_eth_xstats_reset api, instead of the rte_eth_stats_reset. Fixes: c4b7d6761d01 ("net/hns3: get Tx abnormal errors in xstats") Fixes: 521ab3e93361 ("net/hns3: add simple Rx path") Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Lijun Ou --- drivers/net/hns3/hns3_stats.c | 59 ++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c index 94d34bc..1d1f706 100644 --- a/drivers/net/hns3/hns3_stats.c +++ b/drivers/net/hns3/hns3_stats.c @@ -551,7 +551,6 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) struct hns3_hw *hw = &hns->hw; struct hns3_cmd_desc desc_reset; struct hns3_rx_queue *rxq; - struct hns3_tx_queue *txq; uint16_t i; int ret; @@ -581,29 +580,15 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) } } - /* Clear the Rx BD errors stats */ - for (i = 0; i != eth_dev->data->nb_rx_queues; ++i) { + /* + * Clear soft stats of rx error packet which will be dropped + * in driver. + */ + for (i = 0; i < eth_dev->data->nb_rx_queues; ++i) { rxq = eth_dev->data->rx_queues[i]; if (rxq) { rxq->pkt_len_errors = 0; rxq->l2_errors = 0; - rxq->l3_csum_errors = 0; - rxq->l4_csum_errors = 0; - rxq->ol3_csum_errors = 0; - rxq->ol4_csum_errors = 0; - } - } - - /* Clear the Tx errors stats */ - for (i = 0; i != eth_dev->data->nb_tx_queues; ++i) { - txq = eth_dev->data->tx_queues[i]; - if (txq) { - txq->over_length_pkt_cnt = 0; - txq->exceed_limit_bd_pkt_cnt = 0; - txq->exceed_limit_bd_reassem_fail = 0; - txq->unsupported_tunnel_pkt_cnt = 0; - txq->queue_full_cnt = 0; - txq->pkt_padding_fail_cnt = 0; } } @@ -1030,6 +1015,38 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, return size; } +static void +hns3_tqp_dfx_stats_clear(struct rte_eth_dev *dev) +{ + struct hns3_rx_queue *rxq; + struct hns3_tx_queue *txq; + int i; + + /* Clear Rx dfx stats */ + for (i = 0; i < dev->data->nb_rx_queues; ++i) { + rxq = dev->data->rx_queues[i]; + if (rxq) { + rxq->l3_csum_errors = 0; + rxq->l4_csum_errors = 0; + rxq->ol3_csum_errors = 0; + rxq->ol4_csum_errors = 0; + } + } + + /* Clear Tx dfx stats */ + for (i = 0; i < dev->data->nb_tx_queues; ++i) { + txq = dev->data->tx_queues[i]; + if (txq) { + txq->over_length_pkt_cnt = 0; + txq->exceed_limit_bd_pkt_cnt = 0; + txq->exceed_limit_bd_reassem_fail = 0; + txq->unsupported_tunnel_pkt_cnt = 0; + txq->queue_full_cnt = 0; + txq->pkt_padding_fail_cnt = 0; + } + } +} + int hns3_dev_xstats_reset(struct rte_eth_dev *dev) { @@ -1045,6 +1062,8 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev) /* Clear reset stats */ memset(&hns->hw.reset.stats, 0, sizeof(struct hns3_reset_stats)); + hns3_tqp_dfx_stats_clear(dev); + if (hns->is_vf) return 0; From patchwork Sun Dec 13 08:03:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 85039 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DC27DA04B5; Sun, 13 Dec 2020 09:03:15 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A6D5237B7; Sun, 13 Dec 2020 09:03:12 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by dpdk.org (Postfix) with ESMTP id B741737B7 for ; Sun, 13 Dec 2020 09:03:11 +0100 (CET) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Ctxnz31Q9z15cDF for ; Sun, 13 Dec 2020 16:02:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Sun, 13 Dec 2020 16:02:59 +0800 From: Lijun Ou To: CC: , Date: Sun, 13 Dec 2020 16:03:03 +0800 Message-ID: <1607846585-2381-6-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1607846585-2381-1-git-send-email-oulijun@huawei.com> References: <1607846585-2381-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 5/7] net/hns3: fix location of saving ethdev 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: "Min Hu (Connor)" In current version, procedure of saving eth_dev in hns3 PMD init will be called more than twice, one for primary, the other for secondary. That will cause segmentation fault in Multi-process as eth_dev will be changed in secondary process, which is different from one in primary process. This patch saved eth_dev in dev_private only in primary process, as dev_private is shared by primary process and secondary process. Fixes: 8929efbc1c46 ("net/hns3: fix FEC state query") Cc: stable@dpdk.org Signed-off-by: Min Hu (Connor) Signed-off-by: Lijun Ou --- drivers/net/hns3/hns3_ethdev.c | 3 +-- drivers/net/hns3/hns3_ethdev_vf.c | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 7c34e38..f49b779 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -6106,8 +6106,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) PMD_INIT_FUNC_TRACE(); - hns->eth_dev = eth_dev; - eth_dev->process_private = (struct hns3_process_private *) rte_zmalloc_socket("hns3_filter_list", sizeof(struct hns3_process_private), @@ -6134,6 +6132,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) return 0; } + hns->eth_dev = eth_dev; eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; ret = hns3_mp_init_primary(); diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index f09cabc..9c382bf 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -2753,6 +2753,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) return 0; } + hns->eth_dev = eth_dev; eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; ret = hns3_mp_init_primary(); From patchwork Sun Dec 13 08:03:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 85046 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9C224A04B5; Sun, 13 Dec 2020 09:05:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 615BDC872; Sun, 13 Dec 2020 09:03:24 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by dpdk.org (Postfix) with ESMTP id 196B8C9C4 for ; Sun, 13 Dec 2020 09:03:22 +0100 (CET) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Ctxnz2Sl1z15cD3 for ; Sun, 13 Dec 2020 16:02:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Sun, 13 Dec 2020 16:02:59 +0800 From: Lijun Ou To: CC: , Date: Sun, 13 Dec 2020 16:03:04 +0800 Message-ID: <1607846585-2381-7-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1607846585-2381-1-git-send-email-oulijun@huawei.com> References: <1607846585-2381-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 6/7] net/hns3: fix directly access with rte device 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: "Min Hu (Connor)" In current version, there exists the way of access global 'rte_eth_devices' array directly, and this is not a good way. Better way is to store the 'eth_dev' in the device private data in the probe(). Then driver could use it later. Fixes: ab2e2e344163 ("net/hns3: get device capability in primary process") Fixes: c4ae39b2cfc5 ("net/hns3: fix Rx interrupt after reset") Fixes: 2790c6464725 ("net/hns3: support device reset") Fixes: c203571b3602 ("net/hns3: register and add log interface") Fixes: 1265b5372d9d ("net/hns3: add some definitions for data structure and macro") Fixes: 521ab3e93361 ("net/hns3: add simple Rx path") Fixes: a3d4f4d291d7 ("net/hns3: support NEON Rx") Fixes: 952ebacce4f2 ("net/hns3: support SVE Rx") Cc: stable@dpdk.org Signed-off-by: Min Hu (Connor) Signed-off-by: Lijun Ou --- drivers/net/hns3/hns3_ethdev.c | 11 +++++------ drivers/net/hns3/hns3_ethdev.h | 6 ++++++ drivers/net/hns3/hns3_ethdev_vf.c | 13 ++++++------- drivers/net/hns3/hns3_rxtx.c | 13 ++++++------- drivers/net/hns3/hns3_rxtx_vec.c | 4 +++- drivers/net/hns3/hns3_rxtx_vec_sve.c | 4 +++- 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index f49b779..1093be1 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2992,15 +2992,14 @@ hns3_query_dev_specifications(struct hns3_hw *hw) static int hns3_get_capability(struct hns3_hw *hw) { + struct rte_eth_dev *eth_dev = HNS3_DEV_HW_TO_ETH_DEV(hw); struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); struct rte_pci_device *pci_dev; struct hns3_pf *pf = &hns->pf; - struct rte_eth_dev *eth_dev; uint16_t device_id; uint8_t revision; int ret; - eth_dev = &rte_eth_devices[hw->data->port_id]; pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); device_id = pci_dev->id.device_id; @@ -4836,7 +4835,7 @@ hns3_map_rx_interrupt(struct rte_eth_dev *dev) static int hns3_restore_rx_interrupt(struct hns3_hw *hw) { - struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; + struct rte_eth_dev *dev = HNS3_DEV_HW_TO_ETH_DEV(hw); struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; uint16_t q_id; @@ -5526,7 +5525,7 @@ hns3_stop_service(struct hns3_adapter *hns) struct hns3_hw *hw = &hns->hw; struct rte_eth_dev *eth_dev; - eth_dev = &rte_eth_devices[hw->data->port_id]; + eth_dev = hns->eth_dev; if (hw->adapter_state == HNS3_NIC_STARTED) rte_eal_alarm_cancel(hns3_service_handler, eth_dev); hw->mac.link_status = ETH_LINK_DOWN; @@ -5567,7 +5566,7 @@ hns3_start_service(struct hns3_adapter *hns) if (hw->reset.level == HNS3_IMP_RESET || hw->reset.level == HNS3_GLOBAL_RESET) hns3_set_rst_done(hw); - eth_dev = &rte_eth_devices[hw->data->port_id]; + eth_dev = hns->eth_dev; hns3_set_rxtx_function(eth_dev); hns3_mp_req_start_rxtx(eth_dev); if (hw->adapter_state == HNS3_NIC_STARTED) { @@ -5668,7 +5667,7 @@ hns3_reset_service(void *param) if (rte_atomic16_read(&hns->hw.reset.schedule) == SCHEDULE_DEFERRED) { rte_atomic16_set(&hns->hw.reset.schedule, SCHEDULE_REQUESTED); hns3_err(hw, "Handling interrupts in delayed tasks"); - hns3_interrupt_handler(&rte_eth_devices[hw->data->port_id]); + hns3_interrupt_handler(hns->eth_dev); reset_level = hns3_get_reset_level(hns, &hw->reset.pending); if (reset_level == HNS3_NONE_RESET) { hns3_err(hw, "No reset level is set, try IMP reset"); diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 8d6b8cd..51e450a 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -798,6 +798,12 @@ struct hns3_adapter { #define HNS3_DEV_HW_TO_ADAPTER(hw) \ container_of(hw, struct hns3_adapter, hw) +static inline struct rte_eth_dev *HNS3_DEV_HW_TO_ETH_DEV(struct hns3_hw *hw) +{ + struct hns3_adapter *adapter = HNS3_DEV_HW_TO_ADAPTER(hw); + return adapter->eth_dev; +} + #define hns3_set_field(origin, mask, shift, val) \ do { \ (origin) &= (~(mask)); \ diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 9c382bf..890d33d 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1180,12 +1180,11 @@ hns3vf_query_dev_specifications(struct hns3_hw *hw) static int hns3vf_get_capability(struct hns3_hw *hw) { + struct rte_eth_dev *eth_dev = HNS3_DEV_HW_TO_ETH_DEV(hw); struct rte_pci_device *pci_dev; - struct rte_eth_dev *eth_dev; uint8_t revision; int ret; - eth_dev = &rte_eth_devices[hw->data->port_id]; pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); /* Get PCI revision id */ @@ -2152,7 +2151,7 @@ hns3vf_map_rx_interrupt(struct rte_eth_dev *dev) static int hns3vf_restore_rx_interrupt(struct hns3_hw *hw) { - struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; + struct rte_eth_dev *dev = HNS3_DEV_HW_TO_ETH_DEV(hw); struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; uint16_t q_id; @@ -2377,7 +2376,7 @@ hns3vf_stop_service(struct hns3_adapter *hns) struct hns3_hw *hw = &hns->hw; struct rte_eth_dev *eth_dev; - eth_dev = &rte_eth_devices[hw->data->port_id]; + eth_dev = hns->eth_dev; if (hw->adapter_state == HNS3_NIC_STARTED) rte_eal_alarm_cancel(hns3vf_service_handler, eth_dev); hw->mac.link_status = ETH_LINK_DOWN; @@ -2415,7 +2414,7 @@ hns3vf_start_service(struct hns3_adapter *hns) struct hns3_hw *hw = &hns->hw; struct rte_eth_dev *eth_dev; - eth_dev = &rte_eth_devices[hw->data->port_id]; + eth_dev = hns->eth_dev; hns3_set_rxtx_function(eth_dev); hns3_mp_req_start_rxtx(eth_dev); if (hw->adapter_state == HNS3_NIC_STARTED) { @@ -2577,7 +2576,7 @@ hns3vf_reset_service(void *param) if (rte_atomic16_read(&hns->hw.reset.schedule) == SCHEDULE_DEFERRED) { rte_atomic16_set(&hns->hw.reset.schedule, SCHEDULE_REQUESTED); hns3_err(hw, "Handling interrupts in delayed tasks"); - hns3vf_interrupt_handler(&rte_eth_devices[hw->data->port_id]); + hns3vf_interrupt_handler(hns->eth_dev); reset_level = hns3vf_get_reset_level(hw, &hw->reset.pending); if (reset_level == HNS3_NONE_RESET) { hns3_err(hw, "No reset level is set, try global reset"); @@ -2608,7 +2607,7 @@ hns3vf_reset_service(void *param) static int hns3vf_reinit_dev(struct hns3_adapter *hns) { - struct rte_eth_dev *eth_dev = &rte_eth_devices[hns->hw.data->port_id]; + struct rte_eth_dev *eth_dev = hns->eth_dev; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct hns3_hw *hw = &hns->hw; int ret; diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 88d3bab..b7a28e8 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -912,7 +912,7 @@ hns3_queue_intr_enable(struct hns3_hw *hw, uint16_t queue_id, bool en) void hns3_dev_all_rx_queue_intr_enable(struct hns3_hw *hw, bool en) { - struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; + struct rte_eth_dev *dev = HNS3_DEV_HW_TO_ETH_DEV(hw); uint16_t nb_rx_q = hw->data->nb_rx_queues; int i; @@ -1620,7 +1620,7 @@ static int hns3_rxq_conf_runtime_check(struct hns3_hw *hw, uint16_t buf_size, uint16_t nb_desc) { - struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; + struct rte_eth_dev *dev = HNS3_DEV_HW_TO_ETH_DEV(hw); struct rte_eth_rxmode *rxmode = &hw->data->dev_conf.rxmode; eth_rx_burst_t pkt_burst = dev->rx_pkt_burst; uint16_t min_vec_bds; @@ -2078,6 +2078,7 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) volatile struct hns3_desc *rxdp; /* pointer of the current desc */ struct hns3_rx_queue *rxq; /* RX queue */ struct hns3_entry *sw_ring; + struct rte_eth_dev *dev; struct hns3_entry *rxe; struct hns3_desc rxd; struct rte_mbuf *nmb; /* pointer of the new mbuf */ @@ -2110,10 +2111,8 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) nmb = hns3_rx_alloc_buffer(rxq); if (unlikely(nmb == NULL)) { - uint16_t port_id; - - port_id = rxq->port_id; - rte_eth_devices[port_id].data->rx_mbuf_alloc_failed++; + dev = rxq->hns->eth_dev; + dev->data->rx_mbuf_alloc_failed++; break; } @@ -2289,7 +2288,7 @@ hns3_recv_scattered_pkts(void *rx_queue, nmb = hns3_rx_alloc_buffer(rxq); if (unlikely(nmb == NULL)) { - dev = &rte_eth_devices[rxq->port_id]; + dev = rxq->hns->eth_dev; dev->data->rx_mbuf_alloc_failed++; break; } diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c index a26c83d..5d02588 100644 --- a/drivers/net/hns3/hns3_rxtx_vec.c +++ b/drivers/net/hns3/hns3_rxtx_vec.c @@ -52,12 +52,14 @@ hns3_rxq_rearm_mbuf(struct hns3_rx_queue *rxq) #define REARM_LOOP_STEP_NUM 4 struct hns3_entry *rxep = &rxq->sw_ring[rxq->rx_rearm_start]; struct hns3_desc *rxdp = rxq->rx_ring + rxq->rx_rearm_start; + struct rte_eth_dev *dev; uint64_t dma_addr; int i; if (unlikely(rte_mempool_get_bulk(rxq->mb_pool, (void *)rxep, HNS3_DEFAULT_RXQ_REARM_THRESH) < 0)) { - rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed++; + dev = rxq->hns->eth_dev; + dev->data->rx_mbuf_alloc_failed++; return; } diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c index 8c2c8f6..603d726 100644 --- a/drivers/net/hns3/hns3_rxtx_vec_sve.c +++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c @@ -239,11 +239,13 @@ hns3_rxq_rearm_mbuf_sve(struct hns3_rx_queue *rxq) struct hns3_entry *rxep = &rxq->sw_ring[rxq->rx_rearm_start]; struct hns3_desc *rxdp = rxq->rx_ring + rxq->rx_rearm_start; struct hns3_entry *rxep_tmp = rxep; + struct rte_eth_dev *dev; int i; if (unlikely(rte_mempool_get_bulk(rxq->mb_pool, (void *)rxep, HNS3_DEFAULT_RXQ_REARM_THRESH) < 0)) { - rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed++; + dev = rxq->hns->eth_dev; + dev->data->rx_mbuf_alloc_failed++; return; } From patchwork Sun Dec 13 08:03:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 85040 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2485A04B5; Sun, 13 Dec 2020 09:03:35 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 51B1CC876; Sun, 13 Dec 2020 09:03:14 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by dpdk.org (Postfix) with ESMTP id E83B84C7B for ; Sun, 13 Dec 2020 09:03:11 +0100 (CET) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Ctxnz2mXXz15cD9 for ; Sun, 13 Dec 2020 16:02:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Sun, 13 Dec 2020 16:03:00 +0800 From: Lijun Ou To: CC: , Date: Sun, 13 Dec 2020 16:03:05 +0800 Message-ID: <1607846585-2381-8-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1607846585-2381-1-git-send-email-oulijun@huawei.com> References: <1607846585-2381-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 7/7] net/hns3: remove unnecessary memset 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" The hns3_cmd_desc has memset when setup and the memset for req is unnecessary. Signed-off-by: Lijun Ou --- drivers/net/hns3/hns3_rss.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index e2f0468..b5df374 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -633,16 +633,11 @@ hns3_set_rss_tc_mode(struct hns3_hw *hw) static void hns3_rss_tuple_uninit(struct hns3_hw *hw) { - struct hns3_rss_input_tuple_cmd *req; struct hns3_cmd_desc desc; int ret; hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INPUT_TUPLE, false); - req = (struct hns3_rss_input_tuple_cmd *)desc.data; - - memset(req, 0, sizeof(struct hns3_rss_tuple_cfg)); - ret = hns3_cmd_send(hw, &desc, 1); if (ret) { hns3_err(hw, "RSS uninit tuple failed %d", ret);