From patchwork Tue Sep 26 09:41:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 726404 Delivered-To: patch@linaro.org Received: by 2002:adf:ea87:0:b0:31d:da82:a3b4 with SMTP id s7csp2834188wrm; Tue, 26 Sep 2023 02:44:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+Cefq2dgJUG8ilqcr9zx/JE9feIFdfzqiUyzu/P/n7ltBjzed3JJv1wv38Nm0mOFibIJ5 X-Received: by 2002:a7b:cc88:0:b0:3fc:7eb:1119 with SMTP id p8-20020a7bcc88000000b003fc07eb1119mr8693629wma.15.1695721453321; Tue, 26 Sep 2023 02:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695721453; cv=none; d=google.com; s=arc-20160816; b=NEZBTVt3hSQENtMjYMGA21oElwthaQk1v+Il5Ag6C4B/MG9jKN42HXkeTFLyiKifYh yqWoGSNGccjm/Sr9/8vLqyrRMIonXODeoQ8zvKAr7SRaDZ4YzaSku3LC0slfLmpqYasl ERGwSUjnpXr9mTCgh0RrQ89IB2JGJbFxHzLnRJ6ZPqFIYC9Yq1F1pSX1AnhKDaw4DOUe lF1rC2i56t2AUf/LP088lSK2xulOP5wrrq6mIzyCk5BoUUZfleXEwuOcVni++CjAG0uV 0smf7zFRfYqVOda4dz39mt804wN1vw+ivHDG5gFF0w77P1XyObI0JGT6GMXbKNCFV3aZ WG3g== 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=KlGOSpnuP038/3uWYsQ6F/fPIq0GHwMSq4PrefaoKZA=; fh=g6X7VLA7Hwc4ddn6ja9UNjzyIs7WWcGrFqfXM5IokKA=; b=Y4+rCEfm3Dy+PU5BvfD+Tcs6aU1tGnIBSoZXIMuQq0OdStz6khov1I6tibgkuwcrXV okGeSRLHuAWP+58J4zbB5wKiJRcgD/7nzNvqg/PAdKp09C6jo63a9z2NXhTcH/hnyqvE vxknbRWijG6fcaDO/Vlf9etloSDKZe3e8WVN23Q2GGAdfLKh7FRf70MU4+w2lXjgvcni YAuhS5JCLJvr7l6nMB7iPN65/OGTFioKu1JBoMnJ7KUAnJGa8I74vhSVxd4YX6KG2dc7 BhMmw0s9ot6GdSdUWClWm4vNu0xYpGQexEtHOQf0JN42LMtlWyAIxh95Y7SZ45eg0zmx WVXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="xGHR/Jkk"; 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 Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id z22-20020a05600c0a1600b004053edf7356si5130770wmp.78.2023.09.26.02.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 02:44: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="xGHR/Jkk"; 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 Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 80A9286D24; Tue, 26 Sep 2023 11:43:51 +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="xGHR/Jkk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C289486D24; Tue, 26 Sep 2023 11:43:49 +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-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) (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 7F4A886AF7 for ; Tue, 26 Sep 2023 11:43:47 +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-x22b.google.com with SMTP id 38308e7fff4ca-2c123eed8b2so138887281fa.0 for ; Tue, 26 Sep 2023 02:43:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695721426; x=1696326226; 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=KlGOSpnuP038/3uWYsQ6F/fPIq0GHwMSq4PrefaoKZA=; b=xGHR/JkkORgxkxWACmHhnaz110u+XWpdU07Aowb6gncHkkIIKCrQYKZo9Lu8m3ITW3 bYu/NtDIXlliX8um3DAZRjEbCST3CPpY+azUBOM+m2rmlI1DyXgsEBvAo9GcWXP6KjoN hzGEr7O2R0nCnVWAa0HwjikZ804LxxFTcDtggCAShIoIaHtmqk3oVl0Fd4WtS8o0OXy1 IjSEKmPM9Y2RT8RLDk2xtK8MdY4LmQlpWn9DoUEMtSeWa9kgi5BlhQN38pzp+F7Emh8G c5BnCU7IBF+CXGYj0ouWp2RU6hirQsqtuXuou4Etd+WUhQ6zqOGmfKZPFj4Aj+/YWv5J pMuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695721426; x=1696326226; 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=KlGOSpnuP038/3uWYsQ6F/fPIq0GHwMSq4PrefaoKZA=; b=OFjNVPXSds6P5aSnjvOhNpAp0QeYPAwBChWvXkb+noJS3SfsoFUfSNJEQjtdOvxXX2 eaWPm0HPrlrbOezdvCZUoooiKOEGwLv7U+xlNsj9x8jBQGWE5YMqKVBDsAyiA+Hrylcj EBM1pulWK5pTziOrA95Cmcd5Z0En2IkM7Uo9wujmVpDmB3Vl8zD2oAfgtJWJ6g8ozXyy 7FzJv6xmkRwnBnue9kcNmPJ9/Vy2EKG1S9pwn1cm4BX4hoiCoRXvCH4AgRXAyp0zjXmi jwYvGQLV1jIx0fc5+j025YB4Hl9lUZ4cJbAnoB6q8wj62+/2U15t7NGpP5QzHBWAn0mv K4Pg== X-Gm-Message-State: AOJu0YzDEsgNkpduQsBXotfWB7nilOrk+sYccrUh7O74bXKvJqV+raUC VCegiMFTw8BtDLYuyiOmIIYvL1bKbCV+H1SLiPPTZQ== X-Received: by 2002:ac2:58cc:0:b0:500:7fc1:414b with SMTP id u12-20020ac258cc000000b005007fc1414bmr7480977lfo.25.1695721426641; Tue, 26 Sep 2023 02:43:46 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id x6-20020ac25dc6000000b004fe09e6d1e7sm2131131lfq.110.2023.09.26.02.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 02:43:46 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@gmail.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, Maxim Uvarov , Simon Glass Subject: [PATCHv10 03/15] net/lwip: add doc/develop/net_lwip.rst Date: Tue, 26 Sep 2023 15:41:12 +0600 Message-Id: <20230926094124.7024-4-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230926094124.7024-1-maxim.uvarov@linaro.org> References: <20230926094124.7024-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 Add initial documentation of lwIP network IP stack integration to the U-Boot (net_lwip.rst). Signed-off-by: Maxim Uvarov Reviewed-by: Simon Glass Reviewed-by: Ilias Apalodimas --- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 75 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 doc/develop/net_lwip.rst diff --git a/doc/develop/index.rst b/doc/develop/index.rst index 5b230d0321..4764990f25 100644 --- a/doc/develop/index.rst +++ b/doc/develop/index.rst @@ -48,6 +48,7 @@ Implementation spl falcon 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..a77ab60d0f --- /dev/null +++ b/doc/develop/net_lwip.rst @@ -0,0 +1,75 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +lwIP IP stack integration for U-Boot +==================================== + +Intro +----- + +lwIP is a library implementing 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 second variant was selected: lwIP is very customizable + with defines for features, memory size, types of allocation, some internal + types and platform specific code. It turned out easier 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. + +In raw IP mode a callback function for RX path is registered and will be called +when packet is passed to the IP stack and is ready for the application. + +One example is the unmodified working ping example from lwip sources which +registered 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) + +3.  Input and output + +RX packet path is injected to U-Boot eth_rx() polling loop and TX patch is in +eth_send() accordingly. That way we can leave the driver code unmodified and +consume packets once they are ready. So we do not touch any drivers code and +just eat packets when they are ready. + +U-Boot lwIP Applications +======================== + +.. kernel-doc:: include/net/lwip.h + :internal: + +lwIP API to control polling loop +================================ + +.. kernel-doc:: include/net/ulwip.h + :internal: