From patchwork Fri May 5 10:25:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 679298 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp283222wrs; Fri, 5 May 2023 03:50:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Dvo6woB4/UAmlrmdpVSroSxVXHSkCg/kLFDJdXx5sqeVHk2bBga3PL1rRqcdU6NAGmVzp X-Received: by 2002:a17:903:41cd:b0:1ac:3fe0:d696 with SMTP id u13-20020a17090341cd00b001ac3fe0d696mr1679862ple.9.1683283851354; Fri, 05 May 2023 03:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683283851; cv=none; d=google.com; s=arc-20160816; b=o/8osZSZ+a/y2iVCgOHuijH7/sX2Jlc0HXrexwZHuG7HHAHqbk2tUWVAXn8ikjYWv5 L4Ie4Riyo6e9rTskYe725OkU3FgjzUuiX0r1cBbsYiFoDknKjdrJjdkfPM0Wtnsc9j0Z mmdgBh23MdAsm03Rjm6hsKd+c3LP7fmD/Rl4MwN5QxcLgswxzkPuwPaLsj18ayWMpHWn S8nZWuGSGt1IHApMRjtsEU5dXsC+nlIqmH3Fzfrf0d7ZVjDGOW+UP4SL97UEKIZXqvuB klQTcgF4ds2fXBivzvoqC9uPCP8naz+PUIAAqrW2KHNPj0XKdoLWzVYHjLSydSoxFAfg 7xDw== 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=4LkM4W7ivpVVW5/EZUVZyK9/9jX+Jixz6g1kXRSSlwc=; b=gKOMZBfH8JALNGZoHuKhxbA/6+pP0J0Li1QHDe37Ur13xkXAZ8cGL0RPWHCKxmskp2 qTUzLhBrRxe5/IFbAB4RcOq9RMJV4HeGDK2Yc+Mt3jIBvKps9NrdYVlbH0NK2jYdIutA EqMYhHpCFyAmnG8iGIvAMZvd9qVXzGpNxdn7W84sUuq60u74izaC7jaXGb952gYTOnP0 /xilIcq4CpN4FxbESgS3ezRzHWEVKPKLhpESw63sYCJnuu4erx5k5Q9pQOX+fbkqW5/4 /yDR+3Osim9ICAn6CyuplGFB+uu9y+ddKAzOOxC46RdNxeaHF5pKM812PhdlSBrxNd/o 6PiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="iTKwH//h"; 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 c12-20020a170903234c00b001a64e7b702fsi1500607plh.447.2023.05.05.03.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 03:50:51 -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="iTKwH//h"; 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 72AB6847BD; Fri, 5 May 2023 12:50:33 +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="iTKwH//h"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5AF9784735; Fri, 5 May 2023 12:25:39 +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-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) (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 92E6F8475F for ; Fri, 5 May 2023 12:25:36 +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-oa1-x2a.google.com with SMTP id 586e51a60fabf-18f4a6d2822so16424977fac.1 for ; Fri, 05 May 2023 03:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683282335; x=1685874335; 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=4LkM4W7ivpVVW5/EZUVZyK9/9jX+Jixz6g1kXRSSlwc=; b=iTKwH//h9DmQgE3mWvnbgLNV3y4JnaE9A0A03ld6+8BAJirtSKALepUgYsOalmZ+Gu XDS+8QTnFVuhEzUwt3weU5cMinlJuKcgARNNH70EFMtUFwNqF6Ut2piHYJO65TyxCKHu JO1NQUcbhnozcYAaheKB3/XoMbHLF42OYIyZUwx7LDF03A6AeF5tmPgKw/wrsIZMAm+s /IKGSpykYE9Qpvn+c4Eewnoz2PsKP9yXUgHErtgiuot1c9Ohd+sYeeWeh0kte5o5TQrS zJhdhCHn2OSN3kRJ++ffDPhmYu10OPFyJnBBPBYNY0KfLGTLRU28Wl4l2KeYUze15eIT +RTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683282335; x=1685874335; 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=4LkM4W7ivpVVW5/EZUVZyK9/9jX+Jixz6g1kXRSSlwc=; b=Hfl3N8LOZW240WMgjkKOBYdO76Xony1dIVje+71N6inDYbR8oTfTR7sKynN0r4iF/R M1u2sv6Ck5dvLcUgMpq1dYialc+dmRMyE1l3E+nLv1Gt2dTP5uM4HdZ1P0MCTk1fefl9 SoEhWJMMJSsPvQZW9m7PGyfFEdKdImbF7tllV0NGqTTmqo0Uc6lOhb3BfmRX6RY1W0LR Y1+Z+IcPDk6vE61acYK+ZxCDt+VzDUPBsiCA84HiixocR6F9wbOMfpg4ylC0tvOl98c5 nvDfAROrUdqztFubWezxrH4sluyV8Br3p6kUSZYKNv1n+is3RnpzaDpyWMSvEbpZi29r 8YHA== X-Gm-Message-State: AC+VfDxg9FVnfqGi1C+Rj0VvlSyD/ealRKCAz0jP0hhi2lDsTx+VY8/V m19BEmg9EdVTdxm1OxOLnJSqcORFDNCQJhZbdzg= X-Received: by 2002:a05:6830:1bd8:b0:6a9:2f56:942e with SMTP id v24-20020a0568301bd800b006a92f56942emr641771ota.2.1683282334809; Fri, 05 May 2023 03:25:34 -0700 (PDT) Received: from ledge.ozog.com ([2604:1380:4111:b700::1]) by smtp.gmail.com with ESMTPSA id b21-20020a056830105500b006a6169cf6b0sm635068otp.47.2023.05.05.03.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 03:25:34 -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, Maxim Uvarov Subject: [RFC PATCH 1/5] add lwip-external submodule Date: Fri, 5 May 2023 10:25:25 +0000 Message-ID: <20230505102529.1254445-2-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.40.1.476.g69c786637d In-Reply-To: <20230505102529.1254445-1-maxim.uvarov@linaro.org> References: <20230505102529.1254445-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 05 May 2023 12:50:31 +0200 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 Signed-off-by: Maxim Uvarov --- .gitmodules | 3 +++ lib/lwip/lwip-external | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 lib/lwip/lwip-external diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..afc709af10 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/lwip/lwip-external"] + path = lib/lwip/lwip-external + url = https://git.savannah.nongnu.org/git/lwip.git diff --git a/lib/lwip/lwip-external b/lib/lwip/lwip-external new file mode 160000 index 0000000000..3fe8d2fc43 --- /dev/null +++ b/lib/lwip/lwip-external @@ -0,0 +1 @@ +Subproject commit 3fe8d2fc43a9b69f7ed28c63d44a7744f9c0def9 From patchwork Fri May 5 10:25:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 679302 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp283573wrs; Fri, 5 May 2023 03:51:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5/1mIzewpZpSF1SCCx1wRmFBBSkGseWwpdIQ7Aa4jaxtJPR/vp5LYFM2XEx1oGMTXdod03 X-Received: by 2002:a05:6a20:432b:b0:f5:a437:26f with SMTP id h43-20020a056a20432b00b000f5a437026fmr1349050pzk.18.1683283910468; Fri, 05 May 2023 03:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683283910; cv=none; d=google.com; s=arc-20160816; b=WsKG8rQ6364uAfNc4YpAIZrp3QL8GWF55yQRinsYAXNWxN80D9+VrNgoCNp1HpaMl8 JIa8Z5iEGe98jglX41N+Ah3iCOZMGMvBwMLalDnZNAB8M2N5n0yxplQiXJ8ps6rUz7Tu rO4jL3LvMeqZ5LmHWG/+Si6dsZepl1jKqbYWA5UuFfS+MwgbPINmCu6Xf5VOAzrSl+zI GzdQpWE9G+Y+G9V2MU90cLegHxaB+0Yj5sz7jUJOCWz2BDnqsu8Uz1FBKw60dNKQhluB RXEIYnn6rERwiG9zQYQ9wuZ3PAcfILWYEQ5db2qeJyeETKhWZm6/AcJRh0hQ1OI4510B x5rA== 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=Mhk2NjaYWbj8D/PycDDKwb6E/D6WhOaV1npGrYuj1ck=; b=KegaA6DQjEK6SxDAyp5UaQT4YjmQsNbTzawC9btZS2p4AyCVDG2nS+Dm34qGd0TKcz Ji1/Nr4DclTzEHpd1gmhN2sNQwQSHx7PsYZPYVySHiqJX61IA1KxYDclRmj1+5p4W4Sh m3Z2kIGJwKHsSKyx3Se6MbCAPDM2Ed3Jr1MBLk56zDUakE/dExovF6D7s/bOSVwll9pB i2l7hH4LgHlq+JxtKz+jT+ixBro4OePCFgfwt6I4E7LW5W/0yrdrxO2Ine1abRYM3cCu Qe9xowi9hWdLXYTFGt6CCJpFliL0n5n+vD4PEXuI9ilgH8LRhflP/RALJYvfX/DcuBEp /i3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=byq1pNJw; 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 z13-20020a637e0d000000b0050beec91e30si1611946pgc.768.2023.05.05.03.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 03:51:50 -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=byq1pNJw; 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 7DCD085815; Fri, 5 May 2023 12:50:39 +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="byq1pNJw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C162B84761; Fri, 5 May 2023 12:25: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-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) (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 D11E48476E for ; Fri, 5 May 2023 12:25:37 +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-ot1-x32e.google.com with SMTP id 46e09a7af769-6a5fe1ebc42so590581a34.1 for ; Fri, 05 May 2023 03:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683282336; x=1685874336; 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=Mhk2NjaYWbj8D/PycDDKwb6E/D6WhOaV1npGrYuj1ck=; b=byq1pNJwf7ynXOFLfgcvyoXMlxzn8u8en7QT9kJcz2D8WT2c2sFVD734K8A6COz++u r+RcqPZzKcrIJ2YOR4c+HfZJ/xA4UAoeaZSPGVjbD9LEpakm0oRg60dRFuAI5YsjmaaR /O7xO3gamgKY2SOmXMVZmwTGFPILGOiCgkNGH3giACRWID1rU/zNURAViFWQX6e+F8RN Dg8Y8cEP7W9dFgjl7WT954RpaouiAbzT0+C7sUYb7wGG9tUEOR0fWTG9/Y5WeSyJ6dt7 N5RLiK9bXuolPYoJSlFY8Kn2PIqh4DwsrZilF3XLt6qTYz9sDomxORBxgQq3ksl9q9v0 rBeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683282336; x=1685874336; 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=Mhk2NjaYWbj8D/PycDDKwb6E/D6WhOaV1npGrYuj1ck=; b=BJbRjQF/9rkn7Pc4XYy+Y1flDM/cA7h0+RwP4OvCGpC/F5d5LUy09Vkj8+cnTuOn00 CYJgY8G6YHcvuyCP+iyzGtWRJXoVOp/RgfSit1pROu4SUBM7RuBHPQ29dYADKSbpPT/q qoOSPg9giUfNpDg1sJtyZo4I9xsmZ5vx7+ghXcxBAaM8NCgQLUrSuNij/HvcYOChxtCb 3O7Y5a2V3zhTWM2ttCB3/mAvM826JAQ7o7Vh/czS/M3RhLBsIt1OLE2y7qlAwBEMqgF0 0ju0VXqdddLQ6iwsJ1OJSiZ4y7FENbBr1lhpGl366a+t5alEOnVUxyos3srNstGVaIE/ zOag== X-Gm-Message-State: AC+VfDweZmyLyrlM51tQnm7H8KCX9qgctD8gg2v21cIL85vOopTo5hQg X6fGk2FvgZamyM7q9UA0plShbGhDOqdxJLbhfEsWnzoW X-Received: by 2002:a9d:730f:0:b0:6a4:402d:a725 with SMTP id e15-20020a9d730f000000b006a4402da725mr386933otk.4.1683282335548; Fri, 05 May 2023 03:25:35 -0700 (PDT) Received: from ledge.ozog.com ([2604:1380:4111:b700::1]) by smtp.gmail.com with ESMTPSA id b21-20020a056830105500b006a6169cf6b0sm635068otp.47.2023.05.05.03.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 03:25:35 -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, Maxim Uvarov Subject: [RFC PATCH 2/5] lib/lwip: compile-in core files Date: Fri, 5 May 2023 10:25:26 +0000 Message-ID: <20230505102529.1254445-3-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.40.1.476.g69c786637d In-Reply-To: <20230505102529.1254445-1-maxim.uvarov@linaro.org> References: <20230505102529.1254445-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 05 May 2023 12:50:31 +0200 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 Signed-off-by: Maxim Uvarov --- .gitignore | 3 + include/net.h | 2 +- lib/Kconfig | 2 + lib/Makefile | 2 + lib/lwip/Kconfig | 12 + lib/lwip/Makefile | 78 ++++ lib/lwip/apps/ping/lwip_ping.c | 33 ++ lib/lwip/apps/ping/lwip_ping.h | 19 + lib/lwip/apps/ping/ping.h | 0 lib/lwip/apps/ping/rmstatic.patch | 32 ++ lib/lwip/cmd-lwip.c | 98 +++++ lib/lwip/lwipopts.h | 484 +++++++++++++++++++++++++ lib/lwip/port/if.c | 256 +++++++++++++ lib/lwip/port/include/arch/cc.h | 41 +++ lib/lwip/port/include/arch/sys_arch.h | 78 ++++ lib/lwip/port/include/arch/u-sockets.h | 26 ++ lib/lwip/port/include/limits.h | 0 lib/lwip/port/sys-arch.c | 7 + net/eth-uclass.c | 4 +- net/net.c | 14 + 20 files changed, 1189 insertions(+), 2 deletions(-) create mode 100644 lib/lwip/Kconfig create mode 100644 lib/lwip/Makefile create mode 100644 lib/lwip/apps/ping/lwip_ping.c create mode 100644 lib/lwip/apps/ping/lwip_ping.h create mode 100644 lib/lwip/apps/ping/ping.h create mode 100644 lib/lwip/apps/ping/rmstatic.patch create mode 100644 lib/lwip/cmd-lwip.c create mode 100644 lib/lwip/lwipopts.h create mode 100644 lib/lwip/port/if.c create mode 100644 lib/lwip/port/include/arch/cc.h create mode 100644 lib/lwip/port/include/arch/sys_arch.h create mode 100644 lib/lwip/port/include/arch/u-sockets.h create mode 100644 lib/lwip/port/include/limits.h create mode 100644 lib/lwip/port/sys-arch.c diff --git a/.gitignore b/.gitignore index eb769f144c..aeaf847543 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,6 @@ __pycache__ # pylint files /pylint.cur /pylint.out/ + +/lib/lwip/lwip-external +lib/lwip/apps/ping/ping.c diff --git a/include/net.h b/include/net.h index 1a99009959..8622983597 100644 --- a/include/net.h +++ b/include/net.h @@ -561,7 +561,7 @@ extern int net_restart_wrap; /* Tried all network devices */ enum proto_t { BOOTP, RARP, ARP, TFTPGET, DHCP, PING, PING6, DNS, NFS, CDP, NETCONS, - SNTP, TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, NCSI, WGET + SNTP, TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, NCSI, WGET, LWIP }; extern char net_boot_file_name[1024];/* Boot File name */ diff --git a/lib/Kconfig b/lib/Kconfig index 3c5a4ab386..7485a1f3bf 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -1031,3 +1031,5 @@ menu "FWU Multi Bank Updates" source lib/fwu_updates/Kconfig endmenu + +source lib/lwip/Kconfig diff --git a/lib/Makefile b/lib/Makefile index d77b33e7f4..3b80a41187 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -91,6 +91,8 @@ obj-$(CONFIG_LIBAVB) += libavb/ obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += libfdt/ obj-$(CONFIG_$(SPL_TPL_)OF_REAL) += fdtdec_common.o fdtdec.o +obj-y += lwip/ + ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16-ccitt.o obj-$(CONFIG_$(SPL_TPL_)HASH) += crc16-ccitt.o diff --git a/lib/lwip/Kconfig b/lib/lwip/Kconfig new file mode 100644 index 0000000000..dd0b3d4671 --- /dev/null +++ b/lib/lwip/Kconfig @@ -0,0 +1,12 @@ +config LWIP_LIB + bool "Support LWIP library" + help + Selecting this option will enable the shared LWIP library code. + +config CMD_LWIP + bool "lwip" + default y + depends on LWIP_LIB + help + lwip networking command. + diff --git a/lib/lwip/Makefile b/lib/lwip/Makefile new file mode 100644 index 0000000000..2c665dcb88 --- /dev/null +++ b/lib/lwip/Makefile @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# (C) Copyright 2023 Linaro + +LWIPDIR=lwip-external/src + +ccflags-y += -I$(CURDIR)/lib/lwip/port/include +ccflags-y += -I$(CURDIR)/lib/lwip/lwip-external/src/include -I$(CURDIR)/lib/lwip + +obj-y += $(LWIPDIR)/core/init.o \ + $(LWIPDIR)/core/def.o \ + $(LWIPDIR)/core/dns.o \ + $(LWIPDIR)/core/inet_chksum.o \ + $(LWIPDIR)/core/ip.o \ + $(LWIPDIR)/core/mem.o \ + $(LWIPDIR)/core/memp.o \ + $(LWIPDIR)/core/netif.o \ + $(LWIPDIR)/core/pbuf.o \ + $(LWIPDIR)/core/raw.o \ + $(LWIPDIR)/core/stats.o \ + $(LWIPDIR)/core/sys.o \ + $(LWIPDIR)/core/altcp.o \ + $(LWIPDIR)/core/altcp_alloc.o \ + $(LWIPDIR)/core/altcp_tcp.o \ + $(LWIPDIR)/core/tcp.o \ + $(LWIPDIR)/core/tcp_in.o \ + $(LWIPDIR)/core/tcp_out.o \ + $(LWIPDIR)/core/timeouts.o \ + $(LWIPDIR)/core/udp.o + +# IPv4 +obj-y += $(LWIPDIR)/core/ipv4/acd.o \ + $(LWIPDIR)/core/ipv4/autoip.o \ + $(LWIPDIR)/core/ipv4/dhcp.o \ + $(LWIPDIR)/core/ipv4/etharp.o \ + $(LWIPDIR)/core/ipv4/icmp.o \ + $(LWIPDIR)/core/ipv4/igmp.o \ + $(LWIPDIR)/core/ipv4/ip4_frag.o \ + $(LWIPDIR)/core/ipv4/ip4.o \ + $(LWIPDIR)/core/ipv4/ip4_addr.o +# IPv6 +obj-y += $(LWIPDIR)/core/ipv6/dhcp6.o \ + $(LWIPDIR)/core/ipv6/ethip6.o \ + $(LWIPDIR)/core/ipv6/icmp6.o \ + $(LWIPDIR)/core/ipv6/inet6.o \ + $(LWIPDIR)/core/ipv6/ip6.o \ + $(LWIPDIR)/core/ipv6/ip6_addr.o \ + $(LWIPDIR)/core/ipv6/ip6_frag.o \ + $(LWIPDIR)/core/ipv6/mld6.o \ + $(LWIPDIR)/core/ipv6/nd6.o +# API +obj-y += $(LWIPDIR)/api/api_lib.o \ + $(LWIPDIR)/api/api_msg.o \ + $(LWIPDIR)/api/err.o \ + $(LWIPDIR)/api/if_api.o \ + $(LWIPDIR)/api/netbuf.o \ + $(LWIPDIR)/api/netdb.o \ + $(LWIPDIR)/api/netifapi.o \ + $(LWIPDIR)/api/sockets.o \ + $(LWIPDIR)/api/tcpip.o + +# Netdevs +obj-y += $(LWIPDIR)/netif/ethernet.o + +obj-y += port/if.o +obj-y += port/sys-arch.o + +obj-$(CONFIG_CMD_LWIP) += cmd-lwip.o + +$(obj)/apps/ping/ping.o: $(obj)/apps/ping/ping.c +$(obj)/apps/ping/ping.c: + cp ./lib/lwip/lwip-external/contrib/apps/ping/ping.c $(obj)/apps/ping/ping.c + patch -p1 < $(obj)/apps/ping/rmstatic.patch + +obj-$(CONFIG_CMD_LWIP) += apps/ping/ping.o +obj-$(CONFIG_CMD_LWIP) += apps/ping/lwip_ping.o + + diff --git a/lib/lwip/apps/ping/lwip_ping.c b/lib/lwip/apps/ping/lwip_ping.c new file mode 100644 index 0000000000..91ce63063a --- /dev/null +++ b/lib/lwip/apps/ping/lwip_ping.c @@ -0,0 +1,33 @@ +#include "lwip/opt.h" + +#include "lwip_ping.h" + +#include "lwip/mem.h" +#include "lwip/raw.h" +#include "lwip/icmp.h" +#include "lwip/netif.h" +#include "lwip/sys.h" +#include "lwip/timeouts.h" +#include "lwip/inet_chksum.h" +#include "lwip/prot/ip4.h" + +#include "lwip/ip_addr.h" + +extern const ip_addr_t* ping_target; + +static ip_addr_t ip_target; + +int lwip_ping_init(char *ping_addr) +{ + //ipaddr_aton(ping_addr, ping_target); + IP4_ADDR(&ip_target, 192,168,1,2); + ping_target = &ip_target; + if (ping_target == 0) { + printf("%s() wrong ping addr\n", __func__); + return -1; + } + + ping_raw_init(); + + return 0; +} diff --git a/lib/lwip/apps/ping/lwip_ping.h b/lib/lwip/apps/ping/lwip_ping.h new file mode 100644 index 0000000000..047dfc2111 --- /dev/null +++ b/lib/lwip/apps/ping/lwip_ping.h @@ -0,0 +1,19 @@ +#ifndef LWIP_PING_H +#define LWIP_PING_H + +#include + +/** + * PING_USE_SOCKETS: Set to 1 to use sockets, otherwise the raw api is used + */ +#ifndef PING_USE_SOCKETS +#define PING_USE_SOCKETS 0 +#endif + +//void lwip_ping_init(const ip_addr_t* ping_addr); +int lwip_ping_init(char *ping_addr); + +void ping_raw_init(void); +void lwip_ping_send_now(void); + +#endif /* LWIP_PING_H */ diff --git a/lib/lwip/apps/ping/ping.h b/lib/lwip/apps/ping/ping.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/lwip/apps/ping/rmstatic.patch b/lib/lwip/apps/ping/rmstatic.patch new file mode 100644 index 0000000000..758ce729fa --- /dev/null +++ b/lib/lwip/apps/ping/rmstatic.patch @@ -0,0 +1,32 @@ +--- ./lib/lwip/lwip-external/contrib/apps/ping/ping.c 2023-05-03 13:20:14.510795833 +0000 ++++ ./lib/lwip/apps/ping/ping.c 2023-05-03 14:37:05.497873883 +0000 +@@ -93,7 +93,7 @@ + #endif + + /* ping variables */ +-static const ip_addr_t* ping_target; ++const ip_addr_t* ping_target; + static u16_t ping_seq_num; + #ifdef LWIP_DEBUG + static u32_t ping_time; +@@ -304,9 +304,9 @@ ping_recv(void *arg, struct raw_pcb *pcb + iecho = (struct icmp_echo_hdr *)p->payload; + + if ((iecho->id == PING_ID) && (iecho->seqno == lwip_htons(ping_seq_num))) { +- LWIP_DEBUGF( PING_DEBUG, ("ping: recv ")); ++ printf("ping: recv "); + ip_addr_debug_print(PING_DEBUG, addr); +- LWIP_DEBUGF( PING_DEBUG, (" %"U32_F" ms\n", (sys_now()-ping_time))); ++ printf(" %"U32_F" ms\n", (sys_now()-ping_time)); + + /* do some ping result processing */ + PING_RESULT(1); +@@ -361,7 +361,7 @@ ping_timeout(void *arg) + sys_timeout(PING_DELAY, ping_timeout, pcb); + } + +-static void ++void + ping_raw_init(void) + { + ping_pcb = raw_new(IP_PROTO_ICMP); diff --git a/lib/lwip/cmd-lwip.c b/lib/lwip/cmd-lwip.c new file mode 100644 index 0000000000..f2e25a8c29 --- /dev/null +++ b/lib/lwip/cmd-lwip.c @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2023 + * Maxim Uvarov, maxim.uvarov@linaro.org + */ + +#include +#include +#include +#include +#include +#include + +#include "apps/ping/lwip_ping.h" + +extern int uboot_lwip_init(void); +extern int uboot_lwip_loop_is_done(void); + +static int do_lwip_info(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + printf("TBD: %s\n", __func__); + return CMD_RET_SUCCESS; +} + +static int do_lwip_init(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + if (!uboot_lwip_init()) + return CMD_RET_SUCCESS; + return CMD_RET_FAILURE; +} + +static int do_lwip_ping(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + if (argc < 2) { + printf("argc = %d, error\n", argc); + return CMD_RET_USAGE; + } + + eth_init(); /* activate u-boot eth dev */ + + printf("pinging addr: %s\n", argv[1]); + if (lwip_ping_init(argv[2])) { + printf("ping init fail\n"); + return CMD_RET_FAILURE; + } + + ping_send_now(); + + lwip_loop_set(); + if (net_loop(LWIP) < 0) { + printf("ping failed; host %s is not alive\n", argv[1]); + return CMD_RET_FAILURE; + } + return CMD_RET_SUCCESS; +} + +static struct cmd_tbl cmds[] = { + U_BOOT_CMD_MKENT(info, 1, 0, do_lwip_info, "", ""), + U_BOOT_CMD_MKENT(init, 1, 0, do_lwip_init, "", ""), + U_BOOT_CMD_MKENT(ping, 2, 0, do_lwip_ping, "", ""), +}; + +static int do_ops(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct cmd_tbl *cp; + + cp = find_cmd_tbl(argv[1], cmds, ARRAY_SIZE(cmds)); + + /* Drop the mmc command */ + argc--; + argv++; + + if (cp == NULL || argc > cp->maxargs) + return CMD_RET_USAGE; + if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) + return CMD_RET_SUCCESS; + + return cp->cmd(cmdtp, flag, argc, argv); +} + +U_BOOT_CMD( + lwip, 4, 1, do_ops, + "LWIP sub system", + "info - display info\n" + "init - init LWIP\n" + "ping addr - ping addr\n" + ); + +/* Old command kept for compatibility. Same as 'mmc info' */ +U_BOOT_CMD( + lwipinfo, 1, 0, do_lwip_info, + "display LWIP info", + "- display LWIP stack info" +); diff --git a/lib/lwip/lwipopts.h b/lib/lwip/lwipopts.h new file mode 100644 index 0000000000..581d05420a --- /dev/null +++ b/lib/lwip/lwipopts.h @@ -0,0 +1,484 @@ +/** + * @file + * + * lwIP Options Configuration + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_LWIPOPTS_H +#define LWIP_LWIPOPTS_H + + + +/* + * Include user defined options first. Anything not defined in these files + * will be set to standard values. Override anything you don't like! + */ +#include "lwipopts.h" + +#define LWIP_DEBUG 1 +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#define LWIP_DBG_TYPES_ON LWIP_DBG_OFF +#define ETHARP_DEBUG LWIP_DBG_OFF +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF +#define DHCP6_DEBUG LWIP_DBG_OFF +#define LWIP_TESTMODE 0 +#include "lwip/debug.h" + +/* + ----------------------------------------------- + ---------- Platform specific locking ---------- + ----------------------------------------------- +*/ + +/** + * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain + * critical regions during buffer allocation, deallocation and memory + * allocation and deallocation. + */ +#define SYS_LIGHTWEIGHT_PROT 0 + +/** + * NO_SYS==1: Provides VERY minimal functionality. Otherwise, + * use lwIP facilities. + */ +#define NO_SYS 0 + +/* + ------------------------------------ + ---------- Memory options ---------- + ------------------------------------ +*/ + +/** + * MEM_ALIGNMENT: should be set to the alignment of the CPU + * 4 byte alignment -> #define MEM_ALIGNMENT 4 + * 2 byte alignment -> #define MEM_ALIGNMENT 2 + */ +#define MEM_ALIGNMENT 1 + +/** + * MEM_SIZE: the size of the heap memory. If the application will send + * a lot of data that needs to be copied, this should be set high. + */ +#define MEM_SIZE 1600 + +/* + ------------------------------------------------ + ---------- Internal Memory Pool Sizes ---------- + ------------------------------------------------ +*/ +/** + * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF). + * If the application sends a lot of data out of ROM (or other static memory), + * this should be set high. + */ +#define MEMP_NUM_PBUF 4 + +/** + * MEMP_NUM_RAW_PCB: Number of raw connection PCBs + * (requires the LWIP_RAW option) + */ +#define MEMP_NUM_RAW_PCB 2 + +/** + * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One + * per active UDP "connection". + * (requires the LWIP_UDP option) + */ +#define MEMP_NUM_UDP_PCB 4 + +/** + * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. + * (requires the LWIP_TCP option) + */ +#define MEMP_NUM_TCP_PCB 2 + +/** + * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections. + * (requires the LWIP_TCP option) + */ +#define MEMP_NUM_TCP_PCB_LISTEN 2 + +/** + * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. + * (requires the LWIP_TCP option) + */ +#define MEMP_NUM_TCP_SEG 16 + +/** + * MEMP_NUM_REASSDATA: the number of simultaneously IP packets queued for + * reassembly (whole packets, not fragments!) + */ +#define MEMP_NUM_REASSDATA 1 + +/** + * MEMP_NUM_ARP_QUEUE: the number of simulateously queued outgoing + * packets (pbufs) that are waiting for an ARP request (to resolve + * their destination address) to finish. + * (requires the ARP_QUEUEING option) + */ +#define MEMP_NUM_ARP_QUEUE 2 + +/** + * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. + * (requires NO_SYS==0) + */ +#define MEMP_NUM_SYS_TIMEOUT 4 + +/** + * MEMP_NUM_NETBUF: the number of struct netbufs. + * (only needed if you use the sequential API, like api_lib.c) + */ +#define MEMP_NUM_NETBUF 2 + +/** + * MEMP_NUM_NETCONN: the number of struct netconns. + * (only needed if you use the sequential API, like api_lib.c) + */ +#define MEMP_NUM_NETCONN 32 + +/** + * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used + * for callback/timeout API communication. + * (only needed if you use tcpip.c) + */ +#define MEMP_NUM_TCPIP_MSG_API 8 + +/** + * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used + * for incoming packets. + * (only needed if you use tcpip.c) + */ +#define MEMP_NUM_TCPIP_MSG_INPKT 8 + +/** + * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. + */ +#define PBUF_POOL_SIZE 8 + +/* + --------------------------------- + ---------- ARP options ---------- + --------------------------------- +*/ +/** + * LWIP_ARP==1: Enable ARP functionality. + */ +#define LWIP_ARP 1 + +/* + -------------------------------- + ---------- IP options ---------- + -------------------------------- +*/ +/** + * IP_FORWARD==1: Enables the ability to forward IP packets across network + * interfaces. If you are going to run lwIP on a device with only one network + * interface, define this to 0. + */ +#define IP_FORWARD 0 + +/** + * IP_OPTIONS: Defines the behavior for IP options. + * IP_OPTIONS_ALLOWED==0: All packets with IP options are dropped. + * IP_OPTIONS_ALLOWED==1: IP options are allowed (but not parsed). + */ +#define IP_OPTIONS_ALLOWED 1 + +/** + * IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that + * this option does not affect outgoing packet sizes, which can be controlled + * via IP_FRAG. + */ +#define IP_REASSEMBLY 1 + +/** + * IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note + * that this option does not affect incoming packet sizes, which can be + * controlled via IP_REASSEMBLY. + */ +#define IP_FRAG 1 + +/** + * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally) + * a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived + * in this time, the whole packet is discarded. + */ +#define IP_REASS_MAXAGE 3 + +/** + * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled. + * Since the received pbufs are enqueued, be sure to configure + * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive + * packets even if the maximum amount of fragments is enqueued for reassembly! + */ +#define IP_REASS_MAX_PBUFS 4 + +/** + * IP_FRAG_USES_STATIC_BUF==1: Use a static MTU-sized buffer for IP + * fragmentation. Otherwise pbufs are allocated and reference the original + * packet data to be fragmented. +*/ +#define IP_FRAG_USES_STATIC_BUF 0 + +/** + * IP_DEFAULT_TTL: Default value for Time-To-Live used by transport layers. + */ +#define IP_DEFAULT_TTL 255 + +/* + ---------------------------------- + ---------- ICMP options ---------- + ---------------------------------- +*/ +/** + * LWIP_ICMP==1: Enable ICMP module inside the IP stack. + * Be careful, disable that make your product non-compliant to RFC1122 + */ +#define LWIP_ICMP 1 + +/* + --------------------------------- + ---------- RAW options ---------- + --------------------------------- +*/ +/** + * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. + */ +#define LWIP_RAW 1 + +/* + ---------------------------------- + ---------- DHCP options ---------- + ---------------------------------- +*/ +/** + * LWIP_DHCP==1: Enable DHCP module. + */ +#define LWIP_DHCP 0 + + +/* + ------------------------------------ + ---------- AUTOIP options ---------- + ------------------------------------ +*/ +/** + * LWIP_AUTOIP==1: Enable AUTOIP module. + */ +#define LWIP_AUTOIP 0 + +/* + ---------------------------------- + ---------- SNMP options ---------- + ---------------------------------- +*/ +/** + * LWIP_SNMP==1: Turn on SNMP module. UDP must be available for SNMP + * transport. + */ +#define LWIP_SNMP 0 + +/* + ---------------------------------- + ---------- IGMP options ---------- + ---------------------------------- +*/ +/** + * LWIP_IGMP==1: Turn on IGMP module. + */ +#define LWIP_IGMP 0 + +/* + ---------------------------------- + ---------- DNS options ----------- + ---------------------------------- +*/ +/** + * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS + * transport. + */ +#define LWIP_DNS 0 + +/* + --------------------------------- + ---------- UDP options ---------- + --------------------------------- +*/ +/** + * LWIP_UDP==1: Turn on UDP. + */ +#define LWIP_UDP 1 + +/* + --------------------------------- + ---------- TCP options ---------- + --------------------------------- +*/ +/** + * LWIP_TCP==1: Turn on TCP. + */ +#define LWIP_TCP 1 + +#define LWIP_LISTEN_BACKLOG 0 + +/* + ---------------------------------- + ---------- Pbuf options ---------- + ---------------------------------- +*/ +/** + * PBUF_LINK_HLEN: the number of bytes that should be allocated for a + * link level header. The default is 14, the standard value for + * Ethernet. + */ +#define PBUF_LINK_HLEN 16 + +/** + * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is + * designed to accommodate single full size TCP frame in one pbuf, including + * TCP_MSS, IP header, and link header. +* + */ +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_HLEN) + +/* + ------------------------------------ + ---------- LOOPIF options ---------- + ------------------------------------ +*/ +/** + * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1) and loopif.c + */ +#define LWIP_HAVE_LOOPIF 0 + +/* + ---------------------------------------------- + ---------- Sequential layer options ---------- + ---------------------------------------------- +*/ + +/** + * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) + */ +#define LWIP_NETCONN 1 + +/* + ------------------------------------ + ---------- Socket options ---------- + ------------------------------------ +*/ +/** + * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) + */ +#define LWIP_SOCKET 1 + +/** + * SO_REUSE==1: Enable SO_REUSEADDR + */ +#define SO_REUSE 1 + +/* + ---------------------------------------- + ---------- Statistics options ---------- + ---------------------------------------- +*/ +/** + * LWIP_STATS==1: Enable statistics collection in lwip_stats. + */ +#define LWIP_STATS 0 +/* + --------------------------------- + ---------- PPP options ---------- + --------------------------------- +*/ +/** + * PPP_SUPPORT==1: Enable PPP. + */ +#define PPP_SUPPORT 0 + + + +/* + --------------------------------------- + ---------- Threading options ---------- + --------------------------------------- +*/ + +#define LWIP_TCPIP_CORE_LOCKING 0 + +// #if !NO_SYS +// void sys_check_core_locking(void); +// #define LWIP_ASSERT_CORE_LOCKED() sys_check_core_locking() +// #endif + +#define LWIP_NETIF_LOOPBACK 1 +/* use malloc instead of pool */ +#define MEMP_MEM_MALLOC 1 +#define MEMP_MEM_INIT 1 +#define MEM_LIBC_MALLOC 1 + + + +#endif /* LWIP_LWIPOPTS_H */ diff --git a/lib/lwip/port/if.c b/lib/lwip/port/if.c new file mode 100644 index 0000000000..dd423eed16 --- /dev/null +++ b/lib/lwip/port/if.c @@ -0,0 +1,256 @@ +#include +#include + +#include "lwip/debug.h" +#include "lwip/arch.h" +#include "netif/etharp.h" +#include "lwip/stats.h" +#include "lwip/def.h" +#include "lwip/mem.h" +#include "lwip/pbuf.h" +#include "lwip/sys.h" +#include "lwip/netif.h" + +#include "lwip/ip.h" + +#define IFNAME0 'e' +#define IFNAME1 '0' + +static struct pbuf * low_level_input(struct netif *netif); +static int uboot_net_use_lwip = 0; + +int lwip_enabled(void) +{ + return uboot_net_use_lwip; +} + +static int loop_lwip; + +/* ret 0 - loop not done + * 1 - loop is done. + */ +int lwip_loop_is_done(void) +{ + return loop_lwip; +} + +void lwip_loop_set(void) +{ + loop_lwip = 1; +} + +struct uboot_lwip_if { +}; + +static struct netif uboot_netif; + +#define LWIP_PORT_INIT_IPADDR(addr) IP4_ADDR((addr), 192,168,1,200) +#define LWIP_PORT_INIT_GW(addr) IP4_ADDR((addr), 192,168,1,1) +#define LWIP_PORT_INIT_NETMASK(addr) IP4_ADDR((addr), 255,255,255,0) + +extern uchar *net_rx_packet; +extern int net_rx_packet_len; + +int uboot_lwip_poll(void) { + struct pbuf *p; + int err; + + //printf("call for netif_poll!!!!\n"); + //netif_poll(&uboot_netif); + p = low_level_input(&uboot_netif); + if (NULL == p) { + printf("error p = low_level_input = NULL\n"); + return 0; + } + err = ethernet_input(p, &uboot_netif); + if (err) + printf("ip4_input err %d\n", err); + + return 0; +} + +static struct pbuf * low_level_input(struct netif *netif) +{ + struct pbuf *p, *q; + u16_t len = net_rx_packet_len; + uchar *data = net_rx_packet; + + //printf("%s()\n", __func__); +#if ETH_PAD_SIZE + len += ETH_PAD_SIZE; /* allow room for Ethernet padding */ +#endif + + /* We allocate a pbuf chain of pbufs from the pool. */ + p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); + if (p != NULL) { +#if ETH_PAD_SIZE + pbuf_remove_header(p, ETH_PAD_SIZE); /* drop the padding word */ +#endif + /* We iterate over the pbuf chain until we have read the entire + * packet into the pbuf. */ + for (q = p; q != NULL; q = q->next) { + /* Read enough bytes to fill this pbuf in the chain. The + * available data in the pbuf is given by the q->len + * variable. + * This does not necessarily have to be a memcpy, you can also preallocate + * pbufs for a DMA-enabled MAC and after receiving truncate it to the + * actually received size. In this case, ensure the tot_len member of the + * pbuf is the sum of the chained pbuf len members. + */ + MEMCPY(q->payload, data, q->len); + data += q->len; + } + //acknowledge that packet has been read(); + +#if ETH_PAD_SIZE + pbuf_add_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ +#endif + LINK_STATS_INC(link.recv); + } else { + //drop packet(); + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.drop); + } + + return p; +} + +/* Maxim: accoding to lwip idea this has to be separate thread in the background + * to poll RX packets from the network. The first we need to try to inject + * it directly to net/net.c eth_rx() calls. Assuming we do not implement threading + * and we roll in the main polling loop. Then socket operation should also be possible + * to call for non blocking socket calls. + * If lwip will not work without threading, then we to implement some scheduler with semaphores. + * We can base ./examples/standalone/sched.c example code for that. + * + */ +static int ethernetif_input(struct pbuf *p, struct netif *netif) +{ + struct ethernetif *ethernetif; + + ethernetif = netif->state; + + /* move received packet into a new pbuf */ + p = low_level_input(netif); + + /* if no packet could be read, silently ignore this */ + if (p != NULL) { + /* pass all packets to ethernet_input, which decides what packets it supports */ + if (netif->input(p, netif) != ERR_OK) { + LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); + pbuf_free(p); + p = NULL; + } + } + return 0; +} + +static err_t low_level_output(struct netif *netif, struct pbuf *p) +{ + int err; + + //printf("TX data len %d, tot_len %d\n", p->len, p->tot_len); + err = eth_send(p->payload, p->len); + if (err != 0) { + printf("eth_send error %d\n", err); + return ERR_ABRT; + } + return ERR_OK; +} + +err_t uboot_lwip_if_init(struct netif *netif) +{ + struct uboot_lwip_if *uif = (struct uboot_lwip_if *)malloc(sizeof(struct uboot_lwip_if)); + + if (uif == NULL) { + printf("uboot_lwip_if: out of memory\n"); + return ERR_MEM; + } + netif->state = uif; + + netif->name[0] = IFNAME0; + netif->name[1] = IFNAME1; + + netif->hwaddr_len = ETHARP_HWADDR_LEN; + /* set MAC hardware address */ + netif->hwaddr[0] = 0xf6; + netif->hwaddr[1] = 0x11; + netif->hwaddr[2] = 0x1; + netif->hwaddr[3] = 0x2; + netif->hwaddr[4] = 0x3; + netif->hwaddr[5] = 0x4; + +#if LWIP_IPV4 + netif->output = etharp_output; +#endif /* LWIP_IPV4 */ +#if LWIP_IPV6 + netif->output_ip6 = ethip6_output; +#endif /* LWIP_IPV6 */ + netif->linkoutput = low_level_output; + netif->mtu = 1500; + netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; + + eth_init(); /* activate u-boot eth dev */ + + printf("Initialized LWIP stack\n"); + return ERR_OK; +} + +int uboot_lwip_init() +{ + ip4_addr_t ipaddr, netmask, gw; + //int err; + + if (uboot_net_use_lwip) + return CMD_RET_SUCCESS; + + ip4_addr_set_zero(&gw); + ip4_addr_set_zero(&ipaddr); + ip4_addr_set_zero(&netmask); + +#if USE_DHCP + printf("Starting lwIP, local interface IP is dhcp-enabled\n"); +#elif USE_AUTOIP + printf("Starting lwIP, local interface IP is autoip-enabled\n"); +#else /* USE_DHCP */ + LWIP_PORT_INIT_GW(&gw); + LWIP_PORT_INIT_IPADDR(&ipaddr); + LWIP_PORT_INIT_NETMASK(&netmask); + printf("Starting lwIP, local interface IP is %s\n", ip4addr_ntoa(&ipaddr)); +#endif /* USE_DHCP */ + + if (netif_add(&uboot_netif, &ipaddr, &netmask, &gw, &uboot_netif, uboot_lwip_if_init, ethernetif_input) == NULL) + printf("err: netif_add failed!\n"); + netif_set_up(&uboot_netif); + netif_set_link_up(&uboot_netif); + +#if LWIP_IPV6 + netif_create_ip6_linklocal_address(netif_default, 1); + printf("ip6 linklocal address: %s\n", ip6addr_ntoa(netif_ip6_addr(netif_default, 0))); +#endif /* LWIP_IPV6 */ + +#if LWIP_NETIF_STATUS_CALLBACK + netif_set_status_callback(netif_default, status_callback); +#endif /* LWIP_NETIF_STATUS_CALLBACK */ +#if LWIP_NETIF_LINK_CALLBACK + netif_set_link_callback(netif_default, link_callback); +#endif /* LWIP_NETIF_LINK_CALLBACK */ + +#if LWIP_AUTOIP + autoip_set_struct(netif_default, &netif_autoip); +#endif /* LWIP_AUTOIP */ +#if LWIP_DHCP + dhcp_set_struct(netif_default, &netif_dhcp); +#endif /* LWIP_DHCP */ + //netif_set_up(netif_default); +#if USE_DHCP + err = dhcp_start(netif_default); + LWIP_ASSERT("dhcp_start failed", err == ERR_OK); +#elif USE_AUTOIP + err = autoip_start(netif_default); + LWIP_ASSERT("autoip_start failed", err == ERR_OK); +#endif /* USE_DHCP */ + uboot_net_use_lwip = 1; + + return CMD_RET_SUCCESS; +} diff --git a/lib/lwip/port/include/arch/cc.h b/lib/lwip/port/include/arch/cc.h new file mode 100644 index 0000000000..06cc807e85 --- /dev/null +++ b/lib/lwip/port/include/arch/cc.h @@ -0,0 +1,41 @@ +#ifndef LWIP_ARCH_CC_H +#define LWIP_ARCH_CC_H + +#include +#include +#include "u-sockets.h" + +#define LWIP_ERRNO_INCLUDE + +#define LWIP_ERRNO_STDINCLUDE 1 +#define LWIP_NO_UNISTD_H 1 +#define LWIP_TIMEVAL_PRIVATE 1 + +extern unsigned int lwip_port_rand(void); +#define LWIP_RAND() (lwip_port_rand()) + +/* different handling for unit test, normally not needed */ +#ifdef LWIP_NOASSERT_ON_ERROR +#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ + handler;}} while(0) +#endif + +#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS + +#define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d in %s\n", \ + x, __LINE__, __FILE__);} while(0) + +static inline int atoi(const char* str) +{ + int r = 0; + int i; + + for (i = 0; str[i] != '\0'; ++i) + r = r * 10 + str[i] - '0'; + + return r; +} + +#define LWIP_ERR_T int + +#endif /* LWIP_ARCH_CC_H */ diff --git a/lib/lwip/port/include/arch/sys_arch.h b/lib/lwip/port/include/arch/sys_arch.h new file mode 100644 index 0000000000..929a35e12d --- /dev/null +++ b/lib/lwip/port/include/arch/sys_arch.h @@ -0,0 +1,78 @@ +#ifndef LWIP_ARCH_SYS_ARCH_H +#define LWIP_ARCH_SYS_ARCH_H + +#include "lwip/opt.h" +#include "lwip/arch.h" +#include "lwip/err.h" + +#define ERR_NEED_SCHED 123 + +void sys_arch_msleep(u32_t delay_ms); +#define sys_msleep(ms) sys_arch_msleep(ms) + +#if SYS_LIGHTWEIGHT_PROT +typedef u32_t sys_prot_t; +#endif /* SYS_LIGHTWEIGHT_PROT */ + +#include + +#define SYS_MBOX_NULL NULL +#define SYS_SEM_NULL NULL + +typedef u32_t sys_prot_t; + +struct sys_sem; +typedef struct sys_sem * sys_sem_t; +#define sys_sem_valid(sem) (((sem) != NULL) && (*(sem) != NULL)) +#define sys_sem_set_invalid(sem) do { if((sem) != NULL) { *(sem) = NULL; }}while(0) + +/* let sys.h use binary semaphores for mutexes */ +#define LWIP_COMPAT_MUTEX 1 +#define LWIP_COMPAT_MUTEX_ALLOWED 1 + +struct sys_mbox; +typedef struct sys_mbox *sys_mbox_t; +#define sys_mbox_valid(mbox) (((mbox) != NULL) && (*(mbox) != NULL)) +#define sys_mbox_set_invalid(mbox) do { if((mbox) != NULL) { *(mbox) = NULL; }}while(0) + +struct sys_thread; +typedef struct sys_thread * sys_thread_t; + +static inline u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) +{ + return 0; +}; + +static inline err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg) +{ + return 0; +}; + +#if 0 +#define sys_sem_new(s, c) ERR_OK + +#define sys_sem_wait(s) +#define sys_sem_free(s) +#define sys_sem_valid(s) 0 +#define sys_sem_set_invalid(s) +#define sys_mutex_new(mu) ERR_OK +#define sys_mutex_lock(mu) +#define sys_mutex_unlock(mu) +#define sys_mutex_free(mu) +#define sys_mutex_valid(mu) 0 +#define sys_mutex_set_invalid(mu) +#define sys_mbox_new(m, s) ERR_OK +#define sys_mbox_fetch(m,d) +#define sys_mbox_tryfetch(m,d) +#define sys_mbox_post(m,d) + +#define sys_mbox_free(m) +#define sys_mbox_valid(m) +#define sys_mbox_set_invalid(m) +#endif + +#define sys_sem_signal(s) + +//int uboot_lwip_init(void); + +#endif /* LWIP_ARCH_SYS_ARCH_H */ diff --git a/lib/lwip/port/include/arch/u-sockets.h b/lib/lwip/port/include/arch/u-sockets.h new file mode 100644 index 0000000000..aef0b94ee0 --- /dev/null +++ b/lib/lwip/port/include/arch/u-sockets.h @@ -0,0 +1,26 @@ +#define MEMP_NUM_NETCONN 32 +#define LWIP_SOCKET_OFFSET 0 +#undef FD_SETSIZE +/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */ +#define FD_SETSIZE MEMP_NUM_NETCONN +#define FDSETSAFESET(n, code) do { \ + if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \ + code; }} while(0) +#define FDSETSAFEGET(n, code) (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\ + (code) : 0) +//#define FD_SET(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] = (u8_t)((p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] | (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))) +#define FD_SET(n, p) FDSETSAFESET(n, (p)->fds_bits[((n)-LWIP_SOCKET_OFFSET)/8] = (u8_t)((p)->fds_bits[((n)-LWIP_SOCKET_OFFSET)/8] | (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))) +#define FD_CLR(n, p) FDSETSAFESET(n, (p)->fds_bits[((n)-LWIP_SOCKET_OFFSET)/8] = (u8_t)((p)->fds_bits[((n)-LWIP_SOCKET_OFFSET)/8] & ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))) +#define FD_ISSET(n,p) FDSETSAFEGET(n, (p)->fds_bits[((n)-LWIP_SOCKET_OFFSET)/8] & (1 << (((n)-LWIP_SOCKET_OFFSET) & 7))) +#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p))) + +#if 0 +typedef struct fd_set +{ + unsigned char fd_bits [(FD_SETSIZE+7)/8]; +} fd_set; +#endif + +#if FD_SETSIZE < (LWIP_SOCKET_OFFSET + MEMP_NUM_NETCONN) +#error "external FD_SETSIZE too small for number of sockets" +#endif diff --git a/lib/lwip/port/include/limits.h b/lib/lwip/port/include/limits.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/lwip/port/sys-arch.c b/lib/lwip/port/sys-arch.c new file mode 100644 index 0000000000..1ae521fde7 --- /dev/null +++ b/lib/lwip/port/sys-arch.c @@ -0,0 +1,7 @@ +#include +#include "lwip/opt.h" + +u32_t sys_now(void) +{ + return get_timer(0); +} diff --git a/net/eth-uclass.c b/net/eth-uclass.c index f41da4b37b..6031ad805d 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -367,8 +367,10 @@ int eth_send(void *packet, int length) if (!current) return -ENODEV; - if (!eth_is_active(current)) + if (!eth_is_active(current)) { + printf("%s() !eth_is_active\n", __func__); return -EINVAL; + } ret = eth_get_ops(current)->send(current, packet, length); if (ret < 0) { diff --git a/net/net.c b/net/net.c index 57da9bda85..301d825462 100644 --- a/net/net.c +++ b/net/net.c @@ -201,6 +201,10 @@ static ulong time_delta; /* THE transmit packet */ uchar *net_tx_packet; +extern int lwip_enabled(void); +extern int lwip_loop_is_done(void); +extern int uboot_lwip_poll(void); + static int net_check_prereq(enum proto_t protocol); static int net_try_count; @@ -1177,6 +1181,16 @@ void net_process_received_packet(uchar *in_packet, int len) if (len < ETHER_HDR_SIZE) return; + +#if defined(CONFIG_LWIP_LIB) + if (lwip_enabled()) { + if (lwip_loop_is_done()) + net_set_state(NETLOOP_SUCCESS); + uboot_lwip_poll(); + return; + } +#endif + #if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER) if (push_packet) { (*push_packet)(in_packet, len); From patchwork Fri May 5 10:25:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 679299 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp283294wrs; Fri, 5 May 2023 03:51:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ44nqeoGVLZdTchNLfIJFUupnggIWVT925UM0Nlp/kmk1yFo9WXmZMpuDS3/zbc6AVMGBY8 X-Received: by 2002:a17:903:2451:b0:1ab:142a:3dd7 with SMTP id l17-20020a170903245100b001ab142a3dd7mr916020pls.68.1683283864490; Fri, 05 May 2023 03:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683283864; cv=none; d=google.com; s=arc-20160816; b=I9p9bWzBVQNgyVc3NmY5c01LAv/ai3I7RRgSjSZ3HxrpKg7YtyEyiHuRtfMTc9ifZd uuq6/cEtHnmC7iJg5TgvKLO/exc7ksew5uS7SZ4WvKh55qP13Kj0iayNxU5RFk1ODCku bS6a2ib8GuuJVNmVDlPHddvcEP9k9243mf45FM7cwxHkdIcx2nsbKG5BJI1pbsRsKNCi gScUpQAF2IE124v8jNJDY1ZrSUVFo/VkJEid4HxdZrDZN4B4GBfSTpQyzKgAFlDryQpr UCXQ751trnbQphhbNWiDS+gPqepczCMu/1My/yNUVFw5PRS/fVAZC45M9u04ar0RqyI+ +XzQ== 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=bGtQROW8CgSIpc8sC+xnf/7FVLmoH1qm1QTvSE8uz7Q=; b=xegyo1WXdKz3Yb8qo1uqu2cYTsazdqmir1KNy0DFlDAn1sIpRXZR8NbiPuh3aS1XWN GVFwmak/PHv4wLduCKaMMK0pNT5GvVPK03G9AmxKPBUM2q2ZGTyatJAFdDZ9WufSoZJb SXMkbU602MPZVeQpvS7pNPKi7rEWNYDPh5vEfPD4dyPTRbhwTFX/uc1C8fmTDwzpg+ld lXMPAwOqNW6/FVrE8tNGCH4sP/Ezi1ALiK+Bk/dy+ZJ8VYFCPs7JLbryRYpMZJRL1Vkr 8b1nKAPtqzVz5di1wBOIEybihaR1rIz6jz0eDVJF2F3THubNQ2K6tCV6Eh3h1vzRRFQn RjDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="O//10d4t"; 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 s2-20020a170902ea0200b001a05d12eeb3si398574plg.189.2023.05.05.03.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 03:51:04 -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="O//10d4t"; 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 7C103847E1; Fri, 5 May 2023 12:50:35 +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="O//10d4t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 85C7284798; Fri, 5 May 2023 12:25:42 +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-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) (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 EC2C48476F for ; Fri, 5 May 2023 12:25:37 +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-ot1-x32b.google.com with SMTP id 46e09a7af769-6a5ecdb455bso594360a34.0 for ; Fri, 05 May 2023 03:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683282336; x=1685874336; 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=bGtQROW8CgSIpc8sC+xnf/7FVLmoH1qm1QTvSE8uz7Q=; b=O//10d4tXMkb4GmKCMy2ioWYEvISiHUwyV1PcvyMBqbZmQLcXPoGDszXimmVhRJoqz 20syo0F1l+fVaM/l++moM0xcyXWf+p/QDtgAo12mOfWbBFT/QY5ac++SJUYI8wrlI+PW mWirFv1AbefA4LN5nujBj5LD/LS/QLT0CG0TfJRCff4BHktvt/CEA1Ri3kldd+xlqArp XMzu/QvY0e1Wmn2t4z0x/RwMTi0or3Lq3UNBRpj0VVin8oLed6LPoRm6l5PvYTAmpii3 WEGTiJyG6ed7lFiHmXph33Wv7Xhn56g+Qlk29D6wb33UrYaTaoupvrNZFx1vm5wipvz8 B40w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683282336; x=1685874336; 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=bGtQROW8CgSIpc8sC+xnf/7FVLmoH1qm1QTvSE8uz7Q=; b=UjflSJZMdyWUSQYzeaJ1BaXcKbl8i8DI3/8Gh31Nn69Fxx+JjRF+/0MiH78KYRhh2N nG6nrvzFZvqb9RIJYh4o004xkoZ1EPiCD8/JenI33jJbfYivf70pI97BcQvV6UwGnAm/ E1RlWEWuVGvQwzRPzJ4s140uRLLr4895OHQyuvBFW3WjyoTEocTPN6a57euM4eiCGIVV BsNjMDZeKdSf3AHCo2C2wj0Uz0McdgrYAj6OSs68j7sYARVVzF0RC2jby46vTRAYK7dz u++US5jzd58bmuXzCoVwEF5Cltpd38GxbthJl8BK4TlYekP7wPdtd9Z1ppIuLTFN1kUF 2u+g== X-Gm-Message-State: AC+VfDwGtonVsymMB9gClQjWLnVFKkZS75rGoKwqKiqNPx3VpjPAXEWg 42mAhnM5vfXcLE2TEznFavJy6H1vn6mwIH2/BWyIsLKY X-Received: by 2002:a05:6830:14da:b0:6a5:dc9f:6cd9 with SMTP id t26-20020a05683014da00b006a5dc9f6cd9mr373612otq.9.1683282336340; Fri, 05 May 2023 03:25:36 -0700 (PDT) Received: from ledge.ozog.com ([2604:1380:4111:b700::1]) by smtp.gmail.com with ESMTPSA id b21-20020a056830105500b006a6169cf6b0sm635068otp.47.2023.05.05.03.25.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 03:25:35 -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, Maxim Uvarov Subject: [RFC PATCH 3/5] add doc/README.lwip Date: Fri, 5 May 2023 10:25:27 +0000 Message-ID: <20230505102529.1254445-4-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.40.1.476.g69c786637d In-Reply-To: <20230505102529.1254445-1-maxim.uvarov@linaro.org> References: <20230505102529.1254445-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 05 May 2023 12:50:31 +0200 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 Signed-off-by: Maxim Uvarov --- doc/README.lwip | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 doc/README.lwip diff --git a/doc/README.lwip b/doc/README.lwip new file mode 100644 index 0000000000..df3462ca1b --- /dev/null +++ b/doc/README.lwip @@ -0,0 +1,56 @@ + RFC LWIP IP stack intergation for U-boot + ---------------------------------------- + +Reliable and bug free IP stack is usually an issue when you are trying to write it +from scratch. It looks like not, but when addinging new features it will be chelledging. +This RFC work is a demo to enable lwIP (lightweight IP) which is a widely used open-source +TCP/IP stack designed for embedded systems for U-boot. That will allow using already +written network applications for microcontrollers. + +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: iwIP 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). + This RFC implements only raw API as the proof of work. + +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. + +This RFC has an unmodified working ping example from lwip sources which registeres this callback. +  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. + +4. Testing + +Unmodified ping example can be used. I did ping from qemu/u-boot tap device on the host: + +=> lwip init +=> lwip ping 192.168.1.2 +ping: recv 3 ms +tcpdump on the host: +5:09:10.925951 ARP, Request who-has 192.168.1.200 tell 192.168.1.200, length 28 15:09:12.114643 IP6 fe80::38e2:41ff:fec3:8bda > ip6-allrouters: ICMP6, router solicitation, length 16 15:09:20.370725 ARP, Request who-has 192.168.1.2 tell 192.168.1.200, length 28 15:09:20.370740 ARP, Reply 192.168.1.2 is-at 3a:e2:41:c3:8b:da (oui Unknown), length 28 15:09:20.372789 IP 192.168.1.200 > 192.168.1.2: ICMP echo request, id 44975, seq 1, length 40 15:09:20.372810 IP 192.168.1.2 > 192.168.1.200: ICMP echo reply, id 44975, seq 1, length 40 15:09:25.426636 ARP, Request who-has 192.168.1.200 tell 192.168.1.2, length 28 15:09:25.426870 ARP, Reply 192.168.1.200 is-at f6:11:01:02:03:04 (oui Unknown), length 28 From patchwork Fri May 5 10:25:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 679300 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp283392wrs; Fri, 5 May 2023 03:51:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5w7TmCsFUuzVkBBn8t7CI43c/C7v7PQv0K2gRvzH6dRAiHg2v2vgZ37Y4OQgSrbpUt9Sf9 X-Received: by 2002:a05:6a20:9401:b0:f0:df6b:d233 with SMTP id hl1-20020a056a20940100b000f0df6bd233mr954993pzb.4.1683283879915; Fri, 05 May 2023 03:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683283879; cv=none; d=google.com; s=arc-20160816; b=mmdcoJ4oBeDEGv739Wa0j4VULV8Mch226wcbS836LaBshGaCldHpT1BsOa8/Ux5DDx J4Jsyj78Wqwp9EJyn4MeG8Tw+p3rXpXRIh3nOifl8e0PwTkQY7fI8BDBW5XLi6zMajJj 0WgdyKrnS959Gf2R/Y1NJf18MNzIKY2HwdITh7qk7j4YFss0Amjq8pE7W9UCTZ3iQfz2 62/HQrUqyUNyq4HWPQ+2NwM41wJH1RisMCa2hf5JRxMykxg2JBNjjhk5sY/B3Ulm5CpA uKcxfsHSx9nyLoct70xdmqvXlrWdbcbzhLiYdRjKZ13bPd0r3MaoPUOk45ybciZ0o/Cb rVJA== 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=vaUHOyT1LIyTYWNSTn2cNjIHhQTtmflDxQJya+CBkLg=; b=tulsBxQC5zxfcBSIGsk488+h2tyb/ReUiSkpSG4Ah2/ktd//Ixoq/Uk+h0RoTUg4lF Iuqd4Ylh4CXmQ6waUax3enS7wTrEYO6DCCQyBhogmrzyZZHmrkMfXBcWSYwooQxVa7Ar 8qfxAte2qRkTIfeSxGoraUGwLu1raE0yEpWrZNYtlZ92gDqoCn65rouNopaCklbhOVgQ VQTePc0nAoJiaXiE5qNuPN4NujXfdFKafHxQ92LADyouhVlqh011ndbDabwoPYdKk28x uSHVYRLi9xnN8wC6LY3g3SIIWMDa+6AGruzn0EGHHCtYZ30foXrPbVG21r0zNFSTTe2I xoow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o4FN9Y6q; 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 v62-20020a638941000000b0052c7f7bc72csi1782983pgd.634.2023.05.05.03.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 03:51:19 -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=o4FN9Y6q; 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 DD4A3857AE; Fri, 5 May 2023 12:50:36 +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="o4FN9Y6q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BE8588476F; Fri, 5 May 2023 12:25:42 +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-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) (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 24243846E7 for ; Fri, 5 May 2023 12:25:39 +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-ot1-x333.google.com with SMTP id 46e09a7af769-6a981550a6fso1188882a34.1 for ; Fri, 05 May 2023 03:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683282337; x=1685874337; 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=vaUHOyT1LIyTYWNSTn2cNjIHhQTtmflDxQJya+CBkLg=; b=o4FN9Y6qe2bHGd5WktDWImgklI/BsLE/2opSKrlVjaQkZgKc2RdfwkHGt3slQPY2KL FcL+2ryaAjknJQIEwsvio7hzYgw2j0PCZy6ug21sUQlC1rSA1C57lu15GXkwtgwoRPSM xS2C0XB8sZwfad+w0x7kagY7B5NZddKKlEqqvYKiMe6XHPeafunvpXm5eZ02XtgKtA02 8QoDZwHa/JbIwXaMysuGCLrN2PyBowRNd33OxERHoDtWuxHDooNOCD+3OgovD0OmscLB nrWTg114oNSeXkNVPcCSd7HYDXHMdbMpiMXFDOFg+RDZPN8UVIn+5uIm1CIKZhi2rc/E lXMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683282337; x=1685874337; 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=vaUHOyT1LIyTYWNSTn2cNjIHhQTtmflDxQJya+CBkLg=; b=CvCMri+mPzf8EktLMXNZcVKJho3cn0o0L/SQwnccGwQLOamkXrS10N5g9+b27/4rkR tQrdiiOqC6hwxOSxmP+V9TtayBLIq/a5As80ty5Tzh0pVQlP3kwthD4NPmhfJTeZw7CE R9lpsdC4X6cmbrATkZdDa3uEVr2CL6jsIFc+N8mluYzFjWa4W+Vre43PmaDVh2tIe9/C RCyy9V7Szr8T8RQZYu9wGGIm3q0Wn4jFN8yMANWBrdsJGacDWZTZluXXRIZ7O/7ChebK bBuhxSZ+7kTzbeNEuuCG8tTsqEgnsGrn8zg4EgcA+6YzuNN8SVfXlFj/s1MIblQm+BaD 3X5A== X-Gm-Message-State: AC+VfDzy8i1QpaHzGKdVqeTW+PZfZIyvhhbfQvvuLhI+c2opuEE4dGyf 5twT+owjrLpXvYSXWlYM6PImd1SuB/u+BilctjCME2iU X-Received: by 2002:a9d:6f97:0:b0:69f:7b9b:473e with SMTP id h23-20020a9d6f97000000b0069f7b9b473emr381802otq.38.1683282337241; Fri, 05 May 2023 03:25:37 -0700 (PDT) Received: from ledge.ozog.com ([2604:1380:4111:b700::1]) by smtp.gmail.com with ESMTPSA id b21-20020a056830105500b006a6169cf6b0sm635068otp.47.2023.05.05.03.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 03:25:36 -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, Maxim Uvarov Subject: [RFC PATCH 4/5] add doc/README.lwip.size Date: Fri, 5 May 2023 10:25:28 +0000 Message-ID: <20230505102529.1254445-5-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.40.1.476.g69c786637d In-Reply-To: <20230505102529.1254445-1-maxim.uvarov@linaro.org> References: <20230505102529.1254445-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 05 May 2023 12:50:31 +0200 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 doc with size calculation accoding to original u-boot. Signed-off-by: Maxim Uvarov --- doc/README.lwip.size | 291 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 doc/README.lwip.size diff --git a/doc/README.lwip.size b/doc/README.lwip.size new file mode 100644 index 0000000000..7d3ff1e4d6 --- /dev/null +++ b/doc/README.lwip.size @@ -0,0 +1,291 @@ +Size with lwip stack + ping app + http wget app related +to original U-boot is: + +Total: Before=546322, After=594494, chg +8.82% +Total: Before=99215, After=100365, chg +1.16% +Total: Before=77777, After=78227, chg +0.58% + +(gdb) p (594494-546322) + (100365-99215) + (78227-77777) +$1 = 49772 +(gdb) p 49772 / 1024 +$2 = 48 + +Size will be increased on 48Kib. + +Full log: +linux/scripts/bloat-o-meter -c u-boot_orig/u-boot u-boot/u-boot +add/remove: 187/0 grow/shrink: 2/0 up/down: 48172/0 (48172) +Function old new delta +tcp_input - 4364 +4364 +tcp_receive - 3444 +3444 +tcp_write - 2192 +2192 +ip4_reass - 2096 +2096 +tcp_output - 1616 +1616 +tcp_slowtmr - 1572 +1572 +httpc_tcp_recv - 1044 +1044 +udp_input - 812 +812 +ip4_frag - 748 +748 +tcp_close_shutdown - 716 +716 +ip4_input - 688 +688 +icmp_input - 672 +672 +tcp_split_unsent_seg - 660 +660 +ip4_output_if_src - 612 +612 +tcp_connect - 608 +608 +etharp_input - 568 +568 +httpc_init_connection_common.constprop - 556 +556 +etharp_query - 556 +556 +ip_reass_free_complete_datagram - 520 +520 +etharp_output - 512 +512 +pbuf_alloc - 488 +488 +tcp_alloc - 484 +484 +pbuf_copy_partial_pbuf - 484 +484 +etharp_find_entry - 476 +476 +tcp_enqueue_flags - 440 +440 +tcp_create_segment - 424 +424 +tcp_abandon - 420 +420 +netif_add - 412 +412 +etharp_raw - 408 +408 +tcp_zero_window_probe - 400 +400 +raw_sendto_if_src - 360 +360 +tcp_pcb_remove - 356 +356 +raw_input - 352 +352 +pbuf_realloc - 336 +336 +tcp_free_acked_segments.constprop - 328 +328 +pbuf_free - 328 +328 +icmp_send_response - 324 +324 +tcp_output_alloc_header_common.constprop - 316 +316 +tcp_oos_insert_segment - 312 +312 +netif_loop_output - 296 +296 +httpc_create_request_string.constprop.isra - 292 +292 +ethernet_input - 284 +284 +etharp_output_to_arp_index - 280 +280 +tcp_rexmit - 276 +276 +netif_poll - 276 +276 +ip_reass_remove_oldest_datagram - 272 +272 +tcp_rexmit_rto_prepare - 260 +260 +tcp_pbuf_prealloc - 260 +260 +ping_send - 256 +256 +tcp_parseopt - 244 +244 +ping_recv - 244 +244 +ethernet_output - 236 +236 +inet_chksum_pseudo - 216 +216 +ip4addr_ntoa_r - 212 +212 +tcp_send_fin - 208 +208 +tcp_process_refused_data - 208 +208 +pbuf_copy_partial - 208 +208 +netif_set_addr - 204 +204 +tcp_output_control_segment_netif - 200 +200 +tcp_fasttmr - 200 +200 +pbuf_cat - 200 +200 +uboot_lwip_init - 196 +196 +lwip_wget - 192 +192 +tcp_rst_common.isra - 188 +188 +ip4_route - 188 +188 +tcp_update_rcv_ann_wnd - 184 +184 +sys_timeout_abs - 184 +184 +pbuf_memcmp - 184 +184 +tcp_recved - 180 +180 +pbuf_add_header_impl - 176 +176 +lwip_ping_init - 176 +176 +netif_do_set_ipaddr.isra - 172 +172 +httpc_free_state - 172 +172 +tcp_close_shutdown_fin - 168 +168 +httpc_recv - 168 +168 +tcp_send_empty_ack - 164 +164 +tcp_output_control_segment - 164 +164 +do_ops - 164 +164 +tcp_rexmit_fast - 160 +160 +raw_sendto - 160 +160 +do_lwip_ping - 156 +156 +pbuf_remove_header - 144 +144 +uboot_lwip_if_init - 140 +140 +tcp_input_delayed_close - 140 +140 +do_lwip_wget - 140 +140 +tcp_keepalive - 136 +136 +tcp_output_alloc_header.constprop - 132 +132 +tcp_netif_ip_addr_changed - 132 +132 +inet_chksum_pbuf - 132 +132 +pbuf_memfind - 128 +128 +pbuf_alloc_reference - 128 +128 +lwip_standard_chksum - 128 +128 +tcp_pcb_purge - 124 +124 +tcp_new_port - 124 +124 +pbuf_free_header - 120 +120 +tcp_rst_netif - 116 +116 +tcp_netif_ip_addr_changed_pcblist - 116 +116 +netif_issue_reports - 116 +116 +tcpip_try_callback - 112 +112 +tcp_poll - 112 +112 +tcp_eff_send_mss_netif - 112 +112 +ip_reass_dequeue_datagram - 112 +112 +ip4_input_accept - 112 +112 +httpc_tcp_connected - 112 +112 +etharp_free_entry - 112 +112 +tcp_rst - 108 +108 +ping_timeout - 108 +108 +low_level_input.constprop - 108 +108 +tcp_seg_copy - 104 +104 +tcp_next_iss - 104 +104 +sys_timeout - 104 +104 +httpc_get_internal_addr - 104 +104 +tcp_recv_null - 96 +96 +pbuf_clone - 96 +96 +tcp_rexmit_rto - 92 +92 +ip4_addr_isbroadcast_u32 - 92 +92 +tcp_sent - 88 +88 +tcp_rexmit_rto_commit - 88 +88 +tcp_recv - 88 +88 +tcp_kill_state - 88 +88 +tcp_err - 88 +88 +raw_new - 88 +88 +lwip_ping_send_now - 84 +84 +tcp_output_segment_busy - 80 +80 +tcp_get_next_optbyte - 80 +80 +tcp_free - 80 +80 +pbuf_alloced_custom - 80 +80 +ipfrag_free_pbuf_custom - 80 +80 +httpc_close - 80 +80 +uboot_lwip_poll - 76 +76 +tcpip_tcp_timer - 76 +76 +udp_netif_ip_addr_changed - 72 +72 +raw_netif_ip_addr_changed - 72 +72 +ip_frag_free_pbuf_custom_ref - 72 +72 +tcp_timer_needed - 68 +68 +tcp_close - 68 +68 +mem_free - 68 +68 +ethernetif_input - 68 +68 +pbuf_try_get_at - 64 +64 +pbuf_ref - 60 +60 +net_process_received_packet 768 828 +60 +memp_malloc - 60 +60 +tcp_seg_free - 56 +56 +netif_get_by_index - 56 +56 +low_level_output - 56 +56 +tcp_tmr - 52 +52 +tcp_segs_free - 48 +48 +pbuf_skip_const - 48 +48 +pbuf_copy - 48 +48 +httpc_tcp_poll - 48 +48 +tcp_free_ooseq - 44 +44 +pbuf_free_ooseq_callback - 44 +44 +netif_set_up - 44 +44 +netif_set_link_up - 44 +44 +tcp_output_fill_options.constprop - 40 +40 +etharp_request - 40 +40 +do_lwip_info - 40 +40 +raw_bind - 36 +36 +pbuf_chain - 36 +36 +memp_free - 36 +36 +ip4_output_if - 36 +36 +pbuf_header_force - 32 +32 +pbuf_clen - 32 +32 +inet_chksum - 32 +32 +pbuf_get_at - 28 +28 +httpc_tcp_err - 28 +28 +do_lwip_init - 28 +28 +sys_now - 24 +24 +tcp_trigger_input_pcb_close - 20 +20 +eth_send 116 136 +20 +lwip_loop_set - 16 +16 +ip4addr_ntoa - 16 +16 +tcp_arg - 12 +12 +lwip_loop_is_done - 12 +12 +lwip_enabled - 12 +12 +icmp_time_exceeded - 12 +12 +icmp_dest_unreach - 12 +12 +tcp_new - 8 +8 +tcp_abort - 8 +8 +raw_recv - 8 +8 +pbuf_add_header - 8 +8 +netif_null_output_ip4 - 8 +8 +lwip_htons - 8 +8 +lwip_htonl - 8 +8 +httpc_tcp_sent - 8 +8 +mem_trim - 4 +4 +mem_malloc - 4 +4 +ip_chksum_pseudo - 4 +4 +httpc_init_connection - 4 +4 +Total: Before=546322, After=594494, chg +8.82% +add/remove: 53/0 grow/shrink: 0/0 up/down: 1150/0 (1150) +Data old new delta +arp_table - 400 +400 +cmds - 224 +224 +uboot_netif - 96 +96 +_u_boot_list_2_cmd_2_lwipinfo - 56 +56 +_u_boot_list_2_cmd_2_lwip - 56 +56 +ip_data - 40 +40 +inseg - 32 +32 +settings - 24 +24 +str - 16 +16 +udp_pcbs - 8 +8 +tcpip_mbox - 8 +8 +tcphdr_opt2 - 8 +8 +tcphdr - 8 +8 +tcp_tw_pcbs - 8 +8 +tcp_listen_pcbs - 8 +8 +tcp_input_pcb - 8 +8 +tcp_bound_pcbs - 8 +8 +tcp_active_pcbs - 8 +8 +recv_data - 8 +8 +reassdatagrams - 8 +8 +raw_pcbs - 8 +8 +ping_target - 8 +8 +ping_pcb - 8 +8 +next_timeout - 8 +8 +netif_list - 8 +8 +netif_default - 8 +8 +daddr - 8 +8 +uboot_net_use_lwip - 4 +4 +tcpip_tcp_timer_active - 4 +4 +tcp_ticks - 4 +4 +seqno - 4 +4 +ping_time - 4 +4 +loop_lwip - 4 +4 +iss - 4 +4 +ip_target - 4 +4 +ackno - 4 +4 +tcplen - 2 +2 +tcphdr_optlen - 2 +2 +tcphdr_opt1len - 2 +2 +tcp_port - 2 +2 +tcp_optidx - 2 +2 +recv_acked - 2 +2 +ping_seq_num - 2 +2 +ip_reass_pbufcount - 2 +2 +ip_id - 2 +2 +tcp_timer_ctr - 1 +1 +tcp_timer - 1 +1 +tcp_active_pcbs_changed - 1 +1 +recv_flags - 1 +1 +pbuf_free_ooseq_pending - 1 +1 +netif_num - 1 +1 +flags - 1 +1 +etharp_cached_entry - 1 +1 +Total: Before=99215, After=100365, chg +1.16% +add/remove: 21/0 grow/shrink: 2/0 up/down: 450/0 (450) +RO Data old new delta +memp_pools - 112 +112 +tcp_pcb_lists - 32 +32 +version_string 46 70 +24 +__func__ 1317 1339 +22 +memp_UDP_PCB - 16 +16 +memp_TCP_SEG - 16 +16 +memp_TCP_PCB_LISTEN - 16 +16 +memp_TCP_PCB - 16 +16 +memp_TCPIP_MSG_INPKT - 16 +16 +memp_TCPIP_MSG_API - 16 +16 +memp_SYS_TIMEOUT - 16 +16 +memp_REASSDATA - 16 +16 +memp_RAW_PCB - 16 +16 +memp_PBUF_POOL - 16 +16 +memp_PBUF - 16 +16 +memp_NETCONN - 16 +16 +memp_NETBUF - 16 +16 +memp_FRAG_PBUF - 16 +16 +tcp_backoff - 13 +13 +tcp_persist_backoff - 7 +7 +ethzero - 6 +6 +ethbroadcast - 6 +6 +ip_addr_any - 4 +4 +Total: Before=77777, After=78227, chg +0.58% + From patchwork Fri May 5 10:25:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 679301 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp283472wrs; Fri, 5 May 2023 03:51:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6MoGcApuuBES1UFk+YtAXwtD/nB0Qw0hbvF8XXpdCX3h416FHFghlC3bUKemP6iyzaWC3w X-Received: by 2002:a05:6a20:d2cc:b0:f0:471f:4aef with SMTP id ir12-20020a056a20d2cc00b000f0471f4aefmr1197527pzb.49.1683283894683; Fri, 05 May 2023 03:51:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683283894; cv=none; d=google.com; s=arc-20160816; b=wl2H12RJymKPzmzlOCtEyjBportaV7XYlkvyrPMIrwfRd1iaHz9vDOx/XYX+SKYdd+ NpjCYJwxmjgFm6G18j6GM9zAwGWyRj5CGsZa+1/f4QXYQdNVcCqlKrG8En1WcAugRopb /FJ0bMwjqvMOgJTVA80xM9h9M8J5MTEojcuJYlh1jnlLXIurgPw9jdSlYBMxbfMHkS/+ fSK8MQc2PtIAOdMIhWfJq4wOsV0LOH2r3G1Pk6mDEJJbqvXabireNCmfg05JoL4rt5Tf xvTqkpOu9Ju0lwq/DJdCVFBgzMePaA/475beenHA4IQth4kLStAZflZjK2ijZY34i+WP pioQ== 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=vSEBQDuAFGDNriE8tgs+Rg9pPzILFY2IiPKxw8yP//E=; b=Fz89e1ENY8wudG2+2FkrDpSf43oEg2dvrLGNLlt7Mle74M5f81xsa2Ejv51Pu+7vi8 S0ptzypqbVBcKLWRkpbvaEv7UKtoSKhnXmojI0DWQwiCJWZPpZ6t9bS0nEH4wm5X4wm4 +S60N5AHkSyn8iz6bM1Mrj0qKmevHy9vISQ262eoacvM1FFqhORs+m9g6OcLUHijCEzR fX2B41s5P7yvjLDqmH4pGAwpOyAZezxBNEz6BgUywGJaw5nmsJIvAVrtrnDTJXeIpYlN iLE704AZTnr5JJjOP8zNnqQi+wTaB3BLaBCSUiDX66Zwi9g9BGATx0RcBdghIOIz4FQl rqxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qQbKur7v; 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 y29-20020a637d1d000000b0052883ac6949si1788623pgc.13.2023.05.05.03.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 03:51:34 -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=qQbKur7v; 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 24E64857D1; Fri, 5 May 2023 12:50:38 +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="qQbKur7v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B9CF28475F; Fri, 5 May 2023 12:25: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=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NUMERIC_HTTP_ADDR,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) (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 90F6984761 for ; Fri, 5 May 2023 12:25:39 +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-ot1-x331.google.com with SMTP id 46e09a7af769-6a5da18f7f5so1212047a34.1 for ; Fri, 05 May 2023 03:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683282338; x=1685874338; 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=vSEBQDuAFGDNriE8tgs+Rg9pPzILFY2IiPKxw8yP//E=; b=qQbKur7vURzLqnQDyQOsfJkRyDY+4+8BmtJ9q2RY9/LCskmW7f91Q6YLlGbp/45IPF veLc9bTV8pBfJKd/7aacS2Ozk68Z3a0Oy2aYefV/ADLKtXK9oIiewnKLX11hoDvmTj4G ae9yS0/mcsiswrIMEljh7nBIoxKdCO2g7NFsE3tyCmiKOg/ouTRq+vQab+66qgNLTdEK LggBkEkbfa5g8q5pzcrz51EuGNG2gpZYKxYpDSsM+YkMR+QVXx36Oy0rCS2Ly6JnpI4U 4lLwrGMwph22IXdK+ASpSC1k/sSIZIFXpNE72SbvxuDxQ7dQoke23C3j8h1BWqj9m2Tg NJlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683282338; x=1685874338; 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=vSEBQDuAFGDNriE8tgs+Rg9pPzILFY2IiPKxw8yP//E=; b=Noxvln3pJCwVNZJE2g8XDidTR0QCHhVaRRCEBG3bn3e0Ui2X5DVRrrpIiRE+uWu44b D7ovzLYnXPNGB8OzrbiKU9P7V5j1JR46GCDhGCVnAxR+3z4dKDEEi1iZj+ex3xpX9B0f Aq7UXTpS/19ECOTs8gELMyRpRPgfOIIsED52ZwBlCopaFK9Vu0cwznQ0LqXJ+yI4pnYW pfUeHBOFEuiWZSzpg/39aY8aH+r4PD4cTFhGPqMdnYj1dq4c+LdvARtlWkt6CEDxxTGa VPPjECfFtk6Fc8izUSzFvegJMgyhS3XBwwowCuk7ySwCeKmb3EpkFQyej8sJIlZKDsX0 GhoA== X-Gm-Message-State: AC+VfDxbVTwI2gAsXHJa7EvaaQEltrp+bm5HBcQKlT0hHxMea4qahX28 t7PXKH0zqVQnoxK1PGImIUQYkpAkpQOCMf+ZEFm6dY3s X-Received: by 2002:a05:6830:22f9:b0:6a7:b0e9:7614 with SMTP id t25-20020a05683022f900b006a7b0e97614mr414751otc.14.1683282337840; Fri, 05 May 2023 03:25:37 -0700 (PDT) Received: from ledge.ozog.com ([2604:1380:4111:b700::1]) by smtp.gmail.com with ESMTPSA id b21-20020a056830105500b006a6169cf6b0sm635068otp.47.2023.05.05.03.25.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 03:25:37 -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, Maxim Uvarov Subject: [RFC PATCH 5/5] lwip: implement wget command from http_client.c example Date: Fri, 5 May 2023 10:25:29 +0000 Message-ID: <20230505102529.1254445-6-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.40.1.476.g69c786637d In-Reply-To: <20230505102529.1254445-1-maxim.uvarov@linaro.org> References: <20230505102529.1254445-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 05 May 2023 12:50:31 +0200 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 Intend of RFC is to show how we can reuse existance lwip apps and examples inside u-boot. This commit shows how to do that with minimal changes. Signed-off-by: Maxim Uvarov --- .gitignore | 2 + doc/README.lwip | 34 ++++++++++++++++ lib/lwip/Makefile | 8 ++++ lib/lwip/apps/http/lwip-wget.c | 67 +++++++++++++++++++++++++++++++ lib/lwip/apps/http/rmstatic.patch | 47 ++++++++++++++++++++++ lib/lwip/cmd-lwip.c | 31 ++++++++++++++ 6 files changed, 189 insertions(+) create mode 100644 lib/lwip/apps/http/lwip-wget.c create mode 100644 lib/lwip/apps/http/rmstatic.patch diff --git a/.gitignore b/.gitignore index aeaf847543..339692f5a7 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,5 @@ __pycache__ /lib/lwip/lwip-external lib/lwip/apps/ping/ping.c +lib/lwip/apps/http/http_client.c +lib/lwip/apps/http/http_client.h diff --git a/doc/README.lwip b/doc/README.lwip index df3462ca1b..b59a1568b4 100644 --- a/doc/README.lwip +++ b/doc/README.lwip @@ -54,3 +54,37 @@ Unmodified ping example can be used. I did ping from qemu/u-boot tap device on t ping: recv 3 ms tcpdump on the host: 5:09:10.925951 ARP, Request who-has 192.168.1.200 tell 192.168.1.200, length 28 15:09:12.114643 IP6 fe80::38e2:41ff:fec3:8bda > ip6-allrouters: ICMP6, router solicitation, length 16 15:09:20.370725 ARP, Request who-has 192.168.1.2 tell 192.168.1.200, length 28 15:09:20.370740 ARP, Reply 192.168.1.2 is-at 3a:e2:41:c3:8b:da (oui Unknown), length 28 15:09:20.372789 IP 192.168.1.200 > 192.168.1.2: ICMP echo request, id 44975, seq 1, length 40 15:09:20.372810 IP 192.168.1.2 > 192.168.1.200: ICMP echo reply, id 44975, seq 1, length 40 15:09:25.426636 ARP, Request who-has 192.168.1.200 tell 192.168.1.2, length 28 15:09:25.426870 ARP, Reply 192.168.1.200 is-at f6:11:01:02:03:04 (oui Unknown), length 28 + + +5. Wget example + +Http server has 192.168.1.2 IP address. (I did not port DNS resolving yet, +but it's also exist in lwip.) So example just downloads some file with http +protocol: + +Net: eth0: virtio-net#30 +Hit any key to stop autoboot: 0 +=> lwip init +Starting lwIP, local interface IP is 192.168.1.200 +Initialized LWIP stack +=> lwip wget http://192.168.1.2/ +downloading http://192.168.1.2/ to addr 0x40200000 +downloaded chunk size 294, to addr 0x40200000 +downloaded chunk size 318, to addr 0x40200126 +=> md 0x40200000 0x40 +40200000: 4f44213c 50595443 74682045 0a3e6c6d . +40200010: 6d74683c 3c0a3e6c 64616568 743c0a3e ..Welcome to +40200030: 6e69676e 2f3c2178 6c746974 3c0a3e65 nginx!.< +40200040: 6c797473 200a3e65 62202020 2079646f style>. body +40200050: 20200a7b 20202020 69772020 3a687464 {. width: +40200060: 65353320 200a3b6d 20202020 6d202020 35em;. m +40200070: 69677261 30203a6e 74756120 200a3b6f argin: 0 auto;. +40200080: 20202020 66202020 2d746e6f 696d6166 font-fami +40200090: 203a796c 6f686154 202c616d 64726556 ly: Tahoma, Verd +402000a0: 2c616e61 69724120 202c6c61 736e6173 ana, Arial, sans +402000b0: 7265732d 0a3b6669 20202020 2f3c0a7d -serif;. }...< +402000d0: 79646f62 683c0a3e 65573e31 6d6f636c body>.

Welcom +402000e0: 6f742065 69676e20 3c21786e 3e31682f e to nginx!

+402000f0: 3e703c0a 79206649 7320756f 74206565 .

If you see t diff --git a/lib/lwip/Makefile b/lib/lwip/Makefile index 2c665dcb88..e28cfd726e 100644 --- a/lib/lwip/Makefile +++ b/lib/lwip/Makefile @@ -75,4 +75,12 @@ $(obj)/apps/ping/ping.c: obj-$(CONFIG_CMD_LWIP) += apps/ping/ping.o obj-$(CONFIG_CMD_LWIP) += apps/ping/lwip_ping.o +$(obj)/apps/http/http_clinet.o: $(obj)/apps/http/http_client.c +$(obj)/apps/http/http_client.c: + cp ./lib/lwip/lwip-external/src/apps/http/http_client.c $(obj)/apps/http/http_client.c + cp ./lib/lwip/lwip-external/src/include/lwip/apps/http_client.h $(obj)/apps/http/http_client.h + patch -p0 < $(obj)/apps/http/rmstatic.patch + +obj-y += apps/http/http_client.o +obj-y += apps/http/lwip-wget.o diff --git a/lib/lwip/apps/http/lwip-wget.c b/lib/lwip/apps/http/lwip-wget.c new file mode 100644 index 0000000000..f3295d67f1 --- /dev/null +++ b/lib/lwip/apps/http/lwip-wget.c @@ -0,0 +1,67 @@ +#include +#include +#include + +#include "http_client.h" + +extern err_t +httpc_init_connection(httpc_state_t **connection, const httpc_connection_t *settings, const char* server_name, + u16_t server_port, const char* uri, altcp_recv_fn recv_fn, void* callback_arg); +extern err_t +httpc_get_internal_addr(httpc_state_t* req, const ip_addr_t *ipaddr); +extern err_t +httpc_free_state(httpc_state_t* req); + +static ulong daddr; +static httpc_connection_t settings; + +static err_t +httpc_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *p, err_t err) +{ + struct pbuf* q; + LWIP_UNUSED_ARG(err); + + if (p == NULL) { + printf("httpc_tcp_recv bug!\n"); + return ERR_BUF; + } + + for (q = p; q != NULL; q = q->next) { + memcpy(daddr, q->payload, q->len); + printf("downloaded chunk size %d, to addr 0x%lx\n", q->len, daddr); + daddr += q->len; + } + altcp_recved(pcb, p->tot_len); + pbuf_free(p); + return ERR_OK; +} + +int lwip_wget(ulong addr, char *url) +{ + httpc_state_t* req; + err_t err; + int port = 80; + ip4_addr_t server_addr; + char *server_name; + + daddr = addr; + IP4_ADDR(&server_addr, 192,168,1,2); + server_name = ipaddr_ntoa(&server_addr); + + memset(&settings, 0, sizeof(httpc_connection_t)); + err = httpc_init_connection(&req, &settings, server_name, port, + url, httpc_recv, NULL /*&addr*/); + if (err != ERR_OK) { + printf("httpc_init_connection failed\n"); + return err; + } + + err = httpc_get_internal_addr(req, &server_addr); + if (err != ERR_OK) { + httpc_free_state(req); + printf("error httpc_get_internal_addr\n"); + return err; + } + + return 0; +} diff --git a/lib/lwip/apps/http/rmstatic.patch b/lib/lwip/apps/http/rmstatic.patch new file mode 100644 index 0000000000..547236de52 --- /dev/null +++ b/lib/lwip/apps/http/rmstatic.patch @@ -0,0 +1,47 @@ +--- ./lib/lwip/lwip-external/src/apps/http/http_client.c 2023-05-03 15:26:42.038088829 +0000 ++++ lib/lwip/apps/http/http_client.c 2023-05-03 15:27:25.298151160 +0000 +@@ -45,7 +48,7 @@ + * - IPv6 support + */ + +-#include "lwip/apps/http_client.h" ++#include "http_client.h" + + #include "lwip/altcp_tcp.h" + #include "lwip/dns.h" +@@ -153,7 +156,7 @@ typedef struct _httpc_state + } httpc_state_t; + + /** Free http client state and deallocate all resources within */ +-static err_t ++/*static*/ err_t + httpc_free_state(httpc_state_t* req) + { + struct altcp_pcb* tpcb; +@@ -415,7 +418,7 @@ httpc_tcp_connected(void *arg, struct al + } + + /** Start the http request when the server IP addr is known */ +-static err_t ++/*static*/ err_t + httpc_get_internal_addr(httpc_state_t* req, const ip_addr_t *ipaddr) + { + err_t err; +@@ -592,7 +595,7 @@ httpc_init_connection_common(httpc_state + /** + * Initialize the connection struct + */ +-static err_t ++/* static */ err_t + httpc_init_connection(httpc_state_t **connection, const httpc_connection_t *settings, const char* server_name, + u16_t server_port, const char* uri, altcp_recv_fn recv_fn, void* callback_arg) + { +@@ -786,7 +789,7 @@ httpc_fs_result(void *arg, httpc_result_ + } + + /** tcp recv callback */ +-static err_t ++/*static*/ err_t + httpc_fs_tcp_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *p, err_t err) + { + httpc_filestate_t *filestate = (httpc_filestate_t*)arg; diff --git a/lib/lwip/cmd-lwip.c b/lib/lwip/cmd-lwip.c index f2e25a8c29..797f0f2fe2 100644 --- a/lib/lwip/cmd-lwip.c +++ b/lib/lwip/cmd-lwip.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "apps/ping/lwip_ping.h" @@ -57,10 +58,39 @@ static int do_lwip_ping(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_SUCCESS; } +extern int lwip_wget(ulong addr, char *url); + +static int do_lwip_wget(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + char *url; + + if (argc < 2) { + printf("argc = %d, error\n", argc); + return CMD_RET_USAGE; + } + + url = argv[1]; + printf("downloading %s to addr 0x%lx\n", url, image_load_addr); + + eth_init(); /* activate u-boot eth dev */ + + lwip_wget(image_load_addr, url); + + lwip_loop_set(); + if (net_loop(LWIP) < 0) { + printf("wget failed\n"); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; +} + static struct cmd_tbl cmds[] = { U_BOOT_CMD_MKENT(info, 1, 0, do_lwip_info, "", ""), U_BOOT_CMD_MKENT(init, 1, 0, do_lwip_init, "", ""), U_BOOT_CMD_MKENT(ping, 2, 0, do_lwip_ping, "", ""), + U_BOOT_CMD_MKENT(wget, 2, 0, do_lwip_wget, "", ""), }; static int do_ops(struct cmd_tbl *cmdtp, int flag, int argc, @@ -88,6 +118,7 @@ U_BOOT_CMD( "info - display info\n" "init - init LWIP\n" "ping addr - ping addr\n" + "wget http://192.168.1.2/ \n" ); /* Old command kept for compatibility. Same as 'mmc info' */