[PATCH RFC next 4/5] net: guard SYS_RX_ETH_BUFFER with NET

Quentin Schulz foss+uboot at 0leil.net
Wed Apr 29 12:35:04 CEST 2026


From: Quentin Schulz <quentin.schulz at cherry.de>

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,

Signed-off-by: Quentin Schulz <quentin.schulz at cherry.de>
---
 include/net-common.h | 4 ++++
 net/Kconfig          | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/net-common.h b/include/net-common.h
index 69b6316c1ec..0c260873c2c 100644
--- a/include/net-common.h
+++ b/include/net-common.h
@@ -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 */
diff --git a/net/Kconfig b/net/Kconfig
index e712a0dd2ac..171a88f8ed2 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -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

-- 
2.54.0



More information about the U-Boot mailing list