* [PATCH] net: fec: account for VLAN header in MAX_FL calculation
@ 2026-01-20 16:04 Clemens Gruber
2026-01-21 1:57 ` Wei Fang
2026-01-21 8:37 ` [PATCH v2] net: fec: account for VLAN header in frame length calculations Clemens Gruber
0 siblings, 2 replies; 6+ messages in thread
From: Clemens Gruber @ 2026-01-20 16:04 UTC (permalink / raw)
To: netdev; +Cc: Shenwei Wang, Wei Fang, Jakub Kicinski, imx, Clemens Gruber,
stable
Commit 62b5bb7be7bc ("net: fec: update MAX_FL based on the current MTU")
changed the MAX_FL (maximum frame length) calculation without accounting
for VLAN-tagged frames, leading to RX errors / dropped frames.
Add VLAN_HLEN to the MAX_FL calculation.
Fixes: 62b5bb7be7bc ("net: fec: update MAX_FL based on the current MTU")
Signed-off-by: Clemens Gruber <mail@clemensgruber.at>
Cc: stable@kernel.org
---
drivers/net/ethernet/freescale/fec_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index e2b75d1970ae..f8f88c592323 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1151,7 +1151,7 @@ fec_restart(struct net_device *ndev)
u32 rcntl = FEC_RCR_MII;
if (OPT_ARCH_HAS_MAX_FL)
- rcntl |= (fep->netdev->mtu + ETH_HLEN + ETH_FCS_LEN) << 16;
+ rcntl |= (fep->netdev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN) << 16;
if (fep->bufdesc_ex)
fec_ptp_save_state(fep);
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH] net: fec: account for VLAN header in MAX_FL calculation
2026-01-20 16:04 [PATCH] net: fec: account for VLAN header in MAX_FL calculation Clemens Gruber
@ 2026-01-21 1:57 ` Wei Fang
2026-01-21 8:37 ` [PATCH v2] net: fec: account for VLAN header in frame length calculations Clemens Gruber
1 sibling, 0 replies; 6+ messages in thread
From: Wei Fang @ 2026-01-21 1:57 UTC (permalink / raw)
To: Clemens Gruber, netdev@vger.kernel.org
Cc: Shenwei Wang, Jakub Kicinski, imx@lists.linux.dev,
stable@kernel.org
> Commit 62b5bb7be7bc ("net: fec: update MAX_FL based on the current MTU")
> changed the MAX_FL (maximum frame length) calculation without accounting
> for VLAN-tagged frames, leading to RX errors / dropped frames.
>
> Add VLAN_HLEN to the MAX_FL calculation.
>
> Fixes: 62b5bb7be7bc ("net: fec: update MAX_FL based on the current MTU")
>
> Signed-off-by: Clemens Gruber <mail@clemensgruber.at>
> Cc: stable@kernel.org
> ---
> drivers/net/ethernet/freescale/fec_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index e2b75d1970ae..f8f88c592323 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1151,7 +1151,7 @@ fec_restart(struct net_device *ndev)
> u32 rcntl = FEC_RCR_MII;
>
> if (OPT_ARCH_HAS_MAX_FL)
> - rcntl |= (fep->netdev->mtu + ETH_HLEN + ETH_FCS_LEN) <<
> 16;
> + rcntl |= (fep->netdev->mtu + ETH_HLEN + ETH_FCS_LEN +
> VLAN_HLEN) << 16;
The line is more than 80 characters after the change, so you can use
VLAN_ETH_HLEN instead of (ETH_HLEN + VLAN_HLEN).
Additionally, I believe the code in other places also needs to be modified
accordingly. See below.
fec_restart():
if ((fep->quirks & FEC_QUIRK_JUMBO_FRAME) &&
(ndev->mtu > (PKT_MAXBUF_SIZE - ETH_HLEN - ETH_FCS_LEN)))
writel(0xF, fep->hwp + FEC_X_WMRK);
fec_change_mtu():
order = get_order(new_mtu + ETH_HLEN + ETH_FCS_LEN
+ FEC_DRV_RESERVE_SPACE);
fec_probe():
ndev->max_mtu = fep->max_buf_size - ETH_HLEN - ETH_FCS_LEN;
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] net: fec: account for VLAN header in frame length calculations
2026-01-20 16:04 [PATCH] net: fec: account for VLAN header in MAX_FL calculation Clemens Gruber
2026-01-21 1:57 ` Wei Fang
@ 2026-01-21 8:37 ` Clemens Gruber
2026-01-22 6:07 ` Wei Fang
` (2 more replies)
1 sibling, 3 replies; 6+ messages in thread
From: Clemens Gruber @ 2026-01-21 8:37 UTC (permalink / raw)
To: wei.fang, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: shenwei.wang, xiaoning.wang, imx, netdev, Clemens Gruber, stable
The MAX_FL (maximum frame length) and related calculations used ETH_HLEN,
which does not account for the 4-byte VLAN tag in tagged frames. This
caused the hardware to reject valid VLAN frames as oversized, resulting
in RX errors and dropped packets.
Use VLAN_ETH_HLEN instead of ETH_HLEN in the MAX_FL register setup,
cut-through mode threshold, buffer allocation, and max_mtu calculation.
Cc: stable@kernel.org # v6.18+
Fixes: 62b5bb7be7bc ("net: fec: update MAX_FL based on the current MTU")
Fixes: d466c16026e9 ("net: fec: enable the Jumbo frame support for i.MX8QM")
Fixes: 59e9bf037d75 ("net: fec: add change_mtu to support dynamic buffer allocation")
Fixes: ec2a1681ed4f ("net: fec: use a member variable for maximum buffer size")
Signed-off-by: Clemens Gruber <mail@clemensgruber.at>
---
Changes in v2:
- Fix the other frame length calculations too
- Improved title and commit message
One line in fec_restart (after the FEC_QUIRK_JUMBO_FRAME check) has now
82 characters but I think folding it would make it less readable.
Let me know if this should be changed.
---
drivers/net/ethernet/freescale/fec_main.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index a753265961af..797ef6899657 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1150,7 +1150,7 @@ fec_restart(struct net_device *ndev)
u32 rcntl = FEC_RCR_MII;
if (OPT_ARCH_HAS_MAX_FL)
- rcntl |= (fep->netdev->mtu + ETH_HLEN + ETH_FCS_LEN) << 16;
+ rcntl |= (fep->netdev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN) << 16;
if (fep->bufdesc_ex)
fec_ptp_save_state(fep);
@@ -1285,12 +1285,13 @@ fec_restart(struct net_device *ndev)
/* When Jumbo Frame is enabled, the FIFO may not be large enough
* to hold an entire frame. In such cases, if the MTU exceeds
- * (PKT_MAXBUF_SIZE - ETH_HLEN - ETH_FCS_LEN), configure the interface
- * to operate in cut-through mode, triggered by the FIFO threshold.
+ * (PKT_MAXBUF_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN), configure
+ * the interface to operate in cut-through mode, triggered by
+ * the FIFO threshold.
* Otherwise, enable the ENET store-and-forward mode.
*/
if ((fep->quirks & FEC_QUIRK_JUMBO_FRAME) &&
- (ndev->mtu > (PKT_MAXBUF_SIZE - ETH_HLEN - ETH_FCS_LEN)))
+ (ndev->mtu > (PKT_MAXBUF_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN)))
writel(0xF, fep->hwp + FEC_X_WMRK);
else
writel(FEC_TXWMRK_STRFWD, fep->hwp + FEC_X_WMRK);
@@ -4037,7 +4038,7 @@ static int fec_change_mtu(struct net_device *ndev, int new_mtu)
if (netif_running(ndev))
return -EBUSY;
- order = get_order(new_mtu + ETH_HLEN + ETH_FCS_LEN
+ order = get_order(new_mtu + VLAN_ETH_HLEN + ETH_FCS_LEN
+ FEC_DRV_RESERVE_SPACE);
fep->rx_frame_size = (PAGE_SIZE << order) - FEC_DRV_RESERVE_SPACE;
fep->pagepool_order = order;
@@ -4588,7 +4589,7 @@ fec_probe(struct platform_device *pdev)
else
fep->max_buf_size = PKT_MAXBUF_SIZE;
- ndev->max_mtu = fep->max_buf_size - ETH_HLEN - ETH_FCS_LEN;
+ ndev->max_mtu = fep->max_buf_size - VLAN_ETH_HLEN - ETH_FCS_LEN;
ret = register_netdev(ndev);
if (ret)
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH v2] net: fec: account for VLAN header in frame length calculations
2026-01-21 8:37 ` [PATCH v2] net: fec: account for VLAN header in frame length calculations Clemens Gruber
@ 2026-01-22 6:07 ` Wei Fang
2026-01-22 12:23 ` Paolo Abeni
2026-01-22 12:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: Wei Fang @ 2026-01-22 6:07 UTC (permalink / raw)
To: Clemens Gruber
Cc: Shenwei Wang, Clark Wang, imx@lists.linux.dev,
netdev@vger.kernel.org, stable@kernel.org, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
> The MAX_FL (maximum frame length) and related calculations used
> ETH_HLEN,
> which does not account for the 4-byte VLAN tag in tagged frames. This
> caused the hardware to reject valid VLAN frames as oversized, resulting
> in RX errors and dropped packets.
>
> Use VLAN_ETH_HLEN instead of ETH_HLEN in the MAX_FL register setup,
> cut-through mode threshold, buffer allocation, and max_mtu calculation.
>
> Cc: stable@kernel.org # v6.18+
> Fixes: 62b5bb7be7bc ("net: fec: update MAX_FL based on the current MTU")
> Fixes: d466c16026e9 ("net: fec: enable the Jumbo frame support for
> i.MX8QM")
> Fixes: 59e9bf037d75 ("net: fec: add change_mtu to support dynamic buffer
> allocation")
> Fixes: ec2a1681ed4f ("net: fec: use a member variable for maximum buffer
> size")
> Signed-off-by: Clemens Gruber <mail@clemensgruber.at>
> ---
> Changes in v2:
> - Fix the other frame length calculations too
> - Improved title and commit message
>
> One line in fec_restart (after the FEC_QUIRK_JUMBO_FRAME check) has now
> 82 characters but I think folding it would make it less readable.
> Let me know if this should be changed.
> ---
Thanks, this patch looks good to me.
Reviewed-by: Wei Fang <wei.fang@nxp.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] net: fec: account for VLAN header in frame length calculations
2026-01-21 8:37 ` [PATCH v2] net: fec: account for VLAN header in frame length calculations Clemens Gruber
2026-01-22 6:07 ` Wei Fang
@ 2026-01-22 12:23 ` Paolo Abeni
2026-01-22 12:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: Paolo Abeni @ 2026-01-22 12:23 UTC (permalink / raw)
To: Clemens Gruber, wei.fang, andrew+netdev, davem, edumazet, kuba
Cc: shenwei.wang, xiaoning.wang, imx, netdev, stable
On 1/21/26 9:37 AM, Clemens Gruber wrote:
> The MAX_FL (maximum frame length) and related calculations used ETH_HLEN,
> which does not account for the 4-byte VLAN tag in tagged frames. This
> caused the hardware to reject valid VLAN frames as oversized, resulting
> in RX errors and dropped packets.
>
> Use VLAN_ETH_HLEN instead of ETH_HLEN in the MAX_FL register setup,
> cut-through mode threshold, buffer allocation, and max_mtu calculation.
>
> Cc: stable@kernel.org # v6.18+
> Fixes: 62b5bb7be7bc ("net: fec: update MAX_FL based on the current MTU")
> Fixes: d466c16026e9 ("net: fec: enable the Jumbo frame support for i.MX8QM")
> Fixes: 59e9bf037d75 ("net: fec: add change_mtu to support dynamic buffer allocation")
> Fixes: ec2a1681ed4f ("net: fec: use a member variable for maximum buffer size")
> Signed-off-by: Clemens Gruber <mail@clemensgruber.at>
A couple of things to remember for future submissions: you should
include the target tree into the subj prefix ('net' in this case) and
you should avoid sending you revision in reply to older ones as it may
foul patchwork.
No repost needed, the patch looks good, I'm applying it.
Thanks,
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] net: fec: account for VLAN header in frame length calculations
2026-01-21 8:37 ` [PATCH v2] net: fec: account for VLAN header in frame length calculations Clemens Gruber
2026-01-22 6:07 ` Wei Fang
2026-01-22 12:23 ` Paolo Abeni
@ 2026-01-22 12:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-22 12:30 UTC (permalink / raw)
To: Clemens Gruber
Cc: wei.fang, andrew+netdev, davem, edumazet, kuba, pabeni,
shenwei.wang, xiaoning.wang, imx, netdev, stable
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Wed, 21 Jan 2026 09:37:51 +0100 you wrote:
> The MAX_FL (maximum frame length) and related calculations used ETH_HLEN,
> which does not account for the 4-byte VLAN tag in tagged frames. This
> caused the hardware to reject valid VLAN frames as oversized, resulting
> in RX errors and dropped packets.
>
> Use VLAN_ETH_HLEN instead of ETH_HLEN in the MAX_FL register setup,
> cut-through mode threshold, buffer allocation, and max_mtu calculation.
>
> [...]
Here is the summary with links:
- [v2] net: fec: account for VLAN header in frame length calculations
https://git.kernel.org/netdev/net/c/ca1bb3fedf26
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-01-22 12:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-20 16:04 [PATCH] net: fec: account for VLAN header in MAX_FL calculation Clemens Gruber
2026-01-21 1:57 ` Wei Fang
2026-01-21 8:37 ` [PATCH v2] net: fec: account for VLAN header in frame length calculations Clemens Gruber
2026-01-22 6:07 ` Wei Fang
2026-01-22 12:23 ` Paolo Abeni
2026-01-22 12:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox