From patchwork Thu Sep 14 16:18:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 722559 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp485420wro; Thu, 14 Sep 2023 09:21:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJSce5PXqKbbFF+SC0CN+HBo2aoN6lOcDRGDYABjFI62AVU8Ko3gH9e6ROicaRIMWp2iWw X-Received: by 2002:a5d:6a4c:0:b0:31f:af30:1bd9 with SMTP id t12-20020a5d6a4c000000b0031faf301bd9mr5029381wrw.44.1694708466433; Thu, 14 Sep 2023 09:21:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694708466; cv=none; d=google.com; s=arc-20160816; b=wQcmfojsNXMSINAfarlS6g05q0qUieNJ8G3XIYn2epf/0ylqR0etccImewhRizmkdx DSEntqUDgYyjfQM1oka5gIJD+DQ3efS+Bs2e5rm8TgIHhB0JHBfERRTAEWGh1Q7E1VQ7 oE0eSqmF3UQtJCr3kqE8yRA8r+ADZFzuctsG12FAmnHqzytkgzNGe7M3Ny4pZeoORxx5 KcYoWOvSH0S7GJR5o5JNj6Cf4y6QcCUalAO4NbJ95JMgePY9HP/3YCAGY8G9xGjT2XAU s8ADEd1JSXIU+wn+oUmUT3Ry9+au8UpusMoLw6gPnNtdrRYd7vGmjcRGRHeaIhA2/1ld 3Aug== 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=yCo0/5HYbNI4YL/U8alANvkZXn1a+pYOQPYcaoF6hFBI7tZAgy3L6ZauNTR9w35WOe E1iEAtwVU9CZ9sD/8iBY1EKCDjS8nykKGflZcQsGGx581RaTuNC/vbLDe3DnHdZK0sxU 1Jsicmi5NKLREBQL6XuYqVNt72ntgZ0Mqgr96fpb7apc4oHk8QDS4+aZKjys7hNx+dxf oI1chvpHGpqKtgFKG4hJBYOhJQwcUz4X60l19IscgR1m45SMELjgLQ9ptkrp2Y8wp/dT 3SN6fqgC38xLGEh+ii5jbOOXBkTwf4yLo4kjes5xJ8OE/t06rztDPikx48IpEiI3+WKA 6g5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yz2s0py2; 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 e12-20020adfef0c000000b0031f8cb5250fsi805480wro.1025.2023.09.14.09.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 09:21:06 -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=yz2s0py2; 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 0452A86AA2; Thu, 14 Sep 2023 18:20:45 +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="yz2s0py2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 945E286A3C; Thu, 14 Sep 2023 18:20:43 +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-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) (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 4762186672 for ; Thu, 14 Sep 2023 18:20:41 +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-x229.google.com with SMTP id 38308e7fff4ca-2bf66a32f25so17920021fa.2 for ; Thu, 14 Sep 2023 09:20:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694708440; x=1695313240; 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=yz2s0py2u8LPS/cBbe9AtJjfshM61oQDbP3BOJn2F0lbuA2U7mSqTGNz8o1dJPNabf Rr72xeE1nsN9spWqZi2kUZEQiJ+zW9PrwEEJra2lnGY8raQqnRFf0B5x0AJg2TMwUl5T KBCEFjAfc/YO9KRKnig68+QPxcp1QJu7P5g8Epf6sEsUst09UGA0FZh/hDLxWNcTsK2N nI5j+PE+oto/wSTPhv7Xo+MmPKuUj+4LJE9FgoZztxesyEqaonosX5Stlpdau5/nKh/t IvGwbwhLSy5+9iBG/DZg7pDtTXjjlfaOxAzd+92vcyYW79LdX2GICvqOLIA6cKjCDAfj hsFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694708440; x=1695313240; 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=SI/YPwBCW7Aj69ZLnLGnbveJTn2NsCRimMjy/oZUzawGQr+LJbp4MAyNMl30mQDQUw wvOnHFEaxr2Y0jkCVdaxGn1YVVIjjh8y2to7acN0b6Sz9I6tCW/oDK3DLaV966Gu5B+r QT4YvAubNFMILrPHJxWpHKQE7eITwfLcvm+mHWHdNQx4CXemygCwy+LbXFrlMeDDrChC 8UpWpATBk3nI6j/O9NuqEmNFidPrgXnFOWK03D1/6jVlUFrz5+5Q99dKA8TGuZAirdMp q4tpuFow+Rn6cwB/w0sHvL2uTcg85HO/0CA47RX70PHO7On9l76qUeAu1/5d8OwApa6x Ot4w== X-Gm-Message-State: AOJu0YyPqelK8Jg74WY9yLNR1RQVriqMcIeVzc1mUoQVqIrni4Us/EDy plCLjTfcHFwZmBwnBDQzaBshqjJuKRoGr4zZrxVkkg== X-Received: by 2002:a2e:9f06:0:b0:2bd:beb:4aca with SMTP id u6-20020a2e9f06000000b002bd0beb4acamr5170780ljk.13.1694708440428; Thu, 14 Sep 2023 09:20:40 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z15-20020a2e8e8f000000b002ba7ae1f52asm346919ljk.0.2023.09.14.09.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 09:20:40 -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: [PATCHv9 02/15] net/lwip: add doc/develop/net_lwip.rst Date: Thu, 14 Sep 2023 22:18:15 +0600 Message-Id: <20230914161828.3662-3-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230914161828.3662-1-maxim.uvarov@linaro.org> References: <20230914161828.3662-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: