From patchwork Fri Jul 14 14:19:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 702723 Delivered-To: patch@linaro.org Received: by 2002:adf:db4e:0:b0:314:25da:8dc4 with SMTP id f14csp1114120wrj; Fri, 14 Jul 2023 07:22:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlHygk9PtsT2jbyRSN4lPmxc+yJhO7LPY3PJgWEeR0Kd2jYFparj0s5ZM/1RLMuLof/uH+a+ X-Received: by 2002:a05:6402:541:b0:516:81d3:2627 with SMTP id i1-20020a056402054100b0051681d32627mr5641847edx.0.1689344569314; Fri, 14 Jul 2023 07:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689344569; cv=none; d=google.com; s=arc-20160816; b=aYA8W66KYRE3MgQnKoi3Lk6K+FYK+puGYFFvbG1sgjbSxQB3SA6NurYFkbBEexp/XW HtmgX4YfgOzrDF6xCpip0bK/K6baBVQ4rVzJoo2Cq2C5TZH7FQ0MC7OyeoISzOxEFVA3 HU6EVmQ7hqPPTs3XWV7A47Z/KeTEXFWq3NKay1CjGnBHprjDqBBMxsMf0uxdYg5Boaji 42+PerOh4ksrqPM4zQV/Vg1lq9roFhIvuCoKrG/xCgTZ4eF5Av64mklzOEXchQTfqYiG YwyNGE03nayiNajzTq9Nz59IWnCWGM8KHI7Xb3i0q72WtIeasJHo1AQH8/aEyXfKNPAi HDKQ== 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=0ly0A465EoWIthKLtFvQ0b0chJdW/3kWw9H5ChuX6P4=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=sc1IYJYsxeQEgmsLivHTBDC24ZREj+0teyeCgBJBMigijwmpqCiFme1Mkt8lJT+2rQ EecjMC3PHOLHz/I5RWXxo5oo5TUj7of+CczTokCxOxfRRYyHIwe/StDdjYNOv5nS20tR wkMTXM/fQNXyfdp6BKz0gvzK8Oh+D6/pKF8pjL1li80NlAxSUsGWc932bMVJdEU8MFy7 QTW7u99K6FNCGMLkoZITT22qzwCbjnDNx7ViUbBTtVW2DbIXGXt+4VllHcdtGY7aQSlJ +vY45wn9LDF72YNCuO7KQ2L60uV5KS3wvMebJGSs6ry+1Hq32FasqWE7qgtRFvZcBoOr deEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c3yN6FPj; 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 m12-20020a50ef0c000000b0051df544225csi1992536eds.540.2023.07.14.07.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 07:22:49 -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=c3yN6FPj; 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 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) 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 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-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 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.