From: wei.fang@oss.nxp.com
To: claudiu.manoil@nxp.com, vladimir.oltean@nxp.com,
xiaoning.wang@nxp.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, Frank.Li@nxp.com
Cc: wei.fang@nxp.com, imx@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net 1/2] net: enetc: restore RX ring congestion mode after ring reconfiguration
Date: Tue, 28 Jul 2026 10:32:16 +0800 [thread overview]
Message-ID: <20260728023217.2499420-2-wei.fang@oss.nxp.com> (raw)
In-Reply-To: <20260728023217.2499420-1-wei.fang@oss.nxp.com>
From: Wei Fang <wei.fang@nxp.com>
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@nxp.com>
---
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
next prev parent reply other threads:[~2026-07-28 2:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 2:32 [PATCH net 0/2] net: enetc: restore RX ring congestion mode after ring reconfiguration wei.fang
2026-07-28 2:32 ` wei.fang [this message]
2026-07-28 2:32 ` [PATCH net 2/2] net: enetc: restore RX ring congestion mode for ENETC v4 wei.fang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260728023217.2499420-2-wei.fang@oss.nxp.com \
--to=wei.fang@oss.nxp.com \
--cc=Frank.Li@nxp.com \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imx@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox