All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] net: TFTP: add timer count environment variable
@ 2015-07-26  9:08 Albert ARIBAUD
  0 siblings, 0 replies; only message in thread
From: Albert ARIBAUD @ 2015-07-26  9:08 UTC (permalink / raw)
  To: 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 '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 v2: fixed env var name in commit message

 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);
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-26  9:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-26  9:08 [U-Boot] [PATCH v2] net: TFTP: add timer count environment variable Albert ARIBAUD

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.