]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
net: TFTP: variables cleanup and addition
authorAlbert ARIBAUD \(3ADEV\) <albert.aribaud@3adev.fr>
Sun, 11 Oct 2015 22:02:57 +0000 (00:02 +0200)
committerJoe Hershberger <joe.hershberger@ni.com>
Wed, 28 Oct 2015 19:42:24 +0000 (14:42 -0500)
TFTP source and destination port variable names are
'tftpsrcp' and 'tftpdstp' in the code, but 'tftpsrcport'
and 'tftpdstport' in the README file. Fix the README.

Add environment variable 'tftptimeoutcountmax'. As per the
comments about the global variable tftp_timeout_count_max,
make sure tftptimeoutcountmax is nonnegative.

Introduce configuration option CONFIG_NET_TFTP_VARS,
which controls whether environment variables tftpblocksize,
tftptimeout, and tftptimoueoutcountmax are read by the TFTP
client code. CONFIG_NET_TFTP_VARS defaults to y but can be
set to n by targets with to tight size contraints.

Make bf527-ezkit set CONFIG_NET_TFTP_VARS to n to keep the
target size below limit.

README
configs/bf527-ezkit_defconfig
net/Kconfig
net/tftp.c

diff --git a/README b/README
index d18df54ec9a14d662f4a6495b45aa92c61aa9962..c0a9ea0ed8b6be651dc8b97439fab713b8ca3522 100644 (file)
--- a/README
+++ b/README
@@ -5450,10 +5450,10 @@ List of environment variables (most likely not complete):
                  unset, then it will be made silent if the U-Boot console
                  is silent.
 
-  tftpsrcport  - If this is set, the value is used for TFTP's
+  tftpsrcp     - If this is set, the value is used for TFTP's
                  UDP source port.
 
-  tftpdstport  - If this is set, the value is used for TFTP's UDP
+  tftpdstp     - If this is set, the value is used for TFTP's UDP
                  destination port instead of the Well Know Port 69.
 
   tftpblocksize - Block size to use for TFTP transfers; if not set,
@@ -5467,6 +5467,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.
index 2e75225c10c000c67a6bc2972e5f1e9fbfd0e72a..0cc81cc44c1551db343d1d0d00a09f1b045373d7 100644 (file)
@@ -4,3 +4,4 @@ CONFIG_TARGET_BF527_EZKIT=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPI_FLASH=y
 CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y
+CONFIG_NET_TFTP_VARS=n
index 77a2f7e07e012b75bd72f1b48cf1e37a0117f320..a44a783cae239e54cd572149024f8c84743d726c 100644 (file)
@@ -22,4 +22,14 @@ config NETCONSOLE
          Support the 'nc' input/output device for networked console.
          See README.NetConsole for details.
 
+config NET_TFTP_VARS
+       bool "Control TFTP timeout and count through environment"
+       default y
+       help
+         If set, allows controlling the TFTP timeout through the
+         environment variable tftptimeout, and the TFTP maximum
+         timeout count through the variable tftptimeoutcountmax.
+         If unset, timeout and maximum are hard-defined as 1 second
+         and 10 timouts per TFTP transfer.
+
 endif   # if NET
index 1a5113179ac54862b399593ff2419a6745d8ccf9..f2889fe4c9bda3ab1338b9b0f68aa822947f7c4a 100644 (file)
@@ -602,7 +602,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);
@@ -697,12 +697,14 @@ static void tftp_timeout_handler(void)
 
 void tftp_start(enum proto_t protocol)
 {
+#if CONFIG_NET_TFTP_VARS
        char *ep;             /* Environment pointer */
 
        /*
         * Allow the user to choose TFTP blocksize and timeout.
         * TFTP protocol has a minimal timeout of 1 second.
         */
+
        ep = getenv("tftpblocksize");
        if (ep != NULL)
                tftp_block_size_option = simple_strtol(ep, NULL, 10);
@@ -717,6 +719,17 @@ 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;
+       }
+#endif
+
        debug("TFTP blocksize = %i, timeout = %ld ms\n",
              tftp_block_size_option, timeout_ms);
 
@@ -842,7 +855,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);