From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 11D2AA054A for ; Mon, 5 Sep 2022 11:01:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D642242836; 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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); -- 2.22.0