Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: fec: account for VLAN header in frame length calculations

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>
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>

authored by

Clemens Gruber and committed by
Paolo Abeni
ca1bb3fe cc4816bd

+7 -6
+7 -6
drivers/net/ethernet/freescale/fec_main.c
··· 1150 1150 u32 rcntl = FEC_RCR_MII; 1151 1151 1152 1152 if (OPT_ARCH_HAS_MAX_FL) 1153 - rcntl |= (fep->netdev->mtu + ETH_HLEN + ETH_FCS_LEN) << 16; 1153 + rcntl |= (fep->netdev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN) << 16; 1154 1154 1155 1155 if (fep->bufdesc_ex) 1156 1156 fec_ptp_save_state(fep); ··· 1285 1285 1286 1286 /* When Jumbo Frame is enabled, the FIFO may not be large enough 1287 1287 * to hold an entire frame. In such cases, if the MTU exceeds 1288 - * (PKT_MAXBUF_SIZE - ETH_HLEN - ETH_FCS_LEN), configure the interface 1289 - * to operate in cut-through mode, triggered by the FIFO threshold. 1288 + * (PKT_MAXBUF_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN), configure 1289 + * the interface to operate in cut-through mode, triggered by 1290 + * the FIFO threshold. 1290 1291 * Otherwise, enable the ENET store-and-forward mode. 1291 1292 */ 1292 1293 if ((fep->quirks & FEC_QUIRK_JUMBO_FRAME) && 1293 - (ndev->mtu > (PKT_MAXBUF_SIZE - ETH_HLEN - ETH_FCS_LEN))) 1294 + (ndev->mtu > (PKT_MAXBUF_SIZE - VLAN_ETH_HLEN - ETH_FCS_LEN))) 1294 1295 writel(0xF, fep->hwp + FEC_X_WMRK); 1295 1296 else 1296 1297 writel(FEC_TXWMRK_STRFWD, fep->hwp + FEC_X_WMRK); ··· 4038 4037 if (netif_running(ndev)) 4039 4038 return -EBUSY; 4040 4039 4041 - order = get_order(new_mtu + ETH_HLEN + ETH_FCS_LEN 4040 + order = get_order(new_mtu + VLAN_ETH_HLEN + ETH_FCS_LEN 4042 4041 + FEC_DRV_RESERVE_SPACE); 4043 4042 fep->rx_frame_size = (PAGE_SIZE << order) - FEC_DRV_RESERVE_SPACE; 4044 4043 fep->pagepool_order = order; ··· 4589 4588 else 4590 4589 fep->max_buf_size = PKT_MAXBUF_SIZE; 4591 4590 4592 - ndev->max_mtu = fep->max_buf_size - ETH_HLEN - ETH_FCS_LEN; 4591 + ndev->max_mtu = fep->max_buf_size - VLAN_ETH_HLEN - ETH_FCS_LEN; 4593 4592 4594 4593 ret = register_netdev(ndev); 4595 4594 if (ret)