When an AML40 port is configured in 10G forced mode (auto_neg=0),
the hardware can link up but the driver keeps reporting link down
after a peer link failure: link_valid is cleared on timeout but
never restored when the peer recovers, so the link stays down until
the port is restarted.

Restore hw->link_valid = true in the success path of
txgbe_setup_phy_link_aml40(), symmetric to the 40G path. Handle
TXGBE_ERR_PHY_INIT_NOT_DONE before the timeout split and leave
link_valid untouched, matching the 25G path in
txgbe_setup_phy_link_aml(); the alarm retry then attempts the
setup again.

Fixes: f7cfc21e9f75 ("net/txgbe: fix link stability for 40G NIC")
Cc: [email protected]

Signed-off-by: Zaiyu Wang <[email protected]>
---
 drivers/net/txgbe/base/txgbe_aml40.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/txgbe/base/txgbe_aml40.c 
b/drivers/net/txgbe/base/txgbe_aml40.c
index 7476759d4d..5fa7c6a243 100644
--- a/drivers/net/txgbe/base/txgbe_aml40.c
+++ b/drivers/net/txgbe/base/txgbe_aml40.c
@@ -202,9 +202,18 @@ s32 txgbe_setup_phy_link_aml40(struct txgbe_hw *hw,
 
        rte_spinlock_lock(&hw->phy_lock);
        ret_status = txgbe_set_link_to_amlite(hw, speed);
+       rte_spinlock_unlock(&hw->phy_lock);
+
+       /* The PHY did not come out of reset; leave link_valid alone and
+        * let the retry in the alarm handler attempt the setup again.
+        */
+       if (ret_status == TXGBE_ERR_PHY_INIT_NOT_DONE)
+               goto out;
+
        if (ret_status == TXGBE_ERR_TIMEOUT)
                hw->link_valid = false;
-       rte_spinlock_unlock(&hw->phy_lock);
+       else
+               hw->link_valid = true;
 
        for (i = 0; i < 4; i++) {
                txgbe_e56_check_phy_link(hw, &link_speed, &link_up);
-- 
2.55.0.windows.2

Reply via email to