Skip to contentSkip to conversation

amd-xgbe: add robust link-down TX queue handling

PATCH In review Raju Rangoju 2 participants 2 messages Mar 13 – Mar 17

Subsystems (3)
lore
Share & tools
lore

Raju Rangoju

author maintainer
#0 lore raw

PATCH 1/1 amd-xgbe: add robust link-down TX queue handling

Add comprehensive link-down handling to improve driver robustness and enable fast recovery from link failures. Currently, the driver lacks proper cleanup mechanisms when the physical link goes down with packets in-flight, which can impact network stability and failover performance.

This enhancement adds intelligent TX queue management during link state transitions:

Link-down detection improvements:
- Adaptive polling: 100ms intervals when carrier is up for fast link-down detection, vs 1000ms when down to conserve CPU
- Enables ~100-200ms link-down response time (10x improvement)

Smart TX queue handling:
- Immediate TX queue stop on link-down to halt new submissions
- Skip futile hardware drain attempts when link is already down
- Force-cleanup abandoned TX descriptors that hardware won't complete
- Proper descriptor and skb resource reclamation

Benefits:
- Eliminates TX queue hangs during link transitions
- Reduces network stack backpressure buildup
- Enables fast failover in link aggregation configurations
- Improves overall driver resilience to link instability

This is particularly valuable for bonding/teaming deployments where sub-second failover is expected, but improves driver behavior in any environment with dynamic link conditions (cable issues, switch maintenance, etc.)

---
 drivers/net/ethernet/amd/xgbe/xgbe-common.h |  4 +
 drivers/net/ethernet/amd/xgbe/xgbe-dev.c    | 93 +++++++++++++++++----
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c    | 68 +++++++++++++--
 drivers/net/ethernet/amd/xgbe/xgbe-mdio.c   | 17 ++++
 drivers/net/ethernet/amd/xgbe/xgbe.h        |  3 +
 5 files changed, 164 insertions(+), 21 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-common.h +4 -0
index c17900a49595..66807d67e984 100644
@@ -330,6 +330,10 @@
 #define MAC_ISR_SMI_WIDTH		1
 #define MAC_ISR_TSIS_INDEX		12
 #define MAC_ISR_TSIS_WIDTH		1
+#define MAC_ISR_LS_INDEX		24
+#define MAC_ISR_LS_WIDTH		2
+#define MAC_ISR_LSI_INDEX		0
+#define MAC_ISR_LSI_WIDTH		1
 #define MAC_MACA1HR_AE_INDEX		31
 #define MAC_MACA1HR_AE_WIDTH		1
 #define MAC_MDIOIER_SNGLCOMPIE_INDEX	12
drivers/net/ethernet/amd/xgbe/xgbe-dev.c +78 -15

116 lines not on this page · raw message

drivers/net/ethernet/amd/xgbe/xgbe-drv.c +62 -6

101 lines not on this page · raw message

drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +17 -0
index 7675bb98f029..11324b656f12 100644
@@ -1047,11 +1047,28 @@ static void xgbe_phy_adjust_link(struct xgbe_prv_data *pdata)
 		if (pdata->phy_link != pdata->phy.link) {
 			new_state = 1;
 			pdata->phy_link = pdata->phy.link;
+
+			/* Link is coming up - wake TX queues */
+			netif_tx_wake_all_queues(pdata->netdev);
 		}
 	} else if (pdata->phy_link) {
 		new_state = 1;
 		pdata->phy_link = 0;
 		pdata->phy_speed = SPEED_UNKNOWN;
+
+		/* Proactive TX queue management on link-down.
+		 *
+		 * Immediately stop TX queues to enable clean link-down handling
+		 * - Prevents queueing packets that can't be transmitted
+		 * - Allows orderly descriptor cleanup by NAPI poll
+		 * - Enables rapid failover in link aggregation configurations
+		 *
+		 * Note: We do NOT call netdev_tx_reset_queue() here because
+		 * NAPI poll may still be running and would trigger BQL
+		 * assertion. BQL state is cleaned up naturally during
+		 * descriptor reclamation.
+		 */
+		netif_tx_stop_all_queues(pdata->netdev);
 	}
 
 	if (new_state && netif_msg_link(pdata))
drivers/net/ethernet/amd/xgbe/xgbe.h +3 -0
index 3904c293d2d6..ce15613e33cc 100644
@@ -1320,6 +1320,9 @@ void xgbe_init_tx_coalesce(struct xgbe_prv_data *);
 void xgbe_restart_dev(struct xgbe_prv_data *pdata);
 void xgbe_full_restart_dev(struct xgbe_prv_data *pdata);
 
+/* TX queue reset for link-down cleanup*/
+void xgbe_reset_tx_queues(struct xgbe_prv_data *pdata);
+
 /* For Timestamp config */
 void xgbe_config_tstamp(struct xgbe_prv_data *pdata, unsigned int mac_tscr);
 u64 xgbe_get_tstamp_time(struct xgbe_prv_data *pdata);
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 14 lines · Raju Rangoju

Add comprehensive link-down handling to improve driver robustness and enable fast recovery from link failures. Currently, the driver lacks proper cleanup mechanisms when the physical link goes down with packets in-flight, which can impact network stability and failover performance.

This enhancement adds intelligent TX queue management during link state transitions:

Link-down detection improvements:
- Adaptive polling: 100ms intervals when carrier is up for fast link-down detection, vs 1000ms when down to conserve CPU
- Enables ~100-200ms link-down response time (10x improvement)

Quoted 5 lines

Smart TX queue handling:
- Immediate TX queue stop on link-down to halt new submissions
- Skip futile hardware drain attempts when link is already down
- Force-cleanup abandoned TX descriptors that hardware won't complete
- Proper descriptor and skb resource reclamation

It looks like this one should be split in multiple patches, to better isolate each specific improvements.

/P