From patchwork Fri Sep 6 12:33: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: 825983 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp809011wrb; Fri, 6 Sep 2024 06:41:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXcCKv5u0hQfztB5K0aJ4HhDNoxZQCcCYT/56T/Ks/5GP7RQ5K95R59d8pPitsT5o9AVgV4Hw==@linaro.org X-Google-Smtp-Source: AGHT+IF9+EH2ux9hVbXXilY3g6OraqCp07b/fMqiQiCQTdXm3evLMKLXvs51Yb0GblZ5iJD5j6mk X-Received: by 2002:a05:6402:520e:b0:5c0:9fdd:bfff with SMTP id 4fb4d7f45d1cf-5c3dc7be9f5mr1686444a12.28.1725630076442; Fri, 06 Sep 2024 06:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725630076; cv=none; d=google.com; s=arc-20240605; b=L3EY/g9fOpM4YsKTxGriIp3SNbANmJzT/E8mFhqCOwhLOP0w18vVvZwN6j5544fMMz tMhTsuIsZpPcaEaIL71/zhQGlhrtCeySvEPzHTbYaK80ePkbtPzhtHbO67YxcOAxmuto MlRiwRxbSPreHOl3JifqqZ98hG8TE7cKi4WZR7KDEHTc61L/mla95SMjTTwiGFm2DV6O f3DN4ypa03NlXzK2jBsfGQYHpxiCy6vfaKrd9Aj23gRgOVCKveeR2EyhuIWLe/qLaZNC GncmSJtNayAQLWbYrHxcGWhSuQxeSV1LWfBg3PYpvlbwpvtId53J9xdyvmEbOxkqozSU sSZQ== 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=ggP8Mc6HkK9iznSwoLYbgCNE3dFIwKWAG6MuWzwL/aI=; fh=nXwICZ6Flh1IHMV6i/v79wa0+xHYBLW4I5kOTQuMPbs=; b=gQSyPISTobaW/zdxLGMWe3Fq1C2/RQpOjaeCjZWgP69T0USrgCIjq3yZshtR9e1bFn QVdd6I4QLFSTTZKfo+hfUaR91TzVyatC9TNSNtnMrQpjbuHLIPJzNysnzE2IbYmMpVQh U+53S7JmDAhAoqEUfLvTneDoYBTbbISTxL8rdeyNRJUAA9i58DvPgY8THR+h30QLija9 KilflYkKyr03ZR9oXWQ6VKIGzp6gHgg03q2OiWctnbpLRyem1jdnyEGN1u1ls1K1orBw rRH1t6AMvwvIujm4MfuorrnSBC43efkZWVsCy3aYfndvDuzoFH/2EgbFMm7ZpBIPoPaX XBww==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="oF/HJimE"; 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 4fb4d7f45d1cf-5c3cc52b428si3153000a12.49.2024.09.06.06.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 06:41:16 -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="oF/HJimE"; 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 AE19988CB6; Fri, 6 Sep 2024 15:41:13 +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="oF/HJimE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 57D08888C1; Fri, 6 Sep 2024 14:34:32 +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-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (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 422DF88CEB for ; Fri, 6 Sep 2024 14:34:29 +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-x336.google.com with SMTP id 5b1f17b1804b1-42bbe908380so15826085e9.2 for ; Fri, 06 Sep 2024 05:34:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725626068; x=1726230868; 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=ggP8Mc6HkK9iznSwoLYbgCNE3dFIwKWAG6MuWzwL/aI=; b=oF/HJimET3o0MUhPakOaWdrgkn7XiSCSLv5b5cdoNtp+6EBrzDJBAKNv7lbxL1oA8M QMDKyfmJS2DY3eWD1t9HGZBgNASuAvXzV5ngvroqnM3YF509OyObrj+eAUd8JRrBQ6zt B39ZHj8rjhntNpm99JQrFWgJHULjV+Ub7c4faAKwQSiSEczOhGAjCGdZNbaoe6l640ko a9P+9C5iQAxM19T0G08hv4HpH7TPpTL78oQRrtRGxd7zyqgvdErDN2nyynuqYWQqHASK thNCAS+KMt0ox/nwhepThGfMl14WXTLJkGE/R8Eom4ZHET6HihHcT5TZ2ED0IpwJo7hm YRzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725626068; x=1726230868; 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=ggP8Mc6HkK9iznSwoLYbgCNE3dFIwKWAG6MuWzwL/aI=; b=em9RiIGi7FnsPa9KuVKsTacyFMSMLs3xWOt51PKpesTlwW32ImqAJwU6CPXc8mDnFd bFxW0JWDG+OUK27xQVNoOMy8xbUXzBkk0pwDJifQIkjE9nqL6DpHQIUJBmPFiGdVmUi3 tVKU6eHKKXMwpjK3pYUSiJvf67VPUydEgSYH6oKzEUH9JlPS8CLAX+Y4xtg/Le6d/Z5W P3oTirVrriP7DpV+2836HopkpzSbf41zMW867hzK5qevOujS0IDh2ClnawbInP+gdO0F spyFHvFoUUulOH0T9D19qWN11KYbwTF7MKgCfRf7IlU6u77cVtu36g9JN/gzo0waDQ0z pjOA== X-Gm-Message-State: AOJu0YyC5b2sq/c+VvP/gX0vnoRxyJQQRZWGDTI3PsZsDqEp35sbtUKb hCQl+80dNhKxsEF52VELwISY8UxY+iWS1XaZciAPm2dDAZ1emJGlw/HpGXoilCdwv78dTOryesu MkTBirwGU X-Received: by 2002:a05:600c:3b25:b0:429:a0d:b710 with SMTP id 5b1f17b1804b1-42c9f984b00mr15745415e9.12.1725626068369; Fri, 06 Sep 2024 05:34:28 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:1ff1:215c:d8a4:9f99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ca05cf0e8sm19640125e9.27.2024.09.06.05.34.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 05:34:28 -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 , Paul Kocialkowski , Martyn Welch , Sean Anderson , Hiago De Franco , Jesse Taube , Greg Malysa , Heinrich Schuchardt , Andrew Davis , Sumit Garg , Rasmus Villemoes , Bryan Brattlof , "Leon M. Busch-George" , Eddie James , AKASHI Takahiro , Stefan Roese , Jiaxun Yang , Devarsh Thakkar , Andre Przywara , Samuel Holland , Lukas Funke , Jaehoon Chung , Ion Agorria , Alexey Romanov , Yang Xiwen , Boon Khai Ng , Jonas Karlman , Neil Armstrong , Robert Marko , Nicolas Frattaroli , Miquel Raynal , Anand Moon , Baruch Siach Subject: [PATCH v10 02/25] net: introduce alternative implementation as net-lwip/ Date: Fri, 6 Sep 2024 14:33:18 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 06 Sep 2024 15:41:12 +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 +++++++++++++++++++ Makefile | 2 +- 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 | 38 ++++++++++++++++++++++++ 14 files changed, 113 insertions(+), 34 deletions(-) create mode 100644 net/lwip/Kconfig diff --git a/Kconfig b/Kconfig index ab46b27999c..35e34e16789 100644 --- a/Kconfig +++ b/Kconfig @@ -752,8 +752,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/Makefile b/Makefile index 5113098d29c..fa22080408b 100644 --- a/Makefile +++ b/Makefile @@ -859,7 +859,7 @@ libs-$(CONFIG_OF_EMBED) += dts/ libs-y += env/ libs-y += lib/ libs-y += fs/ -libs-y += net/ +libs-$(filter y,$(CONFIG_NET) $(CONFIG_NET_LWIP)) += net/ libs-y += disk/ libs-y += drivers/ libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/ diff --git a/boot/Kconfig b/boot/Kconfig index 7ac34574079..798155a5422 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 83c82818bf4..2817ccbd3dc 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1651,6 +1651,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 968d4fb66a8..16224373227 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 3c44e329d62..243df3a543a 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -1073,6 +1073,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 e7d0ddfe25a..f893edbd094 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..90c62145844 --- /dev/null +++ b/net/lwip/Kconfig @@ -0,0 +1,38 @@ +# +# Network configuration (with lwIP stack) +# + +if NET_LWIP + +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 + +endif # NET_LWIP