net: guard SYS_RX_ETH_BUFFER with NET + required changes (ls1028a!) to make this happen
Subsystems (3)
cover net: guard SYS_RX_ETH_BUFFER with NET + required changes (ls1028a!) to make this happen
Adding ls1028a to the mail subject so that maybe it triggers some filter for maintainers/reviewers of those boards.
Follow-up to the NET->NET_LEGACY rename, where CONFIG_SYS_RX_ETH_BUFFER was discovered[1] to be in net/Kconfig but not guarded by NET.
Move a few things around such that we can guard this symbol by NET.
It'd be nice if someone could check patch 2 works as intended on the impacted platform(s), hence the RFC (and the ls1028a! in the mail subject).
CI passed here: https://source.denx.de/u-boot/contributors/qschulz/u-boot/-/pipelines/29934
[1] https://lore.kernel.org/u-boot/[email protected]/
---
Quentin Schulz (5):
ls1028a: only include drivers/net/fsl_enetc.h when driver is compiled
arm: ls102xa: use platform data to check Ethernet interface is not SGMII
net: tsec: make tsec_private a private structure
net: guard SYS_RX_ETH_BUFFER with NET
net: SYS_RX_ETH_BUFFER defaults to 8 when CONFIG_FSL_ENETC=y
arch/arm/cpu/armv7/ls102xa/fdt.c | 7 +++---- board/nxp/ls1028a/ls1028a.c | 2 ++ drivers/net/tsec.c | 17 +++++++++++++++++ include/net-common.h | 4 ++++ include/tsec.h | 17 ----------------- net/Kconfig | 5 +++-- 6 files changed, 29 insertions(+), 23 deletions(-)
---
base-commit: 4433253ecf2041f9362a763bb6cb79960921ac7e
change-id: 20260428-sys_rx_eth_buffer-no-net-0ac1fd2004fa
Best regards,
Signature · 1 line
Quentin Schulz <[email protected]>
RFC PATCH 1/5 ls1028a: only include drivers/net/fsl_enetc.h when driver is compiled
From: Quentin Schulz <[email protected]>
As hinted by its path, it's not really meant to be included outside of the driver itself. This header uses CONFIG_SYS_RX_ETH_BUFFER which we are trying to move under CONFIG_NET dependency. This file here can be compiled without network support so make sure this only gets included when needed.
The function from that header (fdt_fixup_enetc_mac) is already guarded by CONFIG_FSL_ENETC so simply guard the inclusion of the header the same way.
This was tested by building ls1028aqds_tfa_defconfig with CONFIG_MSCC_FELIX_SWITCH and CONFIG_FSL_ENETC disabled.
--- board/nxp/ls1028a/ls1028a.c | 2 ++ 1 file changed, 2 insertions(+)
board/nxp/ls1028a/ls1028a.c +2 -0
@@ -26,7 +26,9 @@#include <fdtdec.h> #include <miiphy.h> #include "../common/qixis.h" +#ifdef CONFIG_FSL_ENETC #include "../drivers/net/fsl_enetc.h" +#endif DECLARE_GLOBAL_DATA_PTR ;
Signature · 1 line
2.54.0
Re: [PATCH RFC next 1/5] ls1028a: only include drivers/net/fsl_enetc.h when driver is compiled
Quoted 12 lines · Quentin Schulz
ls1028a: only include
drivers/net/fsl_enetc.hwhen driver is compiledAs hinted by its path, it's not really meant to be included outside of the driver itself. This header uses
CONFIG_SYS_RX_ETH_BUFFERwhich we are trying to move underCONFIG_NETdependency. This file here can be compiled without network support so make sure this only gets included when needed.The function from that header (
fdt_fixup_enetc_mac) is already guarded byCONFIG_FSL_ENETCso simply guard the inclusion of the header the same way.
Quoted 7 lines
This was tested by building
ls1028aqds_tfa_defconfigwithCONFIG_MSCC_FELIX_SWITCHandCONFIG_FSL_ENETCdisabled.Signed-off-by Quentin Schulz <[email protected]>
board/nxp/ls1028a/ls1028a.c| 2 ++1 file changed, 2 insertions(+)
RFC PATCH 2/5 arm: ls102xa: use platform data to check Ethernet interface is not SGMII
In reply to Quentin SchulzFrom: Quentin Schulz <[email protected]>
tsec_private should, as its name suggests, be private. In the next commit, it'll be moved from a publicly available header file to the C file that requires it. ls102xa currently does not allow us to do that because it uses the structure.
The flag is actually set if the Ethernet PHY interface is SGMII in drivers/net/tsec.c, so simply replace the current check with the same check made in drivers/net/tsec.c to set the flag.
--- arch/arm/cpu/armv7/ls102xa/fdt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/arm/cpu/armv7/ls102xa/fdt.c +3 -4
@@ -16,7 +16,6 @@#ifdef CONFIG_FSL_ESDHC #include <fsl_esdhc.h> #endif -#include <tsec.h> #include <asm/arch/immap_ls102xa.h> #include <fsl_sec.h> #include <dm.h>
@@ -26,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR;void ft_fixup_enet_phy_connect_type (void *fdt) {struct udevice *dev; -struct tsec_private *priv; +struct eth_pdata *pdata;const char *enet_path, *phy_path;char enet[16 ];char phy[16 ];
@@ -45,8 +44,8 @@ void ft_fixup_enet_phy_connect_type(void *fdt)continue ; } - priv =dev_get_priv (dev); -if (priv->flags &TSEC_SGMII ) + pdata =dev_get_plat (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_SGMII )continue ; enet_path =fdt_get_alias (fdt, enet);
Signature · 1 line
2.54.0
Re: [PATCH RFC next 2/5] arm: ls102xa: use platform data to check Ethernet interface is not SGMII
Quoted 7 lines · Quentin Schulz
arm: ls102xa: use platform data to check Ethernet interface is not SGMII
tsec_privateshould, as its name suggests, be private. In the next commit, it'll be moved from a publicly available header file to the C file that requires it. ls102xa currently does not allow us to do that because it uses the structure.
Quoted 8 lines
The flag is actually set if the Ethernet PHY interface is SGMII in
drivers/net/tsec.c, so simply replace the current check with the same check made indrivers/net/tsec.cto set the flag.Signed-off-by Quentin Schulz <[email protected]>
arch/arm/cpu/armv7/ls102xa/fdt.c| 7 +++----1 file changed, 3 insertions(+), 4 deletions(-)
RFC PATCH 3/5 net: tsec: make tsec_private a private structure
In reply to Quentin SchulzFrom: Quentin Schulz <[email protected]>
Move the definition of tsec_private within the only file that makes use of it.
This adds the benefit of include/tsec.h not referencing PKTBUFSRX (which is set to CONFIG_SYS_RX_ETH_BUFFER, which we're trying to move to be under CONFIG_NET dependency) anymore. Considering drivers/net/tsec.c is only built if CONFIG_NET=y, this is fine.
--- drivers/net/tsec.c | 17 +++++++++++++++++ include/tsec.h | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-)
drivers/net/tsec.c +17 -0
@@ -37,6 +37,23 @@ )#endif /* CFG_TSEC_TBICR_SETTINGS */ +struct tsec_private { +struct txbd8 __iomem txbd[TX_BUF_CNT ]; +struct rxbd8 __iomem rxbd[PKTBUFSRX ]; +struct tsec __iomem *regs; +struct tsec_mii_mng __iomem *phyregs_sgmii; +struct phy_device *phydev; +phy_interface_t interface; +struct mii_dev *bus; +uint phyaddr; +uint tbiaddr; +char mii_devname[16 ]; +u32 flags; +uint rx_idx;/* index of the current RX buffer */ +uint tx_idx;/* index of the current TX buffer */ +struct udevice *dev; +}; +/* Configure the TBI for SGMII operation */ static void tsec_configure_serdes (struct tsec_private *priv) {
include/tsec.h +0 -17
@@ -350,23 +350,6 @@ struct tsec_data {u32 mdio_regs_off; }; -struct tsec_private { -struct txbd8 __iomem txbd[TX_BUF_CNT ]; -struct rxbd8 __iomem rxbd[PKTBUFSRX ]; -struct tsec __iomem *regs; -struct tsec_mii_mng __iomem *phyregs_sgmii; -struct phy_device *phydev; -phy_interface_t interface; -struct mii_dev *bus; -uint phyaddr; -uint tbiaddr; -char mii_devname[16 ]; -u32 flags; -uint rx_idx;/* index of the current RX buffer */ -uint tx_idx;/* index of the current TX buffer */ -struct udevice *dev; -}; -struct tsec_info_struct {struct tsec __iomem *regs;struct tsec_mii_mng __iomem *miiregs_sgmii;
Signature · 1 line
2.54.0
Re: [PATCH RFC next 3/5] net: tsec: make tsec_private a private structure
Quoted 10 lines · Quentin Schulz
net: tsec: make
tsec_privatea private structureMove the definition of
tsec_privatewithin the only file that makes use of it.This adds the benefit of
include/tsec.hnot referencing PKTBUFSRX (which is set toCONFIG_SYS_RX_ETH_BUFFER, which we're trying to move to be underCONFIG_NETdependency) anymore. Consideringdrivers/net/tsec.cis only built ifCONFIG_NET=y, this is fine.
Quoted 5 lines
Signed-off-by Quentin Schulz <[email protected]>
drivers/net/tsec.c| 17 +++++++++++++++++include/tsec.h | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-)
RFC PATCH 4/5 net: guard SYS_RX_ETH_BUFFER with NET
In reply to Quentin SchulzFrom: Quentin Schulz <[email protected]>
SYS_RX_ETH_BUFFER represents the number of Ethernet receive packet buffers. It therefore doesn't make sense it's reachable if NET isn't enabled.
Direct users of SYS_RX_ETH_BUFFER are:
- drivers/net/rtl8169.c, only compiled if CONFIG_RTL8169=y, depends on CONFIG_NETDEVICES=y, depends on CONFIG_NET=y,
- drivers/net/fsl_enetc.h, via ENETC_BD_CNT, included in
drivers/net/{fsl_enetc.c,fsl_enetc_mdio.c,mscc_eswitch/felix_switch.c} First two only compiled if CONFIG_FSL_ENETC=y, latter with CONFIG_MSCC_FELIX_SWITCH=y. Both symbols depends on CONFIG_NETDEVICES=y, depends on CONFIG_NET=y.
- include/net-common.h via PKTBUFSRX,
Indirect users via PKTBUFSRX:
- arch/sandbox/include/asm/eth.h
- according to ./tools/qconfig.py -l -f CONFIG_SANDBOX CONFIG_NO_NET, all sandbox defconfigs have network enabled so ignore this for now,
- drivers/dma/ti/k3-udma.c
- sets UDMA_RX_DESC_NUM to that if defined, else 4. PKTBUFSRX is CONFIG_SYS_RX_ETH_BUFFER which defaults to 4. According to ./tools/qconfig.py -l -f CONFIG_TI_K3_NAVSS_UDMA '~CONFIG_SYS_RX_ETH_BUFFER=4' no defconfig enabling this DMA driver sets CONFIG_SYS_RX_ETH_BUFFER to anything but the default of 4, so regardless of NET being built UDMA_RX_DESC_NUM will always be 4 with current defconfigs.
- drivers/net/{airoha_eth.c,bcm6348-eth.c,bcm6368-eth.c,cortina_ni.c,
dc2114x.c,eepro100.c,essedma.c,ethoc.c,ftgmac100.c,ftmac100.c, hifemac.c,mcffec.c,mpc8xx_fec.c,pic32_eth.c,sandbox.c,sni_ave.c, sni_netsec.c,ti/am65-cpsw-nuss.c,ti/cpsw.c,ti/icssg_prueth.c, tsec.c} all depends on CONFIG_NETDEVICES=y, depends on
CONFIG_NET=y,
- net/lwip/net-lwip.c, only compiled if CONFIG_NET_LWIP=y, depends on CONFIG_NET=y,
- net/{net.c,tcp.c}, only compiled if CONFIG_NET_LEGACY=y, depends on CONFIG_NET=y,
- net/net-common.c, only compiled if CONFIG_NET=y,
- test/cmd/wget.c, only compiled if CONFIG_NET_LEGACY=y, depends on CONFIG_NET=y,
- test/image/spl_load_net.c, only compiled if CONFIG_SPL_UT_LOAD_NET=y, depends on CONFIG_SPL_ETH=y, depends on CONFIG_SPL_NET=y, depends on CONFIG_NET_LEGACY=y, depends on CONFIG_NET=y,
Indirect users via net_rx_packets[PKTBUFSRX]. This array is only externally defined in net/net-common.c which is only compiled if CONFIG_NET=y.
Users of net_rx_packets are:
- drivers/net/{airoha_eth.c,bcm6348-eth.c,bcm6368-eth.c,cortina_ni.c,
dc2114x.c,dm9000x.c,essedma.c,ethoc.c,fsl_enetc.c,ftgmac100.c,
ftmac100.c,hifemac.c,ks8851_mll.c,macb.c,mcffec.c,mpc8xx_fec.c,
mscc_eswitch/jr2_switch.c,mscc_eswitch/luton_switch.c,
mscc_eswitch/ocelot_switch.c,mscc_eswitch/serval_switch.c,
mscc_eswitch/servalt_switch.c,pic32_eth.c,sandbox-raw.c,
sandbox.c,smc911x.c,sni_ave.c,sni_netsec.c,ti/am65-cpsw-nuss.c,
ti/cpsw.c,ti/icssg_prueth.c,tsec.c,xilinx_axi_mrmac.c} all
depends on CONFIG_NETDEVICES=y, depends on CONFIG_NET=y,- drivers/usb/gadget/ether.c only built if CONFIG_$(PHASE_)USB_ETHER=y, depends on CONFIG_NET=y/CONFIG_SPL_NET=y,
- net/lwip/net-lwip.c only compiled if CONFIG_NET_LWIP=y, depends on CONFIG_NET=y,
- net/net.c, only compiled if CONFIG_NET_LEGACY=y, depends on CONFIG_NET=y,
- net/net-common.c, only compiled if CONFIG_NET=y,
--- include/net-common.h | 4 ++++ net/Kconfig | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)
include/net-common.h +4 -0
@@ -20,7 +20,9 @@* alignment in memory. * */ +#if CONFIG_IS_ENABLED (NET )#define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER +#endif #define PKTALIGN ARCH_DMA_MINALIGN/* IPv4 addresses are always 32 bits in size */
@@ -132,7 +134,9 @@ static inline void net_set_state(enum net_loop_state state) }extern int net_restart_wrap;/* Tried all network devices */ +#if CONFIG_IS_ENABLED (NET )extern uchar *net_rx_packets[PKTBUFSRX ];/* Receive packets */ +#endif extern const u8 net_bcast_ethaddr[ARP_HLEN ];/* Ethernet broadcast address */ extern struct in_addr net_ip;/* Our IP addr (0 = unknown) */ /* Indicates whether the pxe path prefix / config file was specified in dhcp option */
net/Kconfig +2 -2
@@ -279,8 +279,6 @@ config TFTP_BLOCKSIZE almost-MTU block sizes. You can also activate CONFIG_IP_DEFRAG to set a larger block. -endif # if NET - config SYS_RX_ETH_BUFFER int "Number of receive packet buffers" default 4
@@ -289,3 +287,5 @@ config SYS_RX_ETH_BUFFER controllers it is recommended to set this value to 8 or even higher, since all buffers can be full shortly after enabling the interface on high Ethernet traffic. + +endif # if NET
Signature · 1 line
2.54.0
Re: [PATCH RFC next 4/5] net: guard SYS_RX_ETH_BUFFER with NET
Quoted 22 lines · Quentin Schulz
net: guard
SYS_RX_ETH_BUFFERwith NET
SYS_RX_ETH_BUFFERrepresents the number of Ethernet receive packet buffers. It therefore doesn't make sense it's reachable if NET isn't enabled.Direct users of
SYS_RX_ETH_BUFFERare:
-drivers/net/rtl8169.c, only compiled ifCONFIG_RTL8169=y, depends onCONFIG_NETDEVICES=y, depends onCONFIG_NET=y,
-drivers/net/fsl_enetc.h, viaENETC_BD_CNT, included indrivers/net/{fsl_enetc.c,fsl_enetc_mdio.c,mscc_eswitch/felix_switch.c}First two only compiled if
CONFIG_FSL_ENETC=y, latter withCONFIG_MSCC_FELIX_SWITCH=y. Both symbols depends onCONFIG_NETDEVICES=y, depends onCONFIG_NET=y.
-include/net-common.hvia PKTBUFSRX,Indirect users via PKTBUFSRX:
-arch/sandbox/include/asm/eth.h
- according to./tools/qconfig.py-l -fCONFIG_SANDBOXCONFIG_NO_NET, all sandbox defconfigs have network enabled so ignore this for now,
[...]
Quoted 3 lines
include/net-common.h| 4 ++++net/Kconfig | 4 ++++ 2 files changed, 8 insertions(+)
RFC PATCH 5/5 net: SYS_RX_ETH_BUFFER defaults to 8 when CONFIG_FSL_ENETC=y
In reply to Quentin SchulzFrom: Quentin Schulz <[email protected]>
drivers/net/fsl_enetc.h specifies ENETC_BD_CNT "buffer descriptors count must be a multiple of 8". This constant is set to CONFIG_SYS_RX_ETH_BUFFER which defaults to 4.
All defconfigs enabling CONFIG_FSL_ENETC fortunately have it set to 8, according to./tools/qconfig.py -l -f CONFIG_FSL_ENETC '~CONFIG_SYS_RX_ETH_BUFFER=8'.
Let's make sure the default is sane by having it set to 8 when this driver is enabled. Note that originally[1] it was said EEPRO100 and 405 EMAC should be 8 or higher. 405 (PPC405?) support seems to have been dropped in commit b5e7c84f72ee ("ppc4xx: remove ASH405 board"), 11 years ago. Maybe there's something we can do for EEPRO100 though?
[1] commit 53cf9435ccf9 ("- CFG_RX_ETH_BUFFER added.")
--- net/Kconfig | 1 + 1 file changed, 1 insertion(+)
net/Kconfig +1 -0
@@ -281,6 +281,7 @@ config TFTP_BLOCKSIZE config SYS_RX_ETH_BUFFER int "Number of receive packet buffers" + default 8 if FSL_ENETC default 4 help Defines the number of Ethernet receive buffers. On some Ethernet
Signature · 1 line
2.54.0
Re: [PATCH RFC next 5/5] net: SYS_RX_ETH_BUFFER defaults to 8 when CONFIG_FSL_ENETC=y
Hi Quentin,
Quoted 24 lines · Quentin Schulz
net:
SYS_RX_ETH_BUFFERdefaults to 8 whenCONFIG_FSL_ENETC=y
drivers/net/fsl_enetc.hspecifiesENETC_BD_CNT"buffer descriptors count must be a multiple of 8". This constant is set toCONFIG_SYS_RX_ETH_BUFFERwhich defaults to 4.All defconfigs enabling
CONFIG_FSL_ENETCfortunately have it set to 8, according to./tools/qconfig.py-l -fCONFIG_FSL_ENETC'~CONFIG_SYS_RX_ETH_BUFFER=8'.Let's make sure the default is sane by having it set to 8 when this driver is enabled. Note that originally[1] it was said EEPRO100 and 405 EMAC should be 8 or higher. 405 (PPC405?) support seems to have been dropped in commit
b5e7c84f72ee("ppc4xx: remove ASH405 board"), 11 years ago. Maybe there's something we can do for EEPRO100 though?[1] commit
53cf9435ccf9("-CFG_RX_ETH_BUFFERadded.")Signed-off-by Quentin Schulz <[email protected]>net/Kconfig | 1 +
1 file changed, 1 insertion(+)
net/Kconfig if NET · line 254
Quoted 5 lines
net/Kconfig +1
-0@@ -250,6 +250,7 @@ if NET config SYS_RX_ETH_BUFFER int "Number of receive packet buffers" + default 8 if FSL_ENETC default 4
Maybe convert the spaces here to tab?
Also suggest a note in the help text mentioning that FSL_ENETC needs ENETC_BD_CNT to be a multiple of 8.
Regards,
Simon