diff options
author | Wolfgang Denk <wd@denx.de> | 2010-01-17 23:55:53 +0100 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2010-03-21 22:22:44 +0100 |
commit | c96f86eefc215b67dd222694ce2b6f60e6a42b0b (patch) | |
tree | 9d076d61d88189965bd24eb0102c199e4c6d5b40 /net | |
parent | 252b404d954f91499a4477a3e1064eb237ce5a1c (diff) | |
download | u-boot-imx-c96f86eefc215b67dd222694ce2b6f60e6a42b0b.zip u-boot-imx-c96f86eefc215b67dd222694ce2b6f60e6a42b0b.tar.gz u-boot-imx-c96f86eefc215b67dd222694ce2b6f60e6a42b0b.tar.bz2 |
TFTP: allow for adjustable retransmission timout
So far, TFTP negotiated a fixed retransmission timeout of 5 seconds.
In some cases (busy networks, slow TFTP servers) this caused very
slow transfers. A new environment variable "tftptimeout" allows to
set this timeout. Lowering this value may make downloads succeed
faster in networks with high packet loss rates or with unreliable
TFTP servers.
Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Ben Warren <biggerbadderben@gmail.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/tftp.c | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -211,7 +211,7 @@ TftpSend (void) pkt += 5 /*strlen("octet")*/ + 1; strcpy ((char *)pkt, "timeout"); pkt += 7 /*strlen("timeout")*/ + 1; - sprintf((char *)pkt, "%lu", TIMEOUT / 1000); + sprintf((char *)pkt, "%lu", TftpTimeoutMSecs / 1000); debug("send option \"timeout %s\"\n", (char *)pkt); pkt += strlen((char *)pkt) + 1; #ifdef CONFIG_TFTP_TSIZE @@ -413,7 +413,6 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len) } TftpLastBlock = TftpBlock; - TftpTimeoutMSecs = TIMEOUT; TftpTimeoutCountMax = TIMEOUT_COUNT; NetSetTimeout (TftpTimeoutMSecs, TftpTimeout); @@ -528,10 +527,25 @@ TftpStart (void) { char *ep; /* Environment pointer */ - /* Allow the user to choose tftpblocksize */ + /* + * Allow the user to choose TFTP blocksize and timeout. + * TFTP protocol has a minimal timeout of 1 second. + */ if ((ep = getenv("tftpblocksize")) != NULL) TftpBlkSizeOption = simple_strtol(ep, NULL, 10); - debug("tftp block size is %i\n", TftpBlkSizeOption); + + if ((ep = getenv("tftptimeout")) != NULL) + TftpTimeoutMSecs = simple_strtol(ep, NULL, 10); + + if (TftpTimeoutMSecs < 1000) { + printf("TFTP timeout (%ld ms) too low, " + "set minimum = 1000 ms\n", + TftpTimeoutMSecs); + TftpTimeoutMSecs = 1000; + } + + debug("TFTP blocksize = %i, timeout = %ld ms\n", + TftpBlkSizeOption, TftpTimeoutMSecs); TftpServerIP = NetServerIP; if (BootFile[0] == '\0') { @@ -588,7 +602,6 @@ TftpStart (void) puts ("Loading: *\b"); - TftpTimeoutMSecs = TftpRRQTimeoutMSecs; TftpTimeoutCountMax = TftpRRQTimeoutCountMax; NetSetTimeout (TftpTimeoutMSecs, TftpTimeout); |