From patchwork Mon Aug 14 13:32:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713471 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1241941wrp; Mon, 14 Aug 2023 06:35:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGT7ErKl7R6jUKQCAMTgClE9KMjIzrGr5Dq+kzlkTxgbBjdD72hxjHNI0+4266VJN4p79PH X-Received: by 2002:a5d:60cc:0:b0:315:ae39:27c with SMTP id x12-20020a5d60cc000000b00315ae39027cmr7134677wrt.70.1692020135676; Mon, 14 Aug 2023 06:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020135; cv=none; d=google.com; s=arc-20160816; b=wk6HjwvyeIRrUjwCzf9y+pjKATdy7D1BO9VQ+xwkB04goa5yZNXvvZ9hHFJpdAVqeQ f83q0qS3ph90VIXtAJy+Lix4AlMpIK1AWHfXY561DO4dk6iaviR/SUGug4Xbp4oDyiXH oQGlqR3tzexCgHqGBIZBINpk8IdRiLGDZdlCWsJ9uZuZDFWOKZOTUZYr4DWmyAzPIfYq o0KHHl0G/0u4uiKI0O84rPZXuLruwVXW9lmQjvjzteXoVqcm1AgB8kve0el/S388SdZT MOM1P4Unl7evg6qcumM46SZhi2wyKZ14Jbv1ZTpPsRHCkKP0LMD8yNDvL2f1dG9V5MPc yZ4w== 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=+5BDe1+laGab+DyI37GMa2W2z5gN/NLvzaH2Cr1H3Kk=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=TPTbOvTBt4VMrHtsOK8d19xsDB1OA5jMYc3geSXEe8ckGdY7gSXEdl23aoEzZZOAqz yPbtXwrXZnX502f7dniqwBL4didET1GxHXH6F0SegDU8+DGzmVM930TlW06ViWU4+HPA FSV7BtRCiQQ/7ERmXgVGPLBF4qTveWJR9FbcuVi2IBGcxn6AHHxTnhRAo5E3Cu99MUmq U5TyOsDyJgJHOgdwG2CDF3OGSIQjd8CH71lELKqpo2ZbZwwjpScG8JAE3obFstkpxnKn mINmfPd4tHVUI6kNZTYhE5Zi0hHQRWoef8Il5zafX08u5ysvX1NfSDTnrHvWoUnfS4l/ vlYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wbWySuAd; 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 n3-20020a5d4c43000000b003177f3e775csi5009183wrt.1030.2023.08.14.06.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:35 -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=wbWySuAd; 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 1CB338694B; Mon, 14 Aug 2023 15:35:20 +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="wbWySuAd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 77204807B4; Mon, 14 Aug 2023 15:35:18 +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=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) (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 238C7807B3 for ; Mon, 14 Aug 2023 15:35:16 +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-lj1-x234.google.com with SMTP id 38308e7fff4ca-2b9b904bb04so68244931fa.1 for ; Mon, 14 Aug 2023 06:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020115; x=1692624915; 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=+5BDe1+laGab+DyI37GMa2W2z5gN/NLvzaH2Cr1H3Kk=; b=wbWySuAdOrfX96d0ki999f/tSNyhjXUoJkGRhV/m5ZtgR/IebAPIIa6rGqkQUR2AHY 3e+KtG40aRm/FIJMzeornpWuD4bZEjllIasuFli1FtKYFW2IM97XOkAUVymycDlQxqrS gbI64Y2CGPEO0h8D7O4vVJxowrmOMB0d45Mv4lEW1tmcdrfMyWPU/n6q5FfMDd9sMRoS /2XUBh//ylJ9gVBi1ouR39kny4IsaO4qVqHrW2rCwKS/hISzUJ9QCiBVoNZOj+2DETnw s3ZncYLPK/btBFiD0loqldN5Y/1/cQ1sWEQ+SL4p3H0W1bUun5KYa6a8QVwNT0+b2kAP GLjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020115; x=1692624915; 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=+5BDe1+laGab+DyI37GMa2W2z5gN/NLvzaH2Cr1H3Kk=; b=g4njzcgbl23JcT2ME0fwhEmBxh3xw5quFVfSgr2UAEBAx0QBwtElt1RJHmn0VwrB3X OTHKUVUeEYnh273Zjr98qFhsSRaBhr02Z14wFF8mMlQB8GW+Co/gKwVBYUM4XSYz9HSv +rY42KNj/d1V+nlulNadPD2fl54F65cSnfmQE+itVjTI+vjVU9A4zk8oKJdlP8R7r0ER qzCq52d4lcqfsDfACSYQg48vZyg5u8bDmCwe7dJ6TpI8aYt7k5NGZuAEAhlWOjjcH2sG XFQ6EievnV6qyuELYBQIC/cWNHZUtGdoJfHPZ/5+CxsGt8aCxXhGv4JKf6F3HDccwBXY IJzA== X-Gm-Message-State: AOJu0Yysp3nDSpCnMojsMXhluST0rNEbWPd7dGV3gqWeOwg9S3WMwyv2 J49Gmwyf9kIqRj3P3lAecbqpnSw1gS+mZNF/OAU= X-Received: by 2002:a2e:3e02:0:b0:2b9:e831:f15f with SMTP id l2-20020a2e3e02000000b002b9e831f15fmr6073193lja.32.1692020115228; Mon, 14 Aug 2023 06:35:15 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:14 -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: [PATCHv6 02/14] net/lwip: integrate lwIP library Date: Mon, 14 Aug 2023 19:32:41 +0600 Message-Id: <20230814133253.4150-3-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-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 Define Makefile and Kconfig to build lwIP inside the U-Boot. We compile lwIP the same as the main code, plus we can do optimization for size at compile time with disabling not needed debug asserts, or not used protocols. So we can tune lwIP configuration specially for U-Boot environments. Signed-off-by: Maxim Uvarov --- net/Kconfig | 3 +++ net/Makefile | 1 + net/lwip/Kconfig | 60 ++++++++++++++++++++++++++++++++++++++++++ net/lwip/Makefile | 66 +++++++++++++++++++++++++++++++++++++++++++++++ net/net.c | 20 ++++++++++++++ 5 files changed, 150 insertions(+) create mode 100644 net/lwip/Kconfig create mode 100644 net/lwip/Makefile diff --git a/net/Kconfig b/net/Kconfig index 4215889127..34c1e43c87 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -5,9 +5,12 @@ menuconfig NET bool "Networking support" default y + imply LWIP if NET +source net/lwip/Kconfig + config ARP_TIMEOUT int "Milliseconds before trying ARP again" default 5000 diff --git a/net/Makefile b/net/Makefile index 3e2d061338..61930c244e 100644 --- a/net/Makefile +++ b/net/Makefile @@ -33,6 +33,7 @@ obj-$(CONFIG_CMD_WOL) += wol.o obj-$(CONFIG_PROT_UDP) += udp.o obj-$(CONFIG_PROT_TCP) += tcp.o obj-$(CONFIG_CMD_WGET) += wget.o +obj-$(CONFIG_LWIP) += lwip/ # Disable this warning as it is triggered by: # sprintf(buf, index ? "foo%d" : "foo", index) diff --git a/net/lwip/Kconfig b/net/lwip/Kconfig new file mode 100644 index 0000000000..233c6c532d --- /dev/null +++ b/net/lwip/Kconfig @@ -0,0 +1,60 @@ +menu "LWIP" +config LWIP + bool "Support LWIP library" + help + 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. + Please see doc/develop/net_lwip.rst for more details. + +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 by 16k. + +config LWIP_LIB_TCP + bool "tcp" + default y + help + Compile lwIP with TCP protocol support. + +config LWIP_LIB_UDP + bool "udp" + default y + help + Compile lwIP with UDP protocol support (needed for TFTP). + +config LWIP_LIB_DNS + bool "dns" + default y + help + Compile lwIP with DNS protocol support. + +config LWIP_LIB_DHCP + bool "dhcp" + default y + help + Compile lwIP with DHCP protocol support. + +config LWIP_LIB_LOOPBACK + bool "loopback" + help + Increases size by 1k. + help + Compile lwIP with loopback interface support. + +config LWIP_LIB_SOCKET + bool "socket API" + +endmenu + +endmenu diff --git a/net/lwip/Makefile b/net/lwip/Makefile new file mode 100644 index 0000000000..d1161bea78 --- /dev/null +++ b/net/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)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/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/net.c b/net/net.c index 43abbac7c3..7f868ee516 100644 --- a/net/net.c +++ b/net/net.c @@ -125,6 +125,7 @@ #endif #include "dhcpv6.h" #include "net_rand.h" +#include /** 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) + if (!ulwip_enabled() || !ulwip_in_loop()) +#endif net_init(); + if (eth_is_on_demand_init()) { eth_halt(); eth_set_current(); @@ -649,6 +654,16 @@ restart: */ eth_rx(); + if (IS_ENABLED(CONFIG_LWIP) && 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; + } + } /* * Abort if ctrl-c was pressed. */ @@ -1213,6 +1228,11 @@ void net_process_received_packet(uchar *in_packet, int len) if (len < ETHER_HDR_SIZE) return; + if (IS_ENABLED(CONFIG_LWIP) && ulwip_enabled()) { + ulwip_poll(); + return; + } + #if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER) if (push_packet) { (*push_packet)(in_packet, len);