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

Message ID 20261122144926.284857-4-maxime.chevallier@bootlin.com (mailing list archive)
State New
Headers
Series net: stmmac: dwmac-sun8i: enable Flow Control |

Commit Message

Maxime Chevallier Nov. 22, 2026, 2:49 p.m. UTC
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@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
  

Comments

Nicolai Buchwitz Nov. 22, 2026, 3:58 p.m. UTC | #1
On 22.11.2026 15:49, Maxime Chevallier wrote:
> 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@bootlin.com>

> [...]

Reviewed-by: Nicolai Buchwitz <nbb@tipi-net.de>

Thanks,
Nicolai
  

Patch

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);
 }