From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1964DC001DB for ; Tue, 8 Aug 2023 18:13:06 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5DF8F865BC; Tue, 8 Aug 2023 20:13:05 +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="B1Q8Fc2R"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F4DA865DE; Tue, 8 Aug 2023 20:13:04 +0200 (CEST) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7CC48863B0 for ; Tue, 8 Aug 2023 20:13:02 +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=ilias.apalodimas@linaro.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fe426b8583so52436715e9.2 for ; Tue, 08 Aug 2023 11:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691518382; x=1692123182; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=vd2POwG+P6uW8bj+ECzd4ypx3mSlf6CoMbwnoIhi880=; b=B1Q8Fc2RGVtfB4a6xBLDGcfSvWhkE3U4DRTyrKd+s9+lRFOBm8teT/5fAm31aaC4j8 DfCktIE99ftoKBeNcdog6txvh1t3pGf4nwBKUtE1fBT294Q3Cu9M1qabNpfOU/Y1zXUz v0+ki8fbnk/KPlyO2AT0UGRG7XxYfMC7y1GWqN7b5a61mAFnoEFcJQY14YIqGwYA90C9 2EtlXlNQ5v5FQf20HwjkPdUJ8oZNQsi/l3UTJ6E2J5N7EvoddOTvK+XOA3mPFEt7clSS UJaukg1dIhXoYT2Z/NTVkWomLLmybDe2Gw1/iqch1aU3BmC3XtzM0/h6EUTdfqRD10v2 t3Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691518382; x=1692123182; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vd2POwG+P6uW8bj+ECzd4ypx3mSlf6CoMbwnoIhi880=; b=VG2o5Lb7gZwuwokwOro/h52w5qpIPXrnWbmNqtwYrshe/7PPfGmPg06zE1VgNLPDiK N0nXSXhMxcNuj1WdO+u95a1JXekfhGmTajvmkmE5HWX+NWh11Gh9259zFuc6dJ9nG9qm elTt1eMeezD3Qwf+Qt95RGBN1AVjdHjJL8ymUveD0dT7xIdDs2Z75xUlq34eXEcNhzLv n1RtDgMmFGDk/HzvVd5A2f6rm+Cr9p1dAOo+I8fKUI8kIqXj4mMqHSpvXQsmjKuEGksq YY+t0uCdrBfNSdbBmXSm028iL4IHVQ6zu19393tXphRH6hSaiOoWiwZYeqemldapP7/z attQ== X-Gm-Message-State: AOJu0YyzlZxN7zgg27L02Otj8i1W8Thiua2tB5ny0c92tdNHAu02CPUj olEc5YyBaJUVyDRDwU1BlVdICw== X-Google-Smtp-Source: AGHT+IG1WywXrXx5gqkWYhgMqmIqV5GhpAyHUtrDsSLuyaD3B7YCEuOsEmHYHmNGyyl/6NtFkq0lOQ== X-Received: by 2002:a1c:7c05:0:b0:3fe:2108:eb8e with SMTP id x5-20020a1c7c05000000b003fe2108eb8emr448419wmc.34.1691518381895; Tue, 08 Aug 2023 11:13:01 -0700 (PDT) Received: from hades (ppp089210246083.access.hol.gr. [89.210.246.83]) by smtp.gmail.com with ESMTPSA id b13-20020a05600c11cd00b003fba6709c68sm14445640wmi.47.2023.08.08.11.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 11:13:01 -0700 (PDT) Date: Tue, 8 Aug 2023 21:12:59 +0300 From: Ilias Apalodimas To: Maxim Uvarov Cc: u-boot@lists.denx.de, pbrobinson@redhat.com, joe.hershberger@ni.com, rfried.dev@gmail.com, trini@konsulko.com, goldsimon@gmx.de, lwip-devel@nongnu.org Subject: Re: [PATCHv5 11/13] net/lwip: connection between cmd and lwip apps Message-ID: References: <20230802140658.10319-1-maxim.uvarov@linaro.org> <20230802140658.10319-12-maxim.uvarov@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Hi Maxim [...] > > > +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 */ > > > > I am not sure what I am reading here. You use callbacks a few lines above > > to set a timeout function. But only set it for dhcp. On top of that the > > function for DHCP has a case for a *successful* asignment of ip addresses. > > Why are we setting the state to fail? And why are we complicating this by > > assigning and removing callbacks if it's only used for dhcp? > > > > > I need two time out callbacks here: > 1. Trap rx polling loop if lwip application works too long. It is used when > code goes to net_loop() code to poll rx packets > and nobody interrupts this loop. This timeout is used for all cmds (lwip > apps). > > 2. Trap lwip application after specific timeout and then check some state. > That is case for DHCP, where LWIP DHCP does not have > callback for changing state. And I need to know when to stop polling loop. Yes but is there a reason to reassing those callback to a function ptr? Just define them and use them [...] > > > + 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) { > > > + printf("no bootfile\n"); > > > + return CMD_RET_FAILURE; > > > > Why is this a failure? You just have the tftp command enabled but dont > > want to download anything > > > > thanks, if dhcp did not return filename, but only IP, then nothing to > download. It's not an error. Yes but downloading a file is not mandatory, it depends on a DHCP option. If you want to emulate this behaviour, you need to fail only if 'bootfile' is set but cant be downloaded. > > > > > + } > > > + Regards /Ilias