From patchwork Mon Aug 14 13:32:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713470 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1241838wrp; Mon, 14 Aug 2023 06:35:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdl0xbHDwXPPEVQMeMOMwYSvkiA286th8tLOgrB7vejrxDi4wkEIiqrWGA7Gi8WEIhGSw7 X-Received: by 2002:a7b:ce99:0:b0:3fe:1f70:9e54 with SMTP id q25-20020a7bce99000000b003fe1f709e54mr9771012wmj.4.1692020123930; Mon, 14 Aug 2023 06:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020123; cv=none; d=google.com; s=arc-20160816; b=eXXAwPtiFOD/+Hpe8ye8KxAxNsHc+v94VSSwt67Y8dNLn6qEUWDr1anCFVkaFTfSIX AZwqHRbfpGVo9SKwpAl96NTek5KYSp2fL59bkZmTsav61gRrnGas6QtsonV1XRxW7Pw1 JYGcpUTrxgM9IRYDMhSZU7LV7lUItBtBmla3UUvL3TTAtoqwsNPDOgRvuT+A9N75HWge 74haF82M0n+wQ2XCqzX0pR1q0HDLlzZoTvhUkJsPYF6zveCOgLPCWTMa6esHXIJsU+t7 +sDEPUIo8U3ivk3OaRMr2CE6flu5FIVjFO3E7mMqct3PBiiyLQKPpr42kE4tUf4rcgcZ jBmQ== 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=hkIGeB291jB+1tGA8HrbTzhGbwVlxBLBG4XoLBsXRw0=; fh=GxT5DUgD3izNRwAKLYTQd/U1zCykdRvuqVJsmcrm2OQ=; b=By0lZPnAYsT+Cxc7JkIlAi/ywmMyyQorhYkZdKtzjjcQFu5ad4H+6Y3jJ3RvYylA9a s1gsiaxt1vywHhNPSeBGJakTr9ePVCUCXwAElLrXAp7g90TzoBhYUw4nXGq1DNiOoy5U Cy0K8bJdhbhG0hhdwfV4/JjnYeZlugxg1Zsooh+JVXtMo8iPVUwmekzjj7VMRKphuyum 2sJsDEwsQRMRRXYlrB0SUqi3wSqZkiU3Tha3Gnle4nEpfEPSBqP2bhhSWJV44UiHhmsn KsN3zegjYftGGqHw9PrWekTDXTZVbVSFPrSEW5+AH5/f98CaYRzLfeT3tZl8H9aIUClQ asYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GlESJvmS; 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 q16-20020adffed0000000b00317544258b5si5368606wrs.288.2023.08.14.06.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:23 -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=GlESJvmS; 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 CCAA386958; Mon, 14 Aug 2023 15:35:16 +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="GlESJvmS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B14CE86918; Mon, 14 Aug 2023 15:35:15 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) (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 7B418807B3 for ; Mon, 14 Aug 2023 15:35:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2bb734a9081so13457191fa.1 for ; Mon, 14 Aug 2023 06:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020112; x=1692624912; 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=hkIGeB291jB+1tGA8HrbTzhGbwVlxBLBG4XoLBsXRw0=; b=GlESJvmS2LQYy0/KSWNOOIOp6/VxGp7YeImtDIxZQd+Hkm+GndEnHdf2/bIQ/LAcNg e2PiysQW0F1S9Gpr5zAqS+KfiWCCUTDU9SffEUz0XLG72fxHZVJKCRz7KcO2aQcQranb HmOMuetZjGEmzxFBNeuCvUMCseYnl0zCPgsaAN785qUqHCSc5U+iu/sF3dTkZlSSJ+D0 yhYnshwp8UHmaCdv7dAPlhQqGk1WjeyjTDU3ivtc1JImW9aX5yEusAU9iJfNYEQNgLHD +jOcklr4NYh8TKau3AioG3pc1cRHDtMrQ6qzAV8Vx1AWn8ED269ShBm6LpC7NfyCIH+b W5Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020112; x=1692624912; 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=hkIGeB291jB+1tGA8HrbTzhGbwVlxBLBG4XoLBsXRw0=; b=LinT55nro1S6G+34vooNmRZLD0gZ5/bEY47XsmX5amKVXe+znnclA1lGrKWvK6qwfP iDYS0W0ig1ftHWSyfOgevZ84xGSKipPcjD9OoucJF09y/Xcq34IUlBsvR2t6pKYcZlpf hk6ZTo6Gccp503IHC5Y2YGUBZBrhdIiZoszplAukK05OZfmqDRWED/GC4aJsK2IoX8Z8 vibobOKTvi7TLzfBKJM/chu2YyI+9Uk8K3KsIQrOEtNyDeYnfm8SHAeiBCtzq+9k5x8+ Vc848367CIxanMND8W7jvSG1qzsnUxWSpQHyE+sJc2Gyhih2kYiJSOwM4O1kqzcOdUzu 5l6g== X-Gm-Message-State: AOJu0YxMd028i1Rtm6mohJ0gQw6Gx5qkp5hI/tswFaMrvGwcabvIodIU h7jJi3EA9V4V7H0NX3r4ij7j/EF51gy2/rKbPyg= X-Received: by 2002:a2e:86d0:0:b0:2b9:a9d8:16a7 with SMTP id n16-20020a2e86d0000000b002b9a9d816a7mr3428223ljj.8.1692020112630; Mon, 14 Aug 2023 06:35:12 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:12 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov , Simon Glass Subject: [PATCHv6 01/14] net/lwip: add doc/develop/net_lwip.rst Date: Mon, 14 Aug 2023 19:32:40 +0600 Message-Id: <20230814133253.4150-2-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add initial documentation of lwIP network IP stack integration to the U-Boot (net_lwip.rst). Signed-off-by: Maxim Uvarov Reviewed-by: Simon Glass --- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 64 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 doc/develop/net_lwip.rst diff --git a/doc/develop/index.rst b/doc/develop/index.rst index 5b230d0321..4764990f25 100644 --- a/doc/develop/index.rst +++ b/doc/develop/index.rst @@ -48,6 +48,7 @@ Implementation spl falcon uefi/index + net_lwip vbe version diff --git a/doc/develop/net_lwip.rst b/doc/develop/net_lwip.rst new file mode 100644 index 0000000000..bdd2c921b3 --- /dev/null +++ b/doc/develop/net_lwip.rst @@ -0,0 +1,64 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +LWIP IP stack intergation for U-Boot +==================================== + +Intro +----- + +LWIP is a library implementing network protocols, which is commonly used +on embedded devices. + +https://savannah.nongnu.org/projects/lwip/ + +LwIP  license: +LwIP is licensed under a BSD-style license: http://lwip.wikia.com/wiki/License. + +Main features include: + +* Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE + +* DHCP client, DNS client (incl. mDNS hostname resolver), + AutoIP/APIPA (Zeroconf), SNMP agent (v1, v2c, v3, private MIB support + & MIB compiler) + +* APIs: specialized APIs for enhanced performance, optional Berkeley-alike + socket API + +* Extended features: IP forwarding over multiple network interfaces, TCP + congestion control, RTT estimation and fast recovery/fast retransmit + +* Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, + NetBIOS nameserver, mDNS responder, MQTT client, TFTP server + +U-Boot implementation details +----------------------------- + +1. In general we can build lwIP as a library and link it against U-Boot or + compile it in the U-Boot tree in the same way as other U-Boot files. There + are few reasons why I selected the second variant: LwIP is very customizable + with defines for features, memory size, types of allocation, some internal + types and platform specific code. It turned out easier to enable/disable + debug which is also done with defines, and is needed periodically. + +2. lwIP has 2 APIs - raw mode and sequential (as lwIP names it, or socket API + as we name it in Linux). +For now only raw API is supported. + +In raw IP mode a callback function for RX path is registered and will be called +when packet is passed to the IP stack and is ready for the application. + +Example is unmodified working ping example from lwip sources which registered +the callback: + +.. code-block:: c + + ping_pcb = raw_new(IP_PROTO_ICMP); + raw_recv(ping_pcb, ping_recv, NULL); <- ping_recv is app callback. + raw_bind(ping_pcb, IP_ADDR_ANY) + +3.  Input and output + +RX packet path is injected to U-Boot eth_rx() polling loop and TX patch is in +eth_send() accordingly. So we do not touch any drivers code and just eat +packets when they are ready. From patchwork Mon Aug 14 13:32:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713471 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1241941wrp; Mon, 14 Aug 2023 06:35:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGT7ErKl7R6jUKQCAMTgClE9KMjIzrGr5Dq+kzlkTxgbBjdD72hxjHNI0+4266VJN4p79PH X-Received: by 2002:a5d:60cc:0:b0:315:ae39:27c with SMTP id x12-20020a5d60cc000000b00315ae39027cmr7134677wrt.70.1692020135676; Mon, 14 Aug 2023 06:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020135; cv=none; d=google.com; s=arc-20160816; b=wk6HjwvyeIRrUjwCzf9y+pjKATdy7D1BO9VQ+xwkB04goa5yZNXvvZ9hHFJpdAVqeQ f83q0qS3ph90VIXtAJy+Lix4AlMpIK1AWHfXY561DO4dk6iaviR/SUGug4Xbp4oDyiXH oQGlqR3tzexCgHqGBIZBINpk8IdRiLGDZdlCWsJ9uZuZDFWOKZOTUZYr4DWmyAzPIfYq o0KHHl0G/0u4uiKI0O84rPZXuLruwVXW9lmQjvjzteXoVqcm1AgB8kve0el/S388SdZT MOM1P4Unl7evg6qcumM46SZhi2wyKZ14Jbv1ZTpPsRHCkKP0LMD8yNDvL2f1dG9V5MPc yZ4w== 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=+5BDe1+laGab+DyI37GMa2W2z5gN/NLvzaH2Cr1H3Kk=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=TPTbOvTBt4VMrHtsOK8d19xsDB1OA5jMYc3geSXEe8ckGdY7gSXEdl23aoEzZZOAqz yPbtXwrXZnX502f7dniqwBL4didET1GxHXH6F0SegDU8+DGzmVM930TlW06ViWU4+HPA FSV7BtRCiQQ/7ERmXgVGPLBF4qTveWJR9FbcuVi2IBGcxn6AHHxTnhRAo5E3Cu99MUmq U5TyOsDyJgJHOgdwG2CDF3OGSIQjd8CH71lELKqpo2ZbZwwjpScG8JAE3obFstkpxnKn mINmfPd4tHVUI6kNZTYhE5Zi0hHQRWoef8Il5zafX08u5ysvX1NfSDTnrHvWoUnfS4l/ vlYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wbWySuAd; 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 n3-20020a5d4c43000000b003177f3e775csi5009183wrt.1030.2023.08.14.06.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:35 -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=wbWySuAd; 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 1CB338694B; Mon, 14 Aug 2023 15:35:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=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="wbWySuAd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 77204807B4; Mon, 14 Aug 2023 15:35:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) (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 238C7807B3 for ; Mon, 14 Aug 2023 15:35:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2b9b904bb04so68244931fa.1 for ; Mon, 14 Aug 2023 06:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020115; x=1692624915; 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=+5BDe1+laGab+DyI37GMa2W2z5gN/NLvzaH2Cr1H3Kk=; b=wbWySuAdOrfX96d0ki999f/tSNyhjXUoJkGRhV/m5ZtgR/IebAPIIa6rGqkQUR2AHY 3e+KtG40aRm/FIJMzeornpWuD4bZEjllIasuFli1FtKYFW2IM97XOkAUVymycDlQxqrS gbI64Y2CGPEO0h8D7O4vVJxowrmOMB0d45Mv4lEW1tmcdrfMyWPU/n6q5FfMDd9sMRoS /2XUBh//ylJ9gVBi1ouR39kny4IsaO4qVqHrW2rCwKS/hISzUJ9QCiBVoNZOj+2DETnw s3ZncYLPK/btBFiD0loqldN5Y/1/cQ1sWEQ+SL4p3H0W1bUun5KYa6a8QVwNT0+b2kAP GLjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020115; x=1692624915; 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=+5BDe1+laGab+DyI37GMa2W2z5gN/NLvzaH2Cr1H3Kk=; b=g4njzcgbl23JcT2ME0fwhEmBxh3xw5quFVfSgr2UAEBAx0QBwtElt1RJHmn0VwrB3X OTHKUVUeEYnh273Zjr98qFhsSRaBhr02Z14wFF8mMlQB8GW+Co/gKwVBYUM4XSYz9HSv +rY42KNj/d1V+nlulNadPD2fl54F65cSnfmQE+itVjTI+vjVU9A4zk8oKJdlP8R7r0ER qzCq52d4lcqfsDfACSYQg48vZyg5u8bDmCwe7dJ6TpI8aYt7k5NGZuAEAhlWOjjcH2sG XFQ6EievnV6qyuELYBQIC/cWNHZUtGdoJfHPZ/5+CxsGt8aCxXhGv4JKf6F3HDccwBXY IJzA== X-Gm-Message-State: AOJu0Yysp3nDSpCnMojsMXhluST0rNEbWPd7dGV3gqWeOwg9S3WMwyv2 J49Gmwyf9kIqRj3P3lAecbqpnSw1gS+mZNF/OAU= X-Received: by 2002:a2e:3e02:0:b0:2b9:e831:f15f with SMTP id l2-20020a2e3e02000000b002b9e831f15fmr6073193lja.32.1692020115228; Mon, 14 Aug 2023 06:35:15 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:14 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 02/14] net/lwip: integrate lwIP library Date: Mon, 14 Aug 2023 19:32:41 +0600 Message-Id: <20230814133253.4150-3-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Define Makefile and Kconfig to build lwIP inside the U-Boot. We compile lwIP the same as the main code, plus we can do optimization for size at compile time with disabling not needed debug asserts, or not used protocols. So we can tune lwIP configuration specially for U-Boot environments. Signed-off-by: Maxim Uvarov --- net/Kconfig | 3 +++ net/Makefile | 1 + net/lwip/Kconfig | 60 ++++++++++++++++++++++++++++++++++++++++++ net/lwip/Makefile | 66 +++++++++++++++++++++++++++++++++++++++++++++++ net/net.c | 20 ++++++++++++++ 5 files changed, 150 insertions(+) create mode 100644 net/lwip/Kconfig create mode 100644 net/lwip/Makefile diff --git a/net/Kconfig b/net/Kconfig index 4215889127..34c1e43c87 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -5,9 +5,12 @@ menuconfig NET bool "Networking support" default y + imply LWIP if NET +source net/lwip/Kconfig + config ARP_TIMEOUT int "Milliseconds before trying ARP again" default 5000 diff --git a/net/Makefile b/net/Makefile index 3e2d061338..61930c244e 100644 --- a/net/Makefile +++ b/net/Makefile @@ -33,6 +33,7 @@ obj-$(CONFIG_CMD_WOL) += wol.o obj-$(CONFIG_PROT_UDP) += udp.o obj-$(CONFIG_PROT_TCP) += tcp.o obj-$(CONFIG_CMD_WGET) += wget.o +obj-$(CONFIG_LWIP) += lwip/ # Disable this warning as it is triggered by: # sprintf(buf, index ? "foo%d" : "foo", index) diff --git a/net/lwip/Kconfig b/net/lwip/Kconfig new file mode 100644 index 0000000000..233c6c532d --- /dev/null +++ b/net/lwip/Kconfig @@ -0,0 +1,60 @@ +menu "LWIP" +config LWIP + bool "Support LWIP library" + help + Enable the lwIP library code with + all dependencies (cmd commands implemented with lwIP + library. This option is automatically enabled if CONFIG_NET=y. + lwIP library (https://git.savannah.nongnu.org/git/lwip.git) provides + network stack and application code for U-Boot cmd commands. + Please see doc/develop/net_lwip.rst for more details. + +menu "LWIP options" + +config LWIP_LIB_DEBUG + bool "enable debug" + default n + +config LWIP_LIB_NOASSERT + bool "disable asserts" + default y + help + Disabling asserts reduces binary size by 16k. + +config LWIP_LIB_TCP + bool "tcp" + default y + help + Compile lwIP with TCP protocol support. + +config LWIP_LIB_UDP + bool "udp" + default y + help + Compile lwIP with UDP protocol support (needed for TFTP). + +config LWIP_LIB_DNS + bool "dns" + default y + help + Compile lwIP with DNS protocol support. + +config LWIP_LIB_DHCP + bool "dhcp" + default y + help + Compile lwIP with DHCP protocol support. + +config LWIP_LIB_LOOPBACK + bool "loopback" + help + Increases size by 1k. + help + Compile lwIP with loopback interface support. + +config LWIP_LIB_SOCKET + bool "socket API" + +endmenu + +endmenu diff --git a/net/lwip/Makefile b/net/lwip/Makefile new file mode 100644 index 0000000000..d1161bea78 --- /dev/null +++ b/net/lwip/Makefile @@ -0,0 +1,66 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# (C) Copyright 2023 Linaro Ltd. + +LWIPDIR=lwip-external/src + +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip + +obj-$(CONFIG_NET) += $(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-$(CONFIG_NET) += $(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-$(CONFIG_NET) += $(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-$(CONFIG_NET) += $(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-$(CONFIG_NET) += $(LWIPDIR)/netif/ethernet.o + +obj-$(CONFIG_NET) += port/if.o +obj-$(CONFIG_NET) += port/sys-arch.o diff --git a/net/net.c b/net/net.c index 43abbac7c3..7f868ee516 100644 --- a/net/net.c +++ b/net/net.c @@ -125,6 +125,7 @@ #endif #include "dhcpv6.h" #include "net_rand.h" +#include /** BOOTP EXTENTIONS **/ @@ -452,7 +453,11 @@ int net_loop(enum proto_t protocol) #endif bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start"); +#if defined(CONFIG_LWIP) + if (!ulwip_enabled() || !ulwip_in_loop()) +#endif net_init(); + if (eth_is_on_demand_init()) { eth_halt(); eth_set_current(); @@ -649,6 +654,16 @@ restart: */ eth_rx(); + if (IS_ENABLED(CONFIG_LWIP) && ulwip_enabled()) { + net_set_state(NETLOOP_CONTINUE); + if (!ulwip_in_loop()) { + if (ulwip_app_get_err()) + net_set_state(NETLOOP_FAIL); + else + net_set_state(NETLOOP_SUCCESS); + goto done; + } + } /* * Abort if ctrl-c was pressed. */ @@ -1213,6 +1228,11 @@ void net_process_received_packet(uchar *in_packet, int len) if (len < ETHER_HDR_SIZE) return; + if (IS_ENABLED(CONFIG_LWIP) && ulwip_enabled()) { + ulwip_poll(); + return; + } + #if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER) if (push_packet) { (*push_packet)(in_packet, len); From patchwork Mon Aug 14 13:32:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713472 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1242028wrp; Mon, 14 Aug 2023 06:35:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEBncqjVummn5V1wSKdnbZg1m5FQVmjwSfRG+MDU4j4N2TrI2z7+M8Oue7Oxn9TydZZ0QJi X-Received: by 2002:a1c:7210:0:b0:3fc:182:7eac with SMTP id n16-20020a1c7210000000b003fc01827eacmr8583705wmc.33.1692020145673; Mon, 14 Aug 2023 06:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020145; cv=none; d=google.com; s=arc-20160816; b=nTYLIy/W8k8P6Y9U31TqqdmKhM1I479dC3/yEsMysP9IgaB/oT5AfxHrsJzA7HCJjQ 2gxUdcSRCVEHmlrp7bh9a/Q/0p9ZJGbtKpFnvrVJh/qZkcSoYMIzNqp97n16sl7AJfGR TSdkrOVQfqnPfip+OWVFDxOcgyxmYiDw52aGB3KmXAO9zKWpqKzxE55jjZRYTDaLIiFI unVBm64yR0V1+CPxQF8P+pzsnQvuTbI3s8iXp/vsU3mkL3UJoFpc2qEvIwFjHRByO/vt gkTAuVNWR3aHRZhEqwQAnKYn1EEwf1VLZpAJ98LcCZX3tfF/lewJlGpKKEwesywNftp9 tp+Q== 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=i7fYJuYnoDdTqIbqyJAYF/Jw5jvYcvNcYushZkJLvN4=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=Q5eb3G+B5iwepl6BD+Dz/5o9F54ZXbphZF8u6eTZt82laU/sEjCdv994MAMMOxjVMc A0hgzyYTrrcw1yuM+FwWpDh9NtYewCEKnO9HLqNsGkvNmUIWc9zCVq/0+kfv3C2SN/Xv 4fEKOpb0mIf7qr8x/PrFvDzzIq6mB6s2QWXgG9MX+KFdWq88hgWCn8E6+PGOXwpuRr8Y vxE9TwEHfzH69m1kn8AdMm+EU4JQN/jDejp+7gNVwI4dfqHVZzdYecLuvr8wqxzewwjy 4O4qUrpwtwKQeHIVPlOvEhCE1Q25tz2xm9U/eHuP10AHcNxQhJaUNCBsKkZQlpwLTex3 Cn8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DOjsmfnQ; 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 k7-20020a05600c0b4700b003fe1cdbc344si7060715wmr.96.2023.08.14.06.35.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:45 -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=DOjsmfnQ; 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 642A786975; Mon, 14 Aug 2023 15:35:22 +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="DOjsmfnQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 473D78696C; Mon, 14 Aug 2023 15:35:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) (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 5EFCF807B3 for ; Mon, 14 Aug 2023 15:35:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2b9ab1725bbso63638821fa.0 for ; Mon, 14 Aug 2023 06:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020118; x=1692624918; 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=i7fYJuYnoDdTqIbqyJAYF/Jw5jvYcvNcYushZkJLvN4=; b=DOjsmfnQVGnBz52a7DPrtE5h4cABQ626xaTCYa3y5T19A3ORqegvt99P+gniYvGPWa YbDkBtSqzBXMsg5I3RKj41n6Kr4bL71sr8fbS2fd8I2ihRF/k5DLxkXwXVUyl2OTqbgJ KY+ZmsExIzxXtK1Vdn13GWGjbjB//0lvcoCXx0Vwq+Yrv5ZAng1lSn80vHnRNHGBpQ0v DIf0XD9Zh9oaCm0+AQa1WnHMH9ywzzo+AFVk3Yn/SqLehEtcNXEH8E5YjZzjaCWgziN1 RCqrJjFKpfwixLtAmRw3gjrAY8nsnrY2Dx6FLNwuc9dUi91tywKvuWQ6aoXrtY3QXBAP 0QAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020118; x=1692624918; 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=i7fYJuYnoDdTqIbqyJAYF/Jw5jvYcvNcYushZkJLvN4=; b=Og+Xg2CaEsT9d0mOYPIJaIsZNwiNhwvlJ51dzEVSobR3YTw194rHGIsk/z8xRtvyXx v0dOGkh5adN7tMayAtkqvichdMfCFGhUp5OcI/AI9Yg+UBXJkujcA6fSJWisb6tNIybQ S+F07O+XjyHS8heZD9aH95zaR+x4Gzz0caHphL2VOTR4FgnGQPviyEL5PYlN7CeBVy9R vlL8lbxVFWf3TOGtKQRsux+AePvqoTexkGrU2qQIbCCbg4AUX5wfiGAvIHarJtWZZLcf rDqfWzrjYfRypblhscXoB2T3Y5crr0UJs+ElasomNz4zivT/xszp+Pefi9QvFwHrT507 qr0g== X-Gm-Message-State: AOJu0YwMnq0FlvrzOc8nrar/mtyqiAuMMv3laHuzJb6X6YnrGb/xzAmj XH3fRF3RDceLq1G+qwUFRP0MNXHZfppLaQ1Lkps= X-Received: by 2002:a05:651c:145:b0:2b9:ef0a:7d40 with SMTP id c5-20020a05651c014500b002b9ef0a7d40mr6781869ljd.41.1692020118186; Mon, 14 Aug 2023 06:35:18 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:17 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 03/14] net/lwip: implement dns cmd Date: Mon, 14 Aug 2023 19:32:42 +0600 Message-Id: <20230814133253.4150-4-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement function for dns command with lwIP variant. Usage and output is the same as the original command. This code called by compatibility code between U-Boot and lwIP. Signed-off-by: Maxim Uvarov --- include/net/lwip.h | 17 +++++++++++++ net/lwip/Makefile | 2 ++ net/lwip/apps/dns/lwip-dns.c | 46 ++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 include/net/lwip.h create mode 100644 net/lwip/apps/dns/lwip-dns.c diff --git a/include/net/lwip.h b/include/net/lwip.h new file mode 100644 index 0000000000..c83b5c8231 --- /dev/null +++ b/include/net/lwip.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +int do_lwip_dns(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); + +/* +* This function creates the DNS request to resolve a domain host name. Function +* can return immediately if previous request was cached or it might require +* entering the polling loop for a request to a remote server. +* +* @name dns name to resolve +* @varname (optional) U-Boot variable name to store the result +* Return: ERR_OK(0) for fetching entry from the cache +* ERR_INPROGRESS(-5) success, can go to the polling loop +* Other value < 0, if error +*/ +int ulwip_dns(char *name, char *varname); diff --git a/net/lwip/Makefile b/net/lwip/Makefile index d1161bea78..6d2c00605b 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -64,3 +64,5 @@ obj-$(CONFIG_NET) += $(LWIPDIR)/netif/ethernet.o obj-$(CONFIG_NET) += port/if.o obj-$(CONFIG_NET) += port/sys-arch.o + +obj-$(CONFIG_CMD_DNS) += apps/dns/lwip-dns.o diff --git a/net/lwip/apps/dns/lwip-dns.c b/net/lwip/apps/dns/lwip-dns.c new file mode 100644 index 0000000000..6e205c1153 --- /dev/null +++ b/net/lwip/apps/dns/lwip-dns.c @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. + */ + +#include +#include +#include + +#include +#include + +#include + +static void dns_found_cb(const char *name, const ip_addr_t *ipaddr, void *callback_arg) +{ + char *varname = (char *)callback_arg; + + if (varname) + env_set(varname, ip4addr_ntoa(ipaddr)); + + log_info("resolved %s to %s\n", name, ip4addr_ntoa(ipaddr)); + ulwip_exit(0); +} + +int ulwip_dns(char *name, char *varname) +{ + int err; + ip_addr_t ipaddr; /* not used */ + ip_addr_t dns1; + ip_addr_t dns2; + + ipaddr_aton(env_get("dnsip"), &dns1); + ipaddr_aton(env_get("dnsip2"), &dns2); + + dns_init(); + dns_setserver(0, &dns1); + dns_setserver(1, &dns2); + + err = dns_gethostbyname(name, &ipaddr, dns_found_cb, varname); + if (err == ERR_OK) + dns_found_cb(name, &ipaddr, varname); + + return err; +} From patchwork Mon Aug 14 13:32:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713473 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1242143wrp; Mon, 14 Aug 2023 06:35:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKE8A9wwDbnUCi696jKHAM855LXOI1X7jxiDtz18OnNOpbn9EOMw/qVs5l44kC2RmD+80y X-Received: by 2002:a7b:cd02:0:b0:3fa:98c3:7dbd with SMTP id f2-20020a7bcd02000000b003fa98c37dbdmr7929176wmj.41.1692020156112; Mon, 14 Aug 2023 06:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020156; cv=none; d=google.com; s=arc-20160816; b=LgYqI4aSPOW7eeLwwZgFmFM9GMPiRpA9eXjS5dXl8RLxFzS8lB83HFmbspScqVhV+d DdE+4gqZM2ptRqd9RodkY4zXfO1c07V1Ci8OB0ZOZZxQM30kC+ZzbGeJEic1j4KTvpWu hw/A7u7Q2wLK+jkRXROV8MH4iVOuRCYWGbwo/4Z3asr13YEiVXUsl/HqOmcad+iOLpOI rvJCcE9qxwSB74rKilMrA7HNRsiXzk3tUw4rUfqrNEcdNbDWF7Be8TjUn22fhhXh9BP5 Oe/tE8LNfn6NrN0xclIcG5UJSEAWeWv8RXWeyxlaPnhOE95SUSmDDNIRNTrAoyaI3wfJ qAqQ== 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=L7zsyex9fOzbWeSrWQFiL7vIBUfwnNHuf3/vMzio0Y8=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=XtwWHCVr3HoyQIcLmmeF/7ulb9TAYk5/EJ8xiqsBJ6tGdJlg3N6McndOznwp0hutPk 1KuMjT/Fgk0XZcjOIkmle9LneizJyVMKLHVoMf5L69tgnYXEtBmGMiost7DlvxlXE8g7 snKFklVzjnvFkQqqTDpGI9nRcgRu4p7XN+9YO4OoKbZgzUtcfsju/YnLhsuU2ECcwFOQ mJs7koBcP+/fQd3FW5BE+Dh3OCsXjDO4aAho64zKc+MEVGl2gD6DC5M//Q80dyvwGg0a RRjvdsRHbq1dUX2ZWYT+PNgyYbRS7WEsftlohybdUxT4fWHOoWCLf997mPUL84QlLnRA dzAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YiEMq8Wn; 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 s12-20020a05600c384c00b003fe5c40ed47si5824711wmr.1.2023.08.14.06.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:56 -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=YiEMq8Wn; 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 A727C86979; Mon, 14 Aug 2023 15:35:24 +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="YiEMq8Wn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A17FC86979; Mon, 14 Aug 2023 15:35:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B2209807B3 for ; Mon, 14 Aug 2023 15:35:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2b9d07a8d84so67981091fa.3 for ; Mon, 14 Aug 2023 06:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020121; x=1692624921; 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=L7zsyex9fOzbWeSrWQFiL7vIBUfwnNHuf3/vMzio0Y8=; b=YiEMq8WnOCxmb92NpiNUfKccN4rNOUmYfQW+tf7I6UqO9/nKFtq6OdfLGaNHFJ6TJc oBvhQ5hW6TSJz4SmEzGSyeRSqRiMOPHJIJDy2QjO9LlEkAPKay+asSFYMANBhslNoh88 Im9gXfnDMzkUfuQL4sIEDcBRO1t55KT8b+gPayzNgOolXOvKSFAO2HB4nYEHTlfjqKFl 9hXwEOOwh+x+KSKQGjoM4QR48ScWSDw9wi8Y8FXN3Dk1EBgqDZwBUgVZ6pXoyknEVZvB dK/vwyfBqilYn3ZzgqVBt4OlPd9J6QeTNT7kKRehmqXQvTiI0Jt2HmY6Ar3eXh/2BBCF AY/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020121; x=1692624921; 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=L7zsyex9fOzbWeSrWQFiL7vIBUfwnNHuf3/vMzio0Y8=; b=Lp5oAmPmnFMN6/HPv+t8f6wtkUtvWY4MMwVSg3w96rsvU3V75dzVQNT8POFOrcnoYB YE1MxZaLSthzfpL9D14lTV4rh+9HO3U8k1LXAYaw7/zK6C3rIcpti2fqnQwOJEqOnprh gN5jYZTlBJ83c/CbO8skAUZtzQsjNmNvJHSwyJg3svy1RHAFBheqOc+TBckiJ9z4xQ+h sgjt8PpxXK+NOvq+MxwjrLH9j90BV+g6d+fhfkx8k3omlSOi6Khia6xEEw8jTKRoZEzW W/KkumqHj9r6NmOdhXhMEo+F/bSzcDzYWKEIpU7cMLJ40h8uzR2XpgEuFswfpVcPNLh9 Jo4Q== X-Gm-Message-State: AOJu0YyHM6acS2L6DXhwFgXnyeJgI74LD1iWJu5FStnyqU+c0+wjb191 utpmqs+E4DpWN3aghx8AmXNq/60dRcfpj66Ii1Q= X-Received: by 2002:a2e:320c:0:b0:2b9:b9c8:99 with SMTP id y12-20020a2e320c000000b002b9b9c80099mr7364513ljy.22.1692020120872; Mon, 14 Aug 2023 06:35:20 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:20 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 04/14] net/lwip: implement dhcp cmd Date: Mon, 14 Aug 2023 19:32:43 +0600 Message-Id: <20230814133253.4150-5-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement function for dhcp command with lwIP variant. Usage and output is the same as the original command. This code called by compatibility code between U-Boot and lwIP. Signed-off-by: Maxim Uvarov --- include/net/lwip.h | 10 +++++++ net/lwip/Makefile | 1 + net/lwip/apps/dhcp/lwip-dhcp.c | 51 ++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c diff --git a/include/net/lwip.h b/include/net/lwip.h index c83b5c8231..2f035280eb 100644 --- a/include/net/lwip.h +++ b/include/net/lwip.h @@ -15,3 +15,13 @@ int do_lwip_dns(struct cmd_tbl *cmdtp, int flag, int argc, * Other value < 0, if error */ int ulwip_dns(char *name, char *varname); + +/* +* This function creates the DHCP request to obtain IP address. If DHCP server +* returns file name, this file will be downloaded with tftp. After this +* function you need to invoke the polling loop to process network communication. +* +* Return: 0 if success +* Other value < 0, if error +*/ +int ulwip_dhcp(void); diff --git a/net/lwip/Makefile b/net/lwip/Makefile index 6d2c00605b..59323fb325 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -65,4 +65,5 @@ obj-$(CONFIG_NET) += $(LWIPDIR)/netif/ethernet.o obj-$(CONFIG_NET) += port/if.o obj-$(CONFIG_NET) += port/sys-arch.o +obj-$(CONFIG_CMD_DHCP) += apps/dhcp/lwip-dhcp.o obj-$(CONFIG_CMD_DNS) += apps/dns/lwip-dns.o diff --git a/net/lwip/apps/dhcp/lwip-dhcp.c b/net/lwip/apps/dhcp/lwip-dhcp.c new file mode 100644 index 0000000000..fb7431b248 --- /dev/null +++ b/net/lwip/apps/dhcp/lwip-dhcp.c @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. + */ + +#include +#include +#include + +#include +#include + +#include + +static struct dhcp dhcp; + +static int ulwip_dhcp_tmo(void) +{ + switch (dhcp.state) { + case DHCP_STATE_BOUND: + env_set("bootfile", dhcp.boot_file_name); + env_set("ipaddr", ip4addr_ntoa(&dhcp.offered_ip_addr)); + env_set("netmask", ip4addr_ntoa(&dhcp.offered_sn_mask)); + env_set("serverip", ip4addr_ntoa(&dhcp.server_ip_addr)); + printf("DHCP client bound to address %s\n", ip4addr_ntoa(&dhcp.offered_ip_addr)); + break; + default: + return -1; + } + + return 0; +} + +int ulwip_dhcp(void) +{ + int err; + struct netif *netif; + + ulwip_set_tmo(ulwip_dhcp_tmo); + netif = netif_get_by_index(1); + + if (!netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP)) + dhcp_set_struct(netif, &dhcp); + + err = dhcp_start(netif); + if (err) + printf("dhcp_start error %d\n", err); + + return err; +} From patchwork Mon Aug 14 13:32:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713474 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1242246wrp; Mon, 14 Aug 2023 06:36:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF5UX0rE72IYq9AWMlk24/qYAIO7/J9gxNehpxbUfY5reEkFqMwkGBhXBsZP5gbVWpUUHM6 X-Received: by 2002:a5d:55c8:0:b0:319:74b5:b67d with SMTP id i8-20020a5d55c8000000b0031974b5b67dmr2966552wrw.66.1692020167583; Mon, 14 Aug 2023 06:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020167; cv=none; d=google.com; s=arc-20160816; b=U/jXpI7+HQyOsTBjwQmHZAlYMcHAQPpfsybXlFC2D49fKmi5OVbuuScI7pyeddFj0d kU8AJn/X5zM+3gUYRvXhVPpXLTtAU1gpY/WZfXIvEU2AGFKeJR2kLLZnR2mWv4xGYDX1 xblgqN1FlWKSRnDoAK/d/YvJazDiDFJKVGfs/zodDPD6d1VztwqaIHGYEv22j/C2PeSe ghmAHNgF2/w06seNdUtj4ICUepXXyW87VmDcRAtJjzYMDhJFBVdJNsjranMLJGy+33WM fdGwZUfPjg7oOk83IPwvmhi521TdrjKyKv4Ljx25hb8JBs2Lx+pvPHLGwO2kQi+F3Va+ 767g== 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=r8QdYd3MXhSbKcLqvYgrLdNh1oz8Fq8WB7WcnBC03uk=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=B4emH+hUvZ7ilImIOQcqvg2kqUshCHRJwpZOZvNc7Ik/RH4A3jrq3pgm1VhXdUqzcM 80ibCXY/97/zTo5Z3Tr3tkeRW3KxKNQ9Xqal8Yg+EL0lOb8IWif+5lNEJ6vnHvTq2Zx0 k4wJP4qu6SB274zkjkDqHXoJV/rZDmF+Je6wdxT52Q42hwKMhv21URSTkYlpWxSnnHzh nbgXloRK+kZytiwiOevDNJ2bnHo3oREp5KDbLytOGctSdxBvPShy5rqD+/NWjqpGf1dc Us8O9kDvI9Oypgxqqpv2xAYg3Z9/JzMGizasGEsGrP2V4iUKBYg9TbEIAHWxPjKGD69n yKrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zg7YsrZ0; 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 b12-20020adff24c000000b003176361290asi5259305wrp.822.2023.08.14.06.36.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:36:07 -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=zg7YsrZ0; 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 EAB5586983; Mon, 14 Aug 2023 15:35:27 +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="zg7YsrZ0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 723CD807B4; Mon, 14 Aug 2023 15:35:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 734AA807B3 for ; Mon, 14 Aug 2023 15:35:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2b9bb097c1bso65033331fa.0 for ; Mon, 14 Aug 2023 06:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020123; x=1692624923; 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=r8QdYd3MXhSbKcLqvYgrLdNh1oz8Fq8WB7WcnBC03uk=; b=zg7YsrZ00yOLBjDprkJ9msV2D4vMO8BnQQOgmJzgKfp8NYLzBuyv3iWHuCJLlK83+m O3jWgnZgS1BCkvn/PFDtavn8Uysjsm/ZnAlq2JQnBY9+fr35D+zx5nVxprTdPpDZ7tBE kS8vRfnxXaKX3qCiHpifjGtPuvxBNLpJ3opiOBuxGfNDKY5Fk7sg5mkHL/GZHDIYYah9 XLTlk3tQNDSDJLcla0OhNwC88oiNLaa+rSPjkCAd0rt1ia6OL2R4nAmBUwCEzyee1jQk gJ+ad8bB+CBK1TQ9tSxlSMkoWnzvKV7ID2mNiaWGK8mtXnyPjFQneZQ+rvnwDI8rRrRL o2qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020123; x=1692624923; 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=r8QdYd3MXhSbKcLqvYgrLdNh1oz8Fq8WB7WcnBC03uk=; b=haSOyea8YUiuoHDSrizqQVuerYMIQnraKWiq67RzlgWiHR6JYE3RH0ZHhVW9GhNobV ZEva9pHXmlCrXpEIvd92XpMW/RR4ypA9n8dR0sHgTZTG0nuhhIQLNtEAJPtmiujvDlvW TmNh+nWCuNwKM7QwIYPUx4a7hIjlrGsvGzvPxIXemrpCmrTs6qFgLDkqb1mReF6TLtMG stUaBx7Bi1grcVkc6VjuM35UeXA9mN/9yPi84Xuw6xCIxXeeyqxDNRO7R372xx5IYlpH wp5JkQiNjAwn6e1NcoUuDH1eWBf2dPxLUXWiqVx6uKapGzxn+p8zSw4XCMirwlLgYF8F eMnQ== X-Gm-Message-State: AOJu0YxmoW1K/SpHhsiFtiBLH9+gWWBTXSbhm2b52mnQpDp7kK5sIBN1 CiDddaI5QEjF9Q9atOXZQ4w3FPMwyWholB/6esE= X-Received: by 2002:a2e:9790:0:b0:2b4:75f0:b9e9 with SMTP id y16-20020a2e9790000000b002b475f0b9e9mr6890562lji.10.1692020123572; Mon, 14 Aug 2023 06:35:23 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:23 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 05/14] net/lwip: implement tftp cmd Date: Mon, 14 Aug 2023 19:32:44 +0600 Message-Id: <20230814133253.4150-6-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement function for dhcp command with lwIP variant. Usage and output is the same as the original command. This code called by compatibility code between U-Boot and lwIP. Signed-off-by: Maxim Uvarov --- net/lwip/Makefile | 1 + net/lwip/apps/tftp/Makefile | 16 ++++ net/lwip/apps/tftp/lwip-tftp.c | 129 +++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+) create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c diff --git a/net/lwip/Makefile b/net/lwip/Makefile index 59323fb325..0337d82cf5 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -67,3 +67,4 @@ obj-$(CONFIG_NET) += port/sys-arch.o obj-$(CONFIG_CMD_DHCP) += apps/dhcp/lwip-dhcp.o obj-$(CONFIG_CMD_DNS) += apps/dns/lwip-dns.o +obj-$(CONFIG_CMD_TFTPBOOT) += apps/tftp/ diff --git a/net/lwip/apps/tftp/Makefile b/net/lwip/apps/tftp/Makefile new file mode 100644 index 0000000000..0e50fcad45 --- /dev/null +++ b/net/lwip/apps/tftp/Makefile @@ -0,0 +1,16 @@ + +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip +ccflags-y += -I$(obj) + +$(obj)/tftp.o: $(obj)/tftp.c +.PHONY: $(obj)/tftp.c +$(obj)/tftp.c: + cp $(srctree)/net/lwip/lwip-external/src/apps/tftp/tftp.c $(obj)/tftp.c + cp $(srctree)/net/lwip/lwip-external/src/include/lwip/apps/tftp_client.h $(obj)/tftp_client.h + cp $(srctree)/net/lwip/lwip-external/src/include/lwip/apps/tftp_common.h $(obj)/tftp_common.h + cp $(srctree)/net/lwip/lwip-external/contrib/examples/tftp/tftp_example.h $(obj)/tftp_example.h + +obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o +obj-$(CONFIG_CMD_TFTPBOOT) += lwip-tftp.o + diff --git a/net/lwip/apps/tftp/lwip-tftp.c b/net/lwip/apps/tftp/lwip-tftp.c new file mode 100644 index 0000000000..290229cb85 --- /dev/null +++ b/net/lwip/apps/tftp/lwip-tftp.c @@ -0,0 +1,129 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. + */ + +#include +#include +#include +#include + +#include "lwip/apps/tftp_client.h" +#include "lwip/apps/tftp_server.h" +#include + +#include + +#include + +#if LWIP_UDP + +static ulong daddr; +static ulong size; + +static void *tftp_open(const char *fname, const char *mode, u8_t is_write) +{ + LWIP_UNUSED_ARG(mode); + return NULL; +} + +static void tftp_close(void *handle) +{ + log_info("\ndone\n"); + log_info("Bytes transferred = %ld (0x%lx hex)\n", size, size); + + bootstage_mark_name(BOOTSTAGE_KERNELREAD_STOP, "tftp_done"); + env_set_ulong("filesize", size); + ulwip_exit(0); +} + +static int tftp_read(void *handle, void *buf, int bytes) +{ + return 0; +} + +static int tftp_write(void *handle, struct pbuf *p) +{ + struct pbuf *q; + + for (q = p; q != NULL; q = q->next) { + memcpy((void *)daddr, q->payload, q->len); + daddr += q->len; + size += q->len; + log_info("#"); + } + + return 0; +} + +static void tftp_error(void *handle, int err, const char *msg, int size) +{ + char message[100]; + + LWIP_UNUSED_ARG(handle); + + memset(message, 0, sizeof(message)); + MEMCPY(message, msg, LWIP_MIN(sizeof(message)-1, (size_t)size)); + + log_info("TFTP error: %d (%s)", err, message); +} + +static const struct tftp_context tftp = { + tftp_open, + tftp_close, + tftp_read, + tftp_write, + tftp_error +}; + +int ulwip_tftp(ulong addr, char *fname) +{ + void *f = (void *)0x1; /* unused fake file handle*/ + err_t err; + ip_addr_t srv; + int ret; + char *server_ip; + + if (!fname || addr == 0) + return CMD_RET_FAILURE; + + size = 0; + daddr = addr; + server_ip = env_get("serverip"); + if (!server_ip) { + log_err("error: serverip variable has to be set\n"); + return CMD_RET_FAILURE; + } + + ret = ipaddr_aton(server_ip, &srv); + if (!ret) { + log_err("error: ipaddr_aton\n"); + return CMD_RET_FAILURE; + } + + log_info("TFTP from server %s; our IP address is %s\n", + server_ip, env_get("ipaddr")); + log_info("Filename '%s'.\n", fname); + log_info("Load address: 0x%lx\n", daddr); + log_info("Loading:"); + + bootstage_mark_name(BOOTSTAGE_KERNELREAD_START, "tftp_start"); + + err = tftp_init_client(&tftp); + if (!(err == ERR_OK || err == ERR_USE)) + log_err("tftp_init_client err: %d\n", err); + + err = tftp_get(f, &srv, TFTP_PORT, fname, TFTP_MODE_OCTET); + /* might return different errors, like routing problems */ + if (err != ERR_OK) { + log_err("tftp_get err=%d\n", err); + return CMD_RET_FAILURE; + } + + env_set_hex("fileaddr", addr); + return err; +} +#else +#error "UDP has to be supported" +#endif /* LWIP_UDP */ From patchwork Mon Aug 14 13:32:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713475 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1242321wrp; Mon, 14 Aug 2023 06:36:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8qJYi8SkxGGizjLnBRs18UpV0Uy4zfDxpySTCSR45Udbf3ZuO+YrrtLRr5n7dq7I++IaG X-Received: by 2002:a05:600c:280b:b0:3fb:e1d5:7f48 with SMTP id m11-20020a05600c280b00b003fbe1d57f48mr7679951wmb.5.1692020175274; Mon, 14 Aug 2023 06:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020175; cv=none; d=google.com; s=arc-20160816; b=Am6obIJg1wOVS6lTKK1Ot3XPrS92XWXNz0XeRd/N4pQSA2DRwytMnVUfpTgvhScfFN HVxhfZiLA0p+lnQlOSw6cylVJFPKmSyzzXs4gqc6P5fiYKkg781BSij+STESMi9XJuk0 yIcfCQZWmxV1Aze1ldlqvmgUqxr5942S+NBH92G7hoTWikL9VS4OYlQRlFWa4LK+L0Yn 7C8L86Ey9Nw5EEdhxIsbtcIUIF+XvKKd20ypFfhTbdiEsKsONYOPCNEYRkTZosXfni1E 3xYXhGRcPRWs8+1FSnZbNWZoxYgUaVJh3kllqaMS8SqlD6nw3v1KIGFvyDjURolhu5cX MlyA== 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=yIEJ87jVxrGRTAvkJzgEaHHXvegpju2xj+haGRixQXI=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=IXCmU2Zzi/0/z+XcDgJUX5clohglWsGewTSXfMHeZnANt4URUOLXnjbrtz9fb2xVvI 8LNgqsdvGnVbuUiNoAQYinVal8FzpeOTUEoZjbpf+uwhpxXIbA5kV1ezT/fdbQtGLzaX UgWEQu+4YSpLa/Lz4NT/fU+HByKW67nyTZhxlswv5upimJd7K4HwwKIyhR49WBaR84vo 3Zl/KmlnQnlKVNXa+pfRZafCHv1anbO2XeWImqUKy8/rbbWWiF1YedxwL52cncVFU8zC mFYZbwuKyk6UCAyP6pvxNDqYE/KPjGo/0CSgzQ3rrexjWi7mFWArvYekVgtQ8d74Gc2m xzuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y6WBCFsS; 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 n2-20020adff082000000b0031790746dfcsi2745261wro.945.2023.08.14.06.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:36:15 -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=Y6WBCFsS; 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 398508698F; Mon, 14 Aug 2023 15:35:30 +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="Y6WBCFsS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 106A38698E; Mon, 14 Aug 2023 15:35:29 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) (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 123E68696D for ; Mon, 14 Aug 2023 15:35:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b9e6cc93c6so65251561fa.2 for ; Mon, 14 Aug 2023 06:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020126; x=1692624926; 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=yIEJ87jVxrGRTAvkJzgEaHHXvegpju2xj+haGRixQXI=; b=Y6WBCFsSn9n0m293329+I9uxh+p843ib7rPTO9qxS/oJ3+L/sVUxThHpJOE26Cocb0 GjANYE3/eCh29OGH8VLJ2QkL9dPfnn4lasgUdvMpQF1l3WxJRZUmSvJyHhLWKPCO4f/R uy3pd9mzkglkftQr/CRdIxpDWsb3TalB0bDy0i7d0N7NfBhMSjWSWbenXwXaaMCVg6Hb f0Nx7qS85wtfkv4dl3tgtoJKton88hNzSZBcoxKhMO3HZMy+5cTVUqWOclCOiStY7Klf zyZVwJJKXb9gRdk+z+g1pI35SgsFa3CqX21AEOUehQ5ZsfGdHgZ5p179cvqSC9+gKO/l Y2lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020126; x=1692624926; 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=yIEJ87jVxrGRTAvkJzgEaHHXvegpju2xj+haGRixQXI=; b=jSBNVvp8Aw/Xv0Ss3Qy5DO79iAR+/lfwzFjUmmolC4LHe4CwQCHkU6QtTMBnU9vWRA pisPoxIkuDutf89Zuj5G0WUFHQwl7KcHn6M3ph8QFN4gwbH7ZgoBoZUQLI8AvFAg/vXF u2kbzPswqR4uqexRerOV6J4K643A2iYII8hLpODBt6NEPTHcOvBU6KpW5gYhYU9/BJQW qPX6tDLVK2sDPD+U+A2Hl9RAVu9qRPr4C8n/u/ii4cSWWf0t5ndyo0WkPcpPWwalxikR 4dilxGeQkJFYhN8CG0IcXNkha3ln+nCu0moPPAv1M36lXQrifEqsDysBBtdW3SJ6c8eV LW4Q== X-Gm-Message-State: AOJu0YyqzloXyn0W4eb5qOZ98EtJ2JWhzHJf1YgCcbruSMgk8cC6XtUT HNS3fRjzdDkn9tWoqbqVuk4zeV3K8Ghyzn+dUSg= X-Received: by 2002:a05:651c:14a:b0:2b9:d3b6:769e with SMTP id c10-20020a05651c014a00b002b9d3b6769emr6372335ljd.24.1692020126243; Mon, 14 Aug 2023 06:35:26 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:25 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 06/14] net/lwip: implement wget cmd Date: Mon, 14 Aug 2023 19:32:45 +0600 Message-Id: <20230814133253.4150-7-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement function for wget command with lwIP variant. Usage and output is the same as the original command. This code called by compatibility code between U-Boot and lwIP. Signed-off-by: Maxim Uvarov --- include/net/lwip.h | 13 ++++ net/lwip/Makefile | 1 + net/lwip/apps/http/Makefile | 13 ++++ net/lwip/apps/http/lwip-wget.c | 131 +++++++++++++++++++++++++++++++++ 4 files changed, 158 insertions(+) create mode 100644 net/lwip/apps/http/Makefile create mode 100644 net/lwip/apps/http/lwip-wget.c diff --git a/include/net/lwip.h b/include/net/lwip.h index 2f035280eb..f1f2c94fc2 100644 --- a/include/net/lwip.h +++ b/include/net/lwip.h @@ -25,3 +25,16 @@ int ulwip_dns(char *name, char *varname); * Other value < 0, if error */ int ulwip_dhcp(void); + +/* +* This function creates the HTTP request to download file from url to the address +* specified in parameters. After this function you need to invoke the polling +* loop to process network communication. +* +* +* @addr start address to download result +* @url url in format http://host[:port]/url +* Return: 0 for success +* !0 if error +*/ +int ulwip_wget(ulong addr, char *url); diff --git a/net/lwip/Makefile b/net/lwip/Makefile index 0337d82cf5..4c6df94807 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -68,3 +68,4 @@ obj-$(CONFIG_NET) += port/sys-arch.o obj-$(CONFIG_CMD_DHCP) += apps/dhcp/lwip-dhcp.o obj-$(CONFIG_CMD_DNS) += apps/dns/lwip-dns.o obj-$(CONFIG_CMD_TFTPBOOT) += apps/tftp/ +obj-$(CONFIG_CMD_WGET) += apps/http/ diff --git a/net/lwip/apps/http/Makefile b/net/lwip/apps/http/Makefile new file mode 100644 index 0000000000..3e92b0ef1b --- /dev/null +++ b/net/lwip/apps/http/Makefile @@ -0,0 +1,13 @@ +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip +ccflags-y += -I$(obj) + +$(obj)/http_clinet.o: $(obj)/http_client.c +.PHONY: $(obj)/http_client.c +$(obj)/http_client.c: + cp $(srctree)/net/lwip/lwip-external/src/apps/http/http_client.c $(obj)/http_client.c + cp $(srctree)/net/lwip/lwip-external/src/include/lwip/apps/http_client.h $(obj)/http_client.h + +obj-$(CONFIG_CMD_WGET) += http_client.o +obj-$(CONFIG_CMD_WGET) += lwip-wget.o + diff --git a/net/lwip/apps/http/lwip-wget.c b/net/lwip/apps/http/lwip-wget.c new file mode 100644 index 0000000000..73d82225a2 --- /dev/null +++ b/net/lwip/apps/http/lwip-wget.c @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. + */ + +#include +#include +#include +#include + +#include "http_client.h" +#include + +static ulong daddr; +static httpc_connection_t settings; + +#define SERVER_NAME_SIZE 200 + +static err_t httpc_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *p, + err_t unused_err) +{ + struct pbuf *q; + + if (!p) + return ERR_BUF; + + for (q = p; q != NULL; q = q->next) { + memcpy((void *)daddr, q->payload, q->len); + log_debug("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; +} + +static void httpc_result(void *arg, httpc_result_t httpc_result, u32_t rx_content_len, + u32_t srv_res, err_t err) +{ + if (httpc_result == HTTPC_RESULT_OK) { + log_info("\n%d bytes successfully downloaded.\n", rx_content_len); + env_set_ulong("filesize", rx_content_len); + ulwip_exit(0); + } else { + log_err("\nhttp eroror: %d\n", httpc_result); + ulwip_exit(-1); + } +} + +/* http://hostname:port/url */ +static int parse_url(char *url, char *host, u16 *port) +{ + char *p, *pp; + + p = strstr(url, "http://"); + if (!p) { + printf("err: no http://!\n"); + return -1; + } + + p += strlen("http://"); + + /* parse hostname */ + pp = strchr(p, ':'); + if (pp) { +#define PORT_STR_SIZE 5 + char portstr[PORT_STR_SIZE]; + + if (pp - p >= SERVER_NAME_SIZE) + return -2; + memcpy(host, p, pp - p); + host[pp - p + 1] = '\0'; + + p = pp + 1; + pp = strchr(p, '/'); + if (!pp) { + printf("wrong url\n"); + return -3; + } + + if (pp - p >= PORT_STR_SIZE) + return -4; + memcpy(portstr, p, pp - p); + portstr[pp - p] = '\0'; + *port = (u16)dectoul(portstr, NULL); + } else { + pp = strchr(p, '/'); + if (!pp) { + printf("wrong url\n"); + return -5; + } + + if (pp - p >= SERVER_NAME_SIZE) + return -6; + memcpy(host, p, pp - p); + host[pp - p + 1] = '\0'; + *port = 80; /* default */ + } + + return 0; +} + +int ulwip_wget(ulong addr, char *url) +{ + err_t err; + u16 port; + char server_name[SERVER_NAME_SIZE]; + httpc_state_t *connection; + + daddr = addr; + + err = parse_url(url, server_name, &port); + if (err) { + log_err("error parse_url\n"); + return -1; + } + + log_info("downloading %s to addr 0x%lx\n", url, addr); + memset(&settings, 0, sizeof(settings)); + settings.result_fn = httpc_result; + err = httpc_get_file_dns(server_name, port, url, &settings, + httpc_recv, NULL, &connection); + if (err != ERR_OK) { + log_err("httpc_init_connection failed\n"); + return err; + } + + env_set_hex("fileaddr", addr); + return 0; +} From patchwork Mon Aug 14 13:32:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713476 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1242415wrp; Mon, 14 Aug 2023 06:36:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcqmrPPpT7HTWCYjtuX2Y1Ungk5wWsaq2eIUkCggQYC5XC6ytxNIpkof5D2jdWduIqV0e1 X-Received: by 2002:a1c:6a14:0:b0:3f5:fff8:d4f3 with SMTP id f20-20020a1c6a14000000b003f5fff8d4f3mr8400499wmc.7.1692020184395; Mon, 14 Aug 2023 06:36:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020184; cv=none; d=google.com; s=arc-20160816; b=WSi9WP5F0m2OuE6g7JzoZm/Lq00ibn6zT7h35DwPHEs0/muox5e50ciiCGteBdwZYc BDXmXqYswSK9A+yzzENPOSrXufEKSQWyMHUD77ryLu1aoQjMas7rTdkGU/zmKjz++ayU 5oTZdA2j7qiP8LggjsRdHAObRr/Le7LVJHEvbh6CkJyiKt7CsD3Ubsd++sgT7FzeQwmq JEG50We9UKUdkujwh1As3wZLh2yN7FwaD7XBaatdtALEDwPbUlhQslcFzYS8AoAy1EMN PB9biYHHRie+ZQ7N1WYz/N9Y3WpSuyJR1iQHbPqEXVAAFO5rtKNB/SkpyBihD7HSzkVm iWWg== 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=FCdrkSEZz2ulQnFDbsrAAqsQyeCAsLOWYHNH6n7RMAU=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=bnoZYA5uIB5u0U7DJxwrQ0lzmxRHVFFUiGSMtMAwJmeJsdsmPV9EN5Ezh3gsySVI3h d78ssFQoBeVx8prYwW97ZbsDi+HnTj/5tsMEN41eB2B1kg7fCYHtBfDmGBet8KY4pZgN Cfl7yXDD9J737AI8do5bFLlp2kk4LjEfRhYmBiq3iiCMWw+iqlS9y3ARzD4eZDEdcKzc g30lemTN7bNS7KMXwAz8a4yc5LOsOF9MS+uGtHAXbltXmLEkM9yQbldUS67Zswb68X4A 3+knMS4ezw8BiLLFMK3TN6rQ9u4psSbj8bGZ4vnGvvMWadcBA2ubneous6XAVWldtpge wXSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="dwHN/drd"; 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 a18-20020a05600c349200b003fe24da4947si5842022wmq.17.2023.08.14.06.36.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:36:24 -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="dwHN/drd"; 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 81E3D86989; Mon, 14 Aug 2023 15:35: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="dwHN/drd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A42CD807B4; Mon, 14 Aug 2023 15:35:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) (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 A3B9E8696D for ; Mon, 14 Aug 2023 15:35:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2b9c907bc68so63249901fa.2 for ; Mon, 14 Aug 2023 06:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020129; x=1692624929; 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=FCdrkSEZz2ulQnFDbsrAAqsQyeCAsLOWYHNH6n7RMAU=; b=dwHN/drd/8kB3EtMpqTyLKFOxJ1voc3NxG976ADAQT8enSnYxAaiK8VKrp+AP8XIz8 6X9uN4k48z6Q0XmQkZbcE0zu+iUkuIhwHYZRxUZk4aLQZ1yxJ96/oIjCN2jQwCPMRtj9 /Z+SN84YwPpmadMPrMpPSP8bDumtzhLHxGNnjskT2/cBUJ+Q0xoaAjhVn+NTPe9nbh7j zH4p4eSNaqaVsSOXPGXahul64OGTWEUKvv+bQZKR53qTlufV5yEEU83j6dMymEL+OUYd mZseDH5p09ze6uOUxPHf3/I65dKjpqjwwhaJF8lcWUG4Vx143j/N7Nd/H3DFWVMjd0zl 8JrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020129; x=1692624929; 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=FCdrkSEZz2ulQnFDbsrAAqsQyeCAsLOWYHNH6n7RMAU=; b=YUH2erLtnpO2G9YNOcBqQ5H2NAW0Pa3G6nFaCgoQKXXiZCVzQ01WkPVBMBGUaG35oM dpsTQUOPJzskkTWFzoe0YWoPDE03HQKAg8LVXKCG23Inmgi3/zu/5JU8arI3uJVUDiuF bRbzvTLvMcGLIBxZ/zEo84vMPklpAmcsw8YCcgAoPGomtPof0JNBoimDZvpS8umY2ssu FJjHwZJySoEJJxG1ukyMDgKZX/dgHAk3zVBKhZict3cmuqDjPrlPc3A2BziGmqRSZ1Fv lOcwheAVuLZWPuu3ywU5KoYRdJHHtYfoHOzMgFeYthrSmo6kBzpGa8EDqBLWerUtb2BD nM6w== X-Gm-Message-State: AOJu0YzNteAGk1WW1Ua47POMtbMDMNs0nYy8xd55GfapEpN/16WKG3OB QoNjFLRHzpYG38R0TESbht59YJISBRB6uCXoYPA= X-Received: by 2002:a2e:9f41:0:b0:2b9:4413:864e with SMTP id v1-20020a2e9f41000000b002b94413864emr6380340ljk.53.1692020128773; Mon, 14 Aug 2023 06:35:28 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:28 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 07/14] net/lwip: implement ping cmd Date: Mon, 14 Aug 2023 19:32:46 +0600 Message-Id: <20230814133253.4150-8-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement function for ping command with lwIP variant. Usage and output is the same as the original command. This code called by compatibility code between U-Boot and lwIP. ping uses lwIP contrib/apps/ping/ping.c code. Signed-off-by: Maxim Uvarov --- include/net/lwip.h | 28 ++++++++++++++++++++++++- net/lwip/Makefile | 1 + net/lwip/apps/ping/Makefile | 11 ++++++++++ net/lwip/apps/ping/lwip_ping.c | 37 ++++++++++++++++++++++++++++++++++ net/lwip/apps/ping/lwip_ping.h | 15 ++++++++++++++ net/lwip/apps/ping/ping.h | 19 +++++++++++++++++ 6 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 net/lwip/apps/ping/Makefile create mode 100644 net/lwip/apps/ping/lwip_ping.c create mode 100644 net/lwip/apps/ping/lwip_ping.h create mode 100644 net/lwip/apps/ping/ping.h diff --git a/include/net/lwip.h b/include/net/lwip.h index f1f2c94fc2..e928676b36 100644 --- a/include/net/lwip.h +++ b/include/net/lwip.h @@ -2,7 +2,8 @@ int do_lwip_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); - +int do_lwip_ping(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); /* * This function creates the DNS request to resolve a domain host name. Function * can return immediately if previous request was cached or it might require @@ -38,3 +39,28 @@ int ulwip_dhcp(void); * !0 if error */ int ulwip_wget(ulong addr, char *url); + +/** + * ulwip_tftp() - load file with tftp + * + * Load file with tftp to specific address + * + * @param addr - address to store downloaded file + * @param filename - file name on remote tftp server to download + * + * + * @return 0 if success, !0 if error + */ +int ulwip_tftp(ulong addr, const char *filename); + +/* +* This function creates the ping for address provided in parameters. +* After this function you need to invoke the polling +* loop to process network communication. +* +* +* @ping_addr start address to download result +* Return: 0 for success +* !0 if error +*/ +int ulwip_ping(char *ping_addr); diff --git a/net/lwip/Makefile b/net/lwip/Makefile index 4c6df94807..8b3e843426 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -67,5 +67,6 @@ obj-$(CONFIG_NET) += port/sys-arch.o obj-$(CONFIG_CMD_DHCP) += apps/dhcp/lwip-dhcp.o obj-$(CONFIG_CMD_DNS) += apps/dns/lwip-dns.o +obj-$(CONFIG_CMD_PING) += apps/ping/ obj-$(CONFIG_CMD_TFTPBOOT) += apps/tftp/ obj-$(CONFIG_CMD_WGET) += apps/http/ diff --git a/net/lwip/apps/ping/Makefile b/net/lwip/apps/ping/Makefile new file mode 100644 index 0000000000..dc63feb7b5 --- /dev/null +++ b/net/lwip/apps/ping/Makefile @@ -0,0 +1,11 @@ +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip +ccflags-y += -I$(obj) + +.PHONY: $(obj)/ping.c +$(obj)/ping.o: $(obj)/ping.c +$(obj)/ping.c: + cp $(srctree)/net/lwip/lwip-external/contrib/apps/ping/ping.c $(obj)/ping.c + +obj-$(CONFIG_CMD_PING) += ping.o +obj-$(CONFIG_CMD_PING) += lwip_ping.o diff --git a/net/lwip/apps/ping/lwip_ping.c b/net/lwip/apps/ping/lwip_ping.c new file mode 100644 index 0000000000..611fcaf591 --- /dev/null +++ b/net/lwip/apps/ping/lwip_ping.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. + */ + +#include "lwip/opt.h" +#include "lwip/ip_addr.h" +#include "ping.h" +#include "lwip_ping.h" + +static ip_addr_t ip_target; + +static int ulwip_ping_tmo(void) +{ + + log_err("ping failed; host %s is not alive\n", ipaddr_ntoa(&ip_target)); + return 1; +} + +int ulwip_ping(char *ping_addr) +{ + int err; + + err = ipaddr_aton(ping_addr, &ip_target); + if (!err) { + log_err("wrong ping addr string \"%s\" \n", ping_addr); + return -1; + } + + ulwip_set_tmo(ulwip_ping_tmo); + + ping_init(&ip_target); + ping_send_now(); + + return 0; +} diff --git a/net/lwip/apps/ping/lwip_ping.h b/net/lwip/apps/ping/lwip_ping.h new file mode 100644 index 0000000000..0374f07d9e --- /dev/null +++ b/net/lwip/apps/ping/lwip_ping.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +/* + * (C) Copyright 2023 Linaro Ltd. + */ + +#ifndef LWIP_PING_H +#define LWIP_PING_H + +#include + +void ping_raw_init(void); +void ping_send_now(void); + +#endif /* LWIP_PING_H */ diff --git a/net/lwip/apps/ping/ping.h b/net/lwip/apps/ping/ping.h new file mode 100644 index 0000000000..006a18c658 --- /dev/null +++ b/net/lwip/apps/ping/ping.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#include +#include "lwip/ip_addr.h" + +#define LWIP_DEBUG 1 /* ping_time is under ifdef*/ +#define PING_RESULT(cond) { \ + if (cond == 1) { \ + printf("host %s a alive\n", ipaddr_ntoa(addr)); \ + printf(" %"U32_F" ms\n", (sys_now() - ping_time)); \ + ulwip_exit(0); \ + } else { \ + printf("ping failed; host %s in not alive\n",\ + ipaddr_ntoa(addr)); \ + ulwip_exit(-1); \ + } \ + } while (0); + +void ping_init(const ip_addr_t *ping_addr); From patchwork Mon Aug 14 13:32:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713477 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1242479wrp; Mon, 14 Aug 2023 06:36:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/+8M+DnIoIAgh8+gMzkPuWFK2Tnz7N+GMas6cG8ER5+rsWdjREdcY953OcbiBcG3nEGLm X-Received: by 2002:a05:600c:255:b0:3fb:d1db:545b with SMTP id 21-20020a05600c025500b003fbd1db545bmr7510832wmj.20.1692020193347; Mon, 14 Aug 2023 06:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020193; cv=none; d=google.com; s=arc-20160816; b=H5ew3Y9XadUkaoqqkcME/n8mu8PukFACvNvnS9Gwp7VG+uiCf6REKSF5/EAfauyBGT K9F/XLvm4JR82zSUNROBtP8WeDSCDDpBVTAFWh55qRtunk1B1ka99KIT9fX7vIZ7+uzL CqL2FjZwJyHcI9HxoFW9FCupk1AfSuC1iHceavCZRdWFvxse5skfu2XC8w+TJhoFCti7 pX9J9PCnyp4pucIITJuuAcif1Fb6sL4YmmL0QIDDZ96tybwBRJvUiBhBfU8J3U6Fkh17 DI23vllmjW7NEQ4S16M+NEHiIgvDXrkLfAoldIDsSUrI2GkH8rGWE66K8JHE5m3H054F P5KA== 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=/5V5tpvs1LhDJMpJJGRx35A0cjwDkhqdb/yvrrNf9sU=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=SPqUnV3GjKustQtjLs0QPVfn3QQtw1tS+EMtMuHsWeW4/rHlcpg4yIVelgwy537i32 5NE9u0rVuabn/s8x6nw0SPmXrp50kKxM90qShFzq6kdjm3eMF0vVWq8PbFUMnm2jOHA2 Ow3swqkLQ5BFbyPZvGYXDgGShXSvm1ffoy/kY0sBCw90oiKn/xT5CvaB9DlcniMGsVC1 iuuje+Y5e0tHc2zZeEUEuvpDIW1BV5GZHWDVsedQLmBrQQ8DvxFTIQcZuWq2Z+NNWnXT wqX2by0Ual3ZbwJACtuQbVwP1orohj/19igndM8joe/OAyjs5foTR1oQf/JesugEi3J7 F+PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EWtXSWlP; 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 bd6-20020a05600c1f0600b003fe26afa5b5si5827603wmb.180.2023.08.14.06.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:36:33 -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=EWtXSWlP; 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 C74848696C; Mon, 14 Aug 2023 15:35:34 +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="EWtXSWlP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4387A8698E; Mon, 14 Aug 2023 15:35:34 +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, UPPERCASE_50_75 autolearn=no autolearn_force=no version=3.4.2 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) (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 4881D807B4 for ; Mon, 14 Aug 2023 15:35:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2b9b5ee9c5aso67049011fa.1 for ; Mon, 14 Aug 2023 06:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020131; x=1692624931; 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=/5V5tpvs1LhDJMpJJGRx35A0cjwDkhqdb/yvrrNf9sU=; b=EWtXSWlPh8Xga2QASNm/KDlIfqrMWycLUFrXfv2QqAVWH8sXXbsIWLt+l6cPVH/+tW SPC2F0mSbsjiI2xYwwP9ozjobO0EYkCLho+OPAqp0Vd8yj9Kq/aQDPJLf0w971Dk/y2S v15bY8vQ5TqjnHYzXjsBBu+HYCFivUh26y7yR1usbK4m70pPdJMB6W9FRzVLr8NynPS9 dOSQRyiihsoYl4DLcjmnYcTotAmNBqvWcEV+olITWsVMMp8m919NxH3Ck21jSB3pKFuV xdtXv94kXmB6HWB4AThdCU50DihTgAkVzaPGL+LBhEPNfny0H8FFFzShRn8cDi8xFz5t O3Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020131; x=1692624931; 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=/5V5tpvs1LhDJMpJJGRx35A0cjwDkhqdb/yvrrNf9sU=; b=kmUDkqwZvnInMEdGgUg/zfdReaVmulZo6pHmvkbaGrVFSOb0/dUFUezAZ8SzQo10jx iyBQ2kSHg5e39neo1hIqWBmZRUxkvSq8f+x5m79eKyazICBQP9CHTFn18iaivBzAHAD6 yQ6ErNrQy7wJSHxmShwlK6E6BQvFkPCtGzFbd6+zFnzltfJ/nYRHLvmroYpxQPKkzKll I0g8mbh+gUXpsXxe01EYWA3IBBaY3Hq0kpZRuPLkr8nCfQQpMYPJbRuzt+IqqESHHWUC nP2WM2A9jOJ7/5C32+t0M/oQLFNCQ9cZgFcjTfH68AiZf6TfYJItVIeNOGv6tTp+xGJH tyoA== X-Gm-Message-State: AOJu0Yxnjwo+d5RrZN3bRp8yzsQpJi6pC+V8ZGGG0VR6oIDDlTxisSqt kj43cgcUQcqMfJYQZgyldkaB7e9k99tIj/x73/I= X-Received: by 2002:a2e:9955:0:b0:2b9:ea17:5590 with SMTP id r21-20020a2e9955000000b002b9ea175590mr6041040ljj.16.1692020131382; Mon, 14 Aug 2023 06:35:31 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:31 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 08/14] net/lwip: add lwIP configuration Date: Mon, 14 Aug 2023 19:32:47 +0600 Message-Id: <20230814133253.4150-9-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean lwip configuration can be tuned with header file. Signed-off-by: Maxim Uvarov --- net/lwip/lwipopts.h | 195 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 net/lwip/lwipopts.h diff --git a/net/lwip/lwipopts.h b/net/lwip/lwipopts.h new file mode 100644 index 0000000000..23d87e3f65 --- /dev/null +++ b/net/lwip/lwipopts.h @@ -0,0 +1,195 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +/* + * (C) Copyright 2023 Linaro Ltd. + */ + +#ifndef LWIP_LWIPOPTS_H +#define LWIP_LWIPOPTS_H + +#include "lwipopts.h" + +#if defined(CONFIG_LWIP_LIB_DEBUG) +#define LWIP_DEBUG 1 +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#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_ON +#define AUTOIP_DEBUG LWIP_DBG_ON +#define DNS_DEBUG LWIP_DBG_ON +#define IP6_DEBUG LWIP_DBG_OFF +#define DHCP6_DEBUG LWIP_DBG_OFF +#else +#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 +#endif +#define LWIP_TESTMODE 0 + +#if defined(CONFIG_LWIP_LIB_NOASSERT) +#define LWIP_NOASSERT 1 +#define LWIP_ASSERT(message, assertion) +#endif + +#include "lwip/debug.h" + +#define SYS_LIGHTWEIGHT_PROT 0 +#define NO_SYS 0 + +#define LWIP_IPV6 0 + +#define MEM_ALIGNMENT 1 +#define MEM_SIZE 1600 + +#define MEMP_NUM_PBUF 4 +#define MEMP_NUM_RAW_PCB 2 +#define MEMP_NUM_UDP_PCB 4 +#define MEMP_NUM_TCP_PCB 2 +#define MEMP_NUM_TCP_PCB_LISTEN 2 +#define MEMP_NUM_TCP_SEG 16 +#define MEMP_NUM_REASSDATA 1 +#define MEMP_NUM_ARP_QUEUE 2 +#define MEMP_NUM_SYS_TIMEOUT 4 +#define MEMP_NUM_NETBUF 2 +#define MEMP_NUM_NETCONN 32 +#define MEMP_NUM_TCPIP_MSG_API 8 +#define MEMP_NUM_TCPIP_MSG_INPKT 8 +#define PBUF_POOL_SIZE 8 + +#define LWIP_ARP 1 + +#define IP_FORWARD 0 +#define IP_OPTIONS_ALLOWED 1 +#define IP_REASSEMBLY 1 +#define IP_FRAG 1 +#define IP_REASS_MAXAGE 3 +#define IP_REASS_MAX_PBUFS 4 +#define IP_FRAG_USES_STATIC_BUF 0 + +#define IP_DEFAULT_TTL 255 + +#define LWIP_ICMP 1 + +#define LWIP_RAW 1 + +#if defined(CONFIG_LWIP_LIB_DHCP) +#define LWIP_DHCP 1 +#define LWIP_DHCP_BOOTP_FILE 1 +#else +#define LWIP_DHCP 0 +#endif +#define LWIP_DHCP_DOES_ACD_CHECK 0 + +#define LWIP_AUTOIP 0 + +#define LWIP_SNMP 0 + +#define LWIP_IGMP 0 + +#if defined(CONFIG_LWIP_LIB_DNS) +#define LWIP_DNS 1 +#else +#define LWIP_DNS 0 +#endif + +#if defined(CONFIG_LWIP_LIB_TCP) +#define LWIP_UDP 1 +#else +#define LWIP_UDP 0 +#endif + +#if defined(CONFIG_LWIP_LIB_TCP) +#define LWIP_TCP 1 +#else +#define LWIP_TCP 0 +#endif + +#define LWIP_LISTEN_BACKLOG 0 + +#define PBUF_LINK_HLEN 14 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS + 40 + PBUF_LINK_HLEN) + +#define LWIP_HAVE_LOOPIF 0 + +#define LWIP_NETCONN 0 +#define LWIP_DISABLE_MEMP_SANITY_CHECKS 1 + +#define LWIP_SOCKET 0 +#define SO_REUSE 0 + +#define LWIP_STATS 0 + +#define PPP_SUPPORT 0 + +#define LWIP_TCPIP_CORE_LOCKING 0 + +#if defined(CONFIG_LWIP_LIB_LOOPBACK) +#define LWIP_NETIF_LOOPBACK 1 +#else +#define LWIP_NETIF_LOOPBACK 0 +#endif +/* use malloc instead of pool */ +#define MEMP_MEM_MALLOC 1 +#define MEMP_MEM_INIT 1 +#define MEM_LIBC_MALLOC 1 + +#endif /* LWIP_LWIPOPTS_H */ From patchwork Mon Aug 14 13:32:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713478 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1242563wrp; Mon, 14 Aug 2023 06:36:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGiQwgR3z7lP4tezGG/Dj7PT0tdHlkw6x//yMum08Qaz+O9N07mQgrP0tl74nMhzJ4IgTQ X-Received: by 2002:a7b:cd0f:0:b0:3fe:16d3:7d60 with SMTP id f15-20020a7bcd0f000000b003fe16d37d60mr8283078wmj.9.1692020202329; Mon, 14 Aug 2023 06:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020202; cv=none; d=google.com; s=arc-20160816; b=CS4X5jsk43++ik7rQmjrSffL2aUCWjlG8ak4JjCONb+45eRpikJYQ+1v4xigvj3Uly ZRXeUJ2FCoqiQ5C0JrpUbWu3g9m/QunDt716uKIJ3viodCDy+SsEuPCw8fDVsDVRgbCe BGu9qnGPk7RpIoRgVAgd5n9MTTiVs/hz+SeehjARE2DucjrVte5KzSIQMq+LSPtKBCRV D/gXg7RZ3zJ8xmDK8B6Bus9DMksan+ksASRG53hnB7rz6lHLnuFbhddtQCLSu+xgFU4o YBsQCalx10I+nwaJPpWj6hbNQel4YdyPYNlKm1QKtWxUNRRs7wK3D/5U7ZX6Jss6TFge pxHQ== 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=9EBOOjjgnZS03X3RjvCpp545clOs9Q/KeSeT4XsRkyM=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=smwWaWv8eFNVH1DBsufnjK5z/3IxBb+anP9YIFZTg5ccodvfWIqKPr4l+xWm25rYln aGTSDA+o+iPrLnWlvfMRxsDDvjj3e9Kpwxma+h+aL1Ik+vPlhwwzY2NOvQObAD9ouiPv I4DjhHEK7NXdNYBLqHiXczFxYCca448V89rlk6Algd3IR3us+3WyRKeqsndBNj/5wsDW 3wEb6lGoF8XagWMJdfSpWt6KfM20PA7s8hdVny+VjrzpdHPw0N6spp6dZ7l/IJ75uigr +CxGT7Ilqj8mN/pqfyBZbJym02IQO8gPA+BbCCvF5XDiams/ZY0j6I5xHP+0ASIAr8gZ IiNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y+APy1dH; 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 25-20020a05600c025900b003fc1cf8588fsi6987538wmj.185.2023.08.14.06.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:36:42 -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=Y+APy1dH; 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 1987986970; Mon, 14 Aug 2023 15:35: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="Y+APy1dH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8BBEF8699B; Mon, 14 Aug 2023 15:35:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) (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 6E1D886997 for ; Mon, 14 Aug 2023 15:35: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=maxim.uvarov@linaro.org Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2b9ab1725bbso63643511fa.0 for ; Mon, 14 Aug 2023 06:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020134; x=1692624934; 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=9EBOOjjgnZS03X3RjvCpp545clOs9Q/KeSeT4XsRkyM=; b=Y+APy1dHinrhe4tySDnYAk/NUjvglFIDZrIA0MhARZ4kfRQs8XrxO9o2biRYxl4c2l 19Ih4xKwpKnFK9q4k00XbIAthnxiiZnhkjQx4QANctVY6Z0Q7mZPfyJT89Jr1qxdu5HC BOIvG5K4bk8Mp0MYf1hKZ6bFQKjfT2Qw4fSOyRnEDFnCbsQnGmgg44roeKmI5QphYSTh nTcXtUtCVXUlPqaB+vrdDmXIrkQUXFv8dln1ep5nPBf8X048BkJl7G7tOTIVfpp+7+7e YY3qh3xsqi42I03Nh7VVG2kN989j9GDqkDV6vQKFZIT5N9fms6ALKETcc6frQIwx+Zot IKuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020134; x=1692624934; 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=9EBOOjjgnZS03X3RjvCpp545clOs9Q/KeSeT4XsRkyM=; b=OLDd4z9Gj4Lc0JwXl71qfijoJin0H/A6gM6lmBsYv8yWU/0H3+yafCDD+cvsTPNYqK MYjvoSbO58t86cZjTWUqfohT2JIMT0HDVp0VO31N6ZHWCchABcU77IqfuqufvCxg1/mM Uw41cBVK6+QSDyxb1iWW1OziImlI5VCOSqbC6JHvfSOiN8PnnG9djU7zoi/bsfsDy8rW iqHudjcq2yuT5M+KaGOugrhP6GRUSH42nxnM3+23mR2uiIlJ7vQ3Z+zrDmUk4NqSCm0C qcnvLV5Uj2YikJcoywsoL2nDSH7857cNyl7cneE4djHtlYk+YrCkVtHAodVKpnUiHOA7 OYCQ== X-Gm-Message-State: AOJu0Yy/LGErEqDG9UT568tKNoLHhxz7O6LmtE6ARFgaMhTO3861S++3 TmZYh1EiIsEfPBzcrTduJF1HKzWIT0wjdbRWXAA= X-Received: by 2002:a05:651c:106:b0:2b6:df25:1ab0 with SMTP id a6-20020a05651c010600b002b6df251ab0mr6861370ljb.34.1692020134516; Mon, 14 Aug 2023 06:35:34 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35: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, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 09/14] net/lwip: implement lwIP port to U-Boot Date: Mon, 14 Aug 2023 19:32:48 +0600 Message-Id: <20230814133253.4150-10-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement network lwIP interface connected to the U-boot. Keep original file structure widely used fro lwIP ports. (i.e. port/if.c port/sys-arch.c). Signed-off-by: Maxim Uvarov --- net/eth-uclass.c | 8 + net/lwip/port/if.c | 260 ++++++++++++++++++++++++++ net/lwip/port/include/arch/cc.h | 39 ++++ net/lwip/port/include/arch/sys_arch.h | 56 ++++++ net/lwip/port/include/limits.h | 0 net/lwip/port/sys-arch.c | 20 ++ 6 files changed, 383 insertions(+) create mode 100644 net/lwip/port/if.c create mode 100644 net/lwip/port/include/arch/cc.h create mode 100644 net/lwip/port/include/arch/sys_arch.h create mode 100644 net/lwip/port/include/limits.h create mode 100644 net/lwip/port/sys-arch.c diff --git a/net/eth-uclass.c b/net/eth-uclass.c index c393600fab..6625f6d8a5 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -32,6 +32,7 @@ DECLARE_GLOBAL_DATA_PTR; struct eth_device_priv { enum eth_state_t state; bool running; + ulwip ulwip; }; /** @@ -347,6 +348,13 @@ int eth_init(void) return ret; } +struct ulwip *eth_lwip_priv(struct udevice *current) +{ + struct eth_device_priv *priv = dev_get_uclass_priv(current); + + return &priv->ulwip; +} + void eth_halt(void) { struct udevice *current; diff --git a/net/lwip/port/if.c b/net/lwip/port/if.c new file mode 100644 index 0000000000..625a9c10bf --- /dev/null +++ b/net/lwip/port/if.c @@ -0,0 +1,260 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. + */ + +#include +#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/ethip6.h" + +#include "lwip/ip.h" + +#define IFNAME0 'e' +#define IFNAME1 '0' + +static struct pbuf *low_level_input(struct netif *netif); + +int ulwip_enabled(void) +{ + struct ulwip *ulwip; + + ulwip = eth_lwip_priv(eth_get_dev()); + return ulwip->init_done; +} + +int ulwip_in_loop(void) +{ + struct ulwip *ulwip; + + ulwip = eth_lwip_priv(eth_get_dev()); + return ulwip->loop; +} + +void ulwip_loop_set(int loop) +{ + struct ulwip *ulwip; + + ulwip = eth_lwip_priv(eth_get_dev()); + ulwip->loop = loop; +} + +void ulwip_exit(int err) +{ + struct ulwip *ulwip; + + ulwip = eth_lwip_priv(eth_get_dev()); + ulwip->loop = 0; + ulwip->err = err; +} + +int ulwip_app_get_err(void) +{ + struct ulwip *ulwip; + + ulwip = eth_lwip_priv(eth_get_dev()); + return ulwip->err; +} + +struct ulwip_if { +}; + +#define LWIP_PORT_INIT_NETMASK(addr) IP4_ADDR((addr), 255, 255, 255, 0) + +void ulwip_poll(void) +{ + struct pbuf *p; + int err; + struct netif *netif = netif_get_by_index(1); + + p = low_level_input(netif); + if (!p) { + log_err("error p = low_level_input = NULL\n"); + return; + } + + /* ethernet_input always returns ERR_OK */ + err = ethernet_input(p, netif); + if (err) + log_err("ip4_input err %d\n", err); + + return; +} + +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; + + /* We allocate a pbuf chain of pbufs from the pool. */ + p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); + if (p) { + /* 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(); + + LINK_STATS_INC(link.recv); + } else { + // drop packet(); + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.drop); + } + + return p; +} + +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) { + /* pass all packets to ethernet_input, which decides what packets it supports */ + if (netif->input(p, netif) != ERR_OK) { + LWIP_DEBUGF(NETIF_DEBUG, ("%s: IP input error\n", __func__)); + pbuf_free(p); + p = NULL; + } + } + + return 0; +} + +static err_t low_level_output(struct netif *netif, struct pbuf *p) +{ + int err; + + err = eth_send(p->payload, p->len); + if (err) { + log_err("eth_send error %d\n", err); + return ERR_ABRT; + } + return ERR_OK; +} + +err_t ulwip_if_init(struct netif *netif) +{ + struct ulwip_if *uif; + struct ulwip *ulwip; + + uif = malloc(sizeof(struct ulwip_if)); + if (!uif) { + log_err("uif: out of memory\n"); + return ERR_MEM; + } + netif->state = uif; + + netif->name[0] = IFNAME0; + netif->name[1] = IFNAME1; + + netif->hwaddr_len = ETHARP_HWADDR_LEN; + string_to_enetaddr(env_get("ethaddr"), netif->hwaddr); +#if defined(CONFIG_LWIP_LIB_DEBUG) + printf(" MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", + netif->hwaddr[0], netif->hwaddr[1], netif->hwaddr[2], + netif->hwaddr[3], netif->hwaddr[4], netif->hwaddr[5]); +#endif +#if LWIP_IPV4 + netif->output = etharp_output; +#endif +#if LWIP_IPV6 + netif->output_ip6 = ethip6_output; +#endif + + netif->linkoutput = low_level_output; + netif->mtu = 1500; + netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; + + ulwip = eth_lwip_priv(eth_get_dev()); + ulwip->init_done = 1; + if (IS_ENABLED(CONFIG_LWIP_LIB_DEBUG)) { + log_info("Initialized LWIP stack\n"); + } + + return ERR_OK; +} + +int ulwip_init(void) +{ + ip4_addr_t ipaddr, netmask, gw; + struct netif *unetif; + struct ulwip *ulwip; + int ret; + + ret = eth_init(); + if (ret) { + log_err("eth_init error %d\n", ret); + return ERR_IF; + } + + ulwip = eth_lwip_priv(eth_get_dev()); + if (ulwip->init_done) + return CMD_RET_SUCCESS; + + unetif = malloc(sizeof(struct netif)); + if (!unetif) + return ERR_MEM; + memset(unetif, 0, sizeof(struct netif)); + + ip4_addr_set_zero(&gw); + ip4_addr_set_zero(&ipaddr); + ip4_addr_set_zero(&netmask); + + ipaddr_aton(env_get("ipaddr"), &ipaddr); + ipaddr_aton(env_get("ipaddr"), &netmask); + + LWIP_PORT_INIT_NETMASK(&netmask); + if (IS_ENABLED(CONFIG_LWIP_LIB_DEBUG)) { + printf("Starting lwIP, IP: %s\n", ip4addr_ntoa(&ipaddr)); + printf(" GW: %s\n", ip4addr_ntoa(&gw)); + printf(" mask: %s\n", ip4addr_ntoa(&netmask)); + } + + if (!netif_add(unetif, &ipaddr, &netmask, &gw, + unetif, ulwip_if_init, ethernetif_input)) + printf("err: netif_add failed!\n"); + + netif_set_up(unetif); + netif_set_link_up(unetif); +#if LWIP_IPV6 + netif_create_ip6_linklocal_address(unetif, 1); + printf(" IPv6: %s\n", ip6addr_ntoa(netif_ip6_addr(unetif, 0))); +#endif /* LWIP_IPV6 */ + + return CMD_RET_SUCCESS; +} + +/* placeholder, not used now */ +void ulwip_destroy(void) +{ +} diff --git a/net/lwip/port/include/arch/cc.h b/net/lwip/port/include/arch/cc.h new file mode 100644 index 0000000000..55f7787ce1 --- /dev/null +++ b/net/lwip/port/include/arch/cc.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * (C) Copyright 2023 Linaro Ltd. + */ + +#ifndef LWIP_ARCH_CC_H +#define LWIP_ARCH_CC_H + +#include +#include +//#include /* getenv, atoi */ +#include + +#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) + +#define atoi(str) (int)dectoul(str, NULL) + +#define LWIP_ERR_T int + +#endif /* LWIP_ARCH_CC_H */ diff --git a/net/lwip/port/include/arch/sys_arch.h b/net/lwip/port/include/arch/sys_arch.h new file mode 100644 index 0000000000..92a8560d49 --- /dev/null +++ b/net/lwip/port/include/arch/sys_arch.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * (C) Copyright 2023 Linaro Ltd. + */ + +#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; + +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; +}; + +#endif /* LWIP_ARCH_SYS_ARCH_H */ diff --git a/net/lwip/port/include/limits.h b/net/lwip/port/include/limits.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/net/lwip/port/sys-arch.c b/net/lwip/port/sys-arch.c new file mode 100644 index 0000000000..609eeccf8c --- /dev/null +++ b/net/lwip/port/sys-arch.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. + */ + +#include +#include +#include "lwip/opt.h" + +u32_t sys_now(void) +{ + return get_timer(0); +} + +u32_t lwip_port_rand(void) +{ + return (u32_t)rand(); +} + From patchwork Mon Aug 14 13:32:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713479 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1242668wrp; Mon, 14 Aug 2023 06:36:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpSmhwxAA23d3ZIUwTNMAzp/XkI9b5sQEiV6XXHcuhp2lYF67X0UeAPpuTv0Ykkb7lgOhI X-Received: by 2002:a05:600c:218b:b0:3fb:b3aa:1c8f with SMTP id e11-20020a05600c218b00b003fbb3aa1c8fmr7733830wme.28.1692020211485; Mon, 14 Aug 2023 06:36:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020211; cv=none; d=google.com; s=arc-20160816; b=AAh6BR6O5epOO+nZt+tG32as6o9VXmU0V32aVQPVAqUiakCZFzv1gn0EtXpEmdgbCs losQW+VegLOhN1qXPG85nls2kqPzWYQRzNInZrXnvpicTMSw0JpdHhAeniRf/Q7YfGFq pXZKjTSH3WMLKwB7Las3H8m9L7SXqVqzN6gXj57RU03jD/bNGQi52EX0dycI0Il03F5D N16vy8wVIWMB5WFuQEc8pxvzz5g8nSEys9yjjWzZHwIzfxnqSMg0iuXrUVPBWS912BzS Jv5N5nq9qQ9xtZWAYZ/tlC2SLmPlmfixhVjOi2n9VGd1IAUcaItfeh4BbjXqpeex+RMP Xz+g== 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=EDvrCmEs4AowbUl/thMcgKJCloHgFxRz4FWB3a/1gSQ=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=TRzKN6N6tEbS+TafvqhmZqjHxQM967xl/PiCcXFASaqMZlPDr8sBBWUnhf2AO/L2rA dYM0jAZTH4kBAf3adToegcGz9xPA8m1abFWzBKCU3wwd3JP3ZR/ZT9dF/pi8dPGdxuF9 e6lajKuLmTK6Sq07DN+uk4Wbftcm9bWhMx8RbxwJlNyTEnDd3tE8D1NktlEG4o1RmwM5 DhA4sFm20rxtuZQy/U1iUdYaOEXfb92ofFXiqMBVUcH5ZtddtRDBD9vXDUq2c+hPDzaF vyEDY7w67EzDBQHkofZRM2K9KkK32v6u074SyuPGC+cvL95STm868P4B6zf54nPRsVQd qL9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OIjVPjEZ; 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 e9-20020a056000194900b0031767caae9csi5066262wry.214.2023.08.14.06.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:36: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=OIjVPjEZ; 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 5C073869A0; Mon, 14 Aug 2023 15:35:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=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="OIjVPjEZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CE397869A2; Mon, 14 Aug 2023 15:35: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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 015E286997 for ; Mon, 14 Aug 2023 15:35: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=maxim.uvarov@linaro.org Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2b974031aeaso67195901fa.0 for ; Mon, 14 Aug 2023 06:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020137; x=1692624937; 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=EDvrCmEs4AowbUl/thMcgKJCloHgFxRz4FWB3a/1gSQ=; b=OIjVPjEZkrJF75Vf+WNAZAJDEpVp9yNU3WOoeTZe2A6sGTTW3z8g/3YJxXCFN06UU1 jR9JSQt33z06TvTrhoCULJ/IzzHCE1VszBfId03J3J2DfP8q5aaPmxzLr5do2bq4InRV DWdZ4MaPvGdY9oyYF2KRrVKDAsgNuuEGp8tzNPdJKXsd17GnfTmTZALrmaiFSqtkRC0K QfyWEZHhnQiyzVixovaA0ACyEe1/AeHubiFUKNbPsDKJ9TNs3fOLebhbwz9cwD7ZutmV HXcOpr8uJNc48GBxxfZRg1S19VkUDJLYJSsvl4IEzhCHeflhkvZ924U5z9YDEy3VJups GhAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020137; x=1692624937; 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=EDvrCmEs4AowbUl/thMcgKJCloHgFxRz4FWB3a/1gSQ=; b=K0kZ8ymzyLQ/ecCF44NqkVfQe8Ook+m8WjpiM9DdV36L4eShpi+ZC/hiK1aWhGo9xV YkjyG7iHlw/tOQoPjWHuqbSbbAuvRYzvKotx56DzJH1keeNLLp4bwmBDswj1ejYPURtx ati6vp2VUC3eZHWBCmF/uFpbjgS2aizfMDeomE67y1fPDgLyTyWhSI9Qh4sjmvkm/Q1U 0x3bmVhQlQicacsLExDyui+3rZahmFa+6Q1dWrFZxSm5zTMr8WPnxe/8K/EytqUxBD7h aNmjFd7nt1l9PqDWxg5kxeMWfuzsLrdv1oNy3UmLuFGyZzES0YkfogCsPss3/+OGDQTs B0gg== X-Gm-Message-State: AOJu0YyFl+FtJ53mh/kee+ZciEcPhLWr7GmAmwaKpV8QzXaE9h18p+oU lJoJk0eya87jNDn1gnASFm6WnF31iMNuqELijUg= X-Received: by 2002:a2e:a412:0:b0:2b9:f31e:51ff with SMTP id p18-20020a2ea412000000b002b9f31e51ffmr6563347ljn.37.1692020137106; Mon, 14 Aug 2023 06:35:37 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35: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, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 10/14] net/lwip: update .gitignore with lwIP Date: Mon, 14 Aug 2023 19:32:49 +0600 Message-Id: <20230814133253.4150-11-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean ignore lwIP library code and reused files from the lwIP. Signed-off-by: Maxim Uvarov --- net/lwip/.gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 net/lwip/.gitignore diff --git a/net/lwip/.gitignore b/net/lwip/.gitignore new file mode 100644 index 0000000000..7b5dacce90 --- /dev/null +++ b/net/lwip/.gitignore @@ -0,0 +1,8 @@ +lwip-external +apps/ping/ping.c +apps/http/http_client.c +apps/http/http_client.h +apps/tftp/tftp.c +apps/tftp/tftp_client.h +apps/tftp/tftp_common.h +apps/tftp/tftp_example.h From patchwork Mon Aug 14 13:32:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713480 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1242753wrp; Mon, 14 Aug 2023 06:37:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSRehPtTNNWgIQM6B6944RNKE+m+4QZ2n26tj7j5HLsLu8aRNs40Y/dDmgSSc360WK3Jw0 X-Received: by 2002:a05:600c:11cf:b0:3fe:19cf:93c9 with SMTP id b15-20020a05600c11cf00b003fe19cf93c9mr7110674wmi.1.1692020222088; Mon, 14 Aug 2023 06:37:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020222; cv=none; d=google.com; s=arc-20160816; b=DF9yWGQmmGcGlCT+yXRibgpItGbaNnR/2xX3hbvGhYuXKNXaLVgrvhhmC0O4mZlsxE WUQmMv5HlGjrzs4Evj8fjgcOb8Ob+ktkEX6pD6YuFJeUM2+NETiEd3v/v3lqi+4sLIIq 5ScFDy+d/0wWczyWhPSolb38ueLxc0vr0CkA9UWurbE42OnplwiohUQVhwdMKiFmA2Jp Toju6PDokehUXofLM7gjMmZUXKXgNDTkQJGM6h5nVYfykfCCOFkckLWbBHgeFf75IAZx vaQaeH7xr5lNb5Chz6NBobjcLWWifhGqynHNiIyTeJwb5bytwGybRUtlC7VyOKWxINxj vSgA== 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=FRoLHHce4JOrxPpx2ezZa+k60uaaJrxdQ0nPimAy89s=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=Ur+JXiyqOvpMZYAawfhduwra+C7GmROlM8hgT40JhwyAVCPMUcXKh/E3C1LCvoskog Wt/8BnSIfjroIZ8f18OVCE7lL1boKEImZaAUSmYvOfA+Va9BdNZsz1tlnWvx/iY9gOal k1tq5NVjeaLWMDShioidhzox50MoWvDfVdNFkQK/AAFMGvhGi1xCxetaSd1BWrRw9Py1 Adhn2uvKSdWS23rmi17YCvr96kkvovCvgD6S+sp4toGghrLv4lZF5DlPWL4P6+rN9uOK +sRkpPYH/aLBgD6EdYXmO5i7yHPfSvHfc5z4kJuQBWpjVHq53WQCWcD4timNACHUR3+t e0VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B+zoiKjA; 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 n3-20020adffe03000000b003195cb4dcc0si4027204wrr.385.2023.08.14.06.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:37:02 -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=B+zoiKjA; 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 9F1A5869A6; Mon, 14 Aug 2023 15:35:43 +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="B+zoiKjA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 52467869A4; Mon, 14 Aug 2023 15:35:43 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) (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 C6B02869A5 for ; Mon, 14 Aug 2023 15:35:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2b9f0b7af65so64862791fa.1 for ; Mon, 14 Aug 2023 06:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020140; x=1692624940; 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=FRoLHHce4JOrxPpx2ezZa+k60uaaJrxdQ0nPimAy89s=; b=B+zoiKjAgb2fNE4DHJv+uRxjrvEq2tzL7t0t2agkYnjUP3qFVWa75w8WEke6DFN0h6 /gbYrPB7jvOddGdukHU8RznI+SzdyGOqfiGhxLcLENI+nO4AcoLMdQxu7lXhqH5KNwP0 tYcNsBKHXosfbmLX9fEDUoCC9dNWa3e+s4R8IuYgJsfQeskG4JyXkWw6zJsO6Efd9olX h77NOjtNYPkuZ/26+WknvvMOfrtCu/+o/u1CmRCc6rPDjH7OmPNFLIhBedkYye2UrjP8 ODM+koEJGyTd/jzuV+YeIuaOpz7BK0bgbL+D5MnGlY3hWdswKldN3wUjbRhovpSA35Wu KKGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020140; x=1692624940; 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=FRoLHHce4JOrxPpx2ezZa+k60uaaJrxdQ0nPimAy89s=; b=cQ5NpihInj5Lw15DRfzl5Nu3VXTZSp4DACvAn1cLRrqF2WZPpcdxMPAZ0iPb3OfICS Wa7bkUNlAQuV+0X1EnGWlj46RZkWV3QnBB+5f023IUPO2pIQ73+Q4ERUuujnzTa5yaSu 3/HMW9eHkgSp5/lMyVvi7GBrWxFZ0g1552yrEtB9JaFY5ao9tG967kxc8SaGV+SMz68y hqYw8VGdq9WAqTqI2BBE+V9wC8OQio2miNYb5o12gcwvHpaneQJwl+EUcs1po4abQl/d 4ZU12EMwXjS5h0Vaw0lBYr/ubA62x1H5wYRXymeKZ6d0QB/zbZVMpV+Z9Ux1yH2SJssZ CN3Q== X-Gm-Message-State: AOJu0YyK2q6KeQ11QK5fD5eF0HyRqEFRGCIyd5zdeIJAtMfZLcP+gjM8 oo13K1b3BugqnoqUNgtyZ1pFbDWDN7TrnvcAuKc= X-Received: by 2002:a2e:7809:0:b0:2b6:e625:ba55 with SMTP id t9-20020a2e7809000000b002b6e625ba55mr7144464ljc.41.1692020139750; Mon, 14 Aug 2023 06:35:39 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:39 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 11/14] net/lwip: connection between cmd and lwip apps Date: Mon, 14 Aug 2023 19:32:50 +0600 Message-Id: <20230814133253.4150-12-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Signed-off-by: Maxim Uvarov --- cmd/Makefile | 1 + cmd/net-lwip.c | 306 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 307 insertions(+) create mode 100644 cmd/net-lwip.c diff --git a/cmd/Makefile b/cmd/Makefile index 9bebf321c3..6ab6b16aab 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -128,6 +128,7 @@ endif obj-$(CONFIG_CMD_MUX) += mux.o obj-$(CONFIG_CMD_NAND) += nand.o obj-$(CONFIG_CMD_NET) += net.o +obj-$(CONFIG_CMD_NET) += net-lwip.o obj-$(CONFIG_CMD_NVEDIT_EFI) += nvedit_efi.o obj-$(CONFIG_CMD_ONENAND) += onenand.o obj-$(CONFIG_CMD_OSD) += osd.o diff --git a/cmd/net-lwip.c b/cmd/net-lwip.c new file mode 100644 index 0000000000..46fe4f091f --- /dev/null +++ b/cmd/net-lwip.c @@ -0,0 +1,306 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Maxim Uvarov, maxim.uvarov@linaro.org + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "net/lwip.h" +#include "net/ulwip.h" + +static int do_lwip_init(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + if (!ulwip_init()) + return CMD_RET_SUCCESS; + return CMD_RET_FAILURE; +} + +static int lwip_empty_tmo(void) { return 0; }; +int (*ulwip_tmo)(void) = lwip_empty_tmo; +void ulwip_set_tmo(int (*tmo)(void)) +{ + ulwip_tmo = tmo; +} + +static void ulwip_clear_tmo(void) +{ + ulwip_tmo = lwip_empty_tmo; +} + +static void ulwip_timeout_handler(void) +{ + eth_halt(); + ulwip_tmo(); + net_set_state(NETLOOP_FAIL); /* we did not get the reply */ + ulwip_loop_set(0); +} + +int ulwip_loop(void) +{ + int ret = CMD_RET_FAILURE; + + ulwip_loop_set(1); + if (!net_loop(LWIP)) + ret = CMD_RET_SUCCESS; + ulwip_loop_set(0); + return ret; +} + +#if defined(CONFIG_CMD_PING) +int do_lwip_ping(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + int ret; + + if (argc < 2) { + printf("argc = %d, error\n", argc); + return CMD_RET_USAGE; + } + + ret = ulwip_init(); + if (ret) { + log_err("ulwip_init err %d\n", ret); + return CMD_RET_FAILURE; + } + + printf("Using %s device\n", eth_get_name()); + printf("pinging addr: %s\n", argv[1]); + + net_set_timeout_handler(1000UL, ulwip_timeout_handler); + + if (ulwip_ping(argv[1])) { + printf("ping init fail\n"); + return CMD_RET_FAILURE; + } + + return ulwip_loop(); +} +#endif /* CONFIG_CMD_PING */ + +#if defined(CONFIG_CMD_WGET) +int do_lwip_wget(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + char *url; + int ret; + + if (argc < 2) + return CMD_RET_USAGE; + + url = argv[1]; + + ret = ulwip_init(); + if (ret) { + log_err("ulwip_init err %d\n", ret); + return CMD_RET_FAILURE; + } + + ret = ulwip_wget(image_load_addr, url); + if (ret) { + log_err("lwip_wget err %d\n", ret); + return CMD_RET_FAILURE; + } + + + return ulwip_loop(); +} +#endif + +#if defined(CONFIG_CMD_TFTPBOOT) +int do_lwip_tftp(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + char *filename; + ulong addr; + char *end; + int ret; + + switch (argc) { + case 1: + filename = env_get("bootfile"); + break; + case 2: + /* + * Only one arg - accept two forms: + * Just load address, or just boot file name. The latter + * form must be written in a format which can not be + * mis-interpreted as a valid number. + */ + addr = hextoul(argv[1], &end); + if (end == (argv[1] + strlen(argv[1]))) { + image_load_addr = addr; + filename = env_get("bootfile"); + } else { + filename = argv[1]; + } + break; + case 3: + image_load_addr = hextoul(argv[1], NULL); + filename = argv[2]; + break; + default: + return CMD_RET_USAGE; + } + + ret = ulwip_init(); + if (ret) { + log_err("ulwip_init err %d\n", ret); + return CMD_RET_FAILURE; + } + + ret = ulwip_tftp(image_load_addr, filename); + if (ret) + return ret; + + return ulwip_loop(); +} +#endif /* CONFIG_CMD_TFTPBOOT */ + +#if defined(CONFIG_CMD_DHCP) +int do_lwip_dhcp(void) +{ + int ret; + char *filename; + + ret = ulwip_init(); + if (ret) { + log_err("ulwip_init err %d\n", ret); + return CMD_RET_FAILURE; + } + + ret = ulwip_dhcp(); + + net_set_timeout_handler(2000UL, ulwip_timeout_handler); + + ulwip_loop(); + if (IS_ENABLED(CONFIG_CMD_TFTPBOOT)) { + ulwip_clear_tmo(); + + filename = env_get("bootfile"); + if (!filename) { + log_notice("no bootfile\n"); + return CMD_RET_SUCCESS; + } + + ret = ulwip_init(); + if (ret) { + log_err("ulwip_init err %d\n", ret); + return CMD_RET_FAILURE; + } + + net_set_timeout_handler(20000UL, ulwip_timeout_handler); + ulwip_tftp(image_load_addr, filename); + + ret = ulwip_loop(); + } + + return ret; +} + +static int _do_lwip_dhcp(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + return do_lwip_dhcp(); +} +#endif /* CONFIG_CMD_DHCP */ + +#if defined(CONFIG_CMD_DNS) +int do_lwip_dns(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + int ret; + char *name; + char *varname; + int LWIP_ERR_INPROGRESS = -5; /* lwip/err.h */ + + if (argc == 1) + return CMD_RET_USAGE; + + name = argv[1]; + + if (argc == 3) + varname = argv[2]; + else + varname = NULL; + + ret = ulwip_init(); + if (ret) { + log_err("ulwip_init err %d\n", ret); + return CMD_RET_FAILURE; + } + + ret = ulwip_dns(name, varname); + if (ret == 0) + return CMD_RET_SUCCESS; + if (ret != LWIP_ERR_INPROGRESS) + return CMD_RET_FAILURE; + + net_set_timeout_handler(1000UL, ulwip_timeout_handler); + + return ulwip_loop(); +} +#endif /* CONFIG_CMD_DNS */ + +static struct cmd_tbl cmds[] = { + U_BOOT_CMD_MKENT(init, 1, 0, do_lwip_init, + "initialize lwip stack", ""), +#if defined(CONFIG_CMD_PING) + U_BOOT_CMD_MKENT(ping, 2, 0, do_lwip_ping, + "send ICMP ECHO_REQUEST to network host", + "pingAddress"), +#endif +#if defined(CONFIG_CMD_WGET) + U_BOOT_CMD_MKENT(wget, 2, 0, do_lwip_wget, "", ""), +#endif +#if defined(CONFIG_CMD_TFTPBOOT) + U_BOOT_CMD_MKENT(tftp, 3, 0, do_lwip_tftp, + "boot image via network using TFTP protocol\n", + "[loadAddress] [[hostIPaddr:]bootfilename]"), +#endif +#if defined(CONFIG_CMD_DHCP) + U_BOOT_CMD_MKENT(dhcp, 1, 0, _do_lwip_dhcp, + "boot image via network using DHCP/TFTP protocol", + ""), +#endif +#if defined(CONFIG_CMD_DNS) + U_BOOT_CMD_MKENT(dns, 3, 0, do_lwip_dns, + "lookup dns name [and store address at variable]", + ""), +#endif +}; + +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)); + + 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", + "init - init LWIP\n" + "ping addr - pingAddress\n" + "wget http://IPadress/url/\n" + "tftp [loadAddress] [[hostIPaddr:]bootfilename]\n" + "dhcp - boot image via network using DHCP/TFTP protocol\n" + ); From patchwork Mon Aug 14 13:32:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713481 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1242869wrp; Mon, 14 Aug 2023 06:37:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6C9qqhtpyZYGhSe2nYvAgHulnvDdpa497I3kI+I4j4pVW4pErXm3gwg+zm9DZCGV1XvnV X-Received: by 2002:a05:600c:b44:b0:3fe:6199:9393 with SMTP id k4-20020a05600c0b4400b003fe61999393mr7781138wmr.27.1692020232378; Mon, 14 Aug 2023 06:37:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020232; cv=none; d=google.com; s=arc-20160816; b=Ih0zLCR644IosftPtNvx5BNDvZjJ1yJ1Y4v0uhLB9rzI5q6NIjBqGADRxhrrnTM9N8 1jqQ51eHO63DmQpz6po6yIzcQXDnl9SrlvW1usGjdZKKxfdDBcyM7NouKKg0Dv0Fx+ef CMEupUD2ZcERIzcvzypoUagj318TE37Px5fqm12SApL6qje/jtjqoMftjgiozwzgIeV0 KbjV6cC2xxaB/d6Qsx6gm0LRegJQeDNKe5tGiTDmZEWDUvLKSxtq4gw0J7GV+MKUk6T7 QGqMGiD/GlUB1z7rDc7R6F+xfOFXAGtV9ex3WTgkYv7Z2m6rzcNhg89bh5ezHZzE0M7u SqCw== 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=mN4s7AVIsgW1Nbf0ozqyFDkOIViybpuSo4L8hXoJQ38=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=p929StKHbughB14tlSrlyT/2UcS4QuQ4ZDZVQfdeeke+L94RkFSDY+eLGvFoLRuBQk WEoEHMNxpZxrzTleUigdbA8ZgWx/yFvx1uCehG725EOL+Cym4lMnnTi4hu6Bb0emavoV IsdWkefo2IJzTaGO2ItYjI9b3pr/erSpbZllwRUwoOdrIrEQO3kv6dRtCG9/aBEJV7Ut Nb6VeM8AjLXl7El3s/k1Q3tZoHyzVz0tM2jl5OGe+LNKNJ3bA94A6h5kb3OiEFS7q+84 61nFmBOJT5649IDN/dh+EA1CQAJZujmoFkvFnKdbqbXb1P34MwPlDvCK4v8AE1Jlraqc ghHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lQsQySwn; 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 fa15-20020a05600c518f00b003fc33de01efsi7107683wmb.224.2023.08.14.06.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:37:12 -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=lQsQySwn; 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 E20C1869A3; Mon, 14 Aug 2023 15:35:46 +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="lQsQySwn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9E33F865B6; Mon, 14 Aug 2023 15:35: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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) (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 769F4869A3 for ; Mon, 14 Aug 2023 15:35:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2b9b9f0387dso63888171fa.0 for ; Mon, 14 Aug 2023 06:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020142; x=1692624942; 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=mN4s7AVIsgW1Nbf0ozqyFDkOIViybpuSo4L8hXoJQ38=; b=lQsQySwn36lt2rmk1+wEbRzutdkEt6kmMaSGw+yRLd8WYkeVMxy64NeHCoXtm7basP JbF8T9HjrpSNFn/fq/q3qNG9xyBs5Asio07KfQytSddUaH+RWqay6cRy/Mco6imP3m+W 0Ggth4U7AnAoScHvfv0recma1f+ooQIVRl5aWBKDK95T4qWAt/cXuAJ+B8ZByrVWswz/ pHYTqbGs2AYCImeRubh4Y7AEoy6Q7WqWmw7Jp+ALMAjo+Oq3TsCvoAAOFN1hNqBQNLs2 a+vQuPrLuPr3crnfLiXocM0ftBFyUyM1tTkmtOl8e4W6feEKrsf+u1jnWdbUDwVlqEr8 bkVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020142; x=1692624942; 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=mN4s7AVIsgW1Nbf0ozqyFDkOIViybpuSo4L8hXoJQ38=; b=NkIXq3Did8im2pjBDJRZzky/7FBepq+8vAywJ2Siy5Q4BIHmAcHrTgcm9ovlE2H6RI A6KePoYckQr2LNnoPNm+G9P9UIUIFxqJpL5JPQdK0uIIYnflwe9KjeW+A5B7zbu9T6ym AlrPjV0MPMrh5fI7Z5X3DPEs4/VTAqfSZKbiUTfqGIxo+xjYpRXLu6p0LU2HI6mLOK8e tpBrdp2msiOoo0S+/zeV2iifVUSazlYO+jcHXrKiVQacrHtXnjrjXMjCz2SZYzuOFC8g gmKt2p0GGF6uDQlnPYJ5f3mxBjxvYXXXbgZm038baGCBeQmoxf0LKfU0G9LfbM+FA8CH TOlA== X-Gm-Message-State: AOJu0Yw/GrT50ESpVJexMte8OkMKhFtr4h5aTUNRvwP543YcsMCghzRd lsa1kDCdquPdyyaUab6qFqqMCaN6N/W5aJsOLJE= X-Received: by 2002:a2e:9042:0:b0:2b5:974f:385 with SMTP id n2-20020a2e9042000000b002b5974f0385mr6775452ljg.9.1692020142461; Mon, 14 Aug 2023 06:35:42 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:42 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 12/14] net/lwip: replace original net commands with lwip Date: Mon, 14 Aug 2023 19:32:51 +0600 Message-Id: <20230814133253.4150-13-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Replace original commands: ping, tftp, dhcp and wget. Signed-off-by: Maxim Uvarov --- boot/bootmeth_efi.c | 18 +++++++--- boot/bootmeth_pxe.c | 21 ++++++----- cmd/net.c | 86 +++++---------------------------------------- cmd/pxe.c | 19 +++++----- include/net.h | 8 +++-- include/net/ulwip.h | 68 +++++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 103 deletions(-) create mode 100644 include/net/ulwip.h diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index 1c9f2b1e2f..ea9f3af0f7 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include @@ -319,9 +321,7 @@ static int distro_efi_try_bootflow_files(struct udevice *dev, static int distro_efi_read_bootflow_net(struct bootflow *bflow) { - char file_addr[17], fname[256]; - char *tftp_argv[] = {"tftp", file_addr, fname, NULL}; - struct cmd_tbl cmdtp = {}; /* dummy */ + char fname[256]; const char *addr_str, *fdt_addr_str; int ret, arch, size; ulong addr, fdt_addr; @@ -368,7 +368,6 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow) if (!fdt_addr_str) return log_msg_ret("fdt", -EINVAL); fdt_addr = hextoul(fdt_addr_str, NULL); - sprintf(file_addr, "%lx", fdt_addr); /* We only allow the first prefix with PXE */ ret = distro_efi_get_fdt_name(fname, sizeof(fname), 0); @@ -379,7 +378,16 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow) if (!bflow->fdt_fname) return log_msg_ret("fil", -ENOMEM); - if (!do_tftpb(&cmdtp, 0, 3, tftp_argv)) { + ret = ulwip_init(); + if (ret) + return log_msg_ret("ulwip_init", ret); + + ret = ulwip_tftp(fdt_addr, fname); + if (ret) + return log_msg_ret("ulwip_tftp", ret); + + ret = ulwip_loop(); + if (!ret) { bflow->fdt_size = env_get_hex("filesize", 0); bflow->fdt_addr = fdt_addr; } else { diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 8d489a11aa..fc6aabaa18 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path, @@ -116,18 +118,21 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, const char *file_path, ulong addr, ulong *sizep) { - char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; - struct pxe_context *ctx = dev_get_priv(dev); - char file_addr[17]; ulong size; int ret; - sprintf(file_addr, "%lx", addr); - tftp_argv[1] = file_addr; - tftp_argv[2] = (void *)file_path; + ret = ulwip_init(); + if (ret) + return log_msg_ret("ulwip_init", ret); + + ret = ulwip_tftp(addr, file_path); + if (ret) + return log_msg_ret("ulwip_tftp", ret); + + ret = ulwip_loop(); + if (ret) + return log_msg_ret("ulwip_loop", ret); - if (do_tftpb(ctx->cmdtp, 0, 3, tftp_argv)) - return -ENOENT; ret = pxe_get_file_size(&size); if (ret) return log_msg_ret("tftp", ret); diff --git a/cmd/net.c b/cmd/net.c index d407d8320a..dc5a114309 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -22,6 +22,7 @@ #include #include #include +#include static int netboot_common(enum proto_t, struct cmd_tbl *, int, char * const []); @@ -40,19 +41,9 @@ U_BOOT_CMD( #endif #ifdef CONFIG_CMD_TFTPBOOT -int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - int ret; - - bootstage_mark_name(BOOTSTAGE_KERNELREAD_START, "tftp_start"); - ret = netboot_common(TFTPGET, cmdtp, argc, argv); - bootstage_mark_name(BOOTSTAGE_KERNELREAD_STOP, "tftp_done"); - return ret; -} - #if IS_ENABLED(CONFIG_IPV6) U_BOOT_CMD( - tftpboot, 4, 1, do_tftpb, + tftpboot, 4, 1, do_lwip_tftp, "boot image via network using TFTP protocol\n" "To use IPv6 add -ipv6 parameter or use IPv6 hostIPaddr framed " "with [] brackets", @@ -60,7 +51,7 @@ U_BOOT_CMD( ); #else U_BOOT_CMD( - tftpboot, 3, 1, do_tftpb, + tftpboot, 3, 1, do_lwip_tftp, "load file via network using TFTP protocol", "[loadAddress] [[hostIPaddr:]bootfilename]" ); @@ -139,7 +130,7 @@ U_BOOT_CMD(dhcp6, 3, 1, do_dhcp6, static int do_dhcp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - return netboot_common(DHCP, cmdtp, argc, argv); + return do_lwip_dhcp(); } U_BOOT_CMD( @@ -196,13 +187,11 @@ U_BOOT_CMD( #endif #if defined(CONFIG_CMD_WGET) -static int do_wget(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) -{ - return netboot_common(WGET, cmdtp, argc, argv); -} +int do_lwip_wget(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); U_BOOT_CMD( - wget, 3, 1, do_wget, + wget, 3, 1, do_lwip_wget, "boot image via network using HTTP protocol", "[loadAddress] [[hostIPaddr:]path and image name]" ); @@ -456,28 +445,8 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, } #if defined(CONFIG_CMD_PING) -static int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) -{ - if (argc < 2) - return CMD_RET_USAGE; - - net_ping_ip = string_to_ip(argv[1]); - if (net_ping_ip.s_addr == 0) - return CMD_RET_USAGE; - - if (net_loop(PING) < 0) { - printf("ping failed; host %s is not alive\n", argv[1]); - return CMD_RET_FAILURE; - } - - printf("host %s is alive\n", argv[1]); - - return CMD_RET_SUCCESS; -} - U_BOOT_CMD( - ping, 2, 1, do_ping, + ping, 2, 1, do_lwip_ping, "send ICMP ECHO_REQUEST to network host", "pingAddress" ); @@ -601,45 +570,8 @@ U_BOOT_CMD( #endif #if defined(CONFIG_CMD_DNS) -int do_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - if (argc == 1) - return CMD_RET_USAGE; - - /* - * We should check for a valid hostname: - * - Each label must be between 1 and 63 characters long - * - the entire hostname has a maximum of 255 characters - * - only the ASCII letters 'a' through 'z' (case-insensitive), - * the digits '0' through '9', and the hyphen - * - cannot begin or end with a hyphen - * - no other symbols, punctuation characters, or blank spaces are - * permitted - * but hey - this is a minimalist implmentation, so only check length - * and let the name server deal with things. - */ - if (strlen(argv[1]) >= 255) { - printf("dns error: hostname too long\n"); - return CMD_RET_FAILURE; - } - - net_dns_resolve = argv[1]; - - if (argc == 3) - net_dns_env_var = argv[2]; - else - net_dns_env_var = NULL; - - if (net_loop(DNS) < 0) { - printf("dns lookup of %s failed, check setup\n", argv[1]); - return CMD_RET_FAILURE; - } - - return CMD_RET_SUCCESS; -} - U_BOOT_CMD( - dns, 3, 1, do_dns, + dns, 3, 1, do_lwip_dns, "lookup the IP of a hostname", "hostname [envvar]" ); diff --git a/cmd/pxe.c b/cmd/pxe.c index 677142520b..d44df428d2 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -29,21 +30,19 @@ const char *pxe_default_paths[] = { static int do_get_tftp(struct pxe_context *ctx, const char *file_path, char *file_addr, ulong *sizep) { - char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; + ulong addr; + char *end; int ret; - int num_args; - tftp_argv[1] = file_addr; - tftp_argv[2] = (void *)file_path; + addr = hextoul(file_addr, &end); + if (ctx->use_ipv6) { - tftp_argv[3] = USE_IP6_CMD_PARAM; - num_args = 4; - } else { - num_args = 3; + /* @todo: check and fix me, here */ } - if (do_tftpb(ctx->cmdtp, 0, num_args, tftp_argv)) - return -ENOENT; + ret = ulwip_tftp(addr, file_path); + if (ret) + return log_msg_ret("tftp", ret); ret = pxe_get_file_size(sizep); if (ret) diff --git a/include/net.h b/include/net.h index e254df7d7f..de7baeb121 100644 --- a/include/net.h +++ b/include/net.h @@ -54,8 +54,10 @@ struct in_addr { __be32 s_addr; }; +int do_lwip_dhcp(void); + /** - * do_tftpb - Run the tftpboot command + * do_lwip_tftp - Run the tftpboot command * * @cmdtp: Command information for tftpboot * @flag: Command flags (CMD_FLAG_...) @@ -63,7 +65,7 @@ struct in_addr { * @argv: List of arguments * Return: result (see enum command_ret_t) */ -int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); +int do_lwip_tftp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); /** * dhcp_run() - Run DHCP on the current ethernet device @@ -514,7 +516,7 @@ extern int net_restart_wrap; /* Tried all network devices */ enum proto_t { BOOTP, RARP, ARP, TFTPGET, DHCP, DHCP6, PING, PING6, DNS, NFS, CDP, NETCONS, SNTP, TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT_UDP, FASTBOOT_TCP, - WOL, UDP, NCSI, WGET, RS + WOL, UDP, NCSI, WGET, RS, LWIP }; extern char net_boot_file_name[1024];/* Boot File name */ diff --git a/include/net/ulwip.h b/include/net/ulwip.h new file mode 100644 index 0000000000..39d61fe446 --- /dev/null +++ b/include/net/ulwip.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/** + * ulwip_init() - initialize lwIP network stack + * + * @return 0 if success, !0 if error + */ +int ulwip_init(void); + +/** + * ulwip_enabled() - check if lwIP network stack was initialized + * + * @return 1 lwip initialized, 0 if not yet initialized + */ +int ulwip_enabled(void); + +/** + * ulwip_in_loop() - lwIP controls packet net loop + * + * @return 1 lwIP owns packet loop, 0 lwip does not own packet loop + */ +int ulwip_in_loop(void); + +/** + * ulwip_loop_set() - make loop to be used by lwIP + * + * Function is used to make lwIP control network pool. + * + * @param loop 1. Rx packets go to lwIP 2. Rx packets go to the original stack. + */ +void ulwip_loop_set(int loop); + +/** + * ulwip_exit() - exit from lwIP with a return code + * + * Exit from lwIP application back to the U-Boot with specific error code. + * + * @param err error code to return + */ +void ulwip_exit(int err); + +/** + * ulwip_poll() - polling function to feed lwIP with ethernet packet + * + * Function takes network packet and passes it to lwIP network stack + */ +void ulwip_poll(void); + +/** + * ulwip_app_get_err() - return error code from lwIP application + * + * @return error code + */ +int ulwip_app_get_err(void); + +/** + * ulwip_set_tmo() - set application timeout function to trap lwIP application + * + * lwIP cmd compatibility code does initialization for application then gives + * control to the packet loop. To keep ability for control return code and + * application state after application work special handler can be registered + * with this call. + * + * @param tmo - function to call if timeout happen. + */ +void ulwip_set_tmo(int (*tmo)(void)); + +int ulwip_loop(void); From patchwork Mon Aug 14 13:32:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713482 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1242962wrp; Mon, 14 Aug 2023 06:37:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHx6Di1iTx0X4W4o8KI9zO26Ta2bUP08V6K1LB6PuTa3AsRgAz+TZRB5FuFM5wppBGMONhk X-Received: by 2002:adf:fd82:0:b0:317:5351:e428 with SMTP id d2-20020adffd82000000b003175351e428mr7485545wrr.4.1692020241650; Mon, 14 Aug 2023 06:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020241; cv=none; d=google.com; s=arc-20160816; b=ZIH5+Oy9K4MY3Ik3s8SFiSenAUX816XmfSvuufN/Z35YctGAORkManOJRVQVcCk6C6 gUdHfo0YmLkc4ZSzFjK+xeYpHbnzrYP9mYLCt5m35yu95ThUgJiUxNO4mpOb54C2g2ei Z2LT6E355PNUyRS3GDdvg3wnuQXvkgseTe2DuVIdy3ONC033aupGwXwKgsVn7B9+qUpO NQ6u0ZhCywUIfdLA6pcmw+P4m/ByZxCB9HQyZ8pG3G1AMc9WQX4I6d13oeQZxPTjA88I VsAcMlT5qXvDpdz+okPBgOtYrsu6IpcZ/+e2AI3rLR0C0jaFK34Cx16mlKKYeOuTOCmp Ve4w== 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=E2ziTbeXz5Mw5Zsh+PXRJwRlKMm+1xFvTuTYPCWU9yo=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=Qzu/WnTSnHrDApczxH6PRhRwL+MXsIWlky6gF8NP9tdSCuHfkzK4wISwHleB7xv+L0 Ufj3IITKPvEcFQq531AQ8z6hFf/k4sIHMeyDygk7vmRafZBIm6kGtGPuJjUlCqkGvJ68 9cSgDJboH5BzsVNW81fUlCJFFAXI/a0HxCbaDbl3ZB5kUIw6pUXMbOINNQRukCXJ7zH+ Bxgate7b+I9OQx/pgPRxT1SDIqZO5f2o1uWyTP268Zxb9jjGsZzr4da60orJPY1YRgzt CvfuD6Qu+Te0wHCtVsdKUIuP8t3LV51iAfMpnvnKvMmhbKf8QcbCy/CJZ3TYjY16JQer JyNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Z/kLav91"; 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 x2-20020a5d4902000000b00317c66f238csi5222689wrq.272.2023.08.14.06.37.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:37:21 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Z/kLav91"; 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 312E5869B6; Mon, 14 Aug 2023 15:35:50 +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="Z/kLav91"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EBB00869B0; Mon, 14 Aug 2023 15:35:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) (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 9BF2E865B6 for ; Mon, 14 Aug 2023 15:35:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2b9fa64db41so63549721fa.1 for ; Mon, 14 Aug 2023 06:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020146; x=1692624946; 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=E2ziTbeXz5Mw5Zsh+PXRJwRlKMm+1xFvTuTYPCWU9yo=; b=Z/kLav91Sbqcq8AU+bmMOhzuUA7OguzJQpTBq+aDNTNxYSJJSSjoWxVF7fQdzqfCV7 tCBhXvq2hQJ/S8CFgfMcdWRRxXhLeskkOcsiKNRDLDZ7SkjCNSUs8lZrG+IJUJobjt/m dxbx+vwXg8IhC62xXlDHvLF+C29HQzMu822Jhi+KePgKpCHJo4WZB0UFl6yEpgvX/Ke+ 9DsiGqAxhGZKzcIlrIx1yPZMMGjc2nlkv3zpEyxLJgo2S0gQ+sah0UANtKj1xaYTNZd5 SS0JP+58sDtK4ofv+IoQHGI/Dsl2pwkxPN9aJN3yP3U43yeDs5rDJ+B+7oJxvL2FsxzA DWqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020146; x=1692624946; 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=E2ziTbeXz5Mw5Zsh+PXRJwRlKMm+1xFvTuTYPCWU9yo=; b=ZTMYbpZRl+BueaImU94oh6HPuyMFwwPYPMernCR9lLJcLJCt+6YzMsOYLTDv6G0NJE JEhPguOrvej9EZN6ixPs/2wL6/9/MQkGMcM9ZSCGa9TtWi0nVq54E0IF/69Xmnrsk20x l0qviPpKzOh/HKQN/Mx/p3NG6NSvVoULqqFAHP84Ss1nYsxLQ4asyuTxTvGnNWqRaWeY VfI4uolz7k3FkPMcCXiAdUDIhA8WvvTwceXdFktw8X1Fm51zHeP4HA1JUIEZr3bHYDN9 2GNI+um4lOOdBK2XD8UgoMAUkuAdOjB3yEnuvTf5yXdit7d04xJwhEd9z3z0LTJuMpsD PCBg== X-Gm-Message-State: AOJu0Yzxl7Fs8/eZHRZY9QQJJWmzZVXIhR5mHtHXRVCn5Lv/63n6q27r XOvFBHnwvex80gupH/20pRVyEjG14mslOOYn+8A= X-Received: by 2002:a2e:8747:0:b0:2ba:e8ae:ec7 with SMTP id q7-20020a2e8747000000b002bae8ae0ec7mr3803618ljj.44.1692020145482; Mon, 14 Aug 2023 06:35:45 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:45 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 13/14] net/lwip: split net.h to net.h, arp.h and eth.h Date: Mon, 14 Aug 2023 19:32:52 +0600 Message-Id: <20230814133253.4150-14-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean current net.h has ethernet and protocol definitions. Protocol definitions overlap with lwIP protocol definitions and net.h can not be included from lwIP code. Splitting on logical blocks makes that work. Signed-off-by: Maxim Uvarov --- include/net.h | 189 +-------------------------------------------- include/net/arp.h | 7 ++ include/net/eth.h | 190 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 201 insertions(+), 185 deletions(-) create mode 100644 include/net/arp.h create mode 100644 include/net/eth.h diff --git a/include/net.h b/include/net.h index de7baeb121..780c51fab9 100644 --- a/include/net.h +++ b/include/net.h @@ -20,6 +20,7 @@ #include #include #include +#include struct bd_info; struct cmd_tbl; @@ -30,25 +31,6 @@ struct udevice; #define DEBUG_NET_PKT 0 /* Packets on info on the network at large */ #define DEBUG_INT_STATE 0 /* Internal network state changes */ -/* - * The number of receive packet buffers, and the required packet buffer - * alignment in memory. - * - */ -#define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER -#define PKTALIGN ARCH_DMA_MINALIGN - -/* Number of packets processed together */ -#define ETH_PACKETS_BATCH_RECV 32 - -/* ARP hardware address length */ -#define ARP_HLEN 6 -/* - * The size of a MAC address in string form, each digit requires two chars - * and five separator characters to form '00:00:00:00:00:00'. - */ -#define ARP_HLEN_ASCII (ARP_HLEN * 2) + (ARP_HLEN - 1) - /* IPv4 addresses are always 32 bits in size */ struct in_addr { __be32 s_addr; @@ -112,150 +94,7 @@ typedef void rxhand_icmp_f(unsigned type, unsigned code, unsigned dport, */ typedef void thand_f(void); -enum eth_state_t { - ETH_STATE_INIT, - ETH_STATE_PASSIVE, - ETH_STATE_ACTIVE -}; - -/** - * struct eth_pdata - Platform data for Ethernet MAC controllers - * - * @iobase: The base address of the hardware registers - * @enetaddr: The Ethernet MAC address that is loaded from EEPROM or env - * @phy_interface: PHY interface to use - see PHY_INTERFACE_MODE_... - * @max_speed: Maximum speed of Ethernet connection supported by MAC - * @priv_pdata: device specific plat - */ -struct eth_pdata { - phys_addr_t iobase; - unsigned char enetaddr[ARP_HLEN]; - int phy_interface; - int max_speed; - void *priv_pdata; -}; - -enum eth_recv_flags { - /* - * Check hardware device for new packets (otherwise only return those - * which are already in the memory buffer ready to process) - */ - ETH_RECV_CHECK_DEVICE = 1 << 0, -}; - -/** - * struct eth_ops - functions of Ethernet MAC controllers - * - * start: Prepare the hardware to send and receive packets - * send: Send the bytes passed in "packet" as a packet on the wire - * recv: Check if the hardware received a packet. If so, set the pointer to the - * packet buffer in the packetp parameter. If not, return an error or 0 to - * indicate that the hardware receive FIFO is empty. If 0 is returned, the - * network stack will not process the empty packet, but free_pkt() will be - * called if supplied - * free_pkt: Give the driver an opportunity to manage its packet buffer memory - * when the network stack is finished processing it. This will only be - * called when no error was returned from recv - optional - * stop: Stop the hardware from looking for packets - may be called even if - * state == PASSIVE - * mcast: Join or leave a multicast group (for TFTP) - optional - * write_hwaddr: Write a MAC address to the hardware (used to pass it to Linux - * on some platforms like ARM). This function expects the - * eth_pdata::enetaddr field to be populated. The method can - * return -ENOSYS to indicate that this is not implemented for - this hardware - optional. - * read_rom_hwaddr: Some devices have a backup of the MAC address stored in a - * ROM on the board. This is how the driver should expose it - * to the network stack. This function should fill in the - * eth_pdata::enetaddr field - optional - * set_promisc: Enable or Disable promiscuous mode - * get_sset_count: Number of statistics counters - * get_string: Names of the statistic counters - * get_stats: The values of the statistic counters - */ -struct eth_ops { - int (*start)(struct udevice *dev); - int (*send)(struct udevice *dev, void *packet, int length); - int (*recv)(struct udevice *dev, int flags, uchar **packetp); - int (*free_pkt)(struct udevice *dev, uchar *packet, int length); - void (*stop)(struct udevice *dev); - int (*mcast)(struct udevice *dev, const u8 *enetaddr, int join); - int (*write_hwaddr)(struct udevice *dev); - int (*read_rom_hwaddr)(struct udevice *dev); - int (*set_promisc)(struct udevice *dev, bool enable); - int (*get_sset_count)(struct udevice *dev); - void (*get_strings)(struct udevice *dev, u8 *data); - void (*get_stats)(struct udevice *dev, u64 *data); -}; - -#define eth_get_ops(dev) ((struct eth_ops *)(dev)->driver->ops) - -struct udevice *eth_get_dev(void); /* get the current device */ -/* - * The devname can be either an exact name given by the driver or device tree - * or it can be an alias of the form "eth%d" - */ -struct udevice *eth_get_dev_by_name(const char *devname); -unsigned char *eth_get_ethaddr(void); /* get the current device MAC */ - -/* Used only when NetConsole is enabled */ -int eth_is_active(struct udevice *dev); /* Test device for active state */ -int eth_init_state_only(void); /* Set active state */ -void eth_halt_state_only(void); /* Set passive state */ - -int eth_initialize(void); /* Initialize network subsystem */ -void eth_try_another(int first_restart); /* Change the device */ -void eth_set_current(void); /* set nterface to ethcur var */ - -int eth_get_dev_index(void); /* get the device index */ - -/** - * eth_env_set_enetaddr_by_index() - set the MAC address environment variable - * - * This sets up an environment variable with the given MAC address (@enetaddr). - * The environment variable to be set is defined by <@base_name><@index>addr. - * If @index is 0 it is omitted. For common Ethernet this means ethaddr, - * eth1addr, etc. - * - * @base_name: Base name for variable, typically "eth" - * @index: Index of interface being updated (>=0) - * @enetaddr: Pointer to MAC address to put into the variable - * Return: 0 if OK, other value on error - */ -int eth_env_set_enetaddr_by_index(const char *base_name, int index, - uchar *enetaddr); - - -/* - * Initialize USB ethernet device with CONFIG_DM_ETH - * Returns: - * 0 is success, non-zero is error status. - */ -int usb_ether_init(void); - -/* - * Get the hardware address for an ethernet interface . - * Args: - * base_name - base name for device (normally "eth") - * index - device index number (0 for first) - * enetaddr - returns 6 byte hardware address - * Returns: - * Return true if the address is valid. - */ -int eth_env_get_enetaddr_by_index(const char *base_name, int index, - uchar *enetaddr); - -int eth_init(void); /* Initialize the device */ -int eth_send(void *packet, int length); /* Send a packet */ - -#if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER) -int eth_receive(void *packet, int length); /* Receive a packet*/ -extern void (*push_packet)(void *packet, int length); -#endif -int eth_rx(void); /* Check for received packets */ -void eth_halt(void); /* stop SCC */ -const char *eth_get_name(void); /* get name of current device */ -int eth_mcast_join(struct in_addr mcast_addr, int join); +#include /**********************************************************************/ /* @@ -495,16 +334,6 @@ extern char net_root_path[CONFIG_BOOTP_MAX_ROOT_PATH_LEN]; /* Our root path */ /* Indicates whether the pxe path prefix / config file was specified in dhcp option */ extern char *pxelinux_configfile; /** END OF BOOTP EXTENTIONS **/ -extern u8 net_ethaddr[ARP_HLEN]; /* Our ethernet address */ -extern u8 net_server_ethaddr[ARP_HLEN]; /* Boot server enet address */ -extern struct in_addr net_ip; /* Our IP addr (0 = unknown) */ -extern struct in_addr net_server_ip; /* Server IP addr (0 = unknown) */ -extern uchar *net_tx_packet; /* THE transmit packet */ -extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */ -extern uchar *net_rx_packet; /* Current receive packet */ -extern int net_rx_packet_len; /* Current rx packet length */ -extern const u8 net_bcast_ethaddr[ARP_HLEN]; /* Ethernet broadcast address */ -extern const u8 net_null_ethaddr[ARP_HLEN]; #define VLAN_NONE 4095 /* untagged */ #define VLAN_IDMASK 0x0fff /* mask of valid vlan id */ @@ -557,6 +386,8 @@ extern struct in_addr net_ntp_server; /* the ip address to NTP */ extern int net_ntp_time_offset; /* offset time from UTC */ #endif +int eth_mcast_join(struct in_addr mcast_addr, int join); + /* Initialize the network adapter */ int net_init(void); int net_loop(enum proto_t); @@ -827,18 +658,6 @@ static inline void net_random_ethaddr(uchar *addr) addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ } -/** - * string_to_enetaddr() - Parse a MAC address - * - * Convert a string MAC address - * - * Implemented in lib/net_utils.c (built unconditionally) - * - * @addr: MAC address in aa:bb:cc:dd:ee:ff format, where each part is a 2-digit - * hex value - * @enetaddr: Place to put MAC address (6 bytes) - */ -void string_to_enetaddr(const char *addr, uint8_t *enetaddr); /* Convert an IP address to a string */ void ip_to_string(struct in_addr x, char *s); diff --git a/include/net/arp.h b/include/net/arp.h new file mode 100644 index 0000000000..f614f0ef78 --- /dev/null +++ b/include/net/arp.h @@ -0,0 +1,7 @@ +/* ARP hardware address length */ +#define ARP_HLEN 6 +/* + * The size of a MAC address in string form, each digit requires two chars + * and five separator characters to form '00:00:00:00:00:00'. + */ +#define ARP_HLEN_ASCII (ARP_HLEN * 2) + (ARP_HLEN - 1) diff --git a/include/net/eth.h b/include/net/eth.h new file mode 100644 index 0000000000..17552bca81 --- /dev/null +++ b/include/net/eth.h @@ -0,0 +1,190 @@ +#include + +struct udevice; + +enum eth_state_t { + ETH_STATE_INIT, + ETH_STATE_PASSIVE, + ETH_STATE_ACTIVE +}; + +/** + * struct eth_pdata - Platform data for Ethernet MAC controllers + * + * @iobase: The base address of the hardware registers + * @enetaddr: The Ethernet MAC address that is loaded from EEPROM or env + * @phy_interface: PHY interface to use - see PHY_INTERFACE_MODE_... + * @max_speed: Maximum speed of Ethernet connection supported by MAC + * @priv_pdata: device specific plat + */ +struct eth_pdata { + phys_addr_t iobase; + unsigned char enetaddr[ARP_HLEN]; + int phy_interface; + int max_speed; + void *priv_pdata; +}; + +enum eth_recv_flags { + /* + * Check hardware device for new packets (otherwise only return those + * which are already in the memory buffer ready to process) + */ + ETH_RECV_CHECK_DEVICE = 1 << 0, +}; + +/** + * struct eth_ops - functions of Ethernet MAC controllers + * + * start: Prepare the hardware to send and receive packets + * send: Send the bytes passed in "packet" as a packet on the wire + * recv: Check if the hardware received a packet. If so, set the pointer to the + * packet buffer in the packetp parameter. If not, return an error or 0 to + * indicate that the hardware receive FIFO is empty. If 0 is returned, the + * network stack will not process the empty packet, but free_pkt() will be + * called if supplied + * free_pkt: Give the driver an opportunity to manage its packet buffer memory + * when the network stack is finished processing it. This will only be + * called when no error was returned from recv - optional + * stop: Stop the hardware from looking for packets - may be called even if + * state == PASSIVE + * mcast: Join or leave a multicast group (for TFTP) - optional + * write_hwaddr: Write a MAC address to the hardware (used to pass it to Linux + * on some platforms like ARM). This function expects the + * eth_pdata::enetaddr field to be populated. The method can + * return -ENOSYS to indicate that this is not implemented for + this hardware - optional. + * read_rom_hwaddr: Some devices have a backup of the MAC address stored in a + * ROM on the board. This is how the driver should expose it + * to the network stack. This function should fill in the + * eth_pdata::enetaddr field - optional + * set_promisc: Enable or Disable promiscuous mode + * get_sset_count: Number of statistics counters + * get_string: Names of the statistic counters + * get_stats: The values of the statistic counters + */ +struct eth_ops { + int (*start)(struct udevice *dev); + int (*send)(struct udevice *dev, void *packet, int length); + int (*recv)(struct udevice *dev, int flags, uchar **packetp); + int (*free_pkt)(struct udevice *dev, uchar *packet, int length); + void (*stop)(struct udevice *dev); + int (*mcast)(struct udevice *dev, const u8 *enetaddr, int join); + int (*write_hwaddr)(struct udevice *dev); + int (*read_rom_hwaddr)(struct udevice *dev); + int (*set_promisc)(struct udevice *dev, bool enable); + int (*get_sset_count)(struct udevice *dev); + void (*get_strings)(struct udevice *dev, u8 *data); + void (*get_stats)(struct udevice *dev, u64 *data); +}; + +#define eth_get_ops(dev) ((struct eth_ops *)(dev)->driver->ops) + +struct udevice *eth_get_dev(void); /* get the current device */ +/* + * The devname can be either an exact name given by the driver or device tree + * or it can be an alias of the form "eth%d" + */ +struct udevice *eth_get_dev_by_name(const char *devname); +unsigned char *eth_get_ethaddr(void); /* get the current device MAC */ + +/* Used only when NetConsole is enabled */ +int eth_is_active(struct udevice *dev); /* Test device for active state */ +int eth_init_state_only(void); /* Set active state */ +void eth_halt_state_only(void); /* Set passive state */ + +int eth_initialize(void); /* Initialize network subsystem */ +void eth_try_another(int first_restart); /* Change the device */ +void eth_set_current(void); /* set nterface to ethcur var */ + +int eth_get_dev_index(void); /* get the device index */ + +/** + * eth_env_set_enetaddr_by_index() - set the MAC address environment variable + * + * This sets up an environment variable with the given MAC address (@enetaddr). + * The environment variable to be set is defined by <@base_name><@index>addr. + * If @index is 0 it is omitted. For common Ethernet this means ethaddr, + * eth1addr, etc. + * + * @base_name: Base name for variable, typically "eth" + * @index: Index of interface being updated (>=0) + * @enetaddr: Pointer to MAC address to put into the variable + * Return: 0 if OK, other value on error + */ +int eth_env_set_enetaddr_by_index(const char *base_name, int index, + uchar *enetaddr); + + +/* + * Initialize USB ethernet device with CONFIG_DM_ETH + * Returns: + * 0 is success, non-zero is error status. + */ +int usb_ether_init(void); + +/* + * Get the hardware address for an ethernet interface . + * Args: + * base_name - base name for device (normally "eth") + * index - device index number (0 for first) + * enetaddr - returns 6 byte hardware address + * Returns: + * Return true if the address is valid. + */ +int eth_env_get_enetaddr_by_index(const char *base_name, int index, + uchar *enetaddr); + +int eth_init(void); /* Initialize the device */ +int eth_send(void *packet, int length); /* Send a packet */ + +#if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER) +int eth_receive(void *packet, int length); /* Receive a packet*/ +extern void (*push_packet)(void *packet, int length); +#endif +int eth_rx(void); /* Check for received packets */ +void eth_halt(void); /* stop SCC */ +const char *eth_get_name(void); /* get name of current device */ + +/* + * The number of receive packet buffers, and the required packet buffer + * alignment in memory. + * + */ +#define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER +#define PKTALIGN ARCH_DMA_MINALIGN + +/* Number of packets processed together */ +#define ETH_PACKETS_BATCH_RECV 32 + +extern u8 net_ethaddr[ARP_HLEN]; /* Our ethernet address */ +extern u8 net_server_ethaddr[ARP_HLEN]; /* Boot server enet address */ +extern struct in_addr net_ip; /* Our IP addr (0 = unknown) */ +extern struct in_addr net_server_ip; /* Server IP addr (0 = unknown) */ +extern uchar *net_tx_packet; /* THE transmit packet */ +extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */ +extern uchar *net_rx_packet; /* Current receive packet */ +extern int net_rx_packet_len; /* Current rx packet length */ +extern const u8 net_bcast_ethaddr[ARP_HLEN]; /* Ethernet broadcast address */ +extern const u8 net_null_ethaddr[ARP_HLEN]; + +/** + * string_to_enetaddr() - Parse a MAC address + * + * Convert a string MAC address + * + * Implemented in lib/net_utils.c (built unconditionally) + * + * @addr: MAC address in aa:bb:cc:dd:ee:ff format, where each part is a 2-digit + * hex value + * @enetaddr: Place to put MAC address (6 bytes) + */ +void string_to_enetaddr(const char *addr, uint8_t *enetaddr); + +typedef struct ulwip { + bool loop; + int err; + bool init_done; +} ulwip; + +struct ulwip *eth_lwip_priv(struct udevice *current); From patchwork Mon Aug 14 13:32:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 713483 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1243026wrp; Mon, 14 Aug 2023 06:37:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhW4wDmnbCjz/ZboHAdFF8cDUwMLFqDpJ9R0xW3YWcnkXwQ7Svf7vjGmBH3ZCcb03lMMLg X-Received: by 2002:adf:f8ce:0:b0:314:1228:c4c1 with SMTP id f14-20020adff8ce000000b003141228c4c1mr7954419wrq.23.1692020250887; Mon, 14 Aug 2023 06:37:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020250; cv=none; d=google.com; s=arc-20160816; b=N4Mel65X03ISbEm05S6tgglv45z2VOM6eoIIZm89qamrIyZpApekUDr7mhaPib/kHq Zw/NLSw4Uxsy4mt6sNMJ/yaFYsh6He3vmvxhW9lLHkRGDRWwpZRZdA38LQt4CqMixXfi 9BmG9VK89ZmTLFDtcgnX2/nAEHGT8AuNArAPWXHdq4JDX8Vm8FnTUGHAjgvDJ2yNFUyB vnAmZjprxhSpt2+mDV6ZucQ5bIEZilbpJ/9mqE9AWEzy821OVK+Jyb/vMpv1G2PRWYG2 7PSAgohoNnAyvxaxohbtfzBgbwTZNLOi1k+doftwOuIm8V9KcEuZg5yZWaMv5FXAzLQN jwYg== 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=erCd8ZSiyq6rXET12tNjhpGsxxm9NJMiH8TnEEsQ88A=; fh=KONqw1VFBW9nCv9imase+52c+XJ0MeVkzLj6SOLcJqQ=; b=CQlTP6rgNLnqeBziWV4STD51yn7SH5ath7tgSjYsTvoKc2H95I8AHCwAiExHXCP8Az 5QJjErUJKSw77ww1+FefpcXJHWuBNjhEGSQdP4s0eS104aGk6PZeZU/u3tYKUMb5rF3N F/JprzdpjxTNfej2qW9I5AfJhztap192+E3Ntl8KF/+0u7KAFaGeqUg88NA5e6yaWZi3 uoTAC1PFV7u5QRxCbJzIXXqd1xDvk0vrZReVcvQt+9A3r8r7A1V121UPyizC+DNma8wH 7Rc6QY84bMkwHykwHPaFZh0QBeCb+GlQve5wxgEGq7ICuLBlY3jxUyrnR61p6dF87Zs1 0RGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VvkHMPNy; 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 z1-20020adfec81000000b00317afc7949asi5080979wrn.766.2023.08.14.06.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:37:30 -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=VvkHMPNy; 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 7C10C869B0; Mon, 14 Aug 2023 15:35:52 +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="VvkHMPNy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 78EAD869BE; Mon, 14 Aug 2023 15:35:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) (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 3E754865B6 for ; Mon, 14 Aug 2023 15:35:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2b72161c6e9so62677711fa.0 for ; Mon, 14 Aug 2023 06:35:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692020148; x=1692624948; 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=erCd8ZSiyq6rXET12tNjhpGsxxm9NJMiH8TnEEsQ88A=; b=VvkHMPNy/I+NIJVres4/PTj2+vw1jobu7808KqFPtZs7X/kG8n+gNHiCtaeQU9/OeX /VaVk/Vq0xG+VAscySYAK//dyBQEE8bBocONOzBNxp+OqHIjDJALDn/wLB5n3dSgsrgj hjYLRoqTVpCxj0hXGBLtg8VSDAYorT1EgWNKoibSJbvHL4tqQBr+CtPZGFYUnT9E03vm 55qoVoeQYMpS8mc7honVylrJ/prsLN9rb6VWTxKAeX5n6piKYoaJ8gonFJU4vQHJwmjC z8G33DS2riB4X7CqUj2ML3ZwKREaL71lpEpr5Nu9K9LAnQ44dEcXxHcu9uD5E/F69BuU MVog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692020148; x=1692624948; 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=erCd8ZSiyq6rXET12tNjhpGsxxm9NJMiH8TnEEsQ88A=; b=S+RE+b7gGT4zrpdT9qfUbGfsAv5QZ1PGETwWo0N2jDMcil4G14B1uwRI+NQOCQ0AJV wZ/EEcFUmto1zarENNTKjE5aA43utISzPVZbuHr7UseEmp+7ccTqAUHuPz+iUSpmbQGh pkfU7aOFubnjGyxGgpnRRiapM0wQ891LV0h6uvy9Pe/xBtmZYcDNp5ueuzaUsOuXwMpJ XbAbcz1E19+s59BgopDOZDrZrpOjTi2RMtQdjmlwK8cWI5fxc2boZ53+pkVXKUsQqh82 vWo2M+k8BLAp2hs6rYehCodaC07HIs1YzEIRTWu50wlzC2rIqjeuTJ7dromY+0jjtCPN k1Tg== X-Gm-Message-State: AOJu0YwwleQxgHTUaqeK4grEz4lkdRS7oJHgZCcOX0sZkE/IW5INueUd qaGjEcBXRZBMTJxMYdwnR9F3a1bbaaL+Tga6r8k= X-Received: by 2002:a2e:834b:0:b0:2b6:d03a:5d8d with SMTP id l11-20020a2e834b000000b002b6d03a5d8dmr3062572ljh.6.1692020148188; Mon, 14 Aug 2023 06:35:48 -0700 (PDT) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9658000000b002b9415597d0sm2411102ljh.78.2023.08.14.06.35.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 06:35:47 -0700 (PDT) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: pbrobinson@redhat.com, ilias.apalodimas@linaro.org, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org, Maxim Uvarov Subject: [PATCHv6 14/14] net/lwip: drop old net/wget Date: Mon, 14 Aug 2023 19:32:53 +0600 Message-Id: <20230814133253.4150-15-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230814133253.4150-1-maxim.uvarov@linaro.org> References: <20230814133253.4150-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean After which to lwip variants of working apps we need to drop old code with all dependencies. This commit drop old wget command files. Signed-off-by: Maxim Uvarov --- include/net/wget.h | 22 --- net/Makefile | 1 - net/net.c | 6 - net/wget.c | 440 --------------------------------------------- 4 files changed, 469 deletions(-) delete mode 100644 include/net/wget.h delete mode 100644 net/wget.c diff --git a/include/net/wget.h b/include/net/wget.h deleted file mode 100644 index da0920de11..0000000000 --- a/include/net/wget.h +++ /dev/null @@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Duncan Hare Copyright 2017 - */ - -/** - * wget_start() - begin wget - */ -void wget_start(void); - -enum wget_state { - WGET_CLOSED, - WGET_CONNECTING, - WGET_CONNECTED, - WGET_TRANSFERRING, - WGET_TRANSFERRED -}; - -#define DEBUG_WGET 0 /* Set to 1 for debug messages */ -#define SERVER_PORT 80 -#define WGET_RETRY_COUNT 30 -#define WGET_TIMEOUT 2000UL diff --git a/net/Makefile b/net/Makefile index 61930c244e..eda21f988a 100644 --- a/net/Makefile +++ b/net/Makefile @@ -32,7 +32,6 @@ obj-$(CONFIG_TCP_FUNCTION_FASTBOOT) += fastboot_tcp.o obj-$(CONFIG_CMD_WOL) += wol.o obj-$(CONFIG_PROT_UDP) += udp.o obj-$(CONFIG_PROT_TCP) += tcp.o -obj-$(CONFIG_CMD_WGET) += wget.o obj-$(CONFIG_LWIP) += lwip/ # Disable this warning as it is triggered by: diff --git a/net/net.c b/net/net.c index 7f868ee516..38d34ed5f4 100644 --- a/net/net.c +++ b/net/net.c @@ -109,7 +109,6 @@ #include #include #include -#include #include "arp.h" #include "bootp.h" #include "cdp.h" @@ -566,11 +565,6 @@ restart: nfs_start(); break; #endif -#if defined(CONFIG_CMD_WGET) - case WGET: - wget_start(); - break; -#endif #if defined(CONFIG_CMD_CDP) case CDP: cdp_start(); diff --git a/net/wget.c b/net/wget.c deleted file mode 100644 index 2dbfeb1a1d..0000000000 --- a/net/wget.c +++ /dev/null @@ -1,440 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * WGET/HTTP support driver based on U-BOOT's nfs.c - * Copyright Duncan Hare 2017 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const char bootfile1[] = "GET "; -static const char bootfile3[] = " HTTP/1.0\r\n\r\n"; -static const char http_eom[] = "\r\n\r\n"; -static const char http_ok[] = "200"; -static const char content_len[] = "Content-Length"; -static const char linefeed[] = "\r\n"; -static struct in_addr web_server_ip; -static int our_port; -static int wget_timeout_count; - -struct pkt_qd { - uchar *pkt; - unsigned int tcp_seq_num; - unsigned int len; -}; - -/* - * This is a control structure for out of order packets received. - * The actual packet bufers are in the kernel space, and are - * expected to be overwritten by the downloaded image. - */ -static struct pkt_qd pkt_q[PKTBUFSRX / 4]; -static int pkt_q_idx; -static unsigned long content_length; -static unsigned int packets; - -static unsigned int initial_data_seq_num; - -static enum wget_state current_wget_state; - -static char *image_url; -static unsigned int wget_timeout = WGET_TIMEOUT; - -static enum net_loop_state wget_loop_state; - -/* Timeout retry parameters */ -static u8 retry_action; /* actions for TCP retry */ -static unsigned int retry_tcp_ack_num; /* TCP retry acknowledge number*/ -static unsigned int retry_tcp_seq_num; /* TCP retry sequence number */ -static int retry_len; /* TCP retry length */ - -/** - * store_block() - store block in memory - * @src: source of data - * @offset: offset - * @len: length - */ -static inline int store_block(uchar *src, unsigned int offset, unsigned int len) -{ - ulong newsize = offset + len; - uchar *ptr; - - ptr = map_sysmem(image_load_addr + offset, len); - memcpy(ptr, src, len); - unmap_sysmem(ptr); - - if (net_boot_file_size < (offset + len)) - net_boot_file_size = newsize; - - return 0; -} - -/** - * wget_send_stored() - wget response dispatcher - * - * WARNING, This, and only this, is the place in wget.c where - * SEQUENCE NUMBERS are swapped between incoming (RX) - * and outgoing (TX). - * Procedure wget_handler() is correct for RX traffic. - */ -static void wget_send_stored(void) -{ - u8 action = retry_action; - int len = retry_len; - unsigned int tcp_ack_num = retry_tcp_seq_num + (len == 0 ? 1 : len); - unsigned int tcp_seq_num = retry_tcp_ack_num; - uchar *ptr, *offset; - - switch (current_wget_state) { - case WGET_CLOSED: - debug_cond(DEBUG_WGET, "wget: send SYN\n"); - current_wget_state = WGET_CONNECTING; - net_send_tcp_packet(0, SERVER_PORT, our_port, action, - tcp_seq_num, tcp_ack_num); - packets = 0; - break; - case WGET_CONNECTING: - pkt_q_idx = 0; - net_send_tcp_packet(0, SERVER_PORT, our_port, action, - tcp_seq_num, tcp_ack_num); - - ptr = net_tx_packet + net_eth_hdr_size() + - IP_TCP_HDR_SIZE + TCP_TSOPT_SIZE + 2; - offset = ptr; - - memcpy(offset, &bootfile1, strlen(bootfile1)); - offset += strlen(bootfile1); - - memcpy(offset, image_url, strlen(image_url)); - offset += strlen(image_url); - - memcpy(offset, &bootfile3, strlen(bootfile3)); - offset += strlen(bootfile3); - net_send_tcp_packet((offset - ptr), SERVER_PORT, our_port, - TCP_PUSH, tcp_seq_num, tcp_ack_num); - current_wget_state = WGET_CONNECTED; - break; - case WGET_CONNECTED: - case WGET_TRANSFERRING: - case WGET_TRANSFERRED: - net_send_tcp_packet(0, SERVER_PORT, our_port, action, - tcp_seq_num, tcp_ack_num); - break; - } -} - -static void wget_send(u8 action, unsigned int tcp_seq_num, - unsigned int tcp_ack_num, int len) -{ - retry_action = action; - retry_tcp_ack_num = tcp_ack_num; - retry_tcp_seq_num = tcp_seq_num; - retry_len = len; - - wget_send_stored(); -} - -void wget_fail(char *error_message, unsigned int tcp_seq_num, - unsigned int tcp_ack_num, u8 action) -{ - printf("wget: Transfer Fail - %s\n", error_message); - net_set_timeout_handler(0, NULL); - wget_send(action, tcp_seq_num, tcp_ack_num, 0); -} - -void wget_success(u8 action, unsigned int tcp_seq_num, - unsigned int tcp_ack_num, int len, int packets) -{ - printf("Packets received %d, Transfer Successful\n", packets); - wget_send(action, tcp_seq_num, tcp_ack_num, len); -} - -/* - * Interfaces of U-BOOT - */ -static void wget_timeout_handler(void) -{ - if (++wget_timeout_count > WGET_RETRY_COUNT) { - puts("\nRetry count exceeded; starting again\n"); - wget_send(TCP_RST, 0, 0, 0); - net_start_again(); - } else { - puts("T "); - net_set_timeout_handler(wget_timeout + - WGET_TIMEOUT * wget_timeout_count, - wget_timeout_handler); - wget_send_stored(); - } -} - -#define PKT_QUEUE_OFFSET 0x20000 -#define PKT_QUEUE_PACKET_SIZE 0x800 - -static void wget_connected(uchar *pkt, unsigned int tcp_seq_num, - u8 action, unsigned int tcp_ack_num, unsigned int len) -{ - uchar *pkt_in_q; - char *pos; - int hlen, i; - uchar *ptr1; - - pkt[len] = '\0'; - pos = strstr((char *)pkt, http_eom); - - if (!pos) { - debug_cond(DEBUG_WGET, - "wget: Connected, data before Header %p\n", pkt); - pkt_in_q = (void *)image_load_addr + PKT_QUEUE_OFFSET + - (pkt_q_idx * PKT_QUEUE_PACKET_SIZE); - - ptr1 = map_sysmem((phys_addr_t)pkt_in_q, len); - memcpy(ptr1, pkt, len); - unmap_sysmem(ptr1); - - pkt_q[pkt_q_idx].pkt = pkt_in_q; - pkt_q[pkt_q_idx].tcp_seq_num = tcp_seq_num; - pkt_q[pkt_q_idx].len = len; - pkt_q_idx++; - } else { - debug_cond(DEBUG_WGET, "wget: Connected HTTP Header %p\n", pkt); - /* sizeof(http_eom) - 1 is the string length of (http_eom) */ - hlen = pos - (char *)pkt + sizeof(http_eom) - 1; - pos = strstr((char *)pkt, linefeed); - if (pos > 0) - i = pos - (char *)pkt; - else - i = hlen; - printf("%.*s", i, pkt); - - current_wget_state = WGET_TRANSFERRING; - - if (strstr((char *)pkt, http_ok) == 0) { - debug_cond(DEBUG_WGET, - "wget: Connected Bad Xfer\n"); - initial_data_seq_num = tcp_seq_num + hlen; - wget_loop_state = NETLOOP_FAIL; - wget_send(action, tcp_seq_num, tcp_ack_num, len); - } else { - debug_cond(DEBUG_WGET, - "wget: Connctd pkt %p hlen %x\n", - pkt, hlen); - initial_data_seq_num = tcp_seq_num + hlen; - - pos = strstr((char *)pkt, content_len); - if (!pos) { - content_length = -1; - } else { - pos += sizeof(content_len) + 2; - strict_strtoul(pos, 10, &content_length); - debug_cond(DEBUG_WGET, - "wget: Connected Len %lu\n", - content_length); - } - - net_boot_file_size = 0; - - if (len > hlen) - store_block(pkt + hlen, 0, len - hlen); - - debug_cond(DEBUG_WGET, - "wget: Connected Pkt %p hlen %x\n", - pkt, hlen); - - for (i = 0; i < pkt_q_idx; i++) { - ptr1 = map_sysmem( - (phys_addr_t)(pkt_q[i].pkt), - pkt_q[i].len); - store_block(ptr1, - pkt_q[i].tcp_seq_num - - initial_data_seq_num, - pkt_q[i].len); - unmap_sysmem(ptr1); - debug_cond(DEBUG_WGET, - "wget: Connctd pkt Q %p len %x\n", - pkt_q[i].pkt, pkt_q[i].len); - } - } - } - wget_send(action, tcp_seq_num, tcp_ack_num, len); -} - -/** - * wget_handler() - TCP handler of wget - * @pkt: pointer to the application packet - * @dport: destination TCP port - * @sip: source IP address - * @sport: source TCP port - * @tcp_seq_num: TCP sequential number - * @tcp_ack_num: TCP acknowledgment number - * @action: TCP action (SYN, ACK, FIN, etc) - * @len: packet length - * - * In the "application push" invocation, the TCP header with all - * its information is pointed to by the packet pointer. - */ -static void wget_handler(uchar *pkt, u16 dport, - struct in_addr sip, u16 sport, - u32 tcp_seq_num, u32 tcp_ack_num, - u8 action, unsigned int len) -{ - enum tcp_state wget_tcp_state = tcp_get_tcp_state(); - - net_set_timeout_handler(wget_timeout, wget_timeout_handler); - packets++; - - switch (current_wget_state) { - case WGET_CLOSED: - debug_cond(DEBUG_WGET, "wget: Handler: Error!, State wrong\n"); - break; - case WGET_CONNECTING: - debug_cond(DEBUG_WGET, - "wget: Connecting In len=%x, Seq=%u, Ack=%u\n", - len, tcp_seq_num, tcp_ack_num); - if (!len) { - if (wget_tcp_state == TCP_ESTABLISHED) { - debug_cond(DEBUG_WGET, - "wget: Cting, send, len=%x\n", len); - wget_send(action, tcp_seq_num, tcp_ack_num, - len); - } else { - printf("%.*s", len, pkt); - wget_fail("wget: Handler Connected Fail\n", - tcp_seq_num, tcp_ack_num, action); - } - } - break; - case WGET_CONNECTED: - debug_cond(DEBUG_WGET, "wget: Connected seq=%u, len=%x\n", - tcp_seq_num, len); - if (!len) { - wget_fail("Image not found, no data returned\n", - tcp_seq_num, tcp_ack_num, action); - } else { - wget_connected(pkt, tcp_seq_num, action, tcp_ack_num, len); - } - break; - case WGET_TRANSFERRING: - debug_cond(DEBUG_WGET, - "wget: Transferring, seq=%x, ack=%x,len=%x\n", - tcp_seq_num, tcp_ack_num, len); - - if (tcp_seq_num >= initial_data_seq_num && - store_block(pkt, tcp_seq_num - initial_data_seq_num, - len) != 0) { - wget_fail("wget: store error\n", - tcp_seq_num, tcp_ack_num, action); - return; - } - - switch (wget_tcp_state) { - case TCP_FIN_WAIT_2: - wget_send(TCP_ACK, tcp_seq_num, tcp_ack_num, len); - fallthrough; - case TCP_SYN_SENT: - case TCP_SYN_RECEIVED: - case TCP_CLOSING: - case TCP_FIN_WAIT_1: - case TCP_CLOSED: - net_set_state(NETLOOP_FAIL); - break; - case TCP_ESTABLISHED: - wget_send(TCP_ACK, tcp_seq_num, tcp_ack_num, - len); - wget_loop_state = NETLOOP_SUCCESS; - break; - case TCP_CLOSE_WAIT: /* End of transfer */ - current_wget_state = WGET_TRANSFERRED; - wget_send(action | TCP_ACK | TCP_FIN, - tcp_seq_num, tcp_ack_num, len); - break; - } - break; - case WGET_TRANSFERRED: - printf("Packets received %d, Transfer Successful\n", packets); - net_set_state(wget_loop_state); - break; - } -} - -#define RANDOM_PORT_START 1024 -#define RANDOM_PORT_RANGE 0x4000 - -/** - * random_port() - make port a little random (1024-17407) - * - * Return: random port number from 1024 to 17407 - * - * This keeps the math somewhat trivial to compute, and seems to work with - * all supported protocols/clients/servers - */ -static unsigned int random_port(void) -{ - return RANDOM_PORT_START + (get_timer(0) % RANDOM_PORT_RANGE); -} - -#define BLOCKSIZE 512 - -void wget_start(void) -{ - image_url = strchr(net_boot_file_name, ':'); - if (image_url > 0) { - web_server_ip = string_to_ip(net_boot_file_name); - ++image_url; - net_server_ip = web_server_ip; - } else { - web_server_ip = net_server_ip; - image_url = net_boot_file_name; - } - - debug_cond(DEBUG_WGET, - "wget: Transfer HTTP Server %pI4; our IP %pI4\n", - &web_server_ip, &net_ip); - - /* Check if we need to send across this subnet */ - if (net_gateway.s_addr && net_netmask.s_addr) { - struct in_addr our_net; - struct in_addr server_net; - - our_net.s_addr = net_ip.s_addr & net_netmask.s_addr; - server_net.s_addr = net_server_ip.s_addr & net_netmask.s_addr; - if (our_net.s_addr != server_net.s_addr) - debug_cond(DEBUG_WGET, - "wget: sending through gateway %pI4", - &net_gateway); - } - debug_cond(DEBUG_WGET, "URL '%s'\n", image_url); - - if (net_boot_file_expected_size_in_blocks) { - debug_cond(DEBUG_WGET, "wget: Size is 0x%x Bytes = ", - net_boot_file_expected_size_in_blocks * BLOCKSIZE); - print_size(net_boot_file_expected_size_in_blocks * BLOCKSIZE, - ""); - } - debug_cond(DEBUG_WGET, - "\nwget:Load address: 0x%lx\nLoading: *\b", image_load_addr); - - net_set_timeout_handler(wget_timeout, wget_timeout_handler); - tcp_set_tcp_handler(wget_handler); - - wget_timeout_count = 0; - current_wget_state = WGET_CLOSED; - - our_port = random_port(); - - /* - * Zero out server ether to force arp resolution in case - * the server ip for the previous u-boot command, for example dns - * is not the same as the web server ip. - */ - - memset(net_server_ethaddr, 0, 6); - - wget_send(TCP_SYN, 0, 0, 0); -}