From patchwork Tue Apr 15 21:17:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 881389 Delivered-To: patch@linaro.org Received: by 2002:adf:f902:0:b0:38f:210b:807b with SMTP id b2csp665202wrr; Tue, 15 Apr 2025 14:18:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXJDlnz9Qen+TCfi4bmYlK6+nJaSBNxRkVL6fDRydXITk2y9+xDww7tY4ua1ZpczX0eNRzQyQ==@linaro.org X-Google-Smtp-Source: AGHT+IEoRGjIstQibmIeGU13CXPUV9BwkGZEkZh9toRUbic8/eoGpe64wAvTBaoLaYG61m+KWjxY X-Received: by 2002:a05:6102:232d:b0:4c4:f128:3abb with SMTP id ada2fe7eead31-4cb52b3025fmr764146137.25.1744751935822; Tue, 15 Apr 2025 14:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1744751935; cv=none; d=google.com; s=arc-20240605; b=W2O7EtoG2Yt8Ei4kdkmxcSJQXdT3/2WJDodq/swaC7lpoyjPeWs/SZLOOQLdvvWUui MP7aKPOdaA8R5CIoY4rzx7Pvoo79NZrFuLtCbyS8BJuv8MRsBC0kVh9ZJCcvX2ClgQTx I3DfdcEwyGEodXMlAbR6BjuUtmwsJxbCLVYeTtgPDjjCw8LFIypZYnDL+PxRV4v7CA46 UWJ2kB7jvx/MNm2d7Sst1nm28ReHmG/7YSXLawHGlO5xaKcILJX70M7bMHs1R3NcE1kx fKly08suZQ2C96LRZ+V0PGMVWr8yp5yuBVbIYcICkH7ct2vIyY1MtB/4aY20gPpEG33s trHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=2ANPgtDsQY053tw/r36729R0Xr04aCUCw3FmvtbCeqo=; fh=aUEz3jQF1GWiQLmHzH76kjaLT2+91I7bl4JQ6tJdHG0=; b=HQuI1MH5D2X4C1/SnRMiAcuM75eHGwSOYldoLm6/RQY6qH7cdbrpTsIwM8fCW1j6Gj ZmaDqfMNdXUZsuT6Agi9xGV+JKFrahMNqwVzkAYKfR005wpObeVDiSeqiWcXkkIo3t8O fHKkNdKpnq3IyHzHwHB1MYUaaJ3WkW3R1/7yQ3px+3PT3i4DvAAKPhO4wQ4mEken/yNx FHZDLKb00MacTKuAqafv37/mk7L/29DRcT8vaWvtTAroJb/INMyq/2gwygQ4rfYbozds ReZESQ6cpxSsv73os4cXUpbyAtHj2USuEgkRBBmU5YLJhD86tjmfHbx5as4c3DhzErEY Pdzw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UXrA/d+Z"; 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; dara=neutral header.i=@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 ada2fe7eead31-4c9c9890ea5si4935682137.330.2025.04.15.14.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Apr 2025 14:18:55 -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="UXrA/d+Z"; 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; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 83C3F82BA2; Tue, 15 Apr 2025 23:18:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="UXrA/d+Z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7C37082B97; Tue, 15 Apr 2025 23:18: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,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 CDDB78209C for ; Tue, 15 Apr 2025 23:18:31 +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=jerome.forissier@linaro.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-43cf58eea0fso31290695e9.0 for ; Tue, 15 Apr 2025 14:18:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1744751911; x=1745356711; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2ANPgtDsQY053tw/r36729R0Xr04aCUCw3FmvtbCeqo=; b=UXrA/d+ZwDN7lz+iGeYt7erqR+fzyakpW4TOduKX9Tm5jChWYXd5p9RJZtu7RSqXSN 0isFhXtSICBIrzZICZK0K4xTIdKm4iXorG2HCeMSST+wA34RWSPkVuyoxQmBwbp+EuPt 0fJu5ElVFJWnVWnHo8cbesoVDlfVJTNwPTkYCRnjGn2MiPxQ2Y/PFqEz9OuQKUj4HBKK wfLgVEDIITjA+Q3zAaSe+zWzh04XXfLTn9O7rzk3AZnNQG7h9VWX6U9OASZctz7MzfHI J2hGq674kg+b8LcYw5SM+kbGljbFP2B7jSKF8sJctB6l9/TMahL3vd7i0+WC4JxlcHPW clgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744751911; x=1745356711; 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=2ANPgtDsQY053tw/r36729R0Xr04aCUCw3FmvtbCeqo=; b=Io8xQEhbANoVZEqj4mRO/LTA1//NnH8YExaCiMNL3wEMs57m/q3SpPNzJAS7xUsfcB +Pgsl8ZQjlnkRk/zZb2Ml7xc/EKWSJv4BGCOHC9xXtlYfbLxjhNZRdifrIlYYKnFPd0d 29Zzbr1kTDm/IUC8a+OoCd33zP1SedFupMqzTKSVepnsH1C06MAoy8GifLB1cdKI1d92 o+9E2rns79K3ZFl1AxMvYab+0Wi4VRpQ9Mp3IUyqdxSZBV4+CvLSxrmIiXcKcEalczRK mA4+vxStj9QWAZuK+VzHURf+5PaRNRsOkZPpLxc1kQOHnDatB5ctAHCNvdLRuJ2DA6cm URQw== X-Gm-Message-State: AOJu0Yx4OWvxasRhEk1cBEBG0aa4PqIhqh0Oyv265hcb6O1qeMHiWVoI S0hOplRZTG6nfdgt0giLbRKo1A7T1il+rdWWsKXAl+9a0gABdz4tdDqHxewZdnI6RkytqqD0grP WAXY= X-Gm-Gg: ASbGncuIlUk8jTNXyF/skyZFC1eXuWS5Ae/G/+44gjG8668u3lcYZ9LrjihwvxPZXsm owDHDhpPWcMbidYWCgeM2i8N7Qa4osveVQoZMwE98FXvQnD2u44HMqe8ytt/+Q6psBDQba87o9a Lw04hfbnFG+Pb/pezkkyiJ0FaZTG5WbnEJpp7R4JB1jmtRWoTbblPV7mgfNtXm67OU2xs224J4k 0NPOvTbpIKdnH8mvrKuiTw5Ma4Q0WrUeVvVIteOhoJqQqVnhzJZ7MF4kX8cmF9qtkkt5Sz3q5V9 e82Q8A3mlZscRQp43VrfZHtzKgrQrvkM/i8QwTDkgKrCCwCn X-Received: by 2002:a05:600c:1990:b0:43c:fe90:1279 with SMTP id 5b1f17b1804b1-4405a0f74dcmr4122895e9.21.1744751911085; Tue, 15 Apr 2025 14:18:31 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:6ebc:6ce:770e:95f9]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39eaf43cce3sm15530917f8f.74.2025.04.15.14.18.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Apr 2025 14:18:30 -0700 (PDT) From: Jerome Forissier To: U-Boot mailing list Cc: Jerome Forissier , Simon Glass , Adriano Cordova , Heinrich Schuchardt , Ilias Apalodimas , Joe Hershberger , Marek Vasut , Mikhail Kshevetskiy , Ramon Fried , Tom Rini Subject: [PATCH v2 02/11] net: lwip: provide net_start_again() Date: Tue, 15 Apr 2025 23:17:37 +0200 Message-ID: <20250415211819.1254435-3-jerome.forissier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250415211819.1254435-1-jerome.forissier@linaro.org> References: <20250415211819.1254435-1-jerome.forissier@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 net_start_again() when NET_LWIP=y in a very similar way to NET. This will be used in a future commit to determine if a failed ping needs to be tried again on a different interface. Signed-off-by: Jerome Forissier Reviewed-by: Simon Glass --- (no changes since v1) include/net-common.h | 3 +++ include/net-legacy.h | 3 --- net/lwip/net-lwip.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/include/net-common.h b/include/net-common.h index 30860f5975a..0b7edd7d76b 100644 --- a/include/net-common.h +++ b/include/net-common.h @@ -471,6 +471,9 @@ static inline struct in_addr env_get_ip(char *var) int net_init(void); +/* Called when a network operation fails to know if it should be re-tried */ +int net_start_again(void); + /* NET compatibility */ enum proto_t; int net_loop(enum proto_t protocol); diff --git a/include/net-legacy.h b/include/net-legacy.h index bc0f0cde9fe..51780999a88 100644 --- a/include/net-legacy.h +++ b/include/net-legacy.h @@ -347,9 +347,6 @@ extern int net_ntp_time_offset; /* offset time from UTC */ int net_loop(enum proto_t); -/* Load failed. Start again. */ -int net_start_again(void); - /* Get size of the ethernet header when we send */ int net_eth_hdr_size(void); diff --git a/net/lwip/net-lwip.c b/net/lwip/net-lwip.c index 6748008736b..d566f9f8e6b 100644 --- a/net/lwip/net-lwip.c +++ b/net/lwip/net-lwip.c @@ -21,6 +21,8 @@ #if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER) void (*push_packet)(void *, int len) = 0; #endif +static int net_try_count; +static int net_restarted; int net_restart_wrap; static uchar net_pkt_buf[(PKTBUFSRX) * PKTSIZE_ALIGN + PKTALIGN]; uchar *net_rx_packets[PKTBUFSRX]; @@ -339,3 +341,42 @@ u32_t sys_now(void) { return get_timer(0); } + +int net_start_again(void) +{ + char *nretry; + int retry_forever = 0; + unsigned long retrycnt = 0; + + nretry = env_get("netretry"); + if (nretry) { + if (!strcmp(nretry, "yes")) + retry_forever = 1; + else if (!strcmp(nretry, "no")) + retrycnt = 0; + else if (!strcmp(nretry, "once")) + retrycnt = 1; + else + retrycnt = simple_strtoul(nretry, NULL, 0); + } else { + retrycnt = 0; + retry_forever = 0; + } + + if ((!retry_forever) && (net_try_count > retrycnt)) { + eth_halt(); + /* + * We don't provide a way for the protocol to return an error, + * but this is almost always the reason. + */ + return -ETIMEDOUT; + } + + net_try_count++; + + eth_halt(); +#if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER) + eth_try_another(!net_restarted); +#endif + return eth_init(); +}