DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] net/hns3: bugfix on hns3
@ 2025-02-10  3:01 Jie Hai
  2025-02-10  3:01 ` [PATCH 1/2] net/hns3: fix possible copper port initialize fail Jie Hai
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jie Hai @ 2025-02-10  3:01 UTC (permalink / raw)
  To: dev, thomas, ferruh.yigit; +Cc: lihuisong, fengchengwen, haijie1, huangdengdui

Fix some possible failure on hns3 driver.

Dengdui Huang (2):
  net/hns3: fix possible copper port initialize fail
  net/hns3: fix possible reset timeout

 drivers/net/hns3/hns3_cmd.c    | 18 ++++++++++++------
 drivers/net/hns3/hns3_cmd.h    |  4 ++--
 drivers/net/hns3/hns3_ethdev.c | 29 ++++++++++++++++++++++++++++-
 3 files changed, 42 insertions(+), 9 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] net/hns3: fix possible copper port initialize fail
  2025-02-10  3:01 [PATCH 0/2] net/hns3: bugfix on hns3 Jie Hai
@ 2025-02-10  3:01 ` Jie Hai
  2025-02-10  3:01 ` [PATCH 2/2] net/hns3: fix possible reset timeout Jie Hai
  2025-02-10 20:06 ` [PATCH 0/2] net/hns3: bugfix on hns3 Stephen Hemminger
  2 siblings, 0 replies; 4+ messages in thread
From: Jie Hai @ 2025-02-10  3:01 UTC (permalink / raw)
  To: dev, thomas, ferruh.yigit, Lijun Ou, Huisong Li
  Cc: fengchengwen, haijie1, huangdengdui

From: Dengdui Huang <huangdengdui@huawei.com>

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 72d1c30a7b2e..9f7119b734bc 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.33.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] net/hns3: fix possible reset timeout
  2025-02-10  3:01 [PATCH 0/2] net/hns3: bugfix on hns3 Jie Hai
  2025-02-10  3:01 ` [PATCH 1/2] net/hns3: fix possible copper port initialize fail Jie Hai
@ 2025-02-10  3:01 ` Jie Hai
  2025-02-10 20:06 ` [PATCH 0/2] net/hns3: bugfix on hns3 Stephen Hemminger
  2 siblings, 0 replies; 4+ messages in thread
From: Jie Hai @ 2025-02-10  3:01 UTC (permalink / raw)
  To: dev, thomas, ferruh.yigit, Min Hu (Connor), Wei Hu (Xavier),
	Hao Chen, Ferruh Yigit, Huisong Li
  Cc: fengchengwen, haijie1, huangdengdui

From: Dengdui Huang <huangdengdui@huawei.com>

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 <huangdengdui@huawei.com>
---
 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 146444e2fa99..398b75384ee9 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 79a8c1edad56..4d707c13b29b 100644
--- a/drivers/net/hns3/hns3_cmd.h
+++ b/drivers/net/hns3/hns3_cmd.h
@@ -10,7 +10,8 @@
 #include <rte_byteorder.h>
 #include <rte_spinlock.h>
 
-#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.33.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] net/hns3: bugfix on hns3
  2025-02-10  3:01 [PATCH 0/2] net/hns3: bugfix on hns3 Jie Hai
  2025-02-10  3:01 ` [PATCH 1/2] net/hns3: fix possible copper port initialize fail Jie Hai
  2025-02-10  3:01 ` [PATCH 2/2] net/hns3: fix possible reset timeout Jie Hai
@ 2025-02-10 20:06 ` Stephen Hemminger
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2025-02-10 20:06 UTC (permalink / raw)
  To: Jie Hai; +Cc: dev, thomas, ferruh.yigit, lihuisong, fengchengwen, huangdengdui

On Mon, 10 Feb 2025 11:01:11 +0800
Jie Hai <haijie1@huawei.com> wrote:

> Fix some possible failure on hns3 driver.
> 
> Dengdui Huang (2):
>   net/hns3: fix possible copper port initialize fail
>   net/hns3: fix possible reset timeout
> 
>  drivers/net/hns3/hns3_cmd.c    | 18 ++++++++++++------
>  drivers/net/hns3/hns3_cmd.h    |  4 ++--
>  drivers/net/hns3/hns3_ethdev.c | 29 ++++++++++++++++++++++++++++-
>  3 files changed, 42 insertions(+), 9 deletions(-)

Added to next-net

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-10 20:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-10  3:01 [PATCH 0/2] net/hns3: bugfix on hns3 Jie Hai
2025-02-10  3:01 ` [PATCH 1/2] net/hns3: fix possible copper port initialize fail Jie Hai
2025-02-10  3:01 ` [PATCH 2/2] net/hns3: fix possible reset timeout Jie Hai
2025-02-10 20:06 ` [PATCH 0/2] net/hns3: bugfix on hns3 Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).