Skip to content

Commit 326470b

Browse files
clemensggregkh
authored andcommitted
net: fec: account for VLAN header in frame length calculations
commit ca1bb3f upstream. 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: 62b5bb7 ("net: fec: update MAX_FL based on the current MTU") Fixes: d466c16 ("net: fec: enable the Jumbo frame support for i.MX8QM") Fixes: 59e9bf0 ("net: fec: add change_mtu to support dynamic buffer allocation") Fixes: ec2a168 ("net: fec: use a member variable for maximum buffer size") Signed-off-by: Clemens Gruber <mail@clemensgruber.at> Reviewed-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260121083751.66997-1-mail@clemensgruber.at Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 03faa61 commit 326470b

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ fec_restart(struct net_device *ndev)
11511151
u32 rcntl = FEC_RCR_MII;
11521152

11531153
if (OPT_ARCH_HAS_MAX_FL)
1154-
rcntl |= (fep->netdev->mtu + ETH_HLEN + ETH_FCS_LEN) << 16;
1154+
rcntl |= (fep->netdev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN) << 16;
11551155

11561156
if (fep->bufdesc_ex)
11571157
fec_ptp_save_state(fep);
@@ -1286,12 +1286,13 @@ fec_restart(struct net_device *ndev)
12861286

12871287
/* When Jumbo Frame is enabled, the FIFO may not be large enough
12881288
* to hold an entire frame. In such cases, if the MTU exceeds
1289-
* (PKT_MAXBUF_SIZE - ETH_HLEN - ETH_FCS_LEN), configure the interface
1290-
* to operate in cut-through mode, triggered by the FIFO threshold.
1289+
* (PKT_MAXBUF_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN), configure
1290+
* the interface to operate in cut-through mode, triggered by
1291+
* the FIFO threshold.
12911292
* Otherwise, enable the ENET store-and-forward mode.
12921293
*/
12931294
if ((fep->quirks & FEC_QUIRK_JUMBO_FRAME) &&
1294-
(ndev->mtu > (PKT_MAXBUF_SIZE - ETH_HLEN - ETH_FCS_LEN)))
1295+
(ndev->mtu > (PKT_MAXBUF_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN)))
12951296
writel(0xF, fep->hwp + FEC_X_WMRK);
12961297
else
12971298
writel(FEC_TXWMRK_STRFWD, fep->hwp + FEC_X_WMRK);
@@ -4052,7 +4053,7 @@ static int fec_change_mtu(struct net_device *ndev, int new_mtu)
40524053
if (netif_running(ndev))
40534054
return -EBUSY;
40544055

4055-
order = get_order(new_mtu + ETH_HLEN + ETH_FCS_LEN
4056+
order = get_order(new_mtu + VLAN_ETH_HLEN + ETH_FCS_LEN
40564057
+ FEC_DRV_RESERVE_SPACE);
40574058
fep->rx_frame_size = (PAGE_SIZE << order) - FEC_DRV_RESERVE_SPACE;
40584059
fep->pagepool_order = order;
@@ -4609,7 +4610,7 @@ fec_probe(struct platform_device *pdev)
46094610
else
46104611
fep->max_buf_size = PKT_MAXBUF_SIZE;
46114612

4612-
ndev->max_mtu = fep->max_buf_size - ETH_HLEN - ETH_FCS_LEN;
4613+
ndev->max_mtu = fep->max_buf_size - VLAN_ETH_HLEN - ETH_FCS_LEN;
46134614

46144615
ret = register_netdev(ndev);
46154616
if (ret)

0 commit comments

Comments
 (0)