The link alarm retry calls mac.setup_link() with
autoneg_wait_to_complete = false. On the AN73/xpcs path, this skips
reconfiguration once the link is up and AN is complete. Passing true
from the retry path instead resets an established AN73 link, which
then drops and may not recover after DAC hot-plug.

The setup flag is also passed to txgbe_e56_set_phy_link_mode() as its
need_restart argument. Passing false unchanged would make a retry a
no-op while the link is down or AN is incomplete if the PHY is already
in 10G mode. Derive need_restart from the current link and AN state so
retries recover an incomplete setup without reconfiguring an
established link.

Fixes: 6104fd11086e ("net/txgbe: fix link stability for 25G NIC")
Cc: [email protected]

Signed-off-by: Zaiyu Wang <[email protected]>
---
 drivers/net/txgbe/base/txgbe_aml.c   | 5 ++++-
 drivers/net/txgbe/base/txgbe_aml40.c | 5 ++++-
 drivers/net/txgbe/txgbe_ethdev.c     | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/txgbe/base/txgbe_aml.c 
b/drivers/net/txgbe/base/txgbe_aml.c
index ac80d85f08..7a0839a7d1 100644
--- a/drivers/net/txgbe/base/txgbe_aml.c
+++ b/drivers/net/txgbe/base/txgbe_aml.c
@@ -213,6 +213,7 @@ s32 txgbe_setup_phy_link_aml(struct txgbe_hw *hw,
        s32 ret_status = 0;
        u32 link_speed = TXGBE_LINK_SPEED_UNKNOWN;
        bool link_up = false;
+       bool need_restart;
        int i;
        u32 link_capabilities = TXGBE_LINK_SPEED_UNKNOWN;
        u32 value;
@@ -246,8 +247,10 @@ s32 txgbe_setup_phy_link_aml(struct txgbe_hw *hw,
                txgbe_e56_check_phy_link(hw, &link_speed, &link_up);
                if (link_up && hw->an_done && !autoneg_wait_to_complete)
                        return status;
+
+               need_restart = autoneg_wait_to_complete || !link_up || 
!hw->an_done;
                rte_spinlock_lock(&hw->phy_lock);
-               txgbe_e56_set_phy_link_mode(hw, speed, 
autoneg_wait_to_complete);
+               txgbe_e56_set_phy_link_mode(hw, speed, need_restart);
                rte_spinlock_unlock(&hw->phy_lock);
                return 0;
        }
diff --git a/drivers/net/txgbe/base/txgbe_aml40.c 
b/drivers/net/txgbe/base/txgbe_aml40.c
index 5fa7c6a243..892dddd373 100644
--- a/drivers/net/txgbe/base/txgbe_aml40.c
+++ b/drivers/net/txgbe/base/txgbe_aml40.c
@@ -148,6 +148,7 @@ s32 txgbe_setup_phy_link_aml40(struct txgbe_hw *hw,
        s32 ret_status = 0;
        u32 link_speed = TXGBE_LINK_SPEED_UNKNOWN;
        bool link_up = false;
+       bool need_restart;
        int i;
        u32 link_capabilities = TXGBE_LINK_SPEED_UNKNOWN;
        u32 value;
@@ -171,8 +172,10 @@ s32 txgbe_setup_phy_link_aml40(struct txgbe_hw *hw,
                txgbe_e56_check_phy_link(hw, &link_speed, &link_up);
                if (link_up && hw->an_done && !autoneg_wait_to_complete)
                        return status;
+
+               need_restart = autoneg_wait_to_complete || !link_up || 
!hw->an_done;
                rte_spinlock_lock(&hw->phy_lock);
-               txgbe_e56_set_phy_link_mode(hw, speed, 
autoneg_wait_to_complete);
+               txgbe_e56_set_phy_link_mode(hw, speed, need_restart);
                rte_spinlock_unlock(&hw->phy_lock);
                return status;
        }
diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 2f59b0794f..a5ef0b3e54 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -3237,7 +3237,7 @@ txgbe_dev_setup_link_alarm_handler_aml(void *param)
                return;
        }
 
-       hw->mac.setup_link(hw, speed, true);
+       hw->mac.setup_link(hw, speed, false);
 
        u32 link_speed = TXGBE_LINK_SPEED_UNKNOWN;
        bool link_up = false;
-- 
2.55.0.windows.2

Reply via email to