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 7B10BC001B0 for ; Fri, 14 Jul 2023 14:22:48 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4193C86DBF; Fri, 14 Jul 2023 16:22:25 +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="c3yN6FPj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7B83C86D9F; Fri, 14 Jul 2023 16:22:24 +0200 (CEST) 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 C31A286D9F for ; Fri, 14 Jul 2023 16:22: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=maxim.uvarov@linaro.org Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4fb41682472so3134445e87.2 for ; Fri, 14 Jul 2023 07:22:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689344539; x=1691936539; 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=0ly0A465EoWIthKLtFvQ0b0chJdW/3kWw9H5ChuX6P4=; b=c3yN6FPjX+1JvMuVTisswh+zZYQX0WfYVK6Fo1HwZt2v8D3Cg9yb2wWVF/UkDfOaoa ZRgy2azybiu6U1OLNNAJFb8KSwP3JXNvtBeMpDyK3cppccmGNVQ3rTFuB9LSns55tvY/ PBEQiP9E3MK1LY4XtJV0oZwwKbko74l2NJYhXZDPr9a54h6s8LS4xBcL+MSOU+F9iOsz blKfQOvRQ/OPRp94N8QBA4+xdh2e8PugXCA9pxKuMdcikoImFvnmJ3NGKNgxktpllrHc fSf5JUcCp4QlzG6MwUWueL89IYL8wOHdZuHn5IgkCAjy24zj5VfGXqi1J+O3ZSuKu1RN RXNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689344539; x=1691936539; 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=0ly0A465EoWIthKLtFvQ0b0chJdW/3kWw9H5ChuX6P4=; b=j3AVrjr/2JCM73KbN8xt9eeXqDBiNdOdTQH+bcSuP8vLvGLKyESWVQauVhUtD1oS4u HSgbjYCmTUT75AuS5vcFJKyh/w9EqD+qtM+fMcR7wsdtSRve2Ge/fEQp3dxleCF3n5uC IPLaqUMx67Eq7pDf/MmQbOmy828J9NkdFRwxbNhnkx6jLtuhhj7hoMK/wbknFZ6bjkIg JfmWluV9NMkstC4GELaSjnKyQU2fRYmfJo8KfiF0AOZ3N5q83w63ho08OL4kds9188aY 30J929/r+YTcVkynOD5EaOqAZest9lQXmAGgN9JjLi4RHeCBKmXfFY6x3A+/fmbKlHR4 f/kg== X-Gm-Message-State: ABy/qLa8jcJSI1LfRPWPP0vj6ogNffDXt3cZyO1hHI0xbl1tVMUlDHEN dtTZU6p9IpKOzNfj+1/EXTHCxUGvH6lU3RupnC2Zvg== X-Google-Smtp-Source: APBJJlFfDLHOHPHVpWjc9Jddqu0MWlwYdjc8WCvcOkbdgowxTBFvQ3sfFZxwGdNjt3on54VawjaqvA== X-Received: by 2002:a19:6703:0:b0:4f8:7781:9875 with SMTP id b3-20020a196703000000b004f877819875mr3895542lfc.60.1689344539690; Fri, 14 Jul 2023 07:22:19 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id w28-20020ac2599c000000b004fb759964a9sm1504703lfn.168.2023.07.14.07.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 07:22:19 -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: [PATCHv4 3/5] net/lwip: add doc/develop/net_lwip.rst Date: Fri, 14 Jul 2023 20:19:58 +0600 Message-Id: <20230714142000.5534-4-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230714142000.5534-1-maxim.uvarov@linaro.org> References: <20230714142000.5534-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Just add inital doc. Signed-off-by: Maxim Uvarov --- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 59 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 doc/develop/net_lwip.rst diff --git a/doc/develop/index.rst b/doc/develop/index.rst index 97c526e997..a092c33df0 100644 --- a/doc/develop/index.rst +++ b/doc/develop/index.rst @@ -43,6 +43,7 @@ Implementation smbios spl uefi/index + net_lwip vbe version diff --git a/doc/develop/net_lwip.rst b/doc/develop/net_lwip.rst new file mode 100644 index 0000000000..567234fff2 --- /dev/null +++ b/doc/develop/net_lwip.rst @@ -0,0 +1,59 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +LWIP IP stack intergation for U-Boot +==================================== + +Intro +----- + +LWIP is a library for implementation network protocols, which is commonly used +on embedded devices. + +https://savannah.nongnu.org/projects/lwip/ + +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: LwIP 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). +For now only raw API is supported. + +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. + +Example is unmodified working ping example from lwip sources which registeres the callback: + +.. code-block:: c + + 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. -- 2.30.2