[PATCH net-next 3/3] net: stmmac: dwmac-sun8i: configure the pause time for TX flow control

From: Maxime Chevallier

Date: Sun Nov 22 2026 - 09:50:03 EST


When sending pause frames for flow control, we need to indicate the
number of quantums the peer should wait before sending more frames.

This is maintained in stmmac's "pause_time" global variable (it's a
module param).

Let's program the pause time value, and also allow sending the
zero-quanta pause frame when the peer can resume sending traffic.

Signed-off-by: Maxime Chevallier <maxime.chevallier@xxxxxxxxxxx>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 75c743dfe348..613199da57c1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -232,6 +232,8 @@ static const struct emac_variant emac_variant_h616_emac1 = {

/* Used in EMAC_TX_FLOW_CTL */
#define EMAC_TX_FLOW_CTL_EN BIT(0)
+#define EMAC_TX_FLOW_CTL_ZQP_FRM_EN BIT(1)
+#define EMAC_TX_FLOW_CTL_PAUSE_TIME GENMASK(19, 4)

/* Used in EMAC_INT_STA */
#define EMAC_TX_INT BIT(0)
@@ -784,10 +786,11 @@ static void sun8i_dwmac_flow_ctrl(struct mac_device_info *hw,
writel(v, ioaddr + EMAC_RX_CTL1);

v = readl(ioaddr + EMAC_TX_FLOW_CTL);
+ v &= ~(EMAC_TX_FLOW_CTL_EN | EMAC_TX_FLOW_CTL_ZQP_FRM_EN |
+ EMAC_TX_FLOW_CTL_PAUSE_TIME);
if (fc & FLOW_TX)
- v |= EMAC_TX_FLOW_CTL_EN;
- else
- v &= ~EMAC_TX_FLOW_CTL_EN;
+ v |= EMAC_TX_FLOW_CTL_EN | EMAC_TX_FLOW_CTL_ZQP_FRM_EN |
+ FIELD_PREP(EMAC_TX_FLOW_CTL_PAUSE_TIME, pause_time);
writel(v, ioaddr + EMAC_TX_FLOW_CTL);
}

--
2.56.1