From patchwork Thu Jul 25 12:57:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 814360 Delivered-To: patch@linaro.org Received: by 2002:adf:e641:0:b0:367:895a:4699 with SMTP id b1csp393349wrn; Thu, 25 Jul 2024 06:28:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXogxtRpU4WBQ6i3tkN6UlhHoIJwsSEpN7aZb/tbaYBnCOGO7SQNxWVeV/9tQ9RZoC95xvbCJ0hIRgq6LSFh1bb X-Google-Smtp-Source: AGHT+IHBj5Vr2L41abPtrV7CxxL98HNRQL6Pii4iC5UNu4+7IiQzu/b0bGcSdXAVj4FPs2RRdDYr X-Received: by 2002:a2e:361a:0:b0:2ef:2332:5e63 with SMTP id 38308e7fff4ca-2f03db8ed4fmr15241161fa.23.1721914093679; Thu, 25 Jul 2024 06:28:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721914093; cv=none; d=google.com; s=arc-20160816; b=CZNC6cQMxb4xnYJ3nGC3uSS9LwapohIMuYINUSAWR4frsqeHg+n3lPWFYXo8CXNu2Z GeA0NgfSXQvRMwKhOgvLGMQC/xZ9kamKgkgaEXlmXmjwSJz26+lk/zZ2yjBz/cSVGQrE FDEyE38W4j7OZ4ktKd7JkxqkobdI8xPCs39crx/ThiAxQswFUCZmh6BTI3up5pNsoPHo o9mHFOefe8ZZgT3OJOCmPgydkaCU9bcexqW/bwm5kstDxccbUAWX+nby4l8ITaSTHgCm Tu+qjgyJZTFi9U3tFvxdzbn4cenT5YwtxTHz45I9h2ngK1ECdq8A6jEPrK/Ckq5yHUfl YAHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=lB3rahTvnV9A+Xg0qOR2oAh0gjklWazck+YMw5Z0HnE=; fh=I3QuvCrL3SrXXZmjAb3wwNU0mNkQW03UwrXIJJURRvc=; b=ctz/Z2gGeF/VpqWJcETA7m3/6Vj6G5BpsvLF0aHa1kmDShBisyYymznhipEqQxJyjq TYpOl2mucUJDTsfYyuPybKtaJM/DbC2QKAORtdKQE6BEhs9BCF8ntw10ciEV8BIscbwf ka/dOebCM9s5gY2P5g2W9G4QbEdTK2IW7Pn75+YtOWhQk0Fp7N5ZxEW07jx9EMtRBk7p 17WnJ+u1OKWgNOnrcF+GeL/jyQVLslsr1w3EV7Ne9GvpVjSFlPs/7FJ9ZF7/5CqgjCh1 u69mnfvW7vjEs4ikxEwo/hUvnxH22MmqfDS9aJvm1UDlCg/zLmNK+CyHNiYjNpm3EH3V VFMA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I83M26Oe; 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 38308e7fff4ca-2f03d15217esi4370791fa.378.2024.07.25.06.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 06:28:13 -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=I83M26Oe; 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 0E2958692C; Thu, 25 Jul 2024 15:28:12 +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="I83M26Oe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 741BB87C86; Thu, 25 Jul 2024 14:58: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 autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (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 1388987E64 for ; Thu, 25 Jul 2024 14:58: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-x331.google.com with SMTP id 5b1f17b1804b1-42808071810so3532615e9.1 for ; Thu, 25 Jul 2024 05:58:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721912308; x=1722517108; 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=lB3rahTvnV9A+Xg0qOR2oAh0gjklWazck+YMw5Z0HnE=; b=I83M26OeoUjros4kPfbZGUcs1SY1OeiwLQs37n0n++VEnOXPPjFYW6ylrXGGQHpB6S ++UBydPa1YctA6XeF6hf0egWWBjR1DKWGluK8eBtH7L8X2LbSqFB+/y0VzhW9vhpJ5jn csl73jqCXB5SRNfo7L34YzT/44dCG3eYjl1iyOAplzgHzybSrru5TI+yc64hTw+JrhiO x5H9O5s4y65zgmHboO1edgSl93mDbY/odCaEzA0cThsU+AfhFxSYidlqFcnEZCajK/dK vLYmYYK4AyY8937JLD2fSIWxhRXq8rAYUF9K2GAY3tvnn5wH2Mh0sz63EHRj/E7RbtVH XP3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721912308; x=1722517108; 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=lB3rahTvnV9A+Xg0qOR2oAh0gjklWazck+YMw5Z0HnE=; b=Z3crm615mN+w3wRfJWVX/SbRaHnIL3Y/rPz3i7HP1kkI8ImFx+4IgSzIz9dD4+ov9o u9LYQBgR34ZA7FxVtACBhGJ47vev17n8UMYjcbDKjYYq04Nwe/scehsnIAqQmwKiMKrG MPLFRuf+n7QZHhOce2cq3vswbhhr8F7Ah6nJ8DGcHf321CCvS25JhTBmA0VAFBhxolWK 1NMZz4gRAn4oGA0J+O+7TXU7WvHKshduLB7Gp03BdGG1opu2PUW4Kru4YZ4g19AK3zhd nak2xPal/hczk1hJXXsihtXpumNpTiVVfTtdkQsi+6zLJOMFOMudqoh375TrXOOfl2/P 0YUQ== X-Gm-Message-State: AOJu0YyNQnSZj+j2OpY8qZs3N2iVWBjjMFZYihmnEdnvrB3qjoE/xxk+ T8fPSbWGFVFzmWg6SBzacwhrIk6Gb+CD7T5qUuGTWCKZV+CGnzjlswFii2LJxNIVTFdFoL5pzaC ObKi/dQ== X-Received: by 2002:a7b:ce89:0:b0:425:7c5f:1bac with SMTP id 5b1f17b1804b1-42806ba5f04mr15290625e9.21.1721912307822; Thu, 25 Jul 2024 05:58:27 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:a701:ef5f:d613:3e14]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4280573fd83sm34765205e9.19.2024.07.25.05.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 05:58:27 -0700 (PDT) From: Jerome Forissier To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Javier Tia , Raymond Mao , Maxim Uvarov , Jerome Forissier , Tom Rini , Lukasz Majewski , Mattijs Korpershoek , Joe Hershberger , Ramon Fried , Marek Vasut , Simon Glass , Nathan Barrett-Morrison , Jesse Taube , Bo Gan , Jonas Karlman , Greg Malysa , John Keeping , Shengyu Qu , Stefan Roese , Jagan Teki , Bin Meng , Jiaxun Yang , Rasmus Villemoes , Sean Anderson , Andre Przywara , Samuel Holland , Oleksandr Suvorov , Lukas Funke , Jaehoon Chung , Heinrich Schuchardt , Quentin Schulz , Alexey Romanov , Ion Agorria , Yang Xiwen , Boon Khai Ng , Neil Armstrong , Nicolas Frattaroli , Miquel Raynal , Baruch Siach Subject: [PATCH v5 02/20] net: introduce alternative implementation as net-lwip/ Date: Thu, 25 Jul 2024 14:57:23 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 25 Jul 2024 15:28:10 +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. Signed-off-by: Jerome Forissier --- Kconfig | 26 ++++++++++++++++++++++++++ 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 | 29 +++++++++++++++-------------- net/Makefile | 4 ++++ net/lwip/Kconfig | 36 ++++++++++++++++++++++++++++++++++++ 11 files changed, 88 insertions(+), 17 deletions(-) create mode 100644 net/lwip/Kconfig diff --git a/Kconfig b/Kconfig index 82df59f176e..61bc6529617 100644 --- a/Kconfig +++ b/Kconfig @@ -745,6 +745,32 @@ source "dts/Kconfig" source "env/Kconfig" +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" source "drivers/Kconfig" diff --git a/common/Kconfig b/common/Kconfig index 4bb9f08977a..1daa495080a 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 af43b5f5d3c..2731849841a 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 b4ff033afa9..d332f712a7c 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 73064b2af68..75986162914 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 5dff6336293..952690d677d 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 @@ -255,6 +241,19 @@ 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 SYS_RX_ETH_BUFFER int "Number of receive packet buffers" default 4 @@ -263,3 +262,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 || NET_LWIP 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..0a6bcb41369 --- /dev/null +++ b/net/lwip/Kconfig @@ -0,0 +1,36 @@ +# +# 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 "DHCP support in lwIP" + depends on PROT_UDP_LWIP + help + Enable support for the DHCP protocol in lwIP. + +config PROT_DNS_LWIP + bool + depends on 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