From d1556d5d8fa60ab362a458ee7b3f7864114231f1 Mon Sep 17 00:00:00 2001 From: Dengdui Huang Date: Mon, 28 Apr 2025 11:24:13 +0800 Subject: [PATCH] sync some bugfixes from upstreaming - net/hns3: fix unrelease some resources on reset case - net/hns3: fix divide by zero - net/hns3: fix incorrect failed rollback - net/hns3: fix memory leakage for indirect action - net/hns3: fix extra waiting for link up - net/hns3: fix variable overflow - net/hns3: fix memory leakage in failure path - devtools: fix symbol listing - net/hns3: remove weak symbols - net/hns3: fix reset timeout - net/hns3: fix copper port inialization - net/hns3: rename RAS module - net/hns3: remove PVID info dump for VF - net/hns3: fix mbuf freeing in simple Tx path Signed-off-by: Dengdui Huang (cherry picked from commit 4f2a5e819346fb5bf12b9de68352782319e4a2a6) --- ...3-fix-mbuf-freeing-in-simple-Tx-path.patch | 35 ++++ ...et-hns3-remove-PVID-info-dump-for-VF.patch | 37 ++++ 0082-net-hns3-rename-RAS-module.patch | 49 +++++ ...-hns3-fix-copper-port-initialization.patch | 73 +++++++ 0084-net-hns3-fix-reset-timeout.patch | 97 ++++++++++ 0085-net-hns3-remove-weak-symbols.patch | 98 ++++++++++ 0086-devtools-fix-symbol-listing.patch | 35 ++++ ...3-fix-memory-leakage-in-failure-path.patch | 54 ++++++ 0088-net-hns3-fix-variable-overflow.patch | 36 ++++ ...t-hns3-fix-extra-waiting-for-link-up.patch | 52 +++++ ...x-memory-leakage-for-indirect-action.patch | 179 ++++++++++++++++++ ...t-hns3-fix-incorrect-failed-rollback.patch | 43 +++++ 0092-net-hns3-fix-divide-by-zero.patch | 57 ++++++ ...release-some-resources-on-reset-case.patch | 56 ++++++ dpdk.spec | 35 +++- 15 files changed, 935 insertions(+), 1 deletion(-) create mode 100644 0080-net-hns3-fix-mbuf-freeing-in-simple-Tx-path.patch create mode 100644 0081-net-hns3-remove-PVID-info-dump-for-VF.patch create mode 100644 0082-net-hns3-rename-RAS-module.patch create mode 100644 0083-net-hns3-fix-copper-port-initialization.patch create mode 100644 0084-net-hns3-fix-reset-timeout.patch create mode 100644 0085-net-hns3-remove-weak-symbols.patch create mode 100644 0086-devtools-fix-symbol-listing.patch create mode 100644 0087-net-hns3-fix-memory-leakage-in-failure-path.patch create mode 100644 0088-net-hns3-fix-variable-overflow.patch create mode 100644 0089-net-hns3-fix-extra-waiting-for-link-up.patch create mode 100644 0090-net-hns3-fix-memory-leakage-for-indirect-action.patch create mode 100644 0091-net-hns3-fix-incorrect-failed-rollback.patch create mode 100644 0092-net-hns3-fix-divide-by-zero.patch create mode 100644 0093-net-hns3-fix-unrelease-some-resources-on-reset-case.patch diff --git a/0080-net-hns3-fix-mbuf-freeing-in-simple-Tx-path.patch b/0080-net-hns3-fix-mbuf-freeing-in-simple-Tx-path.patch new file mode 100644 index 0000000..3c75a96 --- /dev/null +++ b/0080-net-hns3-fix-mbuf-freeing-in-simple-Tx-path.patch @@ -0,0 +1,35 @@ +From 3a8ddbaac26d919b6ca0b249faeb0ef1f3af9fd0 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Mon, 30 Dec 2024 14:54:03 +0800 +Subject: [PATCH] net/hns3: fix mbuf freeing in simple Tx path + +[ upstream commit d78c76dbeffbd2994d77236c403281b34612e024 ] + +When RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE offload is not set, +use rte_pktmbuf_free_seg() to free the mbuf. + +Fixes: 7ef933908f04 ("net/hns3: add simple Tx path") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +Signed-off-by: Jie Hai +--- + drivers/net/hns3/hns3_rxtx.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 0203bde..53d086a 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -4090,7 +4090,7 @@ hns3_tx_free_buffer_simple(struct hns3_tx_queue *txq) + for (i = 0; i < txq->tx_rs_thresh; i++) + rte_prefetch0((tx_entry + i)->mbuf); + for (i = 0; i < txq->tx_rs_thresh; i++, tx_entry++) { +- rte_mempool_put(tx_entry->mbuf->pool, tx_entry->mbuf); ++ rte_pktmbuf_free_seg(tx_entry->mbuf); + tx_entry->mbuf = NULL; + } + +-- +2.25.1 + diff --git a/0081-net-hns3-remove-PVID-info-dump-for-VF.patch b/0081-net-hns3-remove-PVID-info-dump-for-VF.patch new file mode 100644 index 0000000..ad87e79 --- /dev/null +++ b/0081-net-hns3-remove-PVID-info-dump-for-VF.patch @@ -0,0 +1,37 @@ +From 64b1d911fadb88f84d666049027502bddb591890 Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Mon, 30 Dec 2024 14:54:04 +0800 +Subject: [PATCH] net/hns3: remove PVID info dump for VF + +[ upstream commit 3c805c1ebe02248bb0c2ba944046c2e3354b0c11 ] + +Since the PVID status obtained from kernel varies on different +platform, and the PVID of VF can be accessed by 'ip link show' +command, so remove it in case of misunderstanding. + +Fixes: 871e5a4f881b ("net/hns3: dump VLAN configuration info") +Cc: stable@dpdk.org + +Signed-off-by: Jie Hai +--- + drivers/net/hns3/hns3_dump.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c +index dcdfcf4..8411835 100644 +--- a/drivers/net/hns3/hns3_dump.c ++++ b/drivers/net/hns3/hns3_dump.c +@@ -693,6 +693,10 @@ hns3_get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw) + static void + hns3_get_port_pvid_info(FILE *file, struct hns3_hw *hw) + { ++ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); ++ if (hns->is_vf) ++ return; ++ + fprintf(file, " - pvid status: %s\n", + hw->port_base_vlan_cfg.state ? "On" : "Off"); + } +-- +2.25.1 + diff --git a/0082-net-hns3-rename-RAS-module.patch b/0082-net-hns3-rename-RAS-module.patch new file mode 100644 index 0000000..4fb7814 --- /dev/null +++ b/0082-net-hns3-rename-RAS-module.patch @@ -0,0 +1,49 @@ +From dfdca582ffab71e9b4258ccedd0725d99e6688eb Mon Sep 17 00:00:00 2001 +From: Jie Hai +Date: Mon, 30 Dec 2024 14:54:05 +0800 +Subject: [PATCH] net/hns3: rename RAS module + +[ upstream commit 501a40ae8370dcbfe086ef080a60c86a8d428ef6 ] + +Rename ROH_MAC module as HIMAC to avoid misunderstandings. + +Fixes: 1c1eb759e9d7 ("net/hns3: support RAS process in Kunpeng 930") +Cc: stable@dpdk.org + +Signed-off-by: Jie Hai +--- + drivers/net/hns3/hns3_intr.c | 4 ++-- + drivers/net/hns3/hns3_intr.h | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c +index d37c7eb..260cfce 100644 +--- a/drivers/net/hns3/hns3_intr.c ++++ b/drivers/net/hns3/hns3_intr.c +@@ -1432,8 +1432,8 @@ static const struct hns3_hw_mod_name hns3_hw_module_name[] = { + .module_name = MODULE_MASTER, + .msg = "MODULE_MASTER" + }, { +- .module_name = MODULE_ROH_MAC, +- .msg = "MODULE_ROH_MAC" ++ .module_name = MODULE_HIMAC, ++ .msg = "MODULE_HIMAC" + } + }; + +diff --git a/drivers/net/hns3/hns3_intr.h b/drivers/net/hns3/hns3_intr.h +index aca1c07..fcfb900 100644 +--- a/drivers/net/hns3/hns3_intr.h ++++ b/drivers/net/hns3/hns3_intr.h +@@ -104,7 +104,7 @@ enum hns3_mod_name_list { + MODULE_RCB_TX, + MODULE_TXDMA, + MODULE_MASTER, +- MODULE_ROH_MAC, ++ MODULE_HIMAC, + }; + + enum hns3_err_type_list { +-- +2.25.1 + diff --git a/0083-net-hns3-fix-copper-port-initialization.patch b/0083-net-hns3-fix-copper-port-initialization.patch new file mode 100644 index 0000000..519ef59 --- /dev/null +++ b/0083-net-hns3-fix-copper-port-initialization.patch @@ -0,0 +1,73 @@ +From a0350f7846be8e77c745659714c569eb2394a9d9 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Mon, 10 Feb 2025 11:01:12 +0800 +Subject: [PATCH] net/hns3: fix copper port initialization + +[ upstream commit 763546c33ea9600e76790c470d2921808068eb3d ] + +The initialization of copper port contains the following two steps. +1. Configure firmware takeover the PHY. The firmware will start an + asynchronous task to initialize the PHY chip. +2. Configure work speed and duplex. +In earlier versions of the firmware, when the asynchronous task is not +finished, the firmware will return -ENOTBLK in the second step. And this +will lead to driver failed to initialize. Here add retry for this case. + +Fixes: 2e4859f3b362 ("net/hns3: support PF device with copper PHYs") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +--- + drivers/net/hns3/hns3_ethdev.c | 29 ++++++++++++++++++++++++++++- + 1 file changed, 28 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 12bb834..df9ca25 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -4852,7 +4852,7 @@ hns3_get_link_duplex(uint32_t link_speeds) + } + + static int +-hns3_set_copper_port_link_speed(struct hns3_hw *hw, ++hns3_copper_port_link_speed_cfg(struct hns3_hw *hw, + struct hns3_set_link_speed_cfg *cfg) + { + struct hns3_cmd_desc desc[HNS3_PHY_PARAM_CFG_BD_NUM]; +@@ -4886,6 +4886,33 @@ hns3_set_copper_port_link_speed(struct hns3_hw *hw, + return hns3_cmd_send(hw, desc, HNS3_PHY_PARAM_CFG_BD_NUM); + } + ++static int ++hns3_set_copper_port_link_speed(struct hns3_hw *hw, ++ struct hns3_set_link_speed_cfg *cfg) ++{ ++#define HNS3_PHY_PARAM_CFG_RETRY_TIMES 10 ++#define HNS3_PHY_PARAM_CFG_RETRY_DELAY_MS 100 ++ uint32_t retry_cnt = 0; ++ int ret; ++ ++ /* ++ * The initialization of copper port contains the following two steps. ++ * 1. Configure firmware takeover the PHY. The firmware will start an ++ * asynchronous task to initialize the PHY chip. ++ * 2. Configure work speed and duplex. ++ * In earlier versions of the firmware, when the asynchronous task is not ++ * finished, the firmware will return -ENOTBLK in the second step. And this ++ * will lead to driver failed to initialize. Here add retry for this case. ++ */ ++ ret = hns3_copper_port_link_speed_cfg(hw, cfg); ++ while (ret == -ENOTBLK && retry_cnt++ < HNS3_PHY_PARAM_CFG_RETRY_TIMES) { ++ rte_delay_ms(HNS3_PHY_PARAM_CFG_RETRY_DELAY_MS); ++ ret = hns3_copper_port_link_speed_cfg(hw, cfg); ++ } ++ ++ return ret; ++} ++ + static int + hns3_set_autoneg(struct hns3_hw *hw, bool enable) + { +-- +2.25.1 + diff --git a/0084-net-hns3-fix-reset-timeout.patch b/0084-net-hns3-fix-reset-timeout.patch new file mode 100644 index 0000000..30d5c09 --- /dev/null +++ b/0084-net-hns3-fix-reset-timeout.patch @@ -0,0 +1,97 @@ +From 1bdb3d84bb0cd4be7cacd456becb3ff2bcda63be Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Mon, 10 Feb 2025 11:01:13 +0800 +Subject: [PATCH] net/hns3: fix reset timeout + +[ upstream commit 9f7c28c5e98062576dfbf555cd5ede7e33d6624b ] + +There is low probability that the driver reset timeout, the root cause is +that the firmware processing take a litter long than normal when process +reset command. This patch fix it by changing the timeout of the reset +command to 100 ms. + +Fixes: 737f30e1c3ab ("net/hns3: support command interface with firmware") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +--- + drivers/net/hns3/hns3_cmd.c | 18 ++++++++++++------ + drivers/net/hns3/hns3_cmd.h | 4 ++-- + 2 files changed, 14 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c +index 2c16644..62da6dd 100644 +--- a/drivers/net/hns3/hns3_cmd.c ++++ b/drivers/net/hns3/hns3_cmd.c +@@ -304,8 +304,17 @@ hns3_cmd_get_hardware_reply(struct hns3_hw *hw, + return hns3_cmd_convert_err_code(desc_ret); + } + +-static int hns3_cmd_poll_reply(struct hns3_hw *hw) ++static uint32_t hns3_get_cmd_tx_timeout(uint16_t opcode) + { ++ if (opcode == HNS3_OPC_CFG_RST_TRIGGER) ++ return HNS3_COMQ_CFG_RST_TIMEOUT; ++ ++ return HNS3_CMDQ_TX_TIMEOUT_DEFAULT; ++} ++ ++static int hns3_cmd_poll_reply(struct hns3_hw *hw, uint16_t opcode) ++{ ++ uint32_t cmdq_tx_timeout = hns3_get_cmd_tx_timeout(opcode); + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + uint32_t timeout = 0; + +@@ -326,7 +335,7 @@ static int hns3_cmd_poll_reply(struct hns3_hw *hw) + + rte_delay_us(1); + timeout++; +- } while (timeout < hw->cmq.tx_timeout); ++ } while (timeout < cmdq_tx_timeout); + hns3_err(hw, "Wait for reply timeout"); + return -ETIME; + } +@@ -400,7 +409,7 @@ hns3_cmd_send(struct hns3_hw *hw, struct hns3_cmd_desc *desc, int num) + * if multi descriptors to be sent, use the first one to check. + */ + if (HNS3_CMD_SEND_SYNC(rte_le_to_cpu_16(desc->flag))) { +- retval = hns3_cmd_poll_reply(hw); ++ retval = hns3_cmd_poll_reply(hw, desc->opcode); + if (!retval) + retval = hns3_cmd_get_hardware_reply(hw, desc, num, + ntc); +@@ -611,9 +620,6 @@ hns3_cmd_init_queue(struct hns3_hw *hw) + hw->cmq.csq.desc_num = HNS3_NIC_CMQ_DESC_NUM; + hw->cmq.crq.desc_num = HNS3_NIC_CMQ_DESC_NUM; + +- /* Setup Tx write back timeout */ +- hw->cmq.tx_timeout = HNS3_CMDQ_TX_TIMEOUT; +- + /* Setup queue rings */ + ret = hns3_alloc_cmd_queue(hw, HNS3_TYPE_CSQ); + if (ret) { +diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h +index 79a8c1e..4d707c1 100644 +--- a/drivers/net/hns3/hns3_cmd.h ++++ b/drivers/net/hns3/hns3_cmd.h +@@ -10,7 +10,8 @@ + #include + #include + +-#define HNS3_CMDQ_TX_TIMEOUT 30000 ++#define HNS3_CMDQ_TX_TIMEOUT_DEFAULT 30000 ++#define HNS3_COMQ_CFG_RST_TIMEOUT 100000 + #define HNS3_CMDQ_CLEAR_WAIT_TIME 200 + #define HNS3_CMDQ_RX_INVLD_B 0 + #define HNS3_CMDQ_RX_OUTVLD_B 1 +@@ -62,7 +63,6 @@ enum hns3_cmd_return_status { + struct hns3_cmq { + struct hns3_cmq_ring csq; + struct hns3_cmq_ring crq; +- uint16_t tx_timeout; + enum hns3_cmd_return_status last_status; + }; + +-- +2.25.1 + diff --git a/0085-net-hns3-remove-weak-symbols.patch b/0085-net-hns3-remove-weak-symbols.patch new file mode 100644 index 0000000..15f437f --- /dev/null +++ b/0085-net-hns3-remove-weak-symbols.patch @@ -0,0 +1,98 @@ +From af1ca12b072d40f7194d6253b740f8beffc5e309 Mon Sep 17 00:00:00 2001 +From: David Marchand +Date: Thu, 6 Feb 2025 22:55:01 +0100 +Subject: [PATCH] net/hns3: remove weak symbols + +[ upstream commit 2d6abf506dfe5cccc0db3e607bc76da30c54236f ] + +Rather than use weak symbols, expose stubs symbols when needed. + +Signed-off-by: David Marchand +Acked-by: Chengwen Feng +--- + drivers/net/hns3/hns3_rxtx.c | 22 +++++++++++++++------- + 1 file changed, 15 insertions(+), 7 deletions(-) + +diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c +index 53d086a..ea01003 100644 +--- a/drivers/net/hns3/hns3_rxtx.c ++++ b/drivers/net/hns3/hns3_rxtx.c +@@ -2784,32 +2784,36 @@ hns3_recv_scattered_pkts(void *rx_queue, + return nb_rx; + } + +-void __rte_weak ++#ifndef RTE_ARCH_ARM64 ++void + hns3_rxq_vec_setup(__rte_unused struct hns3_rx_queue *rxq) + { + } + +-int __rte_weak ++int + hns3_rx_check_vec_support(__rte_unused struct rte_eth_dev *dev) + { + return -ENOTSUP; + } + +-uint16_t __rte_weak ++uint16_t + hns3_recv_pkts_vec(__rte_unused void *rx_queue, + __rte_unused struct rte_mbuf **rx_pkts, + __rte_unused uint16_t nb_pkts) + { + return 0; + } ++#endif /* RTE_ARCH_ARM64 */ + +-uint16_t __rte_weak ++#ifndef RTE_HAS_SVE_ACLE ++uint16_t + hns3_recv_pkts_vec_sve(__rte_unused void *rx_queue, + __rte_unused struct rte_mbuf **rx_pkts, + __rte_unused uint16_t nb_pkts) + { + return 0; + } ++#endif /* RTE_HAS_SVE_ACLE */ + + int + hns3_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id, +@@ -4340,27 +4344,31 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) + return nb_tx; + } + +-int __rte_weak ++#ifndef RTE_ARCH_ARM64 ++int + hns3_tx_check_vec_support(__rte_unused struct rte_eth_dev *dev) + { + return -ENOTSUP; + } + +-uint16_t __rte_weak ++uint16_t + hns3_xmit_pkts_vec(__rte_unused void *tx_queue, + __rte_unused struct rte_mbuf **tx_pkts, + __rte_unused uint16_t nb_pkts) + { + return 0; + } ++#endif /* RTE_ARCH_ARM64 */ + +-uint16_t __rte_weak ++#ifndef RTE_HAS_SVE_ACLE ++uint16_t + hns3_xmit_pkts_vec_sve(void __rte_unused * tx_queue, + struct rte_mbuf __rte_unused **tx_pkts, + uint16_t __rte_unused nb_pkts) + { + return 0; + } ++#endif /* RTE_HAS_SVE_ACLE */ + + int + hns3_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id, +-- +2.25.1 + diff --git a/0086-devtools-fix-symbol-listing.patch b/0086-devtools-fix-symbol-listing.patch new file mode 100644 index 0000000..a48b671 --- /dev/null +++ b/0086-devtools-fix-symbol-listing.patch @@ -0,0 +1,35 @@ +From bd262f591ade398e9d5a1ee3167c5912ad135742 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Wed, 17 Apr 2024 17:32:36 +0800 +Subject: [PATCH] devtools: fix symbol listing + +[ upstream commit 33af003eb13fe0c661f638797bacc50b0cc6f412 ] + +The version variable is not initialized. Therefore, if the -V option +is not specified, the value of $version is obtained from the context, +which may cause the version map parsing failure. + +Fixes: 6edec7f202ac ("devtools: list symbols by version") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +Reviewed-by: David Marchand +--- + buildtools/map-list-symbol.sh | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/buildtools/map-list-symbol.sh b/buildtools/map-list-symbol.sh +index a834399..878c588 100755 +--- a/buildtools/map-list-symbol.sh ++++ b/buildtools/map-list-symbol.sh +@@ -5,6 +5,7 @@ + section=all + symbol=all + quiet= ++version= + + while getopts 'S:s:qV:' name; do + case $name in +-- +2.25.1 + diff --git a/0087-net-hns3-fix-memory-leakage-in-failure-path.patch b/0087-net-hns3-fix-memory-leakage-in-failure-path.patch new file mode 100644 index 0000000..8c71847 --- /dev/null +++ b/0087-net-hns3-fix-memory-leakage-in-failure-path.patch @@ -0,0 +1,54 @@ +From e4e26428428e54c5d4a8d56e960646211b94bda6 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Tue, 8 Apr 2025 16:30:55 +0800 +Subject: [PATCH] net/hns3: fix memory leakage in failure path + +[ upstream commit 11110038e09dac9a2db32032852020d40e5d125d ] + +When the hns3_dfx_reg_fetch_data() function returns from processing +failure, cmd_descs is not freed, which leads to leakage. +This patch fit it. + +By the way, this patch uses calloc to apply for heap memory instead +of hugepage memory. + +Fixes: ef1fbd355451 ("net/hns3: add more registers to dump") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +--- + drivers/net/hns3/hns3_regs.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c +index 37ac957..796e1b3 100644 +--- a/drivers/net/hns3/hns3_regs.c ++++ b/drivers/net/hns3/hns3_regs.c +@@ -1270,7 +1270,7 @@ hns3_get_dfx_regs(struct hns3_hw *hw, struct rte_dev_reg_info *regs, uint32_t mo + for (i = 0; i < opcode_num; i++) + max_bd_num = RTE_MAX(bd_num_list[i], max_bd_num); + +- cmd_descs = rte_zmalloc(NULL, sizeof(*cmd_descs) * max_bd_num, 0); ++ cmd_descs = calloc(max_bd_num, sizeof(*cmd_descs)); + if (cmd_descs == NULL) + return -ENOMEM; + +@@ -1290,13 +1290,14 @@ hns3_get_dfx_regs(struct hns3_hw *hw, struct rte_dev_reg_info *regs, uint32_t mo + if (regs_num != hns3_reg_lists[i].entry_num) { + hns3_err(hw, "Query register number differ from the list for module %s!", + hns3_get_name_by_module(i)); ++ free(cmd_descs); + return -EINVAL; + } + hns3_fill_dfx_regs_name(hw, regs, hns3_reg_lists[i].reg_list, regs_num); + regs->length += regs_num; + data += regs_num; + } +- rte_free(cmd_descs); ++ free(cmd_descs); + + return ret; + } +-- +2.25.1 + diff --git a/0088-net-hns3-fix-variable-overflow.patch b/0088-net-hns3-fix-variable-overflow.patch new file mode 100644 index 0000000..25d4f36 --- /dev/null +++ b/0088-net-hns3-fix-variable-overflow.patch @@ -0,0 +1,36 @@ +From ddd8a70074f58d1861d979ac1d16206ad014e2f3 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Tue, 8 Apr 2025 16:30:54 +0800 +Subject: [PATCH] net/hns3: fix variable overflow + +[ upstream commit 52d4c3c4872be23c173ea14d5d7a5f71ef217bdc ] + +The number of interrupt vector may exceed the range of uint8_t. +So hns3_unmap_rx_interrupt() should use uint16_t for 'vec' variable. + +Fixes: 02a7b55657b2 ("net/hns3: support Rx interrupt") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +--- + drivers/net/hns3/hns3_common.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c +index 25a4521..dc70bf3 100644 +--- a/drivers/net/hns3/hns3_common.c ++++ b/drivers/net/hns3/hns3_common.c +@@ -882,8 +882,8 @@ hns3_unmap_rx_interrupt(struct rte_eth_dev *dev) + struct rte_intr_handle *intr_handle = pci_dev->intr_handle; + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_hw *hw = &hns->hw; +- uint8_t base = RTE_INTR_VEC_ZERO_OFFSET; +- uint8_t vec = RTE_INTR_VEC_ZERO_OFFSET; ++ uint16_t base = RTE_INTR_VEC_ZERO_OFFSET; ++ uint16_t vec = RTE_INTR_VEC_ZERO_OFFSET; + uint16_t q_id; + + if (dev->data->dev_conf.intr_conf.rxq == 0) +-- +2.25.1 + diff --git a/0089-net-hns3-fix-extra-waiting-for-link-up.patch b/0089-net-hns3-fix-extra-waiting-for-link-up.patch new file mode 100644 index 0000000..4690dbd --- /dev/null +++ b/0089-net-hns3-fix-extra-waiting-for-link-up.patch @@ -0,0 +1,52 @@ +From 67fe42273d3a125b9c13ba7db08f33cafacd2f62 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Tue, 8 Apr 2025 16:30:56 +0800 +Subject: [PATCH] net/hns3: fix extra waiting for link up + +[ upstream commit 8dddddeaf26568801f467e73d39094c97860b73f ] + +If the link auto-negotiation of the NIC is disabled, +or the flow control auto-negotiation is not supported, +it's unnecessary to wait for link establishment. + +Fixes: 1f411e31a826 ("net/hns3: support flow control autoneg for copper port") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +--- + drivers/net/hns3/hns3_ethdev.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index df9ca25..70ba935 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -5308,12 +5308,6 @@ hns3_get_current_fc_mode(struct rte_eth_dev *dev) + struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct hns3_mac *mac = &hw->mac; + +- /* +- * When the flow control mode is obtained, the device may not complete +- * auto-negotiation. It is necessary to wait for link establishment. +- */ +- (void)hns3_dev_link_update(dev, 1); +- + /* + * If the link auto-negotiation of the nic is disabled, or the flow + * control auto-negotiation is not supported, the forced flow control +@@ -5322,6 +5316,12 @@ hns3_get_current_fc_mode(struct rte_eth_dev *dev) + if (mac->link_autoneg == 0 || !pf->support_fc_autoneg) + return hw->requested_fc_mode; + ++ /* ++ * When the flow control mode is obtained, the device may not complete ++ * auto-negotiation. It is necessary to wait for link establishment. ++ */ ++ (void)hns3_dev_link_update(dev, 1); ++ + return hns3_get_autoneg_fc_mode(hw); + } + +-- +2.25.1 + diff --git a/0090-net-hns3-fix-memory-leakage-for-indirect-action.patch b/0090-net-hns3-fix-memory-leakage-for-indirect-action.patch new file mode 100644 index 0000000..5cc3fe4 --- /dev/null +++ b/0090-net-hns3-fix-memory-leakage-for-indirect-action.patch @@ -0,0 +1,179 @@ +From 597169acc40ec28b094994ee4a0ded430fc9f367 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Tue, 8 Apr 2025 16:30:57 +0800 +Subject: [PATCH] net/hns3: fix memory leakage for indirect action + +[ upstream commit 89bf96bd89865bf146e2715f64b61948696b6e2b ] + +Currently, when the application creates an indirect action, +the hns3 driver allocates a memory for the structure +rte_flow_action_handle and returns this structure pointer to +application. When the application invokes the destroy function +to destroy the indirect action, the driver releases the memory. + +However, when the application destroys all flows by using the +flush function before destroying the indirect action, the memory +is not released. This patch fix it by using uint64_t instead of +rte_flow_action_handle* to store indirect action avoids memory +leakage. + +Fixes: fdfcb94d8fb3 ("net/hns3: support indirect counter flow action") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +--- + drivers/net/hns3/hns3_flow.c | 41 ++++++++++++++++-------------------- + drivers/net/hns3/hns3_flow.h | 9 ++++++-- + 2 files changed, 25 insertions(+), 25 deletions(-) + +diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c +index 9a0b5d2..73a78ed 100644 +--- a/drivers/net/hns3/hns3_flow.c ++++ b/drivers/net/hns3/hns3_flow.c +@@ -473,19 +473,20 @@ hns3_handle_action_indirect(struct rte_eth_dev *dev, + struct hns3_fdir_rule *rule, + struct rte_flow_error *error) + { +- const struct rte_flow_action_handle *indir = action->conf; ++ struct rte_flow_action_handle indir; + +- if (indir->indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) ++ indir.val64 = (uint64_t)action->conf; ++ if (indir.indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + action, "Invalid indirect type"); + +- if (hns3_counter_lookup(dev, indir->counter_id) == NULL) ++ if (hns3_counter_lookup(dev, indir.counter_id) == NULL) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + action, "Counter id not exist"); + +- rule->act_cnt.id = indir->counter_id; ++ rule->act_cnt.id = indir.counter_id; + rule->flags |= (HNS3_RULE_FLAG_COUNTER | HNS3_RULE_FLAG_COUNTER_INDIR); + + return 0; +@@ -2726,20 +2727,12 @@ hns3_flow_action_create(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); + const struct rte_flow_action_count *act_count; +- struct rte_flow_action_handle *handle = NULL; ++ struct rte_flow_action_handle handle; + struct hns3_flow_counter *counter; + + if (hns3_check_indir_action(conf, action, error)) + return NULL; + +- handle = rte_zmalloc("hns3 action handle", +- sizeof(struct rte_flow_action_handle), 0); +- if (handle == NULL) { +- rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, +- NULL, "Failed to allocate action memory"); +- return NULL; +- } +- + pthread_mutex_lock(&hw->flows_lock); + + act_count = (const struct rte_flow_action_count *)action->conf; +@@ -2762,15 +2755,14 @@ hns3_flow_action_create(struct rte_eth_dev *dev, + } + + counter->indirect = true; +- handle->indirect_type = HNS3_INDIRECT_ACTION_TYPE_COUNT; +- handle->counter_id = counter->id; ++ handle.indirect_type = HNS3_INDIRECT_ACTION_TYPE_COUNT; ++ handle.counter_id = counter->id; + + pthread_mutex_unlock(&hw->flows_lock); +- return handle; ++ return (struct rte_flow_action_handle *)handle.val64; + + err_exit: + pthread_mutex_unlock(&hw->flows_lock); +- rte_free(handle); + return NULL; + } + +@@ -2780,18 +2772,20 @@ hns3_flow_action_destroy(struct rte_eth_dev *dev, + struct rte_flow_error *error) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct rte_flow_action_handle indir; + struct hns3_flow_counter *counter; + + pthread_mutex_lock(&hw->flows_lock); + +- if (handle->indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) { ++ indir.val64 = (uint64_t)handle; ++ if (indir.indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) { + pthread_mutex_unlock(&hw->flows_lock); + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, + handle, "Invalid indirect type"); + } + +- counter = hns3_counter_lookup(dev, handle->counter_id); ++ counter = hns3_counter_lookup(dev, indir.counter_id); + if (counter == NULL) { + pthread_mutex_unlock(&hw->flows_lock); + return rte_flow_error_set(error, EINVAL, +@@ -2806,8 +2800,7 @@ hns3_flow_action_destroy(struct rte_eth_dev *dev, + handle, "Counter id in use"); + } + +- (void)hns3_counter_release(dev, handle->counter_id); +- rte_free(handle); ++ (void)hns3_counter_release(dev, indir.counter_id); + + pthread_mutex_unlock(&hw->flows_lock); + return 0; +@@ -2820,12 +2813,14 @@ hns3_flow_action_query(struct rte_eth_dev *dev, + struct rte_flow_error *error) + { + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); ++ struct rte_flow_action_handle indir; + struct rte_flow flow; + int ret; + + pthread_mutex_lock(&hw->flows_lock); + +- if (handle->indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) { ++ indir.val64 = (uint64_t)handle; ++ if (indir.indirect_type != HNS3_INDIRECT_ACTION_TYPE_COUNT) { + pthread_mutex_unlock(&hw->flows_lock); + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, +@@ -2833,7 +2828,7 @@ hns3_flow_action_query(struct rte_eth_dev *dev, + } + + memset(&flow, 0, sizeof(flow)); +- flow.counter_id = handle->counter_id; ++ flow.counter_id = indir.counter_id; + ret = hns3_counter_query(dev, &flow, + (struct rte_flow_query_count *)data, error); + pthread_mutex_unlock(&hw->flows_lock); +diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h +index 1b49673..6128903 100644 +--- a/drivers/net/hns3/hns3_flow.h ++++ b/drivers/net/hns3/hns3_flow.h +@@ -50,8 +50,13 @@ enum { + }; + + struct rte_flow_action_handle { +- int indirect_type; +- uint32_t counter_id; ++ union { ++ uint64_t val64; ++ struct { ++ int indirect_type; ++ uint32_t counter_id; ++ }; ++ }; + }; + + union hns3_filter_conf { +-- +2.25.1 + diff --git a/0091-net-hns3-fix-incorrect-failed-rollback.patch b/0091-net-hns3-fix-incorrect-failed-rollback.patch new file mode 100644 index 0000000..c01406d --- /dev/null +++ b/0091-net-hns3-fix-incorrect-failed-rollback.patch @@ -0,0 +1,43 @@ +From 32ca5eeedfcdec191a0fb5706307a7deea98d725 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Tue, 8 Apr 2025 16:30:58 +0800 +Subject: [PATCH] net/hns3: fix incorrect failed rollback + +[ upstream commit e00902c8f2db482d744b0f62f479cfeb7d060d38 ] + +When the port is started, if the Tx queue fails to be started, +the map interrupt should be rolled back. + +Fixes: fdfde7a4a0f8 ("net/hns3: fix mbuf leakage") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +--- + drivers/net/hns3/hns3_ethdev.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 70ba935..1baa429 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -5122,7 +5122,7 @@ hns3_dev_start(struct rte_eth_dev *dev) + */ + ret = hns3_start_all_txqs(dev); + if (ret) +- goto map_rx_inter_err; ++ goto start_all_txqs_fail; + + ret = hns3_start_all_rxqs(dev); + if (ret) +@@ -5155,6 +5155,8 @@ hns3_dev_start(struct rte_eth_dev *dev) + + start_all_rxqs_fail: + hns3_stop_all_txqs(dev); ++start_all_txqs_fail: ++ hns3_unmap_rx_interrupt(dev); + map_rx_inter_err: + (void)hns3_do_stop(hns); + do_start_fail: +-- +2.25.1 + diff --git a/0092-net-hns3-fix-divide-by-zero.patch b/0092-net-hns3-fix-divide-by-zero.patch new file mode 100644 index 0000000..a5ad0e3 --- /dev/null +++ b/0092-net-hns3-fix-divide-by-zero.patch @@ -0,0 +1,57 @@ +From da024a1be17b7df8e6707f98be45d44442507731 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Tue, 8 Apr 2025 16:30:59 +0800 +Subject: [PATCH] net/hns3: fix divide by zero + +[ upstream commit 51d0d00eb026ee3ff75548bef2eda137f4eaf494 ] + +Driver may encounter divide-by-zero if the total_tqps_num +and rss_size_max in hw structure from firmware are zero. +So add some verification to them. + +Fixes: d51867db65c1 ("net/hns3: add initialization") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +--- + drivers/net/hns3/hns3_ethdev.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 1baa429..032d5b6 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2544,6 +2544,10 @@ hns3_query_pf_resource(struct hns3_hw *hw) + req = (struct hns3_pf_res_cmd *)desc.data; + hw->total_tqps_num = rte_le_to_cpu_16(req->tqp_num) + + rte_le_to_cpu_16(req->ext_tqp_num); ++ if (hw->total_tqps_num == 0) { ++ PMD_INIT_LOG(ERR, "the total tqp number of the port is 0."); ++ return -EINVAL; ++ } + ret = hns3_get_pf_max_tqp_num(hw); + if (ret) + return ret; +@@ -2795,6 +2799,7 @@ hns3_check_media_type(struct hns3_hw *hw, uint8_t media_type) + static int + hns3_get_board_configuration(struct hns3_hw *hw) + { ++#define HNS3_RSS_SIZE_MAX_DEFAULT 64 + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + struct hns3_pf *pf = &hns->pf; + struct hns3_cfg cfg; +@@ -2813,6 +2818,11 @@ hns3_get_board_configuration(struct hns3_hw *hw) + + hw->mac.media_type = cfg.media_type; + hw->rss_size_max = cfg.rss_size_max; ++ if (hw->rss_size_max == 0) { ++ PMD_INIT_LOG(WARNING, "rss_size_max is 0, already adjust to %u.", ++ HNS3_RSS_SIZE_MAX_DEFAULT); ++ hw->rss_size_max = HNS3_RSS_SIZE_MAX_DEFAULT; ++ } + memcpy(hw->mac.mac_addr, cfg.mac_addr, RTE_ETHER_ADDR_LEN); + hw->mac.phy_addr = cfg.phy_addr; + hw->dcb_info.num_pg = 1; +-- +2.25.1 + diff --git a/0093-net-hns3-fix-unrelease-some-resources-on-reset-case.patch b/0093-net-hns3-fix-unrelease-some-resources-on-reset-case.patch new file mode 100644 index 0000000..b0942de --- /dev/null +++ b/0093-net-hns3-fix-unrelease-some-resources-on-reset-case.patch @@ -0,0 +1,56 @@ +From d64f33e9b9cc9d445927015da4055787d75d7ff4 Mon Sep 17 00:00:00 2001 +From: Dengdui Huang +Date: Tue, 8 Apr 2025 16:31:00 +0800 +Subject: [PATCH] net/hns3: fix unrelease some resources on reset case + +[ upstream commit 56386ece674eea9e5a3cdbe130eeb278764a0a6c ] + +Some resources, like, unmapping Rx interrupt, doesn't perform +when execute dev_stop on reset. This will lead to other issues. + +Fixes: 2790c6464725 ("net/hns3: support device reset") +Cc: stable@dpdk.org + +Signed-off-by: Dengdui Huang +--- + drivers/net/hns3/hns3_ethdev.c | 18 ++++++++++-------- + 1 file changed, 10 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 032d5b6..d324a37 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -5219,20 +5219,22 @@ hns3_dev_stop(struct rte_eth_dev *dev) + struct hns3_hw *hw = &hns->hw; + + PMD_INIT_FUNC_TRACE(); ++ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { ++ hns3_warn(hw, "device is resetting, stop operation is not allowed."); ++ return -EBUSY; ++ } + dev->data->dev_started = 0; + + hw->adapter_state = HNS3_NIC_STOPPING; + hns3_stop_rxtx_datapath(dev); + + rte_spinlock_lock(&hw->lock); +- if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { +- hns3_tm_dev_stop_proc(hw); +- hns3_config_mac_tnl_int(hw, false); +- hns3_stop_tqps(hw); +- hns3_do_stop(hns); +- hns3_unmap_rx_interrupt(dev); +- hw->adapter_state = HNS3_NIC_CONFIGURED; +- } ++ hns3_tm_dev_stop_proc(hw); ++ hns3_config_mac_tnl_int(hw, false); ++ hns3_stop_tqps(hw); ++ hns3_do_stop(hns); ++ hns3_unmap_rx_interrupt(dev); ++ hw->adapter_state = HNS3_NIC_CONFIGURED; + hns3_rx_scattered_reset(dev); + rte_eal_alarm_cancel(hns3_service_handler, dev); + hns3_stop_report_lse(dev); +-- +2.25.1 + diff --git a/dpdk.spec b/dpdk.spec index 9c837d3..216c33a 100644 --- a/dpdk.spec +++ b/dpdk.spec @@ -11,7 +11,7 @@ Name: dpdk Version: 23.11 -Release: 29 +Release: 30 URL: http://dpdk.org Source: https://fast.dpdk.org/rel/dpdk-%{version}.tar.xz @@ -110,6 +110,20 @@ Patch1078: 0078-dpdk-add-sw_64-support.patch Patch6079: 0079-net-xsc-add-xsc-PMD.patch +Patch6080: 0080-net-hns3-fix-mbuf-freeing-in-simple-Tx-path.patch +Patch6081: 0081-net-hns3-remove-PVID-info-dump-for-VF.patch +Patch6082: 0082-net-hns3-rename-RAS-module.patch +Patch6083: 0083-net-hns3-fix-copper-port-initialization.patch +Patch6084: 0084-net-hns3-fix-reset-timeout.patch +Patch6085: 0085-net-hns3-remove-weak-symbols.patch +Patch6086: 0086-devtools-fix-symbol-listing.patch +Patch6087: 0087-net-hns3-fix-memory-leakage-in-failure-path.patch +Patch6088: 0088-net-hns3-fix-variable-overflow.patch +Patch6089: 0089-net-hns3-fix-extra-waiting-for-link-up.patch +Patch6090: 0090-net-hns3-fix-memory-leakage-for-indirect-action.patch +Patch6091: 0091-net-hns3-fix-incorrect-failed-rollback.patch +Patch6092: 0092-net-hns3-fix-divide-by-zero.patch +Patch6093: 0093-net-hns3-fix-unrelease-some-resources-on-reset-case.patch BuildRequires: meson BuildRequires: python3-pyelftools @@ -314,6 +328,25 @@ fi /usr/sbin/depmod %changelog +* Mon Apr 28 2025 huangdengdui - 23.11-30 + Sync some patchs from upstreaming for hns3 pmd and modifications + are as follow: + - net/hns3: fix unrelease some resources on reset case + - net/hns3: fix divide by zero + - net/hns3: fix incorrect failed rollback + - net/hns3: fix memory leakage for indirect action + - net/hns3: fix extra waiting for link up + - net/hns3: fix variable overflow + - net/hns3: fix memory leakage in failure path + - net/hns3: remove weak symbols + - net/hns3: fix reset timeout + - net/hns3: fix copper port initialization + - net/hns3: rename RAS module + - net/hns3: remove PVID info dump for VF + - net/hns3: fix mbuf freeing in simple Tx path + In addition, sync a bugfix for devtools: + - devtools: fix symbol listing + * Fri Mar 14 2025 qianrong - 23.11-29 - add xsc PMD -- Gitee