From: Wei Fang ENETC v4 has the same problem as ENETC v1: the RX BD ring congestion mode (CM) is only configured in the phylink .mac_link_up() callback, so it is cleared when enetc_reconfigure() rebuilds the RX BD rings at runtime (for example when enabling or disabling PTP RX hardware timestamping) without a link status change, and it is never restored. As a result, the MAC can no longer generate PAUSE frames on ingress congestion and flow control stops working. Fix it in the same way as ENETC v1, by tracking the desired CM state in the software flag ENETC_RXBDR_CM. Set or clear the flag in enetc4_set_tx_pause() according to tx_pause, and clear it in enetc4_pl_mac_link_down(). enetc_setup_rxbdr() already restores the CM bit from this flag when the RX BD rings are (re)configured. Fixes: f5b9a1cde0a2 ("net: enetc: add PTP synchronization support for ENETC v4") Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/enetc/enetc4_pf.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c index 437a15bbb47b..8db5a47fdbae 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c @@ -748,6 +748,7 @@ static void enetc4_set_rx_pause(struct enetc_pf *pf, bool rx_pause) static void enetc4_set_tx_pause(struct enetc_pf *pf, int num_rxbdr, bool tx_pause) { + struct enetc_ndev_priv *priv = netdev_priv(pf->si->ndev); u32 pause_off_thresh = 0, pause_on_thresh = 0; u32 init_quanta = 0, refresh_quanta = 0; struct enetc_hw *hw = &pf->si->hw; @@ -764,6 +765,8 @@ static void enetc4_set_tx_pause(struct enetc_pf *pf, int num_rxbdr, bool tx_paus } 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 @@ -783,6 +786,8 @@ static void enetc4_set_tx_pause(struct enetc_pf *pf, int num_rxbdr, bool tx_paus */ 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(pf->si, ENETC4_PM_PAUSE_QUANTA(0), init_quanta); @@ -949,7 +954,10 @@ static void enetc4_pl_mac_link_down(struct phylink_config *config, phy_interface_t interface) { struct enetc_pf *pf = phylink_to_enetc_pf(config); + struct enetc_ndev_priv *priv; + priv = netdev_priv(pf->si->ndev); + clear_bit(ENETC_RXBDR_CM, &priv->flags); enetc4_mac_rx_graceful_stop(pf); enetc4_mac_tx_graceful_stop(pf); } -- 2.34.1