Thread View: linux.kernel.netdev
7 messages
7 total messages
Started by Arun Iyengar via B4 Relay
Sun, 22 Nov 2026 09:13
[PATCH net v2 2/2] net: stmmac: dwmac-sun8i: Limit the MTU to 2018
Author: Arun Iyengar via B4 Relay
Date: Sun, 22 Nov 2026 09:13
Date: Sun, 22 Nov 2026 09:13
29 lines
11606 bytes
11606 bytes
From: Arun Iyengar <aiyengar1990@gmail.com>
The H616 RX DMA fills only 2044 bytes of a buffer, so frames of 2045 to
2047 bytes, allowed by the previous patch, are dropped. Limit the MTU
so that a frame with two VLAN tags and the FCS fits 2044 bytes.
Fixes: 9f93ac8d4085 ("net-next: stmmac: Add dwmac-sun8i")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 2ece7ba9dd73..ec401cae8187 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -1208,6 +1208,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
plat_dat->mac_setup = sun8i_dwmac_setup;
plat_dat->tx_fifo_size = 4096;
plat_dat->rx_fifo_size = 16384;
+ plat_dat->maxmtu = 2044 - ETH_HLEN - 2 * VLAN_HLEN - ETH_FCS_LEN;
ret = sun8i_dwmac_set_syscon(&pdev->dev, plat_dat);
if (ret)
--
2.55.0
Re: [PATCH net v2 2/2] net: stmmac: dwmac-sun8i: Limit the MTU to 2018
Author: Chen-Yu Tsai
Date: Sun, 22 Nov 2026 11:39
Date: Sun, 22 Nov 2026 11:39
74 lines
12058 bytes
12058 bytes
On Sun, Nov 22, 2026 at 5:13 PM Arun Iyengar via B4 Relay
<devnull+aiyengar1990.gmail.com@kernel.org> wrote:
>
> From: Arun Iyengar <aiyengar1990@gmail.com>
>
> The H616 RX DMA fills only 2044 bytes of a buffer, so frames of 2045 to
> 2047 bytes, allowed by the previous patch, are dropped. Limit the MTU
> so that a frame with two VLAN tags and the FCS fits 2044 bytes.
FWIW I think this applies to all DWMAC cores.
So I tried to do some research of my own. Google AI search pointed me to
STM32F4 or STM32F7, and some Altera FPGAs (I used the Intel® Arria® 10 Hard
Processor System Technical Reference Manual"), that had some variant or
version of the DWMAC core, and had proper programming guides.
The STM32F4 reference manuals has this note:
Even when the start address of a receive buffer is not aligned to the
system databus width
the system should allocate a receive buffer of a size aligned to the
system bus width. For
example, if the system allocates a 1024 byte (1 KB) receive buffer
starting from address
0x1000, the software can program the buffer start address in the
receive descriptor to have
a 0x1002 offset. The receive DMA writes the frame to this buffer with
dummy data in the first
two locations (0x1000 and 0x1001). The actual frame is written from
location 0x1002. Thus,
the actual useful space in this buffer is 1022 bytes, even though the
buffer size is
programmed as 1024 bytes, due to the start address offset.
The Intel one had the same note. It looks pretty much the same, but I didn't
compare it word-for-word.
So for normal descriptors the buffer size is bound to (2KB - bus width).
Not tested, but I think there is more evidence supporting a cross-platform
limit.
ChenYu
> Fixes: 9f93ac8d4085 ("net-next: stmmac: Add dwmac-sun8i")
> Cc: stable@vger.kernel.org
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 2ece7ba9dd73..ec401cae8187 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -1208,6 +1208,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
> plat_dat->mac_setup = sun8i_dwmac_setup;
> plat_dat->tx_fifo_size = 4096;
> plat_dat->rx_fifo_size = 16384;
> + plat_dat->maxmtu = 2044 - ETH_HLEN - 2 * VLAN_HLEN - ETH_FCS_LEN;
>
> ret = sun8i_dwmac_set_syscon(&pdev->dev, plat_dat);
> if (ret)
>
> --
> 2.55.0
>
>
Re: [PATCH net v2 2/2] net: stmmac: dwmac-sun8i: Limit the MTU to 2018
Author: Nicolai Buchwitz
Date: Sun, 22 Nov 2026 16:31
Date: Sun, 22 Nov 2026 16:31
21 lines
9353 bytes
9353 bytes
On 22.11.2026 12:39, Chen-Yu Tsai wrote: > [...] > FWIW I think this applies to all DWMAC cores. > [...] > So for normal descriptors the buffer size is bound to (2KB - bus > width). > Not tested, but I think there is more evidence supporting a > cross-platform > limit. The sun8i EMAC isn't a Synopsys core, so this needs a test on one. Maxime, could you try MTU 2019-2021 on your boards? > [...] Regards, Nicolai
Re: [PATCH net v2 2/2] net: stmmac: dwmac-sun8i: Limit the MTU to 2018
Author: Nicolai Buchwitz
Date: Sun, 22 Nov 2026 16:33
Date: Sun, 22 Nov 2026 16:33
18 lines
9445 bytes
9445 bytes
On 22.11.2026 10:13, Arun Iyengar via B4 Relay wrote:
> From: Arun Iyengar <aiyengar1990@gmail.com>
>
> The H616 RX DMA fills only 2044 bytes of a buffer, so frames of 2045 to
> 2047 bytes, allowed by the previous patch, are dropped. Limit the MTU
> so that a frame with two VLAN tags and the FCS fits 2044 bytes.
>
> Fixes: 9f93ac8d4085 ("net-next: stmmac: Add dwmac-sun8i")
> Cc: stable@vger.kernel.org
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
> [...]
Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Thanks,
Nicolai
Re: [PATCH net v2 2/2] net: stmmac: dwmac-sun8i: Limit the MTU to 2018
Author: Nicolai Buchwitz
Date: Sun, 22 Nov 2026 16:40
Date: Sun, 22 Nov 2026 16:40
28 lines
9703 bytes
9703 bytes
On 22.11.2026 17:36, Maxime Chevallier wrote: > [...] >> The sun8i EMAC isn't a Synopsys core, so this needs a test on one. > > It's likely a synopsys core, but with some wrapper around the register > accesses, > hard to tell how much of the actual dwmac is in there ._. Someone really needs to draw fancy cheat sheet with a stmmac family tree - lots of weird uncles and stepmothers :-) > >> Maxime, could you try MTU 2019-2021 on your boards? > > It'll be tested in the nightly runs, I've setup some local MTU sweep > tests > following the previous version of that patch :) Thanks! > > wonder what else will come out of it, I'll report in the morning. > > Maxime Nicolai
Re: [PATCH net v2 2/2] net: stmmac: dwmac-sun8i: Limit the MTU to 2018
Author: Andrew Lunn
Date: Sun, 22 Nov 2026 18:56
Date: Sun, 22 Nov 2026 18:56
25 lines
9867 bytes
9867 bytes
> The STM32F4 reference manuals has this note: > > Even when the start address of a receive buffer is not aligned to the > system databus width > the system should allocate a receive buffer of a size aligned to the > system bus width. For > example, if the system allocates a 1024 byte (1 KB) receive buffer > starting from address > 0x1000, the software can program the buffer start address in the > receive descriptor to have > a 0x1002 offset. The receive DMA writes the frame to this buffer with > dummy data in the first > two locations (0x1000 and 0x1001). The actual frame is written from > location 0x1002. > So for normal descriptors the buffer size is bound to (2KB - bus width). There is a second use for this, unrelated to bus width. The ethernet header is 14 bytes in size, 2x 6 octet MAC address plus a 2 octet ethertype header. By offsetting the start address by two, it means the data after the ethernet header is then 4 byte aligned, making it more efficient to access fields in the IP, TCP UDP headers etc. Andrew
Re: [PATCH net v2 2/2] net: stmmac: dwmac-sun8i: Limit the MTU to 2018
Author: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 10:06
Date: Mon, 23 Nov 2026 10:06
137 lines
13647 bytes
13647 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The patch hard-codes a 2044-byte limit as an MTU cap in one
glue driver.
- [Low] The commit message and the code do not cover the same hardware.
- [Low] The 2044-byte fill limit was measured on the H616, an arm64 SoC
where NET_IP_ALIGN is 0 (arch/arm64/include/asm/processor.h:17).
--
net: stmmac: dwmac-sun8i: Limit the MTU to 2018
This commit caps the maximum MTU of the dwmac-sun8i glue driver by setting
plat_dat->maxmtu in sun8i_dwmac_probe(). The cap makes a frame with two
VLAN tags and the FCS fit in 2044 bytes. According to the commit message,
the H616 RX DMA fills only 2044 bytes of a buffer.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 2ece7ba9dd73b..ec401cae8187b 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -1208,6 +1208,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
> plat_dat->mac_setup = sun8i_dwmac_setup;
> plat_dat->tx_fifo_size = 4096;
> plat_dat->rx_fifo_size = 16384;
> + plat_dat->maxmtu = 2044 - ETH_HLEN - 2 * VLAN_HLEN - ETH_FCS_LEN;
[Severity: Low]
The commit message says:
The H616 RX DMA fills only 2044 bytes of a buffer, so frames of 2045 to
2047 bytes, allowed by the previous patch, are dropped.
This assignment in sun8i_dwmac_probe() does not check gmac->variant. So
it applies to every entry in sun8i_dwmac_match[]:
allwinner,sun8i-h3-emac
allwinner,sun8i-v3s-emac
allwinner,sun8i-a83t-emac
allwinner,sun8i-r40-gmac
allwinner,sun50i-a64-emac
allwinner,sun50i-h6-emac
allwinner,sun50i-h616-emac1
H616 EMAC0 is covered too, through the a64-emac fallback. On all of these
max_mtu drops from 2021 to 2018.
Has the 2044 byte limit been seen on the non-H616 parts as well? If it
belongs to the whole sun8i EMAC IP, could the commit message say so? If
not, should the cap be per variant, for example kept in struct
emac_variant?
The Fixes: tag points to 9f93ac8d4085 ("net-next: stmmac: Add
dwmac-sun8i"). That commit added H3/A83T/A64 support, and H616 was not
supported at the time. Doesn't the tag contradict the H616-only
explanation?
The phrase "allowed by the previous patch" also seems misleading. Before
"net: stmmac: Limit the MTU of normal descriptors to one buffer", max_mtu
for normal descriptors was SKB_MAX_HEAD(), about 3712. So frames of 2045
to 2047 bytes were allowed long before that patch. Once the series is
merged, "the previous patch" will also mean little to stable backporters.
[Severity: Medium]
Is 2044 really a sun8i-specific limit? It could also come from the RX
buffer size that the shared normal descriptor code programs.
drivers/net/ethernet/stmicro/stmmac/common.h states:
/* RX Buffer size must be multiple of 4/8/16 bytes */
#define BUF_SIZE_16KiB 16368
#define BUF_SIZE_8KiB 8188
But ndesc_init_rx_desc() in norm_desc.c still programs 2047:
bfsize1 = min(bfsize, BUF_SIZE_2KiB - 1);
p->des1 |= cpu_to_le32(bfsize1 & RDES1_BUFFER1_SIZE_MASK);
2047 is not a multiple of 4, and 2047 & ~3 is exactly 2044.
__stmmac_dvr_probe() also still sets this for every ndesc_ops platform:
else if (priv->hw->desc == &ndesc_ops)
ndev->max_mtu = BUF_SIZE_2KiB - 1 - ETH_HLEN - 2 * VLAN_HLEN -
ETH_FCS_LEN;
Other normal descriptor users, such as older GMAC 3.x and MAC100 cores
without enhanced descriptors, would still advertise an MTU of 2021. The
largest frames at that MTU need the out-of-spec 2047 byte buffer. If that
hardware handles an unaligned RBS1 the way the H616 does, those frames
would span descriptors and be silently discarded. On 64-bit or 128-bit
buses the aligned size would be 2040 or 2032, so the gap would be larger.
Could ndesc_init_rx_desc() program an aligned RBS1 instead, with the
ndesc max_mtu in __stmmac_dvr_probe() derived from it? That would remove
the need for the hard-coded 2044 here.
Neither the code nor the commit message explains where 2044 comes from.
[Severity: Low]
Was 2044 measured only on the arm64 H616? There NET_IP_ALIGN is 0, so
RX buffers start word-aligned at page + NET_SKB_PAD.
On the 32-bit sun8i SoCs (H3/H2+, V3s, A83T, R40), arch/arm does not
override NET_IP_ALIGN, so the default of 2 applies. stmmac_rx_offset()
includes it in the DMA buffer start:
static unsigned int stmmac_rx_offset(struct stmmac_priv *priv)
{
if (stmmac_xdp_is_enabled(priv))
return XDP_PACKET_HEADROOM + NET_IP_ALIGN;
return NET_SKB_PAD + NET_IP_ALIGN;
}
So every RX buffer on those SoCs starts 2 bytes into a 32-bit word.
Suppose the EMAC DMA rounds its fill relative to the start address and
not only the size field. Could the usable fill on the 32-bit variants
then be below 2044? Maximum-size frames at MTU 2018 would span
descriptors and be silently dropped again.
Could the commit message say which SoCs and buffer alignments the 2044
constant was checked on?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122-sun8i-emac-mtu-limit-v2-0-c4081e5b83cf%40gmail.com
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