From patchwork Wed Jul 13 11:49:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 113941 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 825B0A0032; Wed, 13 Jul 2022 13:51:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DC6A442B76; Wed, 13 Jul 2022 13:51: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 C82D042836; Wed, 13 Jul 2022 13:50:53 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LjbWB3TBRzlVmh; Wed, 13 Jul 2022 19:49:10 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 13 Jul 2022 19:50:44 +0800 From: Dongdong Liu To: , , , CC: , "Min Hu (Connor)" , Dongdong Liu , Yisen Zhuang Subject: [PATCH 1/5] net/hns3: rename hns3 dump file Date: Wed, 13 Jul 2022 19:49:58 +0800 Message-ID: <20220713115002.8959-2-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220713115002.8959-1-liudongdong3@huawei.com> References: <20220713115002.8959-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: "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 Wed Jul 13 11:49:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 113939 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 71AA8A0032; Wed, 13 Jul 2022 13:51:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3BC7142B6E; Wed, 13 Jul 2022 13:50:59 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 183014282D; Wed, 13 Jul 2022 13:50:51 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LjbV43hmDz1L93l; Wed, 13 Jul 2022 19:48:12 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 13 Jul 2022 19:50:46 +0800 From: Dongdong Liu To: , , , CC: , "Min Hu (Connor)" , Dongdong Liu , Yisen Zhuang Subject: [PATCH 2/5] net/hns3: fix code check warning Date: Wed, 13 Jul 2022 19:49:59 +0800 Message-ID: <20220713115002.8959-3-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220713115002.8959-1-liudongdong3@huawei.com> References: <20220713115002.8959-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: "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 Wed Jul 13 11:50:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 113942 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 97970A0032; Wed, 13 Jul 2022 13:51:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5062D42B8F; Wed, 13 Jul 2022 13:51:15 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id DE53A42B76; Wed, 13 Jul 2022 13:51:05 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LjbX148VKzFq2Q; Wed, 13 Jul 2022 19:49:53 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 13 Jul 2022 19:50:48 +0800 From: Dongdong Liu To: , , , CC: , Dongdong Liu , Min Hu , Yisen Zhuang Subject: [PATCH 3/5] net/hns3: adjust code for dump file Date: Wed, 13 Jul 2022 19:50:00 +0800 Message-ID: <20220713115002.8959-4-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220713115002.8959-1-liudongdong3@huawei.com> References: <20220713115002.8959-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 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 Wed Jul 13 11:50:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 113938 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 DABD6A0032; Wed, 13 Jul 2022 13:51:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3679C42B70; Wed, 13 Jul 2022 13:50:57 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 9573F4282E; Wed, 13 Jul 2022 13:50:53 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LjbV83yCtz1L937; Wed, 13 Jul 2022 19:48:16 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 13 Jul 2022 19:50:50 +0800 From: Dongdong Liu To: , , , CC: , Jie Hai , Dongdong Liu , Yisen Zhuang Subject: [PATCH 4/5] net/hns3: add dump of VF vlan filter modify capability Date: Wed, 13 Jul 2022 19:50:01 +0800 Message-ID: <20220713115002.8959-5-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220713115002.8959-1-liudongdong3@huawei.com> References: <20220713115002.8959-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: 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 Wed Jul 13 11:50:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 113940 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 AFBE3A0032; Wed, 13 Jul 2022 13:51:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8B0DC42B81; Wed, 13 Jul 2022 13:51:08 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 34D2042B6F; Wed, 13 Jul 2022 13:51:04 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LjbWS28tjzlVwM; Wed, 13 Jul 2022 19:49:24 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 13 Jul 2022 19:50:58 +0800 From: Dongdong Liu To: , , , CC: , Huisong Li , Dongdong Liu , Yisen Zhuang , "Min Hu (Connor)" Subject: [PATCH 5/5] net/hns3: fix fail to receive PTP packet Date: Wed, 13 Jul 2022 19:50:02 +0800 Message-ID: <20220713115002.8959-6-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220713115002.8959-1-liudongdong3@huawei.com> References: <20220713115002.8959-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500017.china.huawei.com (7.221.188.110) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: 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 73f0ab6bc8..153866cf03 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; @@ -233,9 +236,8 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev) struct rte_eth_fdir_conf *fconf = &dev->data->dev_conf.fdir_conf; 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; @@ -249,9 +251,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; }