mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 12:21:22 -05:00
net: fec: use a member variable for maximum buffer size
Refactor code to support Jumbo frame functionality by adding a member variable in the fec_enet_private structure to store PKT_MAXBUF_SIZE. Remove the OPT_FRAME_SIZE and define a new macro OPT_ARCH_HAS_MAX_FL to indicate architectures that support configurable maximum frame length. And update the MAX_FL register value to max_buf_size when OPT_ARCH_HAS_MAX_FL is defined as 1. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Wei Fang <wei.fang@nxp.com> Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com> Link: https://patch.msgid.link/20250910185211.721341-2-shenwei.wang@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
d586676a27
commit
ec2a1681ed
@@ -619,6 +619,7 @@ struct fec_enet_private {
|
||||
|
||||
unsigned int total_tx_ring_size;
|
||||
unsigned int total_rx_ring_size;
|
||||
unsigned int max_buf_size;
|
||||
|
||||
struct platform_device *pdev;
|
||||
|
||||
|
||||
@@ -253,9 +253,9 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");
|
||||
#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
|
||||
defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARM) || \
|
||||
defined(CONFIG_ARM64)
|
||||
#define OPT_FRAME_SIZE (PKT_MAXBUF_SIZE << 16)
|
||||
#define OPT_ARCH_HAS_MAX_FL 1
|
||||
#else
|
||||
#define OPT_FRAME_SIZE 0
|
||||
#define OPT_ARCH_HAS_MAX_FL 0
|
||||
#endif
|
||||
|
||||
/* FEC MII MMFR bits definition */
|
||||
@@ -1083,7 +1083,7 @@ static void fec_enet_enable_ring(struct net_device *ndev)
|
||||
for (i = 0; i < fep->num_rx_queues; i++) {
|
||||
rxq = fep->rx_queue[i];
|
||||
writel(rxq->bd.dma, fep->hwp + FEC_R_DES_START(i));
|
||||
writel(PKT_MAXBUF_SIZE, fep->hwp + FEC_R_BUFF_SIZE(i));
|
||||
writel(fep->max_buf_size, fep->hwp + FEC_R_BUFF_SIZE(i));
|
||||
|
||||
/* enable DMA1/2 */
|
||||
if (i)
|
||||
@@ -1145,8 +1145,11 @@ static void
|
||||
fec_restart(struct net_device *ndev)
|
||||
{
|
||||
struct fec_enet_private *fep = netdev_priv(ndev);
|
||||
u32 rcntl = OPT_FRAME_SIZE | FEC_RCR_MII;
|
||||
u32 ecntl = FEC_ECR_ETHEREN;
|
||||
u32 rcntl = FEC_RCR_MII;
|
||||
|
||||
if (OPT_ARCH_HAS_MAX_FL)
|
||||
rcntl |= fep->max_buf_size << 16;
|
||||
|
||||
if (fep->bufdesc_ex)
|
||||
fec_ptp_save_state(fep);
|
||||
@@ -1191,7 +1194,7 @@ fec_restart(struct net_device *ndev)
|
||||
else
|
||||
val &= ~FEC_RACC_OPTIONS;
|
||||
writel(val, fep->hwp + FEC_RACC);
|
||||
writel(PKT_MAXBUF_SIZE, fep->hwp + FEC_FTRL);
|
||||
writel(fep->max_buf_size, fep->hwp + FEC_FTRL);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4560,7 +4563,8 @@ fec_probe(struct platform_device *pdev)
|
||||
fec_enet_clk_enable(ndev, false);
|
||||
pinctrl_pm_select_sleep_state(&pdev->dev);
|
||||
|
||||
ndev->max_mtu = PKT_MAXBUF_SIZE - ETH_HLEN - ETH_FCS_LEN;
|
||||
fep->max_buf_size = PKT_MAXBUF_SIZE;
|
||||
ndev->max_mtu = fep->max_buf_size - ETH_HLEN - ETH_FCS_LEN;
|
||||
|
||||
ret = register_netdev(ndev);
|
||||
if (ret)
|
||||
|
||||
Reference in New Issue
Block a user