From patchwork Mon Sep 5 08:59:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115871 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 CA004A054A; Mon, 5 Sep 2022 11:01:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1B772427F6; Mon, 5 Sep 2022 11:01:05 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 1B94C40695; Mon, 5 Sep 2022 11:01:02 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MLj7t2XCPzkX0P; Mon, 5 Sep 2022 16:57:14 +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; Mon, 5 Sep 2022 17:00:59 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 01/13] net/hns3: rename hns3 dump file Date: Mon, 5 Sep 2022 16:59:27 +0800 Message-ID: <20220905085939.22236-2-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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: "Min Hu (Connor)" Rename hns3 dump files and abstract a head file for dump. Signed-off-by: Min Hu (Connor) Signed-off-by: Dongdong Liu --- .../net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} | 2 +- drivers/net/hns3/hns3_dump.h | 13 +++++++++++++ drivers/net/hns3/hns3_ethdev.c | 1 + drivers/net/hns3/hns3_ethdev.h | 1 - drivers/net/hns3/hns3_ethdev_vf.c | 1 + drivers/net/hns3/meson.build | 2 +- 6 files changed, 17 insertions(+), 3 deletions(-) rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (99%) create mode 100644 drivers/net/hns3/hns3_dump.h diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_dump.c similarity index 99% rename from drivers/net/hns3/hns3_ethdev_dump.c rename to drivers/net/hns3/hns3_dump.c index 1bb2ab7556..2cfab429af 100644 --- a/drivers/net/hns3/hns3_ethdev_dump.c +++ b/drivers/net/hns3/hns3_dump.c @@ -6,7 +6,7 @@ #include "hns3_logs.h" #include "hns3_regs.h" #include "hns3_rxtx.h" -#include "hns3_ethdev.h" +#include "hns3_dump.h" static const char * get_adapter_state_name(enum hns3_adapter_state state) diff --git a/drivers/net/hns3/hns3_dump.h b/drivers/net/hns3/hns3_dump.h new file mode 100644 index 0000000000..b0fe37ee21 --- /dev/null +++ b/drivers/net/hns3/hns3_dump.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2022 HiSilicon Limited + */ + +#ifndef _HNS3_DUMP_H_ +#define _HNS3_DUMP_H_ + +#include + +#include + +int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file); +#endif /* _HNS3_DUMP_H_ */ diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 6b1d1a5fb1..c6c3279e0f 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -8,6 +8,7 @@ #include "hns3_ethdev.h" #include "hns3_common.h" +#include "hns3_dump.h" #include "hns3_logs.h" #include "hns3_rxtx.h" #include "hns3_intr.h" diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 5e8a746514..8de5a712f4 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -1062,7 +1062,6 @@ int hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts); int hns3_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts); int hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta); -int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file); static inline bool is_reset_pending(struct hns3_adapter *hns) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 18504e6926..86f2ba24cc 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -10,6 +10,7 @@ #include "hns3_ethdev.h" #include "hns3_common.h" +#include "hns3_dump.h" #include "hns3_logs.h" #include "hns3_rxtx.h" #include "hns3_regs.h" diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build index f2aede94ed..dc99cb0209 100644 --- a/drivers/net/hns3/meson.build +++ b/drivers/net/hns3/meson.build @@ -30,7 +30,7 @@ sources = files( 'hns3_tm.c', 'hns3_ptp.c', 'hns3_common.c', - 'hns3_ethdev_dump.c', + 'hns3_dump.c', ) deps += ['hash'] From patchwork Mon Sep 5 08:59:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115872 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 8A768A054A; Mon, 5 Sep 2022 11:01:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 101AE4282B; Mon, 5 Sep 2022 11:01:06 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 4914C40697; Mon, 5 Sep 2022 11:01:02 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MLj7t5vCvzkX0X; Mon, 5 Sep 2022 16:57:14 +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; Mon, 5 Sep 2022 17:01:00 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 02/13] net/hns3: fix code check warning Date: Mon, 5 Sep 2022 16:59:28 +0800 Message-ID: <20220905085939.22236-3-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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: "Min Hu (Connor)" This patch fixed code check warning according to this: function should have same name with previous declaration. local variable should no be referenced in macro referenced. macro argument 'adapter' should be enclosed in parentheses. Signed-off-by: Min Hu (Connor) Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_common.c | 4 ++-- drivers/net/hns3/hns3_dump.c | 4 ++-- drivers/net/hns3/hns3_ethdev.h | 14 +++++++------- drivers/net/hns3/hns3_flow.c | 4 ++-- drivers/net/hns3/hns3_intr.c | 27 ++++++++++++--------------- drivers/net/hns3/hns3_intr.h | 4 ++-- drivers/net/hns3/hns3_regs.c | 4 ++-- drivers/net/hns3/hns3_rss.c | 2 +- drivers/net/hns3/hns3_rss.h | 2 +- drivers/net/hns3/hns3_rxtx.c | 4 ++-- drivers/net/hns3/hns3_rxtx.h | 14 +++++++++----- drivers/net/hns3/hns3_stats.h | 5 +++-- 12 files changed, 45 insertions(+), 43 deletions(-) diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c index 424205356e..d8605204a6 100644 --- a/drivers/net/hns3/hns3_common.c +++ b/drivers/net/hns3/hns3_common.c @@ -493,7 +493,7 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) if (ret) { hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, addr); - hns3_err(hw, "failed to %s mac addr(%s) index:%d ret = %d.", + hns3_err(hw, "failed to %s mac addr(%s) index:%u ret = %d.", del ? "remove" : "restore", mac_str, i, ret); } } @@ -680,7 +680,7 @@ hns3_init_ring_with_vector(struct hns3_hw *hw) ret = hw->ops.bind_ring_with_vector(hw, vec, false, HNS3_RING_TYPE_TX, i); if (ret) { - PMD_INIT_LOG(ERR, "fail to unbind TX ring(%d) with vector: %u, ret=%d", + PMD_INIT_LOG(ERR, "fail to unbind TX ring(%u) with vector: %u, ret=%d", i, vec, ret); return ret; } diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c index 2cfab429af..1738d3cd4e 100644 --- a/drivers/net/hns3/hns3_dump.c +++ b/drivers/net/hns3/hns3_dump.c @@ -342,7 +342,7 @@ static void print_queue_state_perline(FILE *file, const uint32_t *queue_state, uint32_t nb_queues, uint32_t line_num) { -#define NUM_QUEUE_PER_LINE (sizeof(*queue_state) * CHAR_BIT) +#define NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT) uint32_t qid = line_num * NUM_QUEUE_PER_LINE; uint32_t j; @@ -365,7 +365,7 @@ static void display_queue_enable_state(FILE *file, const uint32_t *queue_state, uint32_t nb_queues, bool is_rxq) { -#define NUM_QUEUE_PER_LINE (sizeof(*queue_state) * CHAR_BIT) +#define NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT) uint32_t i; if (nb_queues == 0) { diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 8de5a712f4..bd5fc689f8 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -898,11 +898,11 @@ enum hns3_dev_cap { hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_##_name##_B) #define HNS3_DEV_PRIVATE_TO_HW(adapter) \ - (&((struct hns3_adapter *)adapter)->hw) + (&((struct hns3_adapter *)(adapter))->hw) #define HNS3_DEV_PRIVATE_TO_PF(adapter) \ - (&((struct hns3_adapter *)adapter)->pf) + (&((struct hns3_adapter *)(adapter))->pf) #define HNS3_DEV_PRIVATE_TO_VF(adapter) \ - (&((struct hns3_adapter *)adapter)->vf) + (&((struct hns3_adapter *)(adapter))->vf) #define HNS3_DEV_HW_TO_ADAPTER(hw) \ container_of(hw, struct hns3_adapter, hw) @@ -999,10 +999,10 @@ static inline uint32_t hns3_read_reg(void *base, uint32_t reg) #define NEXT_ITEM_OF_ACTION(act, actions, index) \ do { \ - act = (actions) + (index); \ - while (act->type == RTE_FLOW_ACTION_TYPE_VOID) { \ + (act) = (actions) + (index); \ + while ((act)->type == RTE_FLOW_ACTION_TYPE_VOID) { \ (index)++; \ - act = actions + index; \ + (act) = (actions) + (index); \ } \ } while (0) @@ -1027,7 +1027,7 @@ hns3_atomic_clear_bit(unsigned int nr, volatile uint64_t *addr) __atomic_fetch_and(addr, ~(1UL << nr), __ATOMIC_RELAXED); } -static inline int64_t +static inline uint64_t hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr) { uint64_t mask = (1UL << nr); diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index fb9354fe7f..b84f26c26c 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -66,7 +66,7 @@ static enum rte_flow_item_type tunnel_next_items[] = { struct items_step_mngr { enum rte_flow_item_type *items; - int count; + size_t count; }; static inline void @@ -1141,7 +1141,7 @@ hns3_validate_item(const struct rte_flow_item *item, struct items_step_mngr step_mngr, struct rte_flow_error *error) { - int i; + uint32_t i; if (item->last) return rte_flow_error_set(error, ENOTSUP, diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c index 3ca2e1e338..4bdcd6070b 100644 --- a/drivers/net/hns3/hns3_intr.c +++ b/drivers/net/hns3/hns3_intr.c @@ -16,12 +16,6 @@ #define SWITCH_CONTEXT_US 10 -#define HNS3_CHECK_MERGE_CNT(val) \ - do { \ - if (val) \ - hw->reset.stats.merge_cnt++; \ - } while (0) - static const char *reset_string[HNS3_MAX_RESET] = { "flr", "vf_func", "vf_pf_func", "vf_full", "vf_global", "pf_func", "global", "IMP", "none", @@ -2525,20 +2519,20 @@ static void hns3_clear_reset_level(struct hns3_hw *hw, uint64_t *levels) { uint64_t merge_cnt = hw->reset.stats.merge_cnt; - int64_t tmp; + uint64_t tmp; switch (hw->reset.level) { case HNS3_IMP_RESET: hns3_atomic_clear_bit(HNS3_IMP_RESET, levels); tmp = hns3_test_and_clear_bit(HNS3_GLOBAL_RESET, levels); - HNS3_CHECK_MERGE_CNT(tmp); + merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; tmp = hns3_test_and_clear_bit(HNS3_FUNC_RESET, levels); - HNS3_CHECK_MERGE_CNT(tmp); + merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; break; case HNS3_GLOBAL_RESET: hns3_atomic_clear_bit(HNS3_GLOBAL_RESET, levels); tmp = hns3_test_and_clear_bit(HNS3_FUNC_RESET, levels); - HNS3_CHECK_MERGE_CNT(tmp); + merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; break; case HNS3_FUNC_RESET: hns3_atomic_clear_bit(HNS3_FUNC_RESET, levels); @@ -2546,19 +2540,19 @@ hns3_clear_reset_level(struct hns3_hw *hw, uint64_t *levels) case HNS3_VF_RESET: hns3_atomic_clear_bit(HNS3_VF_RESET, levels); tmp = hns3_test_and_clear_bit(HNS3_VF_PF_FUNC_RESET, levels); - HNS3_CHECK_MERGE_CNT(tmp); + merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; tmp = hns3_test_and_clear_bit(HNS3_VF_FUNC_RESET, levels); - HNS3_CHECK_MERGE_CNT(tmp); + merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; break; case HNS3_VF_FULL_RESET: hns3_atomic_clear_bit(HNS3_VF_FULL_RESET, levels); tmp = hns3_test_and_clear_bit(HNS3_VF_FUNC_RESET, levels); - HNS3_CHECK_MERGE_CNT(tmp); + merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; break; case HNS3_VF_PF_FUNC_RESET: hns3_atomic_clear_bit(HNS3_VF_PF_FUNC_RESET, levels); tmp = hns3_test_and_clear_bit(HNS3_VF_FUNC_RESET, levels); - HNS3_CHECK_MERGE_CNT(tmp); + merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt; break; case HNS3_VF_FUNC_RESET: hns3_atomic_clear_bit(HNS3_VF_FUNC_RESET, levels); @@ -2570,13 +2564,16 @@ hns3_clear_reset_level(struct hns3_hw *hw, uint64_t *levels) default: return; }; - if (merge_cnt != hw->reset.stats.merge_cnt) + + if (merge_cnt != hw->reset.stats.merge_cnt) { hns3_warn(hw, "No need to do low-level reset after %s reset. " "merge cnt: %" PRIu64 " total merge cnt: %" PRIu64, reset_string[hw->reset.level], hw->reset.stats.merge_cnt - merge_cnt, hw->reset.stats.merge_cnt); + hw->reset.stats.merge_cnt = merge_cnt; + } } static bool diff --git a/drivers/net/hns3/hns3_intr.h b/drivers/net/hns3/hns3_intr.h index 1a0f196614..1490a5e387 100644 --- a/drivers/net/hns3/hns3_intr.h +++ b/drivers/net/hns3/hns3_intr.h @@ -170,7 +170,7 @@ struct hns3_hw_error_desc { const struct hns3_hw_error *hw_err; }; -int hns3_enable_hw_error_intr(struct hns3_adapter *hns, bool state); +int hns3_enable_hw_error_intr(struct hns3_adapter *hns, bool en); void hns3_handle_msix_error(struct hns3_adapter *hns, uint64_t *levels); void hns3_handle_ras_error(struct hns3_adapter *hns, uint64_t *levels); void hns3_config_mac_tnl_int(struct hns3_hw *hw, bool en); @@ -185,7 +185,7 @@ void hns3_schedule_reset(struct hns3_adapter *hns); void hns3_schedule_delayed_reset(struct hns3_adapter *hns); int hns3_reset_req_hw_reset(struct hns3_adapter *hns); int hns3_reset_process(struct hns3_adapter *hns, - enum hns3_reset_level reset_level); + enum hns3_reset_level new_level); void hns3_reset_abort(struct hns3_adapter *hns); void hns3_start_report_lse(struct rte_eth_dev *dev); void hns3_stop_report_lse(struct rte_eth_dev *dev); diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c index 6778e4cfc2..33392fd1f0 100644 --- a/drivers/net/hns3/hns3_regs.c +++ b/drivers/net/hns3/hns3_regs.c @@ -15,7 +15,7 @@ #define REG_NUM_PER_LINE 4 #define REG_LEN_PER_LINE (REG_NUM_PER_LINE * sizeof(uint32_t)) -static int hns3_get_dfx_reg_line(struct hns3_hw *hw, uint32_t *length); +static int hns3_get_dfx_reg_line(struct hns3_hw *hw, uint32_t *lines); static const uint32_t cmdq_reg_addrs[] = {HNS3_CMDQ_TX_ADDR_L_REG, HNS3_CMDQ_TX_ADDR_H_REG, @@ -295,7 +295,7 @@ hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data) uint32_t *origin_data_ptr = data; uint32_t reg_offset; uint16_t i, j; - int reg_num; + size_t reg_num; /* fetching per-PF registers values from PF PCIe register space */ reg_num = sizeof(cmdq_reg_addrs) / sizeof(uint32_t); diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index 1003daf03e..fc912ed2e8 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -10,7 +10,7 @@ #include "hns3_logs.h" /* Default hash keys */ -const uint8_t hns3_hash_key[] = { +const uint8_t hns3_hash_key[HNS3_RSS_KEY_SIZE] = { 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2, 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0, 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4, diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h index 56627cbd4c..39af01ef13 100644 --- a/drivers/net/hns3/hns3_rss.h +++ b/drivers/net/hns3/hns3_rss.h @@ -88,7 +88,7 @@ static inline uint32_t roundup_pow_of_two(uint32_t x) return 1UL << fls(x - 1); } -extern const uint8_t hns3_hash_key[]; +extern const uint8_t hns3_hash_key[HNS3_RSS_KEY_SIZE]; struct hns3_adapter; diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 95f711e7eb..731f1bc0ef 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -2759,7 +2759,7 @@ hns3_rx_check_vec_support(__rte_unused struct rte_eth_dev *dev) } uint16_t __rte_weak -hns3_recv_pkts_vec(__rte_unused void *tx_queue, +hns3_recv_pkts_vec(__rte_unused void *rx_queue, __rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts) { @@ -2767,7 +2767,7 @@ hns3_recv_pkts_vec(__rte_unused void *tx_queue, } uint16_t __rte_weak -hns3_recv_pkts_vec_sve(__rte_unused void *tx_queue, +hns3_recv_pkts_vec_sve(__rte_unused void *rx_queue, __rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts) { diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h index 62efc854e4..455f8b9419 100644 --- a/drivers/net/hns3/hns3_rxtx.h +++ b/drivers/net/hns3/hns3_rxtx.h @@ -691,10 +691,12 @@ int hns3_rxq_iterate(struct rte_eth_dev *dev, int (*callback)(struct hns3_rx_queue *, void *), void *arg); void hns3_dev_release_mbufs(struct hns3_adapter *hns); int hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - unsigned int socket, const struct rte_eth_rxconf *conf, + unsigned int socket_id, + const struct rte_eth_rxconf *conf, struct rte_mempool *mp); int hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - unsigned int socket, const struct rte_eth_txconf *conf); + unsigned int socket_id, + const struct rte_eth_txconf *conf); uint32_t hns3_rx_queue_count(void *rx_queue); int hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id); int hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id); @@ -704,9 +706,11 @@ uint16_t hns3_recv_pkts_simple(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); uint16_t hns3_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); -uint16_t hns3_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, +uint16_t hns3_recv_pkts_vec(void *__restrict rx_queue, + struct rte_mbuf **__restrict rx_pkts, uint16_t nb_pkts); -uint16_t hns3_recv_pkts_vec_sve(void *rx_queue, struct rte_mbuf **rx_pkts, +uint16_t hns3_recv_pkts_vec_sve(void *__restrict rx_queue, + struct rte_mbuf **__restrict rx_pkts, uint16_t nb_pkts); int hns3_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id, @@ -751,7 +755,7 @@ void hns3_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, struct rte_eth_rxq_info *qinfo); void hns3_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, struct rte_eth_txq_info *qinfo); -uint32_t hns3_get_tqp_reg_offset(uint16_t idx); +uint32_t hns3_get_tqp_reg_offset(uint16_t queue_id); int hns3_start_all_txqs(struct rte_eth_dev *dev); int hns3_start_all_rxqs(struct rte_eth_dev *dev); void hns3_stop_all_txqs(struct rte_eth_dev *dev); diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h index b5cd6188b4..9d84072205 100644 --- a/drivers/net/hns3/hns3_stats.h +++ b/drivers/net/hns3/hns3_stats.h @@ -145,7 +145,8 @@ struct hns3_reset_stats; #define HNS3_IMISSED_STATS_FIELD_OFFSET(f) \ (offsetof(struct hns3_rx_missed_stats, f)) -int hns3_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); +int hns3_stats_get(struct rte_eth_dev *eth_dev, + struct rte_eth_stats *rte_stats); int hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned int n); int hns3_dev_xstats_reset(struct rte_eth_dev *dev); @@ -160,7 +161,7 @@ int hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, uint32_t size); -int hns3_stats_reset(struct rte_eth_dev *dev); +int hns3_stats_reset(struct rte_eth_dev *eth_dev); int hns3_stats_init(struct hns3_hw *hw); void hns3_stats_uninit(struct hns3_hw *hw); int hns3_query_mac_stats_reg_num(struct hns3_hw *hw); From patchwork Mon Sep 5 08:59:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115873 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 9A265A054A; Mon, 5 Sep 2022 11:01:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F84242B6C; Mon, 5 Sep 2022 11:01:07 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id B2159406B4; Mon, 5 Sep 2022 11:01:02 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MLj9K3Mz4zbndD; Mon, 5 Sep 2022 16:58:29 +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; Mon, 5 Sep 2022 17:01:00 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 03/13] net/hns3: adjust code for dump file Date: Mon, 5 Sep 2022 16:59:29 +0800 Message-ID: <20220905085939.22236-4-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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 Rename the function name with prefix hns3_ to keep the same code style with other files and adjust some code to make it more readable. Signed-off-by: Dongdong Liu Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_dump.c | 289 +++++++++++++++++++---------------- 1 file changed, 154 insertions(+), 135 deletions(-) diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c index 1738d3cd4e..5ce0530ef6 100644 --- a/drivers/net/hns3/hns3_dump.c +++ b/drivers/net/hns3/hns3_dump.c @@ -2,6 +2,8 @@ * Copyright(C) 2022 HiSilicon Limited */ +#include + #include "hns3_common.h" #include "hns3_logs.h" #include "hns3_regs.h" @@ -9,7 +11,7 @@ #include "hns3_dump.h" static const char * -get_adapter_state_name(enum hns3_adapter_state state) +hns3_get_adapter_state_name(enum hns3_adapter_state state) { const struct { enum hns3_adapter_state state; @@ -37,7 +39,7 @@ get_adapter_state_name(enum hns3_adapter_state state) } static const char * -get_io_func_hint_name(uint32_t hint) +hns3_get_io_func_hint_name(uint32_t hint) { switch (hint) { case HNS3_IO_FUNC_HINT_NONE: @@ -56,7 +58,7 @@ get_io_func_hint_name(uint32_t hint) } static void -get_dev_mac_info(FILE *file, struct hns3_adapter *hns) +hns3_get_dev_mac_info(FILE *file, struct hns3_adapter *hns) { struct hns3_hw *hw = &hns->hw; struct hns3_pf *pf = &hns->pf; @@ -78,7 +80,7 @@ get_dev_mac_info(FILE *file, struct hns3_adapter *hns) } static void -get_dev_feature_capability(FILE *file, struct hns3_hw *hw) +hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw) { const struct { enum hns3_dev_cap cap; @@ -106,9 +108,9 @@ get_dev_feature_capability(FILE *file, struct hns3_hw *hw) } static const char * -get_fdir_tuple_name(uint32_t index) +hns3_get_fdir_tuple_name(uint32_t index) { - static const char * const tuple_name[] = { + const char * const tuple_name[] = { "outer_dst_mac", "outer_src_mac", "outer_vlan_1st_tag", @@ -147,12 +149,10 @@ get_fdir_tuple_name(uint32_t index) } static void -get_fdir_basic_info(FILE *file, struct hns3_pf *pf) +hns3_get_fdir_basic_info(FILE *file, struct hns3_pf *pf) { -#define TMPBUF_SIZE 2048 -#define PERLINE_TUPLE_NAMES 4 +#define HNS3_PERLINE_TUPLE_NAME_LEN 4 struct hns3_fd_cfg *fdcfg = &pf->fdir.fd_cfg; - char tmpbuf[TMPBUF_SIZE] = {0}; uint32_t i, count = 0; fprintf(file, " - Fdir Info:\n"); @@ -175,21 +175,19 @@ get_fdir_basic_info(FILE *file, struct hns3_pf *pf) for (i = 0; i < MAX_TUPLE; i++) { if (!(fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active & BIT(i))) continue; - if (count % PERLINE_TUPLE_NAMES == 0) + if (count % HNS3_PERLINE_TUPLE_NAME_LEN == 0) fprintf(file, "\t "); - fprintf(file, " %s", get_fdir_tuple_name(i)); + fprintf(file, " %s", hns3_get_fdir_tuple_name(i)); count++; - if (count % PERLINE_TUPLE_NAMES == 0) + if (count % HNS3_PERLINE_TUPLE_NAME_LEN == 0) fprintf(file, "\n"); } - if (count % PERLINE_TUPLE_NAMES) + if (count % HNS3_PERLINE_TUPLE_NAME_LEN) fprintf(file, "\n"); - - fprintf(file, "%s", tmpbuf); } static void -get_device_basic_info(FILE *file, struct rte_eth_dev *dev) +hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev) { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; @@ -209,7 +207,7 @@ get_device_basic_info(FILE *file, struct rte_eth_dev *dev) "\t -- dev_flags: lsc=%d\n" "\t -- intr_conf: lsc=%u rxq=%u\n", dev->data->name, - get_adapter_state_name(hw->adapter_state), + hns3_get_adapter_state_name(hw->adapter_state), dev->data->nb_rx_queues, dev->data->nb_tx_queues, hw->total_tqps_num, hw->tqps_num, hw->intr_tqps_num, hw->rss_size_max, hw->alloc_rss_size, hw->tx_qnum_per_tc, @@ -217,15 +215,15 @@ get_device_basic_info(FILE *file, struct rte_eth_dev *dev) hw->tso_mode, hw->max_non_tso_bd_num, hw->max_tm_rate, hw->set_link_down ? "Yes" : "No", - get_io_func_hint_name(hns->rx_func_hint), - get_io_func_hint_name(hns->tx_func_hint), + hns3_get_io_func_hint_name(hns->rx_func_hint), + hns3_get_io_func_hint_name(hns->tx_func_hint), !!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC), dev->data->dev_conf.intr_conf.lsc, dev->data->dev_conf.intr_conf.rxq); } static struct hns3_rx_queue * -get_rx_queue(struct rte_eth_dev *dev) +hns3_get_rx_queue(struct rte_eth_dev *dev) { struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct hns3_rx_queue *rxq; @@ -250,7 +248,7 @@ get_rx_queue(struct rte_eth_dev *dev) } static struct hns3_tx_queue * -get_tx_queue(struct rte_eth_dev *dev) +hns3_get_tx_queue(struct rte_eth_dev *dev) { struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct hns3_tx_queue *txq; @@ -275,7 +273,7 @@ get_tx_queue(struct rte_eth_dev *dev) } static void -get_rxtx_fake_queue_info(FILE *file, struct rte_eth_dev *dev) +hns3_get_rxtx_fake_queue_info(FILE *file, struct rte_eth_dev *dev) { struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct hns3_rx_queue *rxq; @@ -317,10 +315,10 @@ get_rxtx_fake_queue_info(FILE *file, struct rte_eth_dev *dev) } static void -get_queue_enable_state(struct hns3_hw *hw, uint32_t *queue_state, - uint32_t nb_queues, bool is_rxq) +hns3_get_queue_enable_state(struct hns3_hw *hw, uint32_t *queue_state, + uint32_t nb_queues, bool is_rxq) { -#define STATE_SIZE (sizeof(*queue_state) * CHAR_BIT) +#define HNS3_QUEUE_NUM_PER_STATS (sizeof(*queue_state) * HNS3_UINT8_BIT) uint32_t queue_en_reg; uint32_t reg_offset; uint32_t state; @@ -333,28 +331,28 @@ get_queue_enable_state(struct hns3_hw *hw, uint32_t *queue_state, if (hns3_dev_get_support(hw, INDEP_TXRX)) state = state && hns3_read_dev(hw, reg_offset + queue_en_reg); - hns3_set_bit(queue_state[i / STATE_SIZE], - i % STATE_SIZE, state); + hns3_set_bit(queue_state[i / HNS3_QUEUE_NUM_PER_STATS], + i % HNS3_QUEUE_NUM_PER_STATS, state); } } static void -print_queue_state_perline(FILE *file, const uint32_t *queue_state, - uint32_t nb_queues, uint32_t line_num) +hns3_print_queue_state_perline(FILE *file, const uint32_t *queue_state, + uint32_t nb_queues, uint32_t line_num) { -#define NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT) - uint32_t qid = line_num * NUM_QUEUE_PER_LINE; - uint32_t j; +#define HNS3_NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT) + uint32_t id = line_num * HNS3_NUM_QUEUE_PER_LINE; + uint32_t i; - for (j = 0; j < NUM_QUEUE_PER_LINE; j++) { - fprintf(file, "%1lx", hns3_get_bit(queue_state[line_num], j)); + for (i = 0; i < HNS3_NUM_QUEUE_PER_LINE; i++) { + fprintf(file, "%1lx", hns3_get_bit(queue_state[line_num], i)); - if (qid % CHAR_BIT == CHAR_BIT - 1) { + if (id % HNS3_UINT8_BIT == HNS3_UINT8_BIT - 1) { fprintf(file, "%s", - j == NUM_QUEUE_PER_LINE - 1 ? "\n" : ":"); + i == HNS3_NUM_QUEUE_PER_LINE - 1 ? "\n" : ":"); } - qid++; - if (qid >= nb_queues) { + id++; + if (id >= nb_queues) { fprintf(file, "\n"); break; } @@ -362,66 +360,83 @@ print_queue_state_perline(FILE *file, const uint32_t *queue_state, } static void -display_queue_enable_state(FILE *file, const uint32_t *queue_state, - uint32_t nb_queues, bool is_rxq) +hns3_display_queue_enable_state(FILE *file, const uint32_t *queue_state, + uint32_t nb_queues, bool is_rxq) { -#define NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT) +#define HNS3_NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT) uint32_t i; - if (nb_queues == 0) { - fprintf(file, "\t %s queue number is 0\n", - is_rxq ? "Rx" : "Tx"); - return; - } - fprintf(file, "\t %s queue id | enable state bitMap\n", - is_rxq ? "rx" : "tx"); + is_rxq ? "Rx" : "Tx"); - for (i = 0; i < (nb_queues - 1) / NUM_QUEUE_PER_LINE + 1; i++) { - uint32_t line_end = (i + 1) * NUM_QUEUE_PER_LINE - 1; - uint32_t line_start = i * NUM_QUEUE_PER_LINE; + for (i = 0; i < (nb_queues - 1) / HNS3_NUM_QUEUE_PER_LINE + 1; i++) { + uint32_t line_end = (i + 1) * HNS3_NUM_QUEUE_PER_LINE - 1; + uint32_t line_start = i * HNS3_NUM_QUEUE_PER_LINE; fprintf(file, "\t %04u - %04u | ", line_start, nb_queues - 1 > line_end ? line_end : nb_queues - 1); - - print_queue_state_perline(file, queue_state, nb_queues, i); + hns3_print_queue_state_perline(file, queue_state, nb_queues, i); } } static void -get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev) +hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev) { -#define MAX_TQP_NUM 1280 -#define QUEUE_BITMAP_SIZE (MAX_TQP_NUM / 32) struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - uint32_t rx_queue_state[QUEUE_BITMAP_SIZE] = {0}; - uint32_t tx_queue_state[QUEUE_BITMAP_SIZE] = {0}; + uint32_t *rx_queue_state; + uint32_t *tx_queue_state; uint32_t nb_rx_queues; uint32_t nb_tx_queues; + uint32_t bitmap_size; nb_rx_queues = dev->data->nb_rx_queues; nb_tx_queues = dev->data->nb_tx_queues; + if (nb_rx_queues == 0) { + fprintf(file, "\t -- Rx queue number is 0\n"); + return; + } + if (nb_tx_queues == 0) { + fprintf(file, "\t -- Tx queue number is 0\n"); + return; + } + + bitmap_size = (hw->tqps_num * sizeof(uint32_t) + HNS3_UINT32_BIT) / + HNS3_UINT32_BIT; + rx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0); + if (rx_queue_state == NULL) { + hns3_err(hw, "Failed to allocate memory for rx queue state!"); + return; + } + + tx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0); + if (tx_queue_state == NULL) { + hns3_err(hw, "Failed to allocate memory for tx queue state!"); + rte_free(rx_queue_state); + return; + } fprintf(file, "\t -- enable state:\n"); - get_queue_enable_state(hw, rx_queue_state, nb_rx_queues, true); - display_queue_enable_state(file, rx_queue_state, nb_rx_queues, + hns3_get_queue_enable_state(hw, rx_queue_state, nb_rx_queues, true); + hns3_display_queue_enable_state(file, rx_queue_state, nb_rx_queues, true); - get_queue_enable_state(hw, tx_queue_state, nb_tx_queues, false); - display_queue_enable_state(file, tx_queue_state, nb_tx_queues, + hns3_get_queue_enable_state(hw, tx_queue_state, nb_tx_queues, false); + hns3_display_queue_enable_state(file, tx_queue_state, nb_tx_queues, false); + rte_free(rx_queue_state); + rte_free(tx_queue_state); } static void -get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev) +hns3_get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev) { struct hns3_rx_queue *rxq; struct hns3_tx_queue *txq; - rxq = get_rx_queue(dev); + rxq = hns3_get_rx_queue(dev); if (rxq == NULL) return; - txq = get_tx_queue(dev); + txq = hns3_get_tx_queue(dev); if (txq == NULL) return; fprintf(file, " - Rx/Tx Queue Info:\n"); @@ -434,12 +449,12 @@ get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev) txq->port_id, txq->nb_tx_desc, txq->tx_push_enable ? "enabled" : "disabled"); - get_rxtx_fake_queue_info(file, dev); - get_rxtx_queue_enable_state(file, dev); + hns3_get_rxtx_fake_queue_info(file, dev); + hns3_get_rxtx_queue_enable_state(file, dev); } static int -get_vlan_filter_cfg(FILE *file, struct hns3_hw *hw) +hns3_get_vlan_filter_cfg(FILE *file, struct hns3_hw *hw) { #define HNS3_FILTER_TYPE_VF 0 #define HNS3_FILTER_TYPE_PORT 1 @@ -484,7 +499,7 @@ get_vlan_filter_cfg(FILE *file, struct hns3_hw *hw) } static int -get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw) +hns3_get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw) { struct hns3_vport_vtag_rx_cfg_cmd *req; struct hns3_cmd_desc desc; @@ -506,8 +521,8 @@ get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw) ret = hns3_cmd_send(hw, &desc, 1); if (ret != 0) { hns3_err(hw, - "NIC IMP exec ret=%d desc_num=%d optcode=0x%x!", - ret, 1, rte_le_to_cpu_16(desc.opcode)); + "NIC firmware exec ret=%d optcode=0x%x!", ret, + rte_le_to_cpu_16(desc.opcode)); return ret; } @@ -536,7 +551,7 @@ get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw) } static void -parse_tx_vlan_cfg(FILE *file, struct hns3_vport_vtag_tx_cfg_cmd *req) +hns3_parse_tx_vlan_cfg(FILE *file, struct hns3_vport_vtag_tx_cfg_cmd *req) { #define VLAN_VID_MASK 0x0fff #define VLAN_PRIO_SHIFT 13 @@ -574,7 +589,7 @@ parse_tx_vlan_cfg(FILE *file, struct hns3_vport_vtag_tx_cfg_cmd *req) } static int -get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw) +hns3_get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw) { struct hns3_vport_vtag_tx_cfg_cmd *req; struct hns3_cmd_desc desc; @@ -595,50 +610,50 @@ get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw) ret = hns3_cmd_send(hw, &desc, 1); if (ret != 0) { hns3_err(hw, - "NIC IMP exec ret=%d desc_num=%d optcode=0x%x!", + "NIC firmware exec ret=%d desc_num=%d optcode=0x%x!", ret, 1, rte_le_to_cpu_16(desc.opcode)); return ret; } - parse_tx_vlan_cfg(file, req); + hns3_parse_tx_vlan_cfg(file, req); return 0; } static void -get_port_pvid_info(FILE *file, struct hns3_hw *hw) +hns3_get_port_pvid_info(FILE *file, struct hns3_hw *hw) { - fprintf(file, "\t -- pvid status: %s\n", - hw->port_base_vlan_cfg.state ? "on" : "off"); + fprintf(file, " - pvid status: %s\n", + hw->port_base_vlan_cfg.state ? "On" : "Off"); } static void -get_vlan_config_info(FILE *file, struct hns3_hw *hw) +hns3_get_vlan_config_info(FILE *file, struct hns3_hw *hw) { int ret; fprintf(file, " - VLAN Config Info:\n"); - ret = get_vlan_filter_cfg(file, hw); + ret = hns3_get_vlan_filter_cfg(file, hw); if (ret < 0) return; - ret = get_vlan_rx_offload_cfg(file, hw); + ret = hns3_get_vlan_rx_offload_cfg(file, hw); if (ret < 0) return; - ret = get_vlan_tx_offload_cfg(file, hw); + ret = hns3_get_vlan_tx_offload_cfg(file, hw); if (ret < 0) return; } static void -get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf) +hns3_get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf) { struct hns3_shaper_profile_list *shaper_profile_list = &conf->shaper_profile_list; struct hns3_tm_shaper_profile *shaper_profile; - if (!conf->nb_shaper_profile) + if (conf->nb_shaper_profile == 0) return; fprintf(file, " shaper_profile:\n"); @@ -652,9 +667,9 @@ get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf) } static void -get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf) +hns3_get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf) { - if (!conf->root) + if (conf->root == NULL) return; fprintf(file, @@ -666,14 +681,14 @@ get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf) } static void -get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf) +hns3_get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf) { struct hns3_tm_node_list *tc_list = &conf->tc_list; struct hns3_tm_node *tc_node[HNS3_MAX_TC_NUM]; struct hns3_tm_node *tm_node; uint32_t tidx; - if (!conf->nb_tc_node) + if (conf->nb_tc_node == 0) return; fprintf(file, " tc_node:\n"); @@ -700,25 +715,27 @@ get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf) } static void -get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node, - uint32_t *queue_node_tc, uint32_t nb_tx_queues) +hns3_get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node, + uint32_t *queue_node_tc, + uint32_t nb_tx_queues) { -#define PERLINE_QUEUES 32 -#define PERLINE_STRIDE 8 -#define LINE_BUF_SIZE 1024 - uint32_t i, j, line_num, start_queue, end_queue; +#define HNS3_PERLINE_QUEUES 32 +#define HNS3_PERLINE_STRIDE 8 + uint32_t i, j, line_num, start_queue_id, end_queue_id; - line_num = (nb_tx_queues + PERLINE_QUEUES - 1) / PERLINE_QUEUES; + line_num = (nb_tx_queues + HNS3_PERLINE_QUEUES - 1) / + HNS3_PERLINE_QUEUES; for (i = 0; i < line_num; i++) { - start_queue = i * PERLINE_QUEUES; - end_queue = (i + 1) * PERLINE_QUEUES - 1; - if (end_queue > nb_tx_queues - 1) - end_queue = nb_tx_queues - 1; - fprintf(file, " %04u - %04u | ", start_queue, end_queue); - for (j = start_queue; j < nb_tx_queues; j++) { - if (j >= end_queue + 1) + start_queue_id = i * HNS3_PERLINE_QUEUES; + end_queue_id = (i + 1) * HNS3_PERLINE_QUEUES - 1; + if (end_queue_id > nb_tx_queues - 1) + end_queue_id = nb_tx_queues - 1; + fprintf(file, " %04u - %04u | ", start_queue_id, + end_queue_id); + for (j = start_queue_id; j < nb_tx_queues; j++) { + if (j >= end_queue_id + 1) break; - if (j > start_queue && j % PERLINE_STRIDE == 0) + if (j > start_queue_id && j % HNS3_PERLINE_STRIDE == 0) fprintf(file, ":"); fprintf(file, "%u", queue_node[j] ? queue_node_tc[j] : @@ -729,8 +746,8 @@ get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node, } static void -get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf, - uint32_t nb_tx_queues) +hns3_get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf, + uint32_t nb_tx_queues) { struct hns3_tm_node_list *queue_list = &conf->queue_list; uint32_t nb_queue_node = conf->nb_leaf_nodes_max + 1; @@ -738,7 +755,7 @@ get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf, uint32_t queue_node_tc[nb_queue_node]; struct hns3_tm_node *tm_node; - if (!conf->nb_queue_node) + if (conf->nb_queue_node == 0) return; fprintf(file, @@ -757,12 +774,12 @@ get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf, nb_tx_queues = RTE_MAX(nb_tx_queues, tm_node->id + 1); } - get_tm_conf_queue_format_info(file, queue_node, queue_node_tc, + hns3_get_tm_conf_queue_format_info(file, queue_node, queue_node_tc, nb_tx_queues); } static void -get_tm_conf_info(FILE *file, struct rte_eth_dev *dev) +hns3_get_tm_conf_info(FILE *file, struct rte_eth_dev *dev) { struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); @@ -780,10 +797,10 @@ get_tm_conf_info(FILE *file, struct rte_eth_dev *dev) conf->nb_shaper_profile, conf->nb_tc_node, conf->nb_queue_node, conf->committed); - get_tm_conf_shaper_info(file, conf); - get_tm_conf_port_node_info(file, conf); - get_tm_conf_tc_node_info(file, conf); - get_tm_conf_queue_node_info(file, conf, dev->data->nb_tx_queues); + hns3_get_tm_conf_shaper_info(file, conf); + hns3_get_tm_conf_port_node_info(file, conf); + hns3_get_tm_conf_tc_node_info(file, conf); + hns3_get_tm_conf_queue_node_info(file, conf, dev->data->nb_tx_queues); } static void @@ -815,7 +832,7 @@ hns3_fc_mode_to_rxtx_pause(enum hns3_fc_mode fc_mode, bool *rx_pause, } static bool -is_link_fc_mode(struct hns3_adapter *hns) +hns3_is_link_fc_mode(struct hns3_adapter *hns) { struct hns3_hw *hw = &hns->hw; struct hns3_pf *pf = &hns->pf; @@ -830,21 +847,21 @@ is_link_fc_mode(struct hns3_adapter *hns) } static void -get_link_fc_info(FILE *file, struct rte_eth_dev *dev) +hns3_get_link_fc_info(FILE *file, struct rte_eth_dev *dev) { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - struct rte_eth_fc_conf fc_conf; + struct rte_eth_fc_conf cur_fc_conf; bool rx_pause1; bool tx_pause1; bool rx_pause2; bool tx_pause2; int ret; - if (!is_link_fc_mode(hns)) + if (!hns3_is_link_fc_mode(hns)) return; - ret = hns3_flow_ctrl_get(dev, &fc_conf); + ret = hns3_flow_ctrl_get(dev, &cur_fc_conf); if (ret) { fprintf(file, "get device flow control info fail!\n"); return; @@ -852,7 +869,7 @@ get_link_fc_info(FILE *file, struct rte_eth_dev *dev) hns3_fc_mode_to_rxtx_pause(hw->requested_fc_mode, &rx_pause1, &tx_pause1); - hns3_fc_mode_to_rxtx_pause((enum hns3_fc_mode)fc_conf.mode, + hns3_fc_mode_to_rxtx_pause((enum hns3_fc_mode)cur_fc_conf.mode, &rx_pause2, &tx_pause2); fprintf(file, @@ -867,15 +884,14 @@ get_link_fc_info(FILE *file, struct rte_eth_dev *dev) "\t Pause time: 0x%x\n", rx_pause1 ? "On" : "Off", tx_pause1 ? "On" : "Off", rx_pause2 ? "On" : "Off", tx_pause2 ? "On" : "Off", - fc_conf.autoneg == RTE_ETH_LINK_AUTONEG ? "On" : "Off", - fc_conf.pause_time); + cur_fc_conf.autoneg == RTE_ETH_LINK_AUTONEG ? "On" : "Off", + cur_fc_conf.pause_time); } static void -get_flow_ctrl_info(FILE *file, struct rte_eth_dev *dev) +hns3_get_flow_ctrl_info(FILE *file, struct rte_eth_dev *dev) { - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); fprintf(file, " - Flow Ctrl Info:\n"); fprintf(file, @@ -885,7 +901,7 @@ get_flow_ctrl_info(FILE *file, struct rte_eth_dev *dev) hw->current_fc_status, hw->requested_fc_mode); - get_link_fc_info(file, dev); + hns3_get_link_fc_info(file, dev); } int @@ -894,20 +910,23 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - get_device_basic_info(file, dev); - get_dev_feature_capability(file, hw); - get_rxtx_queue_info(file, dev); - get_port_pvid_info(file, hw); + hns3_get_device_basic_info(file, dev); + hns3_get_dev_feature_capability(file, hw); + hns3_get_rxtx_queue_info(file, dev); + hns3_get_port_pvid_info(file, hw); - /* VF only supports dumping basic info and feaure capability */ + /* + * VF only supports dumping basic info, feature capability and queue + * info. + */ if (hns->is_vf) return 0; - get_dev_mac_info(file, hns); - get_vlan_config_info(file, hw); - get_fdir_basic_info(file, &hns->pf); - get_tm_conf_info(file, dev); - get_flow_ctrl_info(file, dev); + hns3_get_dev_mac_info(file, hns); + hns3_get_vlan_config_info(file, hw); + hns3_get_fdir_basic_info(file, &hns->pf); + hns3_get_tm_conf_info(file, dev); + hns3_get_flow_ctrl_info(file, dev); return 0; } From patchwork Mon Sep 5 08:59:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115874 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 74B5AA054A; Mon, 5 Sep 2022 11:01:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BD2D042B7E; Mon, 5 Sep 2022 11:01:09 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 1513C42B70; Mon, 5 Sep 2022 11:01:08 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MLj754PnkzZcf9; Mon, 5 Sep 2022 16:56:33 +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; Mon, 5 Sep 2022 17:01:01 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 04/13] net/hns3: add dump of VF vlan filter modify capability Date: Mon, 5 Sep 2022 16:59:30 +0800 Message-ID: <20220905085939.22236-5-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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: Jie Hai This patch shows whether support modifying VF Vlan Filter or not. Sample output changes: + -- support VF VLAN FILTER MOD: Yes Signed-off-by: Jie Hai Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_dump.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c index 5ce0530ef6..95b64f8896 100644 --- a/drivers/net/hns3/hns3_dump.c +++ b/drivers/net/hns3/hns3_dump.c @@ -97,6 +97,7 @@ hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw) {HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, "OUTER UDP CKSUM"}, {HNS3_DEV_SUPPORT_RAS_IMP_B, "RAS IMP"}, {HNS3_DEV_SUPPORT_TM_B, "TM"}, + {HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, "VF VLAN FILTER MOD"}, }; uint32_t i; From patchwork Mon Sep 5 08:59:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115875 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 A9FDFA054A; Mon, 5 Sep 2022 11:01:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CD8C042B85; Mon, 5 Sep 2022 11:01:10 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id F141742836; Mon, 5 Sep 2022 11:01:08 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MLj814ZJlz1P6hm; Mon, 5 Sep 2022 16:57:21 +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; Mon, 5 Sep 2022 17:01:06 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 05/13] net/hns3: fix fail to receive PTP packet Date: Mon, 5 Sep 2022 16:59:31 +0800 Message-ID: <20220905085939.22236-6-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-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 Rx and Tx vector algorithm of hns3 PMD don't support PTP function. Currently, hns3 driver uses 'pf->ptp_enable' to check whether PTP is enabled so as to not select Rx and Tx vector algorithm. And the variable is set when call rte_eth_timesync_enable(). Namely, it may not be set before selecting Rx/Tx function, let's say the case: set PTP offload in dev_configure(), do dev_start() and then call rte_eth_timesync_enable(). In this case, all PTP packets can not be received to application. So this patch fixes the check based on the RTE_ETH_RX_OFFLOAD_TIMESTAMP flag. Fixes: 71f4d1aae11f ("net/hns3: fix vector burst unsupported when PTP capability set") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_ptp.c | 1 - drivers/net/hns3/hns3_rxtx_vec.c | 20 +++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c index 0b0061bba5..6bbd85ba23 100644 --- a/drivers/net/hns3/hns3_ptp.c +++ b/drivers/net/hns3/hns3_ptp.c @@ -125,7 +125,6 @@ hns3_timesync_enable(struct rte_eth_dev *dev) if (pf->ptp_enable) return 0; - hns3_warn(hw, "note: please ensure Rx/Tx burst mode is simple or common when enabling PTP!"); rte_spinlock_lock(&hw->lock); ret = hns3_timesync_configure(hns, true); diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c index 0dd6fccb13..cd9264d91b 100644 --- a/drivers/net/hns3/hns3_rxtx_vec.c +++ b/drivers/net/hns3/hns3_rxtx_vec.c @@ -17,15 +17,18 @@ int hns3_tx_check_vec_support(struct rte_eth_dev *dev) { struct rte_eth_txmode *txmode = &dev->data->dev_conf.txmode; - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_pf *pf = &hns->pf; + struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode; /* Only support RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE */ if (txmode->offloads != RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) return -ENOTSUP; - /* Vec is not supported when PTP enabled */ - if (pf->ptp_enable) + /* + * PTP function requires the cooperation of Rx and Tx. + * Tx vector isn't supported if RTE_ETH_RX_OFFLOAD_TIMESTAMP is set + * in Rx offloads. + */ + if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) return -ENOTSUP; return 0; @@ -232,9 +235,8 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev) { struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode; uint64_t offloads_mask = RTE_ETH_RX_OFFLOAD_TCP_LRO | - RTE_ETH_RX_OFFLOAD_VLAN; - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_pf *pf = &hns->pf; + RTE_ETH_RX_OFFLOAD_VLAN | + RTE_ETH_RX_OFFLOAD_TIMESTAMP; if (dev->data->scattered_rx) return -ENOTSUP; @@ -245,9 +247,5 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev) if (hns3_rxq_iterate(dev, hns3_rxq_vec_check, NULL) != 0) return -ENOTSUP; - /* Vec is not supported when PTP enabled */ - if (pf->ptp_enable) - return -ENOTSUP; - return 0; } From patchwork Mon Sep 5 08:59:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115876 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 52967A054A; Mon, 5 Sep 2022 11:01:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3F41B42B71; Mon, 5 Sep 2022 11:01:12 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 3E0B0427FF; Mon, 5 Sep 2022 11:01:09 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MLj9R5zHczbnd1; Mon, 5 Sep 2022 16:58:35 +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; Mon, 5 Sep 2022 17:01:07 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 06/13] net/hns3: fix segment fault when using SVE xmit Date: Mon, 5 Sep 2022 16:59:32 +0800 Message-ID: <20220905085939.22236-7-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-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, 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 Mon Sep 5 08:59:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115877 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 5AAB4A054A; Mon, 5 Sep 2022 11:01:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5DB2142B93; Mon, 5 Sep 2022 11:01:13 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 6C5C84281B; Mon, 5 Sep 2022 11:01:09 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MLj82000vzkWxw; Mon, 5 Sep 2022 16:57:21 +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; Mon, 5 Sep 2022 17:01:07 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 07/13] net/hns3: fix next-to-use overflow when using SVE xmit Date: Mon, 5 Sep 2022 16:59:33 +0800 Message-ID: <20220905085939.22236-8-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-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 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 Mon Sep 5 08:59:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115878 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 800D2A054A; Mon, 5 Sep 2022 11:02:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3311842B95; Mon, 5 Sep 2022 11:01:14 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id 2ABA1427FF; Mon, 5 Sep 2022 11:01:10 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MLjBC6LgjzrSFy; Mon, 5 Sep 2022 16:59:15 +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; Mon, 5 Sep 2022 17:01:08 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 08/13] net/hns3: fix next-to-use overflow when using simple xmit Date: Mon, 5 Sep 2022 16:59:34 +0800 Message-ID: <20220905085939.22236-9-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-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 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 731f1bc0ef..1b1dc6b8e4 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 Mon Sep 5 08:59:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115879 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 2F89BA054A; Mon, 5 Sep 2022 11:02:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9827542BAC; Mon, 5 Sep 2022 11:01:15 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 3FD2642836; Mon, 5 Sep 2022 11:01:10 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MLj9T0D6Wzbnch; Mon, 5 Sep 2022 16:58: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; Mon, 5 Sep 2022 17:01:08 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 09/13] net/hns3: optimize SVE xmit performance Date: Mon, 5 Sep 2022 16:59:35 +0800 Message-ID: <20220905085939.22236-10-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-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 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 Mon Sep 5 08:59:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115883 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 F26E8A054A; Mon, 5 Sep 2022 11:02:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A776742BC2; Mon, 5 Sep 2022 11:01:22 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 86B3942B81; Mon, 5 Sep 2022 11:01:20 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MLj7K6N8fzZcD1; Mon, 5 Sep 2022 16:56:45 +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; Mon, 5 Sep 2022 17:01:13 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 10/13] net/hns3: fix segment fault when secondary process access FW Date: Mon, 5 Sep 2022 16:59:36 +0800 Message-ID: <20220905085939.22236-11-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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 c6c3279e0f..7cd1ff53e8 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -5602,7 +5602,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 86f2ba24cc..a72535eb7d 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1864,8 +1864,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 Mon Sep 5 08:59:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115880 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 873BCA054A; Mon, 5 Sep 2022 11:02:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B1F2042B8C; Mon, 5 Sep 2022 11:01:17 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 064AB42BB0; Mon, 5 Sep 2022 11:01:16 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MLj885Z0vz1P6hB; Mon, 5 Sep 2022 16:57:28 +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; Mon, 5 Sep 2022 17:01:13 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 11/13] net/hns3: delete rte unused tag Date: Mon, 5 Sep 2022 16:59:37 +0800 Message-ID: <20220905085939.22236-12-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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 Mon Sep 5 08:59:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115881 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 EC659A054A; Mon, 5 Sep 2022 11:02:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8267042BAF; Mon, 5 Sep 2022 11:01:18 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 3FCE942B74; Mon, 5 Sep 2022 11:01:16 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MLj8861c2zkWsd; Mon, 5 Sep 2022 16:57:28 +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; Mon, 5 Sep 2022 17:01:14 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 12/13] net/hns3: fix uncleared hardware MAC statistics Date: Mon, 5 Sep 2022 16:59:38 +0800 Message-ID: <20220905085939.22236-13-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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 Mon Sep 5 08:59:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 115882 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 E37E3A054A; Mon, 5 Sep 2022 11:02:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7D66A42BB7; Mon, 5 Sep 2022 11:01:19 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id E525F42B74; Mon, 5 Sep 2022 11:01:16 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MLjBL6DMFzrSFy; Mon, 5 Sep 2022 16:59:22 +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; Mon, 5 Sep 2022 17:01:14 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 13/13] net/hns3: revert optimize Tx performance Date: Mon, 5 Sep 2022 16:59:39 +0800 Message-ID: <20220905085939.22236-14-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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 1b1dc6b8e4..ca61b441df 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