[U-Boot] [PATCH v3] net: TFTP: add timer count environment variable

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 'tftptimeoutcountmax'. As per the comments about the global variable tftp_timeout_count_max, make sure tftptimeoutcountmax is nonnegative.
Signed-off-by: Albert ARIBAUD (3ADEV) albert.aribaud@3adev.fr ---
Changes in v3: - fixed mixup between tctp_timeout_count_max and timeout_count_max.
Changes in v2: - fixed env var name in commit message
README | 8 ++++++++ net/tftp.c | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/README b/README index 4e0ff9f..56784b1 100644 --- a/README +++ b/README @@ -5477,6 +5477,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..715fe04 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -600,7 +600,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip, }
tftp_prev_block = tftp_cur_block; - timeout_count_max = TIMEOUT_COUNT; + timeout_count_max = tftp_timeout_count_max; net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
store_block(tftp_cur_block - 1, pkt + 2, len); @@ -715,6 +715,16 @@ void tftp_start(enum proto_t protocol) timeout_ms = 1000; }
+ ep = getenv("tftptimeoutcountmax"); + if (ep != NULL) + tftp_timeout_count_max = simple_strtol(ep, NULL, 10); + + if (tftp_timeout_count_max < 0) { + printf("TFTP timeout count max (%d ms) negative, set to 0\n", + tftp_timeout_count_max); + tftp_timeout_count_max = 0; + } + debug("TFTP blocksize = %i, timeout = %ld ms\n", tftp_block_size_option, timeout_ms);
@@ -840,7 +850,7 @@ void tftp_start_server(void)
puts("Loading: *\b");
- timeout_count_max = TIMEOUT_COUNT; + timeout_count_max = tftp_timeout_count_max; timeout_count = 0; timeout_ms = TIMEOUT; net_set_timeout_handler(timeout_ms, tftp_timeout_handler);

Hi Albert,
On Sun, Jul 26, 2015 at 4:53 PM, Albert ARIBAUD (3ADEV) albert.aribaud@3adev.fr wrote:
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 'tftptimeoutcountmax'. As per the comments about the global variable tftp_timeout_count_max, make sure tftptimeoutcountmax is nonnegative.
Signed-off-by: Albert ARIBAUD (3ADEV) albert.aribaud@3adev.fr
Acked-by: Joe Hershberger joe.hershberger@ni.com

Hi Albert,
On Sun, Jul 26, 2015 at 4:53 PM, Albert ARIBAUD (3ADEV) albert.aribaud@3adev.fr wrote:
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 'tftptimeoutcountmax'. As per the comments about the global variable tftp_timeout_count_max, make sure tftptimeoutcountmax is nonnegative.
Signed-off-by: Albert ARIBAUD (3ADEV) albert.aribaud@3adev.fr
This patch seems to break the bf527-ezkit target. Just a bit too much code.
+(bf527-ezkit) actual: 262240 bytes +(bf527-ezkit) excess: 96 bytes
Anything you can do? Maybe Sonic has some advise or can recommend something else to disable on blackfin. These targets are fairly tedious because they are always so close to breaking for any little reason.
-Joe

Hi Joe,
Le Wed, 12 Aug 2015 12:39:46 -0500, Joe Hershberger joe.hershberger@gmail.com a écrit :
Hi Albert,
On Sun, Jul 26, 2015 at 4:53 PM, Albert ARIBAUD (3ADEV) albert.aribaud@3adev.fr wrote:
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 'tftptimeoutcountmax'. As per the comments about the global variable tftp_timeout_count_max, make sure tftptimeoutcountmax is nonnegative.
Signed-off-by: Albert ARIBAUD (3ADEV) albert.aribaud@3adev.fr
This patch seems to break the bf527-ezkit target. Just a bit too much code.
+(bf527-ezkit) actual: 262240 bytes +(bf527-ezkit) excess: 96 bytes
Anything you can do? Maybe Sonic has some advise or can recommend something else to disable on blackfin. These targets are fairly tedious because they are always so close to breaking for any little reason.
Hmm... I'll see if I can rewrite the patch, but seeing as it is fairly simple, it might require drastic change like not warning if going below the RFC's 1000 ms limit.
-Joe
Cordialement, Albert ARIBAUD 3ADEV
participants (3)
-
Albert ARIBAUD
-
Albert ARIBAUD (3ADEV)
-
Joe Hershberger