On Mon, Oct 26, 2026 at 3:28 PM Marek Vasut
<[email protected]> wrote:
>
> Make timeout configurable outside of the TFTP loop invocation, and store
> the timeout in TFTP context. This is a preparatory patch for porting of
> the DFU TFTP to LwIP, which requires a different timeout than the LwIP
> default one.

There seems to be substantial overlap between this series and one I
recently sent, maybe take a look?:
https://lore.kernel.org/all/20261024-submit-lwip-tftp-combined-v1-v2-0-0f663f735...@gmail.com/

>
> Signed-off-by: Marek Vasut <[email protected]>
> ---
> Cc: Ilias Apalodimas <[email protected]>
> Cc: James Hilliard <[email protected]>
> Cc: Jerome Forissier <[email protected]>
> Cc: Lukasz Majewski <[email protected]>
> Cc: Mattijs Korpershoek <[email protected]>
> Cc: Quentin Schulz <[email protected]>
> Cc: Tom Rini <[email protected]>
> Cc: [email protected]
> ---
>  net/lwip/tftp.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/net/lwip/tftp.c b/net/lwip/tftp.c
> index 48c6eb7022a..1d0e95d826b 100644
> --- a/net/lwip/tftp.c
> +++ b/net/lwip/tftp.c
> @@ -36,6 +36,7 @@ struct tftp_ctx {
>         ulong block_count;
>         ulong hash_count;
>         ulong start_time;
> +       ulong timeout;
>         enum done_state done;
>         bool is_server;
>         bool wrq_accepted;
> @@ -59,7 +60,7 @@ static void transfer_timeout(void *arg)
>  static void restart_transfer_timeout(struct tftp_ctx *ctx)
>  {
>         sys_untimeout(transfer_timeout, ctx);
> -       sys_timeout(TFTP_TIMEOUT_MSECS, transfer_timeout, ctx);
> +       sys_timeout(ctx->timeout, transfer_timeout, ctx);
>  }
>
>  /**
> @@ -227,7 +228,7 @@ static void no_response(void *arg)
>  }
>
>  static int tftp_loop(struct net_lwip_ctx *net, ulong addr, char *fname,
> -                    ip_addr_t srvip, uint16_t srvport)
> +                    ip_addr_t srvip, uint16_t srvport, unsigned long timeout)
>  {
>         int blksize = CONFIG_TFTP_BLOCKSIZE;
>         struct tftp_ctx ctx;
> @@ -248,6 +249,7 @@ static int tftp_loop(struct net_lwip_ctx *net, ulong 
> addr, char *fname,
>         ctx.is_server = false;
>         ctx.wrq_accepted = false;
>         ctx.fname[0] = '\0';
> +       ctx.timeout = timeout;
>
>         printf("Using %s device\n", net->dev->name);
>         printf("TFTP from server %s; our IP address is %s\n",
> @@ -535,7 +537,7 @@ int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>                 goto out;
>         }
>
> -       if (tftp_loop(&net, laddr, fname, srvip, port) < 0)
> +       if (tftp_loop(&net, laddr, fname, srvip, port, TFTP_TIMEOUT_MSECS) < 
> 0)
>                 ret = CMD_RET_FAILURE;
>         else
>                 image_load_addr = laddr;
> --
> 2.53.0
>

Reply via email to