dpdk/0083-net-hns3-fix-copper-port-initialization.patch
Dengdui Huang 37c95ab89b 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 <huangdengdui@huawei.com>
(cherry picked from commit 4f2a5e819346fb5bf12b9de68352782319e4a2a6)
2025-04-28 15:33:14 +08:00

74 lines
2.6 KiB
Diff

From a0350f7846be8e77c745659714c569eb2394a9d9 Mon Sep 17 00:00:00 2001
From: Dengdui Huang <huangdengdui@huawei.com>
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 <huangdengdui@huawei.com>
---
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