[PATCH net 1/2] net: enetc: restore RX ring congestion mode after ring reconfiguration

From: wei . fang

Date: Mon Jul 27 2026 - 22:34:25 EST


From: Wei Fang <wei.fang@xxxxxxx>

The congestion mode (CM) of the RX BD rings is only configured in the
phylink .mac_link_up() callback enetc_pl_mac_link_up(), where the
ENETC_RBMR_CM bit is set when tx_pause is enabled. This callback is
only invoked when the link status changes.

However, enetc_reconfigure() tears down and re-creates the RX BD rings
at runtime without any link status change, for example when attaching
or detaching an XDP program, or when enabling/disabling PTP RX hardware
timestamping. During ring reconfiguration, enetc_setup_rxbdr() rebuilds
the RBMR register starting from zero, which clears the ENETC_RBMR_CM
bit. Because the link status remains unchanged, enetc_pl_mac_link_up()
is not called again, so the CM bit is never restored.

As a result, the ENETC MAC can no longer generate PAUSE frames when
congestion occurs at the ingress direction, and flow control stops
working after such a reconfiguration.

Track the desired CM state in a software flag ENETC_RXBDR_CM. Set or
clear the flag in enetc_pl_mac_link_up() according to tx_pause, and
clear it in enetc_pl_mac_link_down(). When the RX BD rings are
(re)configured, enetc_setup_rxbdr() consults this flag and restores
the ENETC_RBMR_CM bit accordingly, so flow control survives ring
reconfiguration even when the link status does not change.

Fixes: 5093406c784f ("net: enetc: implement ring reconfiguration procedure for PTP RX timestamping")
Signed-off-by: Wei Fang <wei.fang@xxxxxxx>
---
drivers/net/ethernet/freescale/enetc/enetc.c | 4 ++++
drivers/net/ethernet/freescale/enetc/enetc.h | 1 +
drivers/net/ethernet/freescale/enetc/enetc_pf.c | 5 +++++
3 files changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 8e3f345dd9aa..9282e13ccfb2 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -2631,6 +2631,7 @@ static void enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring,
bool extended)
{
+ struct enetc_ndev_priv *priv = netdev_priv(rx_ring->ndev);
int idx = rx_ring->index;
u32 rbmr = 0;

@@ -2666,6 +2667,9 @@ static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring,
if (rx_ring->ndev->features & NETIF_F_HW_VLAN_CTAG_RX)
rbmr |= ENETC_RBMR_VTE;

+ if (test_bit(ENETC_RXBDR_CM, &priv->flags))
+ rbmr |= ENETC_RBMR_CM;
+
rx_ring->rcir = hw->reg + ENETC_BDR(RX, idx, ENETC_RBCIR);
rx_ring->idr = hw->reg + ENETC_SIRXIDR;

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h
index 04a5dd5ea6c7..341f54856deb 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc.h
@@ -419,6 +419,7 @@ enum enetc_active_offloads {
enum enetc_flags_bit {
ENETC_TX_ONESTEP_TSTAMP_IN_PROGRESS = 0,
ENETC_TX_DOWN,
+ ENETC_RXBDR_CM,
};

/* interrupt coalescing modes */
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
index 2d687bb8c3a0..3fb689d27a02 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
@@ -633,6 +633,8 @@ static void enetc_pl_mac_link_up(struct phylink_config *config,
}

if (tx_pause) {
+ set_bit(ENETC_RXBDR_CM, &priv->flags);
+
/* When the port first enters congestion, send a PAUSE request
* with the maximum number of quanta. When the port exits
* congestion, it will automatically send a PAUSE frame with
@@ -652,6 +654,8 @@ static void enetc_pl_mac_link_up(struct phylink_config *config,
*/
pause_on_thresh = 3 * ENETC_MAC_MAXFRM_SIZE;
pause_off_thresh = 1 * ENETC_MAC_MAXFRM_SIZE;
+ } else {
+ clear_bit(ENETC_RXBDR_CM, &priv->flags);
}

enetc_port_mac_wr(si, ENETC_PM0_PAUSE_QUANTA, init_quanta);
@@ -683,6 +687,7 @@ static void enetc_pl_mac_link_down(struct phylink_config *config,
struct enetc_ndev_priv *priv;

priv = netdev_priv(si->ndev);
+ clear_bit(ENETC_RXBDR_CM, &priv->flags);

if (si->hw_features & ENETC_SI_F_QBU)
enetc_mm_link_state_update(priv, false);
--
2.34.1