Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Chen-Yu Tsai
Sun, 22 Nov 2026 16:11
Re: [PATCH net-next 2/3] net: stmmac: dwmac-sun8i: emit pause frames when the RX FIFO fills
Author: Chen-Yu Tsai
Date: Sun, 22 Nov 2026 16:11
Date: Sun, 22 Nov 2026 16:11
85 lines
12516 bytes
12516 bytes
On Sun, Nov 22, 2026 at 10:49 PM Maxime Chevallier
<maxime.chevallier@bootlin.com> wrote:
>
> 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,
typo, as Nicolai mentioned
> 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.
The latest chips (A133, A523) only have 8K for the RX FIFO. I think
that still works.
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Chen-Yu Tsai <wens@kernel.org>
> ---
> .../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/net/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 <clabbe.montjoie@gmail.com>
> */
>
> +#include <linux/bitfield.h>
> #include <linux/clk.h>
> #include <linux/io.h>
> #include <linux/iopoll.h>
> @@ -202,6 +203,11 @@ static const struct emac_variant emac_variant_h616_emac1 = {
> #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)
>
> @@ -766,6 +772,17 @@ static void sun8i_dwmac_flow_ctrl(struct mac_device_info *hw,
> v &= ~EMAC_RX_FLOW_CTL_EN;
> writel(v, ioaddr + EMAC_RX_CTL0);
>
> + v = readl(ioaddr + EMAC_RX_CTL1);
> + v &= ~(EMAC_RX_FIFO_FLOW_CTL | EMAC_RX_FLOW_CTL_TH_ACT |
> + EMAC_RX_FLOW_CTL_TH_DEACT);
> + if (fc & FLOW_TX)
> + v |= 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 = readl(ioaddr + EMAC_TX_FLOW_CTL);
> if (fc & FLOW_TX)
> v |= EMAC_TX_FLOW_CTL_EN;
> --
> 2.56.1
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads