From patchwork Fri Aug 23 13:48:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 821723 Delivered-To: patch@linaro.org Received: by 2002:adf:e044:0:b0:367:895a:4699 with SMTP id w4csp387478wrh; Fri, 23 Aug 2024 06:52:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWZu4pG/Ti7DcYT8XQJx2pgQ9Tr/PJSG21gzGyed8KC9TuTa4PhoHghlHLHm/Xdu6SDxSf+WA==@linaro.org X-Google-Smtp-Source: AGHT+IFpcbKv4zyIEbjzqlmvVnART6eoxu0PDEbcDcLVhGhlBOrSajfkA0OsWnlDJ35iLhR8hwIK X-Received: by 2002:a5d:46cf:0:b0:371:8e85:c58e with SMTP id ffacd0b85a97d-37311863a3cmr1915970f8f.33.1724421143109; Fri, 23 Aug 2024 06:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724421143; cv=none; d=google.com; s=arc-20240605; b=WV3T7HeYbrLdGLIbF2CT9mTTpsEvxGKGW8cu3G1pIEzQRegWonBcCPd+FoxfMXoDNw 12PR1uCFIfP2luXtifadOYb59QjngrmlgssuebrdzUI9bz8OehPDQSb/9Bh8C7RvrUyK w6lPx/0j1f6n1vRkPJomEnw/zVddOiOs/pfSCD7dpzHzzTt2wf/xL5TqA2mmi7YjR0Pi JqFLbw6oMjsOis3mA1aP4FKbV4CUUCMiaZy31Vz5/sG9DXJulkjlxLrDROUlA+tEAciJ 2nS4pswlkumg2rHHJ0icdTmL5dJVv/uzb2vxnrgSxYSJ9vqOowULK5V/fgtBX/kG6V2Y Ab6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8U8R46Kw30PmmmbrNRZRFkbbU6Nd+hxBamNjuNxIY4o=; fh=2iBeGKbRpnfiwYoDz9kxT9CWEw+m0OiCA50bdHYcPvc=; b=JZu9/6dQrwe8aNqadVz5fo5/oGNQIwLtZvzxUwD49LC6R2L/T7WmzJcT9KH8Lak0BD f9BgoSxTvw5wHMsl/oVETHDalLHtpIiwnYwWhT3IJSpg8rrJNMZCXMIA8QWH2d7/TST/ cnE/Vlib2s3enLAlT+sRBpj7J9nY8hXaNxpWEFfhh0cxczR+QNvNsZa3tDbS4gmQLESD jk5RdIHnlBlL9iuvAa6Zd2SWkEgpWXeql/M4HU45i4/MQr7QO436XSUn4F+4jIFe05Xg OMYs5qikPZxsIY+QZBgxY81nQnFigXrYt9B4/4ZysSGIMfPqLimMmR9SJuAKr0CZnmfN tUOQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EcsPBLdl; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 5b1f17b1804b1-42abefe26bdsi29694725e9.176.2024.08.23.06.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 06:52:23 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EcsPBLdl; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E5F6E889D4; Fri, 23 Aug 2024 15:49:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="EcsPBLdl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A447988915; Fri, 23 Aug 2024 15:49:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1734D88A29 for ; Fri, 23 Aug 2024 15:49:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jerome.forissier@linaro.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42ab99fb45dso20771285e9.1 for ; Fri, 23 Aug 2024 06:49:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724420966; x=1725025766; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8U8R46Kw30PmmmbrNRZRFkbbU6Nd+hxBamNjuNxIY4o=; b=EcsPBLdl3VmrNGK/y9a7KaRw5LDrFiCOeOo7v+N87Z4cf7DgTg7huqWfyp56H6zw8i HqhTaUCnT7RJDDYAJn7yIffpDJdT/4l/8dtf8dN1S84RZicGKcpLF5oA+FfY2Dr7x4KM ntunYRQfjDEr1YUuUVrkNv2hp6G/ZGuJUb5AAWPt9N7dRWYcv2tryfey7UTuDVAVMky4 x/f1pdsOn322aumD+x9srjbBXmaHZqb36hbx6ZnE6P3iu/DPN94GYYGRVVjbXryWAiEK Ylxhp6Z66/5fC+zAAdix5KhQ8EAJpWUTxeJyB+cCFExinMVNR2VM1qib4KQ+7EEbXnEQ lyGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724420966; x=1725025766; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8U8R46Kw30PmmmbrNRZRFkbbU6Nd+hxBamNjuNxIY4o=; b=PHJbs5+cOWzxVl6pZLAlfCJvQZB5rr78KKC45QyZ3MhV2vmbCpa8XQx33koNLL99wd IWgMx9usyTYL5r9Iai2+gUs3v9/lHqIFGZmg16VUGWfCyfdPhw6RHDRIxoGOV/VGNFos RS5H6m1wpYQt+4yh8gNdtGrvqgLeDBQqg2OFZd2d0c1IfHuskK1FoRh2JM/wq24p/w2W paQDGqIFl3/qm7OuhytZRrQt8mO9ToQObi7HVN1fH9xbtBa9r6ZX0unnOpajsZiIe/xu EYjGHzIJqR0MfQ4opw2MmzoY1HIHXWAKRcHpuKgfe8qeeUuK+dQMY+7m+A2uqa9ITma2 QrpA== X-Gm-Message-State: AOJu0YwzQi2Ig/iEBfxWmYqeNT4m9wS6xdsgBK9Z7LjtPGFlGujpeRFN RIAIbQ3qp9ByDTFpu0LqEhCzVayCFd/UBlPF+JRA12k4YXRzPTt0Qw0ZL7ATJJBo7lexOgXsXP4 RlaPEBsex X-Received: by 2002:a5d:4604:0:b0:368:4910:8f43 with SMTP id ffacd0b85a97d-37311840913mr1909136f8f.3.1724420966177; Fri, 23 Aug 2024 06:49:26 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:e668:dc94:35c7:8064]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-373081ffb40sm4201665f8f.76.2024.08.23.06.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 06:49:25 -0700 (PDT) From: Jerome Forissier To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Javier Tia , Raymond Mao , Maxim Uvarov , Tim Harvey , Anton Antonov , Jerome Forissier , Tom Rini , Lukasz Majewski , Mattijs Korpershoek , Joe Hershberger , Ramon Fried , Marek Vasut , Simon Glass , Nathan Barrett-Morrison , Jesse Taube , Martyn Welch , Shengyu Qu , John Keeping , Jonas Karlman , Greg Malysa , Heinrich Schuchardt , Eddie James , AKASHI Takahiro , Stefan Roese , Jiaxun Yang , Jagan Teki , Rasmus Villemoes , Sean Anderson , Andre Przywara , Samuel Holland , Lukas Funke , Jaehoon Chung , Alexey Romanov , Ion Agorria , Yang Xiwen , Boon Khai Ng , Kever Yang , Neil Armstrong , Robert Marko , Nicolas Frattaroli , Miquel Raynal , Anand Moon , Baruch Siach Subject: [PATCH v9 14/37] net: introduce alternative implementation as net-lwip/ Date: Fri, 23 Aug 2024 15:48:18 +0200 Message-Id: <073e8210e2c55082d2d9866ffd5344925d9ed008.1724419624.git.jerome.forissier@linaro.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 23 Aug 2024 15:49:55 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Prepare the introduction of the lwIP (lightweight IP) TCP/IP stack by adding a new net/lwip/ directory and the NET_LWIP symbol. Network support is either NO_NET, NET (legacy stack) or NET_LWIP. Subsequent commits will introduce the lwIP code, re-work the NETDEVICE integration and port some of the NET commands and features to lwIP. SPL_NET cannot be enabled when NET_LWIP=y. SPL_NET pulls some symbols that are part of NET (such as arp_init(), arp_timeout_check(), arp_receive(), net_arp_wait_packet_ip()). lwIP support in SPL may be added later. Similarly, DFU_TFTP and FASTBOOT are not compatible with NET_LWIP because of dependencies on net_loop(), tftp_timeout_ms, tftp_timeout_count_max and other NET things. Let's add a dependency on !NET_LWIP for now. As for SANDBOX, NET_LWIP cannot be used either because of strong assumptions on the network stack. Make NET_LWIP depend on !SANDBOX so that the NET_LWIP alternative is not visible in make menuconfig when sandbox_defconfig is used. Other adjustments to Kconfig files are made to fix "unmet direct dependencies detected" for USB_FUNCTION_SDP and CMD_FASTBOOT when the default networking stack is set to NET_LWIP ("default NET_LWIP" instead of "default NET" in Kconfig). Signed-off-by: Jerome Forissier --- Kconfig | 30 +++++++++++++++++++ boot/Kconfig | 1 + cmd/Kconfig | 1 + common/Kconfig | 2 +- common/spl/Kconfig | 1 + drivers/dfu/Kconfig | 1 + drivers/fastboot/Kconfig | 1 + drivers/net/Kconfig | 1 + drivers/net/phy/Kconfig | 2 +- drivers/usb/gadget/Kconfig | 2 +- net/Kconfig | 61 +++++++++++++++++++------------------- net/Makefile | 4 +++ net/lwip/Kconfig | 34 +++++++++++++++++++++ 13 files changed, 108 insertions(+), 33 deletions(-) create mode 100644 net/lwip/Kconfig diff --git a/Kconfig b/Kconfig index 82df59f176e..6657b9e5e30 100644 --- a/Kconfig +++ b/Kconfig @@ -745,8 +745,38 @@ source "dts/Kconfig" source "env/Kconfig" +menu Networking + +choice + prompt "Networking stack" + default NET + +config NO_NET + bool "No networking support" + +config NET + bool "Legacy U-Boot networking stack" + imply NETDEVICES + +config NET_LWIP + bool "Use lwIP for networking stack" + imply NETDEVICES + depends on !SANDBOX + help + Include networking support based on the lwIP (lightweight IP) + TCP/IP stack (https://nongnu.org/lwip). This is a replacement for + the default U-Boot network stack and applications located in net/ + and enabled via CONFIG_NET as well as other pieces of code that + depend on CONFIG_NET (such as cmd/net.c enabled via CONFIG_CMD_NET). + Therefore the two symbols CONFIG_NET and CONFIG_NET_LWIP are mutually + exclusive. + +endchoice + source "net/Kconfig" +endmenu + source "drivers/Kconfig" source "fs/Kconfig" diff --git a/boot/Kconfig b/boot/Kconfig index 940389d4882..5762de87b21 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -502,6 +502,7 @@ config BOOTMETH_ANDROID select ANDROID_BOOT_IMAGE select CMD_BCB select CMD_FASTBOOT + select FASTBOOT select PARTITION_TYPE_GUID select PARTITION_UUIDS help diff --git a/cmd/Kconfig b/cmd/Kconfig index 978f44eda42..de56c497005 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1644,6 +1644,7 @@ config CMD_USB config CMD_USB_SDP bool "sdp" + depends on USB_GADGET_DOWNLOAD select USB_FUNCTION_SDP help Enables the command "sdp" which is used to have U-Boot emulating the diff --git a/common/Kconfig b/common/Kconfig index 83c81edac20..1fbe4e0812f 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -424,7 +424,7 @@ config LOGF_FUNC_PAD config LOG_SYSLOG bool "Log output to syslog server" - depends on NET + depends on NET || NET_LWIP help Enables a log driver which broadcasts log records via UDP port 514 to syslog servers. diff --git a/common/spl/Kconfig b/common/spl/Kconfig index c08ff064493..962ad11102b 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -1063,6 +1063,7 @@ config SPL_DM_SPI_FLASH config SPL_NET bool "Support networking" + depends on !NET_LWIP help Enable support for network devices (such as Ethernet) in SPL. This permits SPL to load U-Boot over a network link rather than diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig index 971204758aa..d034b501360 100644 --- a/drivers/dfu/Kconfig +++ b/drivers/dfu/Kconfig @@ -20,6 +20,7 @@ config DFU_WRITE_ALT config DFU_TFTP bool "DFU via TFTP" depends on NETDEVICES + depends on !NET_LWIP select UPDATE_COMMON select DFU_OVER_TFTP help diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index 70207573de2..1eb460f5a02 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -1,5 +1,6 @@ menu "Fastboot support" depends on CMDLINE + depends on !NET_LWIP config FASTBOOT bool diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 3382e533f42..eba0bf8b1f1 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -48,6 +48,7 @@ config DM_DSA bool "Enable Driver Model for DSA switches" depends on DM_MDIO depends on PHY_FIXED + depends on !NET_LWIP help Enable driver model for DSA switches diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index a9efc509814..13e73810ad6 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -11,7 +11,7 @@ config MV88E6352_SWITCH menuconfig PHYLIB bool "Ethernet PHY (physical media interface) support" - depends on NET + depends on NET || NET_LWIP help Enable Ethernet PHY (physical media interface) support. diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 4621a6fd5e6..03fe3bca197 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -224,7 +224,7 @@ endif # USB_GADGET_DOWNLOAD config USB_ETHER bool "USB Ethernet Gadget" - depends on NET + depends on NET || NET_LWIP default y if ARCH_SUNXI && USB_MUSB_GADGET help Creates an Ethernet network device through a USB peripheral diff --git a/net/Kconfig b/net/Kconfig index 7cb80b880a9..16a9de47e94 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -2,11 +2,6 @@ # Network configuration # -menuconfig NET - bool "Networking support" - default y - imply NETDEVICES - if NET config ARP_TIMEOUT @@ -26,15 +21,6 @@ config PROT_UDP Enable a generic udp framework that allows defining a custom handler for udp protocol. -config BOOTDEV_ETH - bool "Enable bootdev for ethernet" - depends on BOOTSTD - default y - help - Provide a bootdev for ethernet so that is it possible to boot - an operationg system over the network, using the PXE (Preboot - Execution Environment) protocol. - config BOOTP_SEND_HOSTNAME bool "Send hostname to DNS server" help @@ -45,15 +31,6 @@ config BOOTP_SEND_HOSTNAME of the "hostname" environment variable is passed as option 12 to the DHCP server. -config NET_RANDOM_ETHADDR - bool "Random ethaddr if unset" - help - Selecting this will allow the Ethernet interface to function even - when the ethaddr variable for that interface is unset. In this case, - a random MAC address in the locally administered address space is - generated. It will be saved to the appropriate environment variable, - too. - config NETCONSOLE bool "NetConsole support" help @@ -255,11 +232,35 @@ config IPV6 endif # if NET +source "net/lwip/Kconfig" + +if NET || NET_LWIP + +config BOOTDEV_ETH + bool "Enable bootdev for ethernet" + depends on BOOTSTD + default y + help + Provide a bootdev for ethernet so that is it possible to boot + an operating system over the network, using the PXE (Preboot + Execution Environment) protocol. + +config NET_RANDOM_ETHADDR + bool "Random ethaddr if unset" + help + Selecting this will allow the Ethernet interface to function even + when the ethaddr variable for that interface is unset. In this case, + a random MAC address in the locally administered address space is + generated. It will be saved to the appropriate environment variable, + too. + +endif # if NET || NET_LWIP + config SYS_RX_ETH_BUFFER - int "Number of receive packet buffers" - default 4 - help - Defines the number of Ethernet receive buffers. On some Ethernet - 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. + int "Number of receive packet buffers" + default 4 + help + Defines the number of Ethernet receive buffers. On some Ethernet + 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. diff --git a/net/Makefile b/net/Makefile index 64ab7ec740a..70eec8caf0d 100644 --- a/net/Makefile +++ b/net/Makefile @@ -5,6 +5,8 @@ #ccflags-y += -DDEBUG +ifeq ($(CONFIG_NET),y) + obj-$(CONFIG_NET) += arp.o obj-$(CONFIG_CMD_BOOTP) += bootp.o obj-$(CONFIG_CMD_CDP) += cdp.o @@ -38,3 +40,5 @@ obj-$(CONFIG_CMD_WGET) += wget.o # sprintf(buf, index ? "foo%d" : "foo", index) # and this is intentional usage. CFLAGS_eth_common.o += -Wno-format-extra-args + +endif diff --git a/net/lwip/Kconfig b/net/lwip/Kconfig new file mode 100644 index 00000000000..eb31d044197 --- /dev/null +++ b/net/lwip/Kconfig @@ -0,0 +1,34 @@ +# +# Network configuration (with lwIP stack) +# + +config LWIP_DEBUG + bool "Enable debug traces in the lwIP library" + +config LWIP_ASSERT + bool "Enable assertions in the lwIP library" + +config PROT_DHCP_LWIP + bool + select PROT_UDP_LWIP + +config PROT_DNS_LWIP + bool + select PROT_UDP_LWIP + +config PROT_RAW_LWIP + bool + +config PROT_TCP_LWIP + bool + +config PROT_TCP_SACK_LWIP + bool "TCP SACK support" + depends on PROT_TCP_LWIP + default y + help + TCP protocol with selective acknowledgements. Improves + file transfer speed in wget. + +config PROT_UDP_LWIP + bool