
Add small net fixes prior lwip patch.
CI for this patch set: https://dev.azure.com/u-boot/u-boot/_build/results?buildId=7460&view=res...
Maxim Uvarov (9): test_net: print out net list net: sandbox: fix NULL pointer derefences net/smc911x: fix return from smc911x_send sandbox: eth-raw-os: successful return code is 0 driver/net/rtl8139: remove debug print mach-socfpga: do not overlap defines with lwip bcm_ns3: fix overlap define with lwip omap3: rename mem_init Makefile: add dtbs to clean
Makefile | 3 ++- arch/arm/include/asm/arch-omap3/mem.h | 2 +- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-omap2/omap3/emif4.c | 4 ++-- arch/arm/mach-omap2/omap3/sdrc.c | 6 +++--- arch/arm/mach-socfpga/include/mach/handoff_soc64.h | 6 ------ arch/arm/mach-socfpga/wrap_handoff_soc64.c | 9 +++++++++ arch/sandbox/cpu/eth-raw-os.c | 2 +- drivers/net/rtl8139.c | 2 +- drivers/net/sandbox.c | 3 +++ drivers/net/smc911x.c | 2 +- include/configs/bcm_ns3.h | 6 +++--- test/py/tests/test_net.py | 2 ++ 13 files changed, 29 insertions(+), 20 deletions(-)

