From nobody Tue Nov 24 11:51:51 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.85.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795358985; b=znRrUC3NQCJO0JxSnfpn0gqQZEJusrm5H3es8jV2UbZWwOOwT4VtuDCQjmomMro9jvMp Y6kilW6cJde0MSOYziurZ3CyQzr5tPIVjiKijwkgxvU04KtYHgy6Y8AKXqnBds17JZBVh lnz4dlWeLjV4FmN6WW6POnLabKT6aLFzwhnE4fBavadL238ieXedXh6ftOHUomzKbUcMv 8jia19cSS95Lol6sUd3BZ81hhMZoUca79VwtRMOwSs/Cs0IxRcZvTa+gp5wxykY0TtcGV oYjctUrVOqJ0fcOpHljEoIVlHsyOt0TetDF6N3FU1uQ8N/fwC8/nFz+HdL8nxbbuGQQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795358985; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Last-TLS-Session-Version; bh=utK4M7GE/JevjSpCvIwudXzUWEsfoW3c/fssQAD0hxo=; b=gabtoUN3XiOIySgGrCBpJXNDbuMyoJldTYz568lXiW7lTAxkS9R5H/UDfzW3sWS3yIoy TcOifFLr4TPb31o8hR0xH2trZvuqzxDKzb7qrsTQxdGN3+HD3eKmUw7Luj/6eTgkSezXO PpSjpMeE5fT1fnGalThXMRxyAy1KlV5JTl4pzFSqQWPnOil8SenK8X6aRLQCsTFHVFAeW rg24XFsRIimgOqOtVu9jhc0o2qiUObqqJg725/snVOQ+auVM/yEpJVxsXq2iXOZySNNen T64kdct10E5iagztlpMwsNeJd2attvHkbsn3nKQ2VJxxpuhLiyPYVDS6oM+9DrhP2Fw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=Pf3fP81J; arc=none smtp.remote-ip=185.246.85.4 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62819606A681 for ; Sun, 22 Nov 2026 14:49:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 62819606A681 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=Pf3fP81J Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 045AE4E416E0; Sun, 22 Nov 2026 14:49:44 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CC9A460512; Sun, 22 Nov 2026 14:49:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 58F5711E623B4; Sun, 22 Nov 2026 15:49:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1795358982; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=utK4M7GE/JevjSpCvIwudXzUWEsfoW3c/fssQAD0hxo=; b=Pf3fP81JIlkMcHt1EYgMaHvhSnQSV9lrWuFWvJMp7dZTp0VfwGfllF4N9Hj79xMB6L2zN1 SMNsmjRvsaWV503SF2L2pGr+0HHSMdm9nFztbXy0R+glKThJ3cpRr9LeNxaF07M/Rxiagm xABKvek67OsW7AwDZZyrvbQ4HhvTSvd8DtshhFpaPk6KZafsikDiZSyk5MPPtY5akAL3dx w7lBD278dFg11+ppOGQKTWF4hTk/Xwh2yH6jQJsAG8gTJvW5PmBdrt9y8s3YyxrHLMEYPf fISLAOhRSL8tUxkUfMeVEPPxtVr6jI+zIWv8uzlBmHFmaRjSWNBTlSLsx/l1/A== From: Maxime Chevallier To: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Willem de Bruijn , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Maxime Coquelin , Alexandre Torgue , Russell King , Lorenzo Bianconi , Nicolai Buchwitz Cc: Maxime Chevallier , thomas.petazzoni@bootlin.com, =?UTF-8?q?Alexis=20Lothor=C3=A9?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH net-next 1/3] net: stmmac: dwmac-sun8i: allow controlling TX and RX flow control separately Date: Sun, 22 Nov 2026 15:49:23 +0100 Message-ID: <20261122144926.284857-2-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261122144926.284857-1-maxime.chevallier@bootlin.com> References: <20261122144926.284857-1-maxime.chevallier@bootlin.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Currently, the sun8i flow control setup only looks at FLOW_AUTO (which is FLOW_RX | FLOW_TX), and enables RX/TX based on that. Allow enabling RX/TX flow control directions separately. Signed-off-by: Maxime Chevallier Reviewed-by: Chen-Yu Tsai Reviewed-by: Nicolai Buchwitz --- drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/ne= t/ethernet/stmicro/stmmac/dwmac-sun8i.c index 2ece7ba9dd73..c63f4d87de50 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c @@ -760,14 +760,14 @@ static void sun8i_dwmac_flow_ctrl(struct mac_device_i= nfo *hw, u32 v; =20 v =3D readl(ioaddr + EMAC_RX_CTL0); - if (fc =3D=3D FLOW_AUTO) + if (fc & FLOW_RX) v |=3D EMAC_RX_FLOW_CTL_EN; else v &=3D ~EMAC_RX_FLOW_CTL_EN; writel(v, ioaddr + EMAC_RX_CTL0); =20 v =3D readl(ioaddr + EMAC_TX_FLOW_CTL); - if (fc =3D=3D FLOW_AUTO) + if (fc & FLOW_TX) v |=3D EMAC_TX_FLOW_CTL_EN; else v &=3D ~EMAC_TX_FLOW_CTL_EN; --=20 2.56.1 From nobody Tue Nov 24 11:51:51 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.84.56 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795358989; b=Y/rsAC3m8aU/B50ClLtjSvn6+siBqhWuI/i8vg7Ic6Jw4mGRV0HsKyDMsVYltwZaDinF z4RdTa0sxMnK+4QDQlhRRQg1gaYxV67yj8DDucWSIXhigf7Vl80dWpEIebZKYArmL5Vvt pZMFH3uAy4zoJ6xKJpMhTj/69DR8+uMYLUeqSBjethvlhbgTB/8C+ebjZqNzFSdJgQlZs 1zzh+NPgzAxSuUCyyFqhanHgvchLjaNy+iuXBZk7PHiQ3NPkjrzlSsnM/QD/0LGe5zqno zkmDp/JaQS4hjSoi13Pa0CW9nl9ZSbtSdZCjjafGP4IBy8JjyOwqcH+LPJhi5mUDS+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795358989; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Last-TLS-Session-Version; bh=90uW9vPXKmWFpzCjI8Up2KnoezPG5Nbi1kLisqyflSw=; b=1EfYVrWE/n2/sV7SRXSJq71pH7IE2keR1XuV5sJ6D2PSmtLX4Hu/YT023uAzAO9dVbAV XhMduQ+qjuY1igbyD52+vxKLTwecq5l1uyik0UMMLlLXbAv7GPe1AKS8cR2Lpl6O4+tQY HMb5uHjivPyncZ3RC4PIKcpJ39JK4TqC1g4IXM3oOh4xxu4fj5K6xpZZ2JL5gWzKRfI7z hVr3tqGQNTyS3EAACXgJ+sQWIfpbIOBpYjXHgMXQqWsed3dPb2tKtsUFCMEsKt9/nH2fT K6Vc6PKzV6gPpPv8DWZD4+2uG3lj5WBIc+zldH8Y+cKFsv0FXrZejdSvbSxkjdGOc3Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=b3pc9oae; arc=none smtp.remote-ip=185.246.84.56 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D15C606A68E for ; Sun, 22 Nov 2026 14:49:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0D15C606A68E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=b3pc9oae Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id C537D1A1709; Sun, 22 Nov 2026 14:49:46 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 93B7D60512; Sun, 22 Nov 2026 14:49:46 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EAD8111E62396; Sun, 22 Nov 2026 15:49:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1795358985; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=90uW9vPXKmWFpzCjI8Up2KnoezPG5Nbi1kLisqyflSw=; b=b3pc9oaep+z/bJD4QxXY7ItQ9Mhm9vK4KSpxC1+FEcS76h22AnJdRuLoNc2vDv2VilJxFk XB10alWQcDGW5eq/DgZ3BjLf0EqkZ5GLTejX3nEtxaOezKR01W/uW5k+u9wXaFSs+dboIo pEo2LIdE1Zi4EZyGfElNeXUfsrrzZ9XSZRJqphfKOmNb5pUtqetPEu52IQfNs77C+A89Ew FFCVUTg+XhoumzBDVsrCjP19/Rcn4T0G+TIX63yPiJ927z1sqUD8F+t+g/tcWrsQE387al WBqva0f/+8krqadVlEp4T/1ZzzzHyE7mvP2VEoERJYKrrdLy4wWRKJTHbzp/1w== From: Maxime Chevallier To: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Willem de Bruijn , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Maxime Coquelin , Alexandre Torgue , Russell King , Lorenzo Bianconi , Nicolai Buchwitz Cc: Maxime Chevallier , thomas.petazzoni@bootlin.com, =?UTF-8?q?Alexis=20Lothor=C3=A9?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH net-next 2/3] net: stmmac: dwmac-sun8i: emit pause frames when the RX FIFO fills Date: Sun, 22 Nov 2026 15:49:24 +0100 Message-ID: <20261122144926.284857-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261122144926.284857-1-maxime.chevallier@bootlin.com> References: <20261122144926.284857-1-maxime.chevallier@bootlin.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The TX flow control mechanism needs multiple things setup to actually work: - The TX_FLOW_CTL_EN bit needs to be set in the TC_FLOW_CTL register, this is already done - The RX fifo thresholds needs to be set, to indicate when the MAC needs to start sending pause frames based on the RX fifo occupancy, and when it should stop. Let's configure the threshold the following way: - Send pause frames when there's less than 2K left in the RX fifo - Stop sending them when there's more than 4K left in the RX fifo. This was tested in Allwinner H2+ using the ethtool -t "flow control" selftest. On that SoC, the RX fifo is 16K. Signed-off-by: Maxime Chevallier Reviewed-by: Chen-Yu Tsai Reviewed-by: Nicolai Buchwitz --- .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/ne= t/ethernet/stmicro/stmmac/dwmac-sun8i.c index c63f4d87de50..75c743dfe348 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c @@ -5,6 +5,7 @@ * Copyright (C) 2017 Corentin Labbe */ =20 +#include #include #include #include @@ -202,6 +203,11 @@ static const struct emac_variant emac_variant_h616_ema= c1 =3D { #define EMAC_RX_TH_64 (0x1 << 4) #define EMAC_RX_TH_96 (0x2 << 4) #define EMAC_RX_TH_128 (0x3 << 4) +#define EMAC_RX_FLOW_CTL_TH_ACT GENMASK(21, 20) +#define EMAC_RX_FLOW_CTL_TH_DEACT GENMASK(23, 22) +#define EMAC_RX_FLOW_CTL_TH_2K 0x1 +#define EMAC_RX_FLOW_CTL_TH_4K 0x3 +#define EMAC_RX_FIFO_FLOW_CTL BIT(24) #define EMAC_RX_DMA_EN BIT(30) #define EMAC_RX_DMA_START BIT(31) =20 @@ -766,6 +772,17 @@ static void sun8i_dwmac_flow_ctrl(struct mac_device_in= fo *hw, v &=3D ~EMAC_RX_FLOW_CTL_EN; writel(v, ioaddr + EMAC_RX_CTL0); =20 + v =3D readl(ioaddr + EMAC_RX_CTL1); + v &=3D ~(EMAC_RX_FIFO_FLOW_CTL | EMAC_RX_FLOW_CTL_TH_ACT | + EMAC_RX_FLOW_CTL_TH_DEACT); + if (fc & FLOW_TX) + v |=3D EMAC_RX_FIFO_FLOW_CTL | + FIELD_PREP(EMAC_RX_FLOW_CTL_TH_ACT, + EMAC_RX_FLOW_CTL_TH_2K) | + FIELD_PREP(EMAC_RX_FLOW_CTL_TH_DEACT, + EMAC_RX_FLOW_CTL_TH_4K); + writel(v, ioaddr + EMAC_RX_CTL1); + v =3D readl(ioaddr + EMAC_TX_FLOW_CTL); if (fc & FLOW_TX) v |=3D EMAC_TX_FLOW_CTL_EN; --=20 2.56.1 From nobody Tue Nov 24 11:51:51 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.85.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795358991; b=wloIpDz5NeuPd6bp9cO0wHSdHok5lXQJXlojZ4wUs5ShvKok6ce+250YxbgySI0mhYho 5J9m4LwrUgdJFz2VUJxFQjbu+rBFdVj1zCt/RcCu2nr6fgdwbM+H4gyjp/pJtAu1FLGXf aLQ6OYbyMPNJIRGFb1cTQLAHavMK8k89pzKC7lAapaOb9oDhUO6W9Qzh/oyTn3aScd4Xj OAMZ6iNKQHpr/sc4yz+7MUyJuCNnZiicu2uiP5Rr8btXhPipdyKJGhmPIaepyF+kcWa0K pObY/AtbKvHc5QK0d2ah7AmVu9JEsYOBak/YmXVyB0l4yLgS4Odk2nOI16W2YfH9bbQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795358991; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Last-TLS-Session-Version; bh=D7IyEM1xmU0ttRjHhZmbac+rxu8OBN35sVrm+mJoCRk=; b=NClmxcXO8r57yLSQulsKvijLnYWgnZgZl889LI/TxZPDuDNWy4bGVeDDxuLZc7RV3a3Y EnbiB56KioRtZSyxBAbBZtKbZTlk3x72gbYnsLA4h/9R5IbbNH9u09MfYoqLxKv6rPM4s 5J7rPTqFzB7hnm2QtgReL0HHqu+X0rcfytW5GmojY9YhbZjNjFltvuO/6OxU/X7pFdZOk WJxtedbdSd9j2yh+1DM3L61PnOe5f/T29OeNdfIrYJEXv7H8i5cuxoWYtEvxjAsinoRf6 1O7iGRPzg9GMvvuocLezebT9tRqWgtetxjNVepTMUTCzZHMriTmGE+RjviOIfDjZMkA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=GpGtKWCC; arc=none smtp.remote-ip=185.246.85.4 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E10D5606A681; Sun, 22 Nov 2026 14:49:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E10D5606A681 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=GpGtKWCC Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 8F2744E416E5; Sun, 22 Nov 2026 14:49:49 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5E1D460512; Sun, 22 Nov 2026 14:49:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C139A11E60230; Sun, 22 Nov 2026 15:49:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1795358987; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=D7IyEM1xmU0ttRjHhZmbac+rxu8OBN35sVrm+mJoCRk=; b=GpGtKWCCC3MKNfOoI9bnaurUaYqwDrMC0Zhaje4JhlVDcuunKO+frhiuzRN6tbh1rv51QB N3cRNRiHcqOzw9JQHYjXb3DFyuZTgKiO2nHJDLD9SuhMH0U0DqDgL0O798PTLbhv5mPiWV jxhTtAzYrlDl7Mhuyccnpac5QjlNLP2fyT+r06zaRDRrXga4giDTeLBuuWzGUakrodJpBP fj1wUaU5XcRiBFU3oJiDIzptPkQIe9xBnia5O0k7let9FxVAu+fZJAS1uDeKvfO5Gi+20j 2dmChr5IAJip0AAjdvv0XlTMct7YQSh6+jcoetQjzb3XLj1ltzAMgvkK7uxF5Q== From: Maxime Chevallier To: Andrew Lunn , Jakub Kicinski , davem@davemloft.net, Eric Dumazet , Paolo Abeni , Simon Horman , Willem de Bruijn , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Maxime Coquelin , Alexandre Torgue , Russell King , Lorenzo Bianconi , Nicolai Buchwitz Cc: Maxime Chevallier , thomas.petazzoni@bootlin.com, =?UTF-8?q?Alexis=20Lothor=C3=A9?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH net-next 3/3] net: stmmac: dwmac-sun8i: configure the pause time for TX flow control Date: Sun, 22 Nov 2026 15:49:25 +0100 Message-ID: <20261122144926.284857-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261122144926.284857-1-maxime.chevallier@bootlin.com> References: <20261122144926.284857-1-maxime.chevallier@bootlin.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Nicolai Buchwitz --- 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/ne= t/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_emac= 1 =3D { =20 /* 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) =20 /* Used in EMAC_INT_STA */ #define EMAC_TX_INT BIT(0) @@ -784,10 +786,11 @@ static void sun8i_dwmac_flow_ctrl(struct mac_device_i= nfo *hw, writel(v, ioaddr + EMAC_RX_CTL1); =20 v =3D readl(ioaddr + EMAC_TX_FLOW_CTL); + v &=3D ~(EMAC_TX_FLOW_CTL_EN | EMAC_TX_FLOW_CTL_ZQP_FRM_EN | + EMAC_TX_FLOW_CTL_PAUSE_TIME); if (fc & FLOW_TX) - v |=3D EMAC_TX_FLOW_CTL_EN; - else - v &=3D ~EMAC_TX_FLOW_CTL_EN; + v |=3D 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); } =20 --=20 2.56.1