X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=net%2Ftftp.c;h=ced45ec1f1f4aa836670115a8be30bf2e507b291;hb=3b95902d47f89f95242ac143cd2a9ed1fd196157;hp=181f0f363e70d7ad45044910d1216def34e412a7;hpb=cdc7732f3737f2bb97b77eb3d7c9da344bb73612;p=oweals%2Fu-boot.git diff --git a/net/tftp.c b/net/tftp.c index 181f0f363e..ced45ec1f1 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -19,10 +20,10 @@ /* Well known TFTP port # */ #define WELL_KNOWN_PORT 69 /* Millisecs to timeout for lost pkt */ -#define TIMEOUT 100UL +#define TIMEOUT 5000UL #ifndef CONFIG_NET_RETRY_COUNT /* # of timeouts before giving up */ -# define TIMEOUT_COUNT 1000 +# define TIMEOUT_COUNT 10 #else # define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT * 2) #endif @@ -602,7 +603,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 +698,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); @@ -711,12 +714,23 @@ void tftp_start(enum proto_t protocol) if (ep != NULL) timeout_ms = simple_strtol(ep, NULL, 10); - if (timeout_ms < 10) { - printf("TFTP timeout (%ld ms) too low, set min = 10 ms\n", + if (timeout_ms < 1000) { + printf("TFTP timeout (%ld ms) too low, set min = 1000 ms\n", timeout_ms); - timeout_ms = 10; + 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); @@ -791,6 +805,7 @@ void tftp_start(enum proto_t protocol) printf("Load address: 0x%lx\n", load_addr); puts("Loading: *\b"); tftp_state = STATE_SEND_RRQ; + efi_set_bootdev("Net", "", tftp_filename); } time_start = get_timer(0); @@ -842,7 +857,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);