Printing net list is useful in CI log files.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- test/py/tests/test_net.py | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py index b2241ae6a4..cd5b791a6a 100644 --- a/test/py/tests/test_net.py +++ b/test/py/tests/test_net.py @@ -96,6 +96,8 @@ def test_net_pre_commands(u_boot_console): if init_pci: u_boot_console.run_command('pci enum')
+ u_boot_console.run_command('net list') + @pytest.mark.buildconfigspec('cmd_dhcp') def test_net_dhcp(u_boot_console): """Test the dhcp command.

Add additional checks for NULL pointers.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- drivers/net/sandbox.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c index 13022addb6..d91935e032 100644 --- a/drivers/net/sandbox.c +++ b/drivers/net/sandbox.c @@ -65,6 +65,9 @@ int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet, struct ethernet_hdr *eth_recv; struct arp_hdr *arp_recv;
+ if (!priv) + return -EAGAIN; + if (ntohs(eth->et_protlen) != PROT_ARP) return -EAGAIN;

return value of smc911x_send is ignored, but on sucesseful send we need return 0 and or error -ETIMEOUT, not opposite.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org Reviewed-by: Tom Rini trini@konsulko.com --- drivers/net/smc911x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 5c5ad8b84a..616b7ce174 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -403,7 +403,7 @@ static int smc911x_send(struct udevice *dev, void *packet, int length)
ret = smc911x_send_common(priv, packet, length);
- return ret ? 0 : -ETIMEDOUT; + return ret ? -ETIMEDOUT : 0; }
static int smc911x_recv(struct udevice *dev, int flags, uchar **packetp)

all network drivers return 0 on the successful transmission.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org Reviewed-by: Simon Glass sjg@chromium.org --- arch/sandbox/cpu/eth-raw-os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c index e59b96be5f..92c35aed95 100644 --- a/arch/sandbox/cpu/eth-raw-os.c +++ b/arch/sandbox/cpu/eth-raw-os.c @@ -256,7 +256,7 @@ int sandbox_eth_raw_os_send(void *packet, int length, strerror(errno)); return -errno; } - return retval; + return 0; }
int sandbox_eth_raw_os_recv(void *packet, int *length,

debug print delays reset of the driver. Finally I see bunch of "rx error FFFF" errors in the screen. CI can not handle many prints. While network works fine there
Reproduced with: make CROSS_COMPILE=sh2-linux- r2dplus_defconfig all qemu-system-sh4 -M r2d -nographic -serial null \ -serial mon:stdio -net user,tftp=`pwd` \ -net nic,model=rtl8139 -kernel ./u-boot.bin
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- drivers/net/rtl8139.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index 106bc1c7ae..d8f24ec81a 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -453,7 +453,7 @@ static int rtl8139_recv_common(struct rtl8139_priv *priv, unsigned char *rxdata, RTL_STS_RXBADALIGN)) || (rx_size < ETH_ZLEN) || (rx_size > ETH_FRAME_LEN + 4)) { - printf("rx error %hX\n", rx_status); + debug("rx error %hX\n", rx_status); /* this clears all interrupts still pending */ rtl8139_reset(priv); return 0;

Fix compilation issue with overlapping lwip and march defines.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- arch/arm/mach-socfpga/include/mach/handoff_soc64.h | 6 ------ arch/arm/mach-socfpga/wrap_handoff_soc64.c | 9 +++++++++ 2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/arm/mach-socfpga/include/mach/handoff_soc64.h b/arch/arm/mach-socfpga/include/mach/handoff_soc64.h index 902fc6bfb5..9b85e5865b 100644 --- a/arch/arm/mach-socfpga/include/mach/handoff_soc64.h +++ b/arch/arm/mach-socfpga/include/mach/handoff_soc64.h @@ -78,12 +78,6 @@
#ifndef __ASSEMBLY__ #include <asm/types.h> -enum endianness { - LITTLE_ENDIAN = 0, - BIG_ENDIAN, - UNKNOWN_ENDIANNESS -}; - int socfpga_get_handoff_size(void *handoff_address); int socfpga_handoff_read(void *handoff_address, void *table, u32 table_len); #endif diff --git a/arch/arm/mach-socfpga/wrap_handoff_soc64.c b/arch/arm/mach-socfpga/wrap_handoff_soc64.c index e7cb5ea89c..df0701ec85 100644 --- a/arch/arm/mach-socfpga/wrap_handoff_soc64.c +++ b/arch/arm/mach-socfpga/wrap_handoff_soc64.c @@ -10,6 +10,15 @@ #include <errno.h> #include "log.h"
+#ifndef __ASSEMBLY__ +#include <asm/types.h> +enum endianness { + LITTLE_ENDIAN = 0, + BIG_ENDIAN, + UNKNOWN_ENDIANNESS +}; +#endif + static enum endianness check_endianness(u32 handoff) { switch (handoff) {

Rename declaration to not overlap with lwip.
aarch64: + bcm_ns3 +In file included from net/lwip/lwip-external/src/include/lwip/etharp.h:53, + from net/lwip/lwip-external/src/core/init.c:55: +net/lwip/lwip-external/src/include/lwip/prot/ethernet.h:69: error: "ETH_ADDR" redefined [-Werror] + 69 | #define ETH_ADDR(b0, b1, b2, b3, b4, b5) {{b0, b1, b2, b3, b4, b5}} + | +In file included from include/config.h:3, + from arch/arm/include/asm/string.h:4, + from include/linux/string.h:21, + from include/malloc.h:369, + from include/stdlib.h:9, + from net/lwip/lwip-external/src/include/lwip/arch.h:83, + from net/lwip/lwip-external/src/include/lwip/debug.h:40, + from net/lwip/lwipopts.h:93, + from net/lwip/lwip-external/src/include/lwip/opt.h:51, + from net/lwip/lwip-external/src/core/init.c:38: +include/configs/bcm_ns3.h:52: note: this is the location of the previous definition + 52 | #define ETH_ADDR
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org Reviewed-by: Tom Rini trini@konsulko.com --- include/configs/bcm_ns3.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/configs/bcm_ns3.h b/include/configs/bcm_ns3.h index 47de4bc201..7c6e0725a6 100644 --- a/include/configs/bcm_ns3.h +++ b/include/configs/bcm_ns3.h @@ -45,11 +45,11 @@ #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
#ifdef CONFIG_BCM_SF2_ETH -#define ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0" +#define BCM_ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0" #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \ "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off" #else -#define ETH_ADDR +#define BMC_ETH_ADDR #define NET_ARGS #endif
@@ -749,7 +749,7 @@ OS_LOG_LEVEL \ EXTRA_ARGS \ PCIE_ARGS \ - ETH_ADDR \ + BMC_ETH_ADDR \ RESERVED_MEM \ SETBOOTARGS \ UPDATEME_FLASH_PARAMS \

On Tue, Dec 5, 2023 at 8:56 AM Maxim Uvarov maxim.uvarov@linaro.org wrote:
Rename declaration to not overlap with lwip.
I think the commit message can be made more generic like "Use device specific naming for variables so as to not overlap with common function names", I also don't think you need to include the compile error in the commit. Code itself looks good so:
Reviewed-by: Peter Robinson pbrobinson@gmail.com
aarch64: + bcm_ns3 +In file included from net/lwip/lwip-external/src/include/lwip/etharp.h:53,
from net/lwip/lwip-external/src/core/init.c:55:
+net/lwip/lwip-external/src/include/lwip/prot/ethernet.h:69: error: "ETH_ADDR" redefined [-Werror]
- 69 | #define ETH_ADDR(b0, b1, b2, b3, b4, b5) {{b0, b1, b2, b3, b4, b5}}
|
+In file included from include/config.h:3,
from arch/arm/include/asm/string.h:4,
from include/linux/string.h:21,
from include/malloc.h:369,
from include/stdlib.h:9,
from net/lwip/lwip-external/src/include/lwip/arch.h:83,
from net/lwip/lwip-external/src/include/lwip/debug.h:40,
from net/lwip/lwipopts.h:93,
from net/lwip/lwip-external/src/include/lwip/opt.h:51,
from net/lwip/lwip-external/src/core/init.c:38:
+include/configs/bcm_ns3.h:52: note: this is the location of the previous definition
- 52 | #define ETH_ADDR
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org Reviewed-by: Tom Rini trini@konsulko.com
include/configs/bcm_ns3.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/configs/bcm_ns3.h b/include/configs/bcm_ns3.h index 47de4bc201..7c6e0725a6 100644 --- a/include/configs/bcm_ns3.h +++ b/include/configs/bcm_ns3.h @@ -45,11 +45,11 @@ #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
#ifdef CONFIG_BCM_SF2_ETH -#define ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0" +#define BCM_ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0" #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \ "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off" #else -#define ETH_ADDR +#define BMC_ETH_ADDR #define NET_ARGS #endif
@@ -749,7 +749,7 @@ OS_LOG_LEVEL \ EXTRA_ARGS \ PCIE_ARGS \
ETH_ADDR \
BMC_ETH_ADDR \ RESERVED_MEM \ SETBOOTARGS \ UPDATEME_FLASH_PARAMS \
-- 2.30.2

Rename mem_init to solve following compilation error with lwip integrated code: +arm-linux-gnueabi-ld.bfd: net/lwip/lwip-external/src/core/mem.o: in function `mem_init': +net/lwip/lwip-external/src/core/mem.c:162: multiple definition of `mem_init'; arch/arm/mach-omap2/omap3/sdrc.o:arch/arm/mach-omap2/omap3/ sdrc.c:240: first defined here +make[1]: *** [Makefile:1764: u-boot] Error 1 +/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/../lib/gcc/arm-linux- gnueabi/13.1.0/../../ ../../arm-linux-gnueabi/bin/ld: net/lwip/lwip-external/src/core/ mem.o (symbol from plugin): in function `mem_init': +(.text+0x0): multiple definition of `mem_init'; arch/arm/mach-omap2/ omap3/emif4.o (symbol from plugin):(.text+0x0): first defined here +collect2: error: ld returned 1 exit status +(.text+0x0): multiple definition of `mem_init'; arch/arm/mach-omap2/ omap3/sdrc.o (symbol from plugin):(.text+0x0): first defined here +Image 'simple-bin' is missing external blobs and is non-functional: tee-os +/binman/simple-bin/fit/images/op-tee/tee-os (tee-os):
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org Reviewed-by: Tom Rini trini@konsulko.com --- arch/arm/include/asm/arch-omap3/mem.h | 2 +- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-omap2/omap3/emif4.c | 4 ++-- arch/arm/mach-omap2/omap3/sdrc.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/arm/include/asm/arch-omap3/mem.h b/arch/arm/include/asm/arch-omap3/mem.h index 569779c55e..fce3568eca 100644 --- a/arch/arm/include/asm/arch-omap3/mem.h +++ b/arch/arm/include/asm/arch-omap3/mem.h @@ -475,7 +475,7 @@ enum { #ifndef __ASSEMBLY__
/* Function prototypes */ -void mem_init(void); +void omap3_mem_init(void);
u32 is_mem_sdr(void); u32 mem_ok(u32 cs); diff --git a/arch/arm/mach-omap2/omap3/board.c b/arch/arm/mach-omap2/omap3/board.c index 8b70251457..c76a95dd5d 100644 --- a/arch/arm/mach-omap2/omap3/board.c +++ b/arch/arm/mach-omap2/omap3/board.c @@ -216,7 +216,7 @@ void s_init(void) void board_init_f(ulong dummy) { early_system_init(); - mem_init(); + omap3_mem_init(); /* * Save the boot parameters passed from romcode. * We cannot delay the saving further than this, diff --git a/arch/arm/mach-omap2/omap3/emif4.c b/arch/arm/mach-omap2/omap3/emif4.c index 7e5a281922..4fbfb387ab 100644 --- a/arch/arm/mach-omap2/omap3/emif4.c +++ b/arch/arm/mach-omap2/omap3/emif4.c @@ -159,10 +159,10 @@ int dram_init_banksize(void) }
/* - * mem_init() - + * omap3_mem_init() - * - Initialize memory subsystem */ -void mem_init(void) +void omap3_mem_init(void) { do_emif4_init(); } diff --git a/arch/arm/mach-omap2/omap3/sdrc.c b/arch/arm/mach-omap2/omap3/sdrc.c index 5d43e7c9cf..f2a0769b9d 100644 --- a/arch/arm/mach-omap2/omap3/sdrc.c +++ b/arch/arm/mach-omap2/omap3/sdrc.c @@ -4,7 +4,7 @@ * * This file has been created after exctracting and consolidating * the SDRC related content from mem.c and board.c, also created - * generic init function (mem_init). + * generic init function (omap3_mem_init). * * Copyright (C) 2004-2010 * Texas Instruments Incorporated - https://www.ti.com/ @@ -232,11 +232,11 @@ int dram_init_banksize(void) }
/* - * mem_init - + * map3_mem_init - * - Init the sdrc chip, * - Selects CS0 and CS1, */ -void mem_init(void) +void omap3_mem_init(void) { /* only init up first bank here */ do_sdrc_init(CS0, EARLY_INIT);

CI test checks that generated dtb has to be cleaned up.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile index 08604ed3c7..8dd6990584 100644 --- a/Makefile +++ b/Makefile @@ -2165,7 +2165,8 @@ CLEAN_FILES += include/autoconf.mk* include/bmp_logo.h include/bmp_logo_data.h \ mkimage-out.spl.mkimage mkimage.spl.mkimage imx-boot.map \ itb.fit.fit itb.fit.itb itb.map spl.map mkimage-out.rom.mkimage \ mkimage.rom.mkimage mkimage-in-simple-bin* rom.map simple-bin* \ - idbloader-spi.img lib/efi_loader/helloworld_efi.S *.itb + idbloader-spi.img lib/efi_loader/helloworld_efi.S *.itb \ + ./*/*.dtb *.dtb
# Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include/generated spl tpl vpl \

Hi,
Do I need to resend this patchset with small comment message correction or it can be done on the apply?
Thank you, Maxim.
On Mon, 4 Dec 2023 at 18:06, Maxim Uvarov maxim.uvarov@linaro.org wrote:
Add small net fixes prior lwip patch.
CI for this patch set:
https://dev.azure.com/u-boot/u-boot/_build/results?buildId=7460&view=res...
Maxim Uvarov (9): test_net: print out net list net: sandbox: fix NULL pointer derefences net/smc911x: fix return from smc911x_send sandbox: eth-raw-os: successful return code is 0 driver/net/rtl8139: remove debug print mach-socfpga: do not overlap defines with lwip bcm_ns3: fix overlap define with lwip omap3: rename mem_init Makefile: add dtbs to clean
Makefile | 3 ++- arch/arm/include/asm/arch-omap3/mem.h | 2 +- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-omap2/omap3/emif4.c | 4 ++-- arch/arm/mach-omap2/omap3/sdrc.c | 6 +++--- arch/arm/mach-socfpga/include/mach/handoff_soc64.h | 6 ------ arch/arm/mach-socfpga/wrap_handoff_soc64.c | 9 +++++++++ arch/sandbox/cpu/eth-raw-os.c | 2 +- drivers/net/rtl8139.c | 2 +- drivers/net/sandbox.c | 3 +++ drivers/net/smc911x.c | 2 +- include/configs/bcm_ns3.h | 6 +++--- test/py/tests/test_net.py | 2 ++ 13 files changed, 29 insertions(+), 20 deletions(-)
-- 2.30.2

On Mon, Dec 18, 2023 at 09:03:47PM +0600, Maxim Uvarov wrote:
Hi,
Do I need to resend this patchset with small comment message correction or it can be done on the apply?
Yes, please v2 that patch and perhaps re-read all of the commits and see if all of the commit messages could be improved / expanded upon a little more, thanks.
participants (3)
-
Maxim Uvarov
-
Peter Robinson
-
Tom Rini