From patchwork Wed Jul 5 15:14:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 699244 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp2834250wrs; Wed, 5 Jul 2023 08:17:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7dEgfumIuc+S+L4g4kmLBzBGkp17CAM4hPRP60K2PG9E3Y2k9Ukv+MkN1O334ltfkVH5/f X-Received: by 2002:a05:6808:1b0c:b0:3a1:b309:a409 with SMTP id bx12-20020a0568081b0c00b003a1b309a409mr20575619oib.4.1688570241893; Wed, 05 Jul 2023 08:17:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688570241; cv=none; d=google.com; s=arc-20160816; b=FI3h7mBFbhtZW1CQZgopREtlhYwZrZGlcci95nnKkAqBfMaPVuKKmhQzm+LDy8fHci L75Hx35qaWkxunQIx7DC5O8TR6eanUEQpP7p4utpv/hoMxqSEETsGQzHaEbur89YIe7D Iypa8z6cDkNLw54MEdDozUoSSCypru4pLD4EQVuzrzbKEi+f6MrtQ7D0C8h9i5lqfNBf EdT/poSjxhR+FIYX+miOmo4iwUpXh6thPunQDU8bvgq3HC8TELoIwCfK7+9jl/jGKCa9 T3NkNJ3ynJ3bnyN5nMtdK9Yt2gwtCHT+NT9ls0XpmpRxPJtam0SBJ+Y8hzdciNiX9X7L qQaA== 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=NUHfTXvQhD99zw7Pjse+RYnJEZtmJSWWM6c/nveDUUc=; fh=378OOY3Qcv/6SzHacyD4RkrbXzlmlfqp4CO9kQxJxOk=; b=ni0UAIk6xy7fy4ZmYTUhppn1tSY2JxAibWKyAWg3y+gb8OWgDdxMkWHVJHdVSZQ0Iw lN0OYFKejOL5GfMorQKAe5i2mhWMiaS+UA2h76dxCZLrT0tBdv33GGWlrYB65ZUASULY PvxhCHkaT3rbNZseQrIw+oliGwuM/a7Chc+rr9q7a4QRFXYWt8ch/ofohT0Hcgjcctg3 h+DlUbosNtFvVYYY+0Std4OY9+ICNBXNNmZXfUsERUSYW9WAshc6XPMALw3JcaXt/uRb jjUWiq1bfR5TVzk8C7M4WDg07AXxr/oTpN7/tZ5ziDqim0rWv+aZYmS2M97vIs66mUdZ tbNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MLSy1JXS; 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 11-20020a630f4b000000b00553c2f85085si23724121pgp.220.2023.07.05.08.17.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 08:17:21 -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=MLSy1JXS; 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 EA4768639C; Wed, 5 Jul 2023 17:16: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=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="MLSy1JXS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 30CB086288; Wed, 5 Jul 2023 17:16:45 +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-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 64489861E1 for ; Wed, 5 Jul 2023 17:16: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-2b702319893so7811821fa.3 for ; Wed, 05 Jul 2023 08:16:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688570200; x=1691162200; 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=NUHfTXvQhD99zw7Pjse+RYnJEZtmJSWWM6c/nveDUUc=; b=MLSy1JXSKwAB22l+0YuJm4w+qR0S14qnl05i76zR6gCnI4Ot0fQhdRMUsmd1cXoi12 7zOvi7JkQcga0hRDNaEpKHePvEORmEuekrXtzH1n9YpVpL5N4ED8Gzcp7JFvPj15xHdE YHFQCfFXbOZInijbJu2MQZlskKvovRvfL16X70VA/U6o69Op44YuzXe5KpzTmxAHlH2v XdqPVr+3iOTr8+QQAi3BRk+T0RazTIfluj5PpsiPlVwgn24nOis8gXLDqjhife9FEJHJ yrnmErDg9td10Fj6SbxZ0OkAkl0OSdZSbBLQVlKCPA35cAlmlpQdjBX8XNjs7YwbLbgg TkRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688570200; x=1691162200; 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=NUHfTXvQhD99zw7Pjse+RYnJEZtmJSWWM6c/nveDUUc=; b=iadv2QfD4DupZW5U4/6uIGl4p2HJozOatsJ4DMTMGOWbVhmZLVhwgpzNcF4DofYR7y WBKoJLEMskGTTs0CRRkYEnw1wSUROgGuwWa9B2bXp0BqR38Ri8ztaed9crQayugxunMw 5j/vEE0Fn3DbTTRRhWbDlyRHJKbxVc4vMDW45UgS7J5DQTx9k0wB+QDWF6aqCkmFA/dN 9LlHNPWK1Q4612DA5a4I/g6mS4NQlHFXVpSi9v5oW5owkRMJduWLTG5gcC5xPC2O7uCa iNcAEHiajERmUc2tyAhoPPX5U/lPCfjgZrfuf6E2rOmkfV8yrozQ9ZSWb2R5dHhzVI07 uMXA== X-Gm-Message-State: ABy/qLZEeIJJriMccbOqcwbtf/jBG2eFmwg1MzzFZNage324GdtaTVaQ /pnLOc/el2jITpFPH5/u4zRNAwH9kgktLaHOaqM= X-Received: by 2002:a2e:9349:0:b0:2b6:e2c2:d234 with SMTP id m9-20020a2e9349000000b002b6e2c2d234mr7141923ljh.33.1688570200557; Wed, 05 Jul 2023 08:16:40 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id c8-20020a05651c014800b002b6c61bac2esm3990560ljd.92.2023.07.05.08.16.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 08:16:40 -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: [PATCHv3 3/3] net/lwip: add doc/develop/net_lwip.rst Date: Wed, 5 Jul 2023 21:14:21 +0600 Message-Id: <20230705151421.10792-4-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230705151421.10792-1-maxim.uvarov@linaro.org> References: <20230705151421.10792-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..2520fe11b1 --- /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.