From patchwork Wed Aug 2 14:06:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 709166 Delivered-To: patch@linaro.org Received: by 2002:a5d:55c5:0:b0:317:2194:b2bc with SMTP id i5csp930559wrw; Wed, 2 Aug 2023 07:09:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlFy0fTZ+l+hMDZywR4kL8uzQfnUSYAbl3sroV/Pz2efejQTg7B7bCVBj1SKyqYJgBzshV9s X-Received: by 2002:a5d:5963:0:b0:317:732e:d56a with SMTP id e35-20020a5d5963000000b00317732ed56amr4680234wri.43.1690985383523; Wed, 02 Aug 2023 07:09:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690985383; cv=none; d=google.com; s=arc-20160816; b=uAmqn0JCBom0MJh4sibJ5Jktks3YqKOHBQ0CDJemVmcXdGAyBrg4RoFyIbRlO2F84U EKjMuhiOmJtkX9MTkkRb6pzuZL/6r9QTj4K4LurROz/RceBfGVnYlp4h2h5AORnW6n0z vy+O+812b2xzpZU8+GNwD1Y6+BM1Cp5OT14azTQ4ggnW98p/yZb4OmvnkOvZj5yhroyH ViBlizEmF/U8t6vpETWDlYEGY6d9TtZqOqBlNFKH/fpaKQ0soV3z/iKuIu1fzG5fRg6+ auzBWWcGFfnWq1LqLaHPtaXkhd2VkKt0sBYpZjIft7TkxjjoCNyVy5AtpIh+5RySJXtj mb6w== 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=eOtl0KMcVyx3azbvD7j7NxMy2DIs81tAvjABNarZaks=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=uNz3Q/iMEz/90IXGiYYUXwnoiXjOHCALMcfmVeZ2D6Kmwz9UCQlXNQuQFYo/vTtH1D 1yGZhKZ0PBITE80KrtQNXuoc3phFVAqmcr0139T2C6qkMFuonq2FIFXTXi1M5rcLNQb4 5dV5cnp/DxyL3wHkB2rQzU9A8K+sb9+BWOKIyt8tueJ7LKl2wEVtg8okMPvQiLT6vNPg ifU8yqTd7XF/UWMLyc/0BK4vdkksVput8ykU5KJSIEEh2WHaSAZZAmxUKvmca7ebgSee cPkJjCMjGo0oBNreNlJopy4BEjNj5fybccyefQVYa8TgjS2KHApMAj4n8cuaj72IwbeA WlPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=phlXKSsy; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id z13-20020a056000110d00b003174aefd689si585627wrw.761.2023.08.02.07.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 07:09:43 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=phlXKSsy; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6FD9A86B5E; Wed, 2 Aug 2023 16:09:28 +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="phlXKSsy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A959686B5E; Wed, 2 Aug 2023 16:09:27 +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=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) (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 BE5978686B for ; Wed, 2 Aug 2023 16:09:23 +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=maxim.uvarov@linaro.org Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4fe0e23a4b1so11023606e87.3 for ; Wed, 02 Aug 2023 07:09:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690985363; x=1691590163; 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=eOtl0KMcVyx3azbvD7j7NxMy2DIs81tAvjABNarZaks=; b=phlXKSsyapSqNKMtTs5/N1e6GpzSoGC+WqZGjR/OYSNPbmYb4Mg8GWXmVmrS1lBlDm tbgehNH9Ko23UWlBb3SMjHcxkrzRJOQeXbaudENWg33K++GDEO1sBNO/lGxTrgVLyAgm qXDt/7VpEXqbK1kxy+RsXdPTiN18uCih1G1TWLPVuUVpwC3Atiz9jmVf2L4xKHFVZaSD KkSVMWLGApzQuYOELikAYU6mub6x3Ru2N/QdSICDDUfnkLrD3tIUVg7wLo9q/hfsxbBJ h2iwyCeaQDXHyfqa/H2BG6MFBlyRRV8C7iIvhDRwJPaqkL3jU5ylazq4m/K1r3i7d1QI YXSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690985363; x=1691590163; 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=eOtl0KMcVyx3azbvD7j7NxMy2DIs81tAvjABNarZaks=; b=SJmYPSqDH3/kY1vDIXHd89dU6Nf7WcQzhRclznxV3i8uZB36/kP9+ivjNs+7BerKGX 0hlank/lMLGQQOMDd+q87P6hgIyvPEVQ4eWz2wiAC7CObb73BybXKwbVsn6pPKhNEi66 252fZ3fomoey04j+/NwfyCdKTqhRjAYDY4iJowU06FsvGKlHhkW3cNLFIVh6JB3ZnskA J5irUjwaYQ3YPVWYmBUeoecxaHUZmle58OXZsCfsNhNyea2sxi7JZLdbmadnOho0GIp4 al4K+8o1kDkNiJE+wa07GAH65bMJO6XcRc2QsrD895jkIFxWO/t5gn95CYLYWSr+NmOg oCkg== X-Gm-Message-State: ABy/qLZdxnlxK5hsvirV5vSXydu62XMsjatS7rFZKpzC95uKNzJSiJDf f64141r+AEIuCQXx1DlSt4dNFxTv57SvZU0uLUKv4A== X-Received: by 2002:ac2:5bc7:0:b0:4fb:9631:4bb with SMTP id u7-20020ac25bc7000000b004fb963104bbmr4180014lfn.11.1690985362797; Wed, 02 Aug 2023 07:09:22 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id a12-20020a056512020c00b004fbbef8d4dbsm2982026lfo.121.2023.08.02.07.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 07:09:22 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv5 02/13] net/lwip: integrate lwip library Date: Wed, 2 Aug 2023 20:06:47 +0600 Message-Id: <20230802140658.10319-3-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230802140658.10319-1-maxim.uvarov@linaro.org> References: <20230802140658.10319-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 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 --- lib/Kconfig | 2 ++ lib/Makefile | 3 +++ lib/lwip/Kconfig | 67 +++++++++++++++++++++++++++++++++++++++++++++++ lib/lwip/Makefile | 66 ++++++++++++++++++++++++++++++++++++++++++++++ net/Kconfig | 1 + net/net.c | 24 +++++++++++++++++ 6 files changed, 163 insertions(+) create mode 100644 lib/lwip/Kconfig create mode 100644 lib/lwip/Makefile diff --git a/lib/Kconfig b/lib/Kconfig index 3926652db6..79f7d5bc5d 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1112,3 +1112,5 @@ menu "FWU Multi Bank Updates" source lib/fwu_updates/Kconfig endmenu + +source lib/lwip/Kconfig diff --git a/lib/Makefile b/lib/Makefile index 8d8ccc8bbc..598b5755dd 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_EFI_LOADER) += efi_loader/ obj-$(CONFIG_CMD_BOOTEFI_SELFTEST) += efi_selftest/ obj-$(CONFIG_FWU_MULTI_BANK_UPDATE) += fwu_updates/ obj-$(CONFIG_LZMA) += lzma/ +obj-$(CONFIG_LWIP_LIB) += lwip/ obj-$(CONFIG_BZIP2) += bzip2/ obj-$(CONFIG_FIT) += libfdt/ obj-$(CONFIG_OF_LIVE) += of_live.o @@ -92,6 +93,8 @@ obj-$(CONFIG_LIBAVB) += libavb/ obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += libfdt/ obj-$(CONFIG_$(SPL_TPL_)OF_REAL) += fdtdec_common.o fdtdec.o +obj-y += lwip/ + ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16-ccitt.o obj-$(CONFIG_$(SPL_TPL_)HASH) += crc16-ccitt.o diff --git a/lib/lwip/Kconfig b/lib/lwip/Kconfig new file mode 100644 index 0000000000..5d2603701c --- /dev/null +++ b/lib/lwip/Kconfig @@ -0,0 +1,67 @@ +menu "LWIP" +config LWIP_LIB + bool "Support LWIP library" + help + This option will enable the lwIP library code with + all dependencies (cmd commands implemented with lwIP + library. This option is automatically enabled if CONFIG_NET=y. + lwIP library (https://git.savannah.nongnu.org/git/lwip.git) provides + network stack and application code for U-Boot cmd commands. + +menu "LWIP options" + +config LWIP_LIB_DEBUG + bool "enable debug" + default n + +config LWIP_LIB_NOASSERT + bool "disable asserts" + default y + help + Disabling asserts reduces binary size on 16k. + +config LWIP_LIB_TCP + bool "tcp" + default y + +config LWIP_LIB_UDP + bool "udp" + default y + +config LWIP_LIB_DNS + bool "dns" + default y + +config LWIP_LIB_DHCP + bool "dhcp" + default y + +config LWIP_LIB_LOOPBACK + bool "loopback" + help + Increases size on 1k. + +config LWIP_LIB_SOCKET + bool "socket API" + +config LWIP_LIB_NETCONN + bool "netconn API" + +config LWIP_LIB_MEM_SIZE + int "mem size" + default 1600 + range 1 4096 + help + MEM_SIZE: the size of the heap memory. If the application will send + a lot of data that needs to be copied, this should be set high. + +config LWIP_LIB_PBUF_LINK_HLEN + int "pbuf link hlen" + default 14 + range 4 1024 + help + PBUF_LINK_HLEN: the number of bytes that should be allocated for a + link level header. The default is 14, the standard value for Ethernet. +endmenu + +endmenu diff --git a/lib/lwip/Makefile b/lib/lwip/Makefile new file mode 100644 index 0000000000..35f34d7afa --- /dev/null +++ b/lib/lwip/Makefile @@ -0,0 +1,66 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# (C) Copyright 2023 Linaro Ltd. + +LWIPDIR=lwip-external/src + +ccflags-y += -I$(srctree)/lib/lwip/port/include +ccflags-y += -I$(srctree)/lib/lwip/lwip-external/src/include -I$(srctree)/lib/lwip + +obj-$(CONFIG_NET) += $(LWIPDIR)/core/init.o \ + $(LWIPDIR)/core/def.o \ + $(LWIPDIR)/core/dns.o \ + $(LWIPDIR)/core/inet_chksum.o \ + $(LWIPDIR)/core/ip.o \ + $(LWIPDIR)/core/mem.o \ + $(LWIPDIR)/core/memp.o \ + $(LWIPDIR)/core/netif.o \ + $(LWIPDIR)/core/pbuf.o \ + $(LWIPDIR)/core/raw.o \ + $(LWIPDIR)/core/stats.o \ + $(LWIPDIR)/core/sys.o \ + $(LWIPDIR)/core/altcp.o \ + $(LWIPDIR)/core/altcp_alloc.o \ + $(LWIPDIR)/core/altcp_tcp.o \ + $(LWIPDIR)/core/tcp.o \ + $(LWIPDIR)/core/tcp_in.o \ + $(LWIPDIR)/core/tcp_out.o \ + $(LWIPDIR)/core/timeouts.o \ + $(LWIPDIR)/core/udp.o + +# IPv4 +obj-$(CONFIG_NET) += $(LWIPDIR)/core/ipv4/acd.o \ + $(LWIPDIR)/core/ipv4/autoip.o \ + $(LWIPDIR)/core/ipv4/dhcp.o \ + $(LWIPDIR)/core/ipv4/etharp.o \ + $(LWIPDIR)/core/ipv4/icmp.o \ + $(LWIPDIR)/core/ipv4/igmp.o \ + $(LWIPDIR)/core/ipv4/ip4_frag.o \ + $(LWIPDIR)/core/ipv4/ip4.o \ + $(LWIPDIR)/core/ipv4/ip4_addr.o +# IPv6 +obj-$(CONFIG_NET) += $(LWIPDIR)/core/ipv6/dhcp6.o \ + $(LWIPDIR)/core/ipv6/ethip6.o \ + $(LWIPDIR)/core/ipv6/icmp6.o \ + $(LWIPDIR)/core/ipv6/inet6.o \ + $(LWIPDIR)/core/ipv6/ip6.o \ + $(LWIPDIR)/core/ipv6/ip6_addr.o \ + $(LWIPDIR)/core/ipv6/ip6_frag.o \ + $(LWIPDIR)/core/ipv6/mld6.o \ + $(LWIPDIR)/core/ipv6/nd6.o +# API +obj-$(CONFIG_NET) += $(LWIPDIR)/api/api_lib.o \ + $(LWIPDIR)/api/api_msg.o \ + $(LWIPDIR)/api/err.o \ + $(LWIPDIR)/api/if_api.o \ + $(LWIPDIR)/api/netbuf.o \ + $(LWIPDIR)/api/netdb.o \ + $(LWIPDIR)/api/netifapi.o \ + $(LWIPDIR)/api/sockets.o \ + $(LWIPDIR)/api/tcpip.o + +# Netdevs +obj-$(CONFIG_NET) += $(LWIPDIR)/netif/ethernet.o + +obj-$(CONFIG_NET) += port/if.o +obj-$(CONFIG_NET) += port/sys-arch.o diff --git a/net/Kconfig b/net/Kconfig index 4215889127..c3f4a7cae7 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -5,6 +5,7 @@ menuconfig NET bool "Networking support" default y + select LWIP_LIB if NET diff --git a/net/net.c b/net/net.c index 43abbac7c3..d98e51cb80 100644 --- a/net/net.c +++ b/net/net.c @@ -125,6 +125,7 @@ #endif #include "dhcpv6.h" #include "net_rand.h" +#include "../lib/lwip/ulwip.h" /** BOOTP EXTENTIONS **/ @@ -452,7 +453,11 @@ int net_loop(enum proto_t protocol) #endif bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start"); +#if defined(CONFIG_LWIP_LIB) + if (!ulwip_enabled() || !ulwip_in_loop()) +#endif net_init(); + if (eth_is_on_demand_init()) { eth_halt(); eth_set_current(); @@ -649,6 +654,18 @@ restart: */ eth_rx(); +#if defined(CONFIG_LWIP_LIB) + if (ulwip_enabled()) { + net_set_state(NETLOOP_CONTINUE); + if (!ulwip_in_loop()) { + if (ulwip_app_get_err()) + net_set_state(NETLOOP_FAIL); + else + net_set_state(NETLOOP_SUCCESS); + goto done; + } + } +#endif /* * Abort if ctrl-c was pressed. */ @@ -1213,6 +1230,13 @@ void net_process_received_packet(uchar *in_packet, int len) if (len < ETHER_HDR_SIZE) return; +#if defined(CONFIG_LWIP_LIB) + if (ulwip_enabled()) { + uboot_lwip_poll(); + return; + } +#endif + #if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER) if (push_packet) { (*push_packet)(in_packet, len);