net: fec: add rx_frame_size to support configurable RX length

Add a new rx_frame_size member in the fec_enet_private structure to
track the RX buffer size. On the Jumbo frame enabled system, the value
will be recalculated whenever the MTU is updated, allowing the driver
to allocate RX buffer efficiently.

Configure the TRUNC_FL (Frame Truncation Length) based on the smaller
value between max_buf_size and the rx_frame_size to maintain consistent
RX error behavior, regardless of whether Jumbo frames are enabled.

Reviewed-by: Wei Fang <wei.fang@nxp.com>
Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
Link: https://patch.msgid.link/20250910185211.721341-5-shenwei.wang@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Shenwei Wang 2025-09-10 13:52:09 -05:00 committed by Jakub Kicinski
parent 62b5bb7be7
commit 5b14ed3ac5
2 changed files with 3 additions and 1 deletions

View File

@ -621,6 +621,7 @@ struct fec_enet_private {
unsigned int total_rx_ring_size;
unsigned int max_buf_size;
unsigned int pagepool_order;
unsigned int rx_frame_size;
struct platform_device *pdev;

View File

@ -1194,7 +1194,7 @@ fec_restart(struct net_device *ndev)
else
val &= ~FEC_RACC_OPTIONS;
writel(val, fep->hwp + FEC_RACC);
writel(fep->max_buf_size, fep->hwp + FEC_FTRL);
writel(min(fep->rx_frame_size, fep->max_buf_size), fep->hwp + FEC_FTRL);
}
#endif
@ -4565,6 +4565,7 @@ fec_probe(struct platform_device *pdev)
pinctrl_pm_select_sleep_state(&pdev->dev);
fep->pagepool_order = 0;
fep->rx_frame_size = FEC_ENET_RX_FRSIZE;
fep->max_buf_size = PKT_MAXBUF_SIZE;
ndev->max_mtu = fep->max_buf_size - ETH_HLEN - ETH_FCS_LEN;