From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ECDA1EB64D7 for ; Fri, 30 Jun 2023 10:02:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 788808678C; Fri, 30 Jun 2023 12:02:08 +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="dAkPmbMc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 84C4E8678D; Fri, 30 Jun 2023 12:02:04 +0200 (CEST) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) (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 C34078678A for ; Fri, 30 Jun 2023 12:01:57 +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=ilias.apalodimas@linaro.org Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3141140f51bso1987603f8f.1 for ; Fri, 30 Jun 2023 03:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688119317; x=1690711317; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=6UnGPbc1klOU6ul9vfuwiWOOup0hVt+B/0J4S0piAFw=; b=dAkPmbMc33h55XKf+bagHQduoHa5N1vulpFCdIih/Za09yrCzDAErPp83Mib1udFn9 yDfKgXqhIvgIXyc8PSqxuOeOP75jBE0JUD3XbZXaGbOJ2PCYWS+ybxIPQrUI4CUpgA/Z 1HBMPhrRRrRH58/2+zFbzLs5lFK5NWvBqYBHvigr6rpGUTInx7M+W7WK92epSNjLX2ih Ptk8Rz5kk813MSeJ6JtNgCf/CGxySyjv8+8/b4zDXmSJNB1nL7xVy1KS2ogN4TMePRhx mMvMrEmBtm+xT8anEUR+JJWk66p6iUrNva8MuHNmiEnhmDdRZH25OxewWT+Htvulpwn1 aw5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688119317; x=1690711317; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6UnGPbc1klOU6ul9vfuwiWOOup0hVt+B/0J4S0piAFw=; b=kMJdLSSdVksIn7LlrOaAMsgB90vqvKTkABWfIPdgot+oz4YMWSFIcxvIrsRCVW/RT4 hesD7+Vyy6OSZnohZAM/70KM1zRt1GprEXFVvZqjl7ys7nIrxJyn0FVG61g5CpTUKypc TJ10HvrLiGgGJEqczjyPnJsicesd47LwLrDbQzayhBbXE8jSj1WsDSm/ws/ZTPlPR2i5 ESZvE/U8HrcFJS6QjtzD10cwZIabVQ0CVCfPORfDvWGd4Ac2t3zuyUTe3IQ6oTprk6kZ I0XYVuKgRhCuVxtUA4oXRaoEEHhx2x4m96puV+frEo51aif5u6JG0LQLn+hgNs/vtsFJ fP5g== X-Gm-Message-State: ABy/qLb/wt8vIcmaTDMGMzljgpputJvoVN9ms3RmWVyybww6L71qiXkA hnYONDa4sBM1gBLfWb5rS+asvA== X-Google-Smtp-Source: APBJJlGAJH/scZeMaiP6tTbtTWnxKa/emyDOxL/E6dWcRClJUWUPxzQuS1iaKztyLyG/T1bF6LGK1w== X-Received: by 2002:adf:e6ce:0:b0:314:10d6:8910 with SMTP id y14-20020adfe6ce000000b0031410d68910mr1695148wrm.63.1688119317090; Fri, 30 Jun 2023 03:01:57 -0700 (PDT) Received: from hera (ppp089210114029.access.hol.gr. [89.210.114.29]) by smtp.gmail.com with ESMTPSA id c13-20020adfe74d000000b0030ae499da59sm2884240wrn.111.2023.06.30.03.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 03:01:56 -0700 (PDT) Date: Fri, 30 Jun 2023 13:01:54 +0300 From: Ilias Apalodimas To: Maxim Uvarov Cc: u-boot@lists.denx.de, pbrobinson@redhat.com, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org Subject: Re: [PATCHv2 2/3] net/lwip: add README.lwip Message-ID: References: <20230629123430.3679-1-maxim.uvarov@linaro.org> <20230629123430.3679-2-maxim.uvarov@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230629123430.3679-2-maxim.uvarov@linaro.org> 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 Hi Maxim, On Thu, Jun 29, 2023 at 06:34:29PM +0600, Maxim Uvarov wrote: > Just add inital README.lwip doc. We'll need a more accurate description for this. The first paragraph of the documentation you are adding would do > > Signed-off-by: Maxim Uvarov > --- > doc/README.lwip | 90 +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 90 insertions(+) > create mode 100644 doc/README.lwip > > diff --git a/doc/README.lwip b/doc/README.lwip > new file mode 100644 > index 0000000000..16f41049ab > --- /dev/null > +++ b/doc/README.lwip > @@ -0,0 +1,90 @@ > + RFC LWIP IP stack intergation for U-boot > + ---------------------------------------- > + > +Reliable and bug free IP stack is usually an issue when you are trying to write it I am not sure about the bug free part :). Just move this entire paragraph as part of the commit message and remove the 'RFC' parts. > +from scratch. It looks like not, but when addinging new features it will be chelledging. > +This RFC work is a demo to enable lwIP (lightweight IP) which is a widely used open-source > +TCP/IP stack designed for embedded systems for U-boot. That will allow using already > +written network applications for microcontrollers. > + > +LwIP  license: > +lwIP is licensed under a BSD-style license: http://lwip.wikia.com/wiki/License. > + > +Main features include: > +- Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE > +- DHCP client, DNS client (incl. mDNS hostname resolver), AutoIP/APIPA (Zeroconf), SNMP agent (v1, v2c, v3, private MIB support & MIB compiler) > +- APIs: specialized APIs for enhanced performance, optional Berkeley-alike socket API > +- Extended features: IP forwarding over multiple network interfaces, TCP congestion control, RTT estimation and fast recovery/fast retransmit > +- Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, NetBIOS nameserver, mDNS responder, MQTT client, TFTP server > + > +U-boot implementation details: > + > +1. In general we can build lwIP as .a library and link it against u-boot or compile it in > +the U-boot tree in the same way as other U-boot files. There are few reasons why I selected > +the second variant: iwIP is very customizable with defines for features, memory size, types of > +allocation, some internal types and platform specific code. And it was more easy to enable/disable > + debug which is also done with defines, and is needed periodically. > + > +2. lwIP has 2 APIs - raw mode and sequential (as lwIP names it, or socket API as we name it in Linux). > + This RFC implements only raw API as the proof of work. > + > +Raw IP means that the call back function for RX path is registered and will be called when packet > +data passes the IP stack and is ready for the application. > + > +This RFC has an unmodified working ping example from lwip sources which registeres this callback. > +  ping_pcb = raw_new(IP_PROTO_ICMP); > +  raw_recv(ping_pcb, ping_recv, NULL); <- ping_recv is app callback. > +  raw_bind(ping_pcb, IP_ADDR_ANY) > + > +Socket API also gives nice advantages due it will be easy to port linux socket applications to u-boot. > +I.e. lwIP sockets compatible with the linux ones. But that will require RX thread running in the background. > +So that means we need some kind of scheduler, locking and threading support or find some other solution. > + > +3.  Input and output > + > +RX packet path is injected to U-boot eth_rx() polling loop and TX patch is in eth_send() accordingly. > +So we do not touch any drivers code and just eat packets when they are ready. > + > +4. Testing > + > +Unmodified ping example can be used. I did ping from qemu/u-boot tap device on the host: > + > +=> lwip init > +=> lwip ping 192.168.1.2 > +ping: recv 3 ms > +tcpdump on the host: > +5:09:10.925951 ARP, Request who-has 192.168.1.200 tell 192.168.1.200, length 28 15:09:12.114643 IP6 fe80::38e2:41ff:fec3:8bda > ip6-allrouters: ICMP6, router solicitation, length 16 15:09:20.370725 ARP, Request who-has 192.168.1.2 tell 192.168.1.200, length 28 15:09:20.370740 ARP, Reply 192.168.1.2 is-at 3a:e2:41:c3:8b:da (oui Unknown), length 28 15:09:20.372789 IP 192.168.1.200 > 192.168.1.2: ICMP echo request, id 44975, seq 1, length 40 15:09:20.372810 IP 192.168.1.2 > 192.168.1.200: ICMP echo reply, id 44975, seq 1, length 40 15:09:25.426636 ARP, Request who-has 192.168.1.200 tell 192.168.1.2, length 28 15:09:25.426870 ARP, Reply 192.168.1.200 is-at f6:11:01:02:03:04 (oui Unknown), length 28 > + > + > +5. Wget example > + > +Http server has 192.168.1.2 IP address. (I did not port DNS resolving yet, > +but it's also exist in lwip.) So example just downloads some file with http > +protocol: > + > +Net: eth0: virtio-net#30 > +Hit any key to stop autoboot: 0 > +=> lwip init > +Starting lwIP, local interface IP is 192.168.1.200 > +Initialized LWIP stack > +=> lwip wget http://192.168.1.2/ > +downloading http://192.168.1.2/ to addr 0x40200000 Does wget with lwip work with dns as well? > +downloaded chunk size 294, to addr 0x40200000 > +downloaded chunk size 318, to addr 0x40200126 > +=> md 0x40200000 0x40 > +40200000: 4f44213c 50595443 74682045 0a3e6c6d . > +40200010: 6d74683c 3c0a3e6c 64616568 743c0a3e .. +40200020: 656c7469 6c65573e 656d6f63 206f7420 itle>Welcome to > +40200030: 6e69676e 2f3c2178 6c746974 3c0a3e65 nginx!.< > +40200040: 6c797473 200a3e65 62202020 2079646f style>. body > +40200050: 20200a7b 20202020 69772020 3a687464 {. width: > +40200060: 65353320 200a3b6d 20202020 6d202020 35em;. m > +40200070: 69677261 30203a6e 74756120 200a3b6f argin: 0 auto;. > +40200080: 20202020 66202020 2d746e6f 696d6166 font-fami > +40200090: 203a796c 6f686154 202c616d 64726556 ly: Tahoma, Verd > +402000a0: 2c616e61 69724120 202c6c61 736e6173 ana, Arial, sans > +402000b0: 7265732d 0a3b6669 20202020 2f3c0a7d -serif;. }. +402000c0: 6c797473 3c0a3e65 6165682f 3c0a3e64 style>..< > +402000d0: 79646f62 683c0a3e 65573e31 6d6f636c body>.

Welcom > +402000e0: 6f742065 69676e20 3c21786e 3e31682f e to nginx!

> +402000f0: 3e703c0a 79206649 7320756f 74206565 .

If you see t > -- > 2.30.2 > Thanks /Ilias