From patchwork Sun Jul 26 09:01:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 500039 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 5C33C1402ED for ; Sun, 26 Jul 2015 19:01:33 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4111D4B622; Sun, 26 Jul 2015 11:01:31 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sfAWJ7f31xCp; Sun, 26 Jul 2015 11:01:30 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9FA744B615; Sun, 26 Jul 2015 11:01:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CA6CB4B615 for ; Sun, 26 Jul 2015 11:01:28 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6OqmY-kCGuc3 for ; Sun, 26 Jul 2015 11:01:28 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp2-g21.free.fr (smtp2-g21.free.fr [212.27.42.2]) by theia.denx.de (Postfix) with ESMTPS id A52274A03A for ; Sun, 26 Jul 2015 11:01:24 +0200 (CEST) Received: from localhost.localdomain (unknown [82.235.144.2]) (Authenticated sender: aribaud.smtp) by smtp2-g21.free.fr (Postfix) with ESMTPSA id 0345D4B00BC for ; Sun, 26 Jul 2015 11:01:23 +0200 (CEST) From: "Albert ARIBAUD (3ADEV)" To: u-boot@lists.denx.de Date: Sun, 26 Jul 2015 11:01:22 +0200 Message-Id: <1437901282-27374-1-git-send-email-albert.aribaud@3adev.fr> X-Mailer: git-send-email 2.1.4 Subject: [U-Boot] [PATCH] net: TFTP: add timer count environment variable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" There already is an environment variable 'tftptimeout' for setting individuabl block query timeout value, but there is none for setting the maximum TFTP timeout count, which can also help with unreliable network, TFTP server, or client hardware. Add environment variable 'tftptimeoutcount'. As per the comments about the global variable tftp_timeout_count_max, make sure tftptimeoutcount is nonnegative. Signed-off-by: Albert ARIBAUD (3ADEV) --- README | 8 ++++++++ net/tftp.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/README b/README index b564640..c9dea37 100644 --- a/README +++ b/README @@ -5474,6 +5474,14 @@ List of environment variables (most likely not complete): faster in networks with high packet loss rates or with unreliable TFTP servers. + tftptimeoutcountmax - maximum count of TFTP timeouts (no + unit, minimum value = 0). Defines how many timeouts + can happen during a single file transfer before that + transfer is aborted. The default is 10, and 0 means + 'no timeouts allowed'. Increasing this value may help + downloads succeed with high packet loss rates, or with + unreliable TFTP servers or client hardware. + vlan - When set to a value < 4095 the traffic over Ethernet is encapsulated/received over 802.1q VLAN tagged frames. diff --git a/net/tftp.c b/net/tftp.c index 3e99e73..fd44eb2 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -715,6 +715,16 @@ void tftp_start(enum proto_t protocol) timeout_ms = 1000; } + ep = getenv("tftptimeoutcountmax"); + if (ep != NULL) + timeout_count_max = simple_strtol(ep, NULL, 10); + + if (timeout_count_max < 0) { + printf("TFTP timeout count max (%d ms) negative, set to 0\n", + timeout_count_max); + timeout_count_max = 0; + } + debug("TFTP blocksize = %i, timeout = %ld ms\n", tftp_block_size_option, timeout_ms);