summaryrefslogtreecommitdiff
path: root/net/tftp.c
diff options
context:
space:
mode:
authorAlessandro Rubini <rubini-list@gnudd.com>2009-08-07 13:59:06 +0200
committerBen Warren <biggerbadderben@gmail.com>2009-08-25 13:35:54 -0700
commit89ba81d1079a07b8430a98c1746c6d411312eb0d (patch)
treeb04c80d57906d00ee3f055c4f58468e54458f339 /net/tftp.c
parent5cfaa4e54d0eb8232fa1cf092d955fdaed5b673d (diff)
downloadu-boot-imx-89ba81d1079a07b8430a98c1746c6d411312eb0d.zip
u-boot-imx-89ba81d1079a07b8430a98c1746c6d411312eb0d.tar.gz
u-boot-imx-89ba81d1079a07b8430a98c1746c6d411312eb0d.tar.bz2
tftp: get the tftp block size from config file and from the environment
Increasing the block size is useful if CONFIG_IP_DEFRAG is used. Howerver, the last fragments in a burst may overflow the receiving ethernet, so the default is left at 1468, with thre new CONFIG_TFTP_BLOCKSIZE for config files. Further, "tftpblocksize" can be set in the environment. Signed-off-by: Alessandro Rubini <rubini@gnudd.com> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
Diffstat (limited to 'net/tftp.c')
-rw-r--r--net/tftp.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/net/tftp.c b/net/tftp.c
index fb98a34..0fd6c65 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -84,8 +84,14 @@ extern flash_info_t flash_info[];
/* 512 is poor choice for ethernet, MTU is typically 1500.
* Minus eth.hdrs thats 1468. Can get 2x better throughput with
* almost-MTU block sizes. At least try... fall back to 512 if need be.
+ * (but those using CONFIG_IP_DEFRAG may want to set a larger block in cfg file)
*/
+#ifdef CONFIG_TFTP_BLOCKSIZE
+#define TFTP_MTU_BLOCKSIZE CONFIG_TFTP_BLOCKSIZE
+#else
#define TFTP_MTU_BLOCKSIZE 1468
+#endif
+
static unsigned short TftpBlkSize=TFTP_BLOCK_SIZE;
static unsigned short TftpBlkSizeOption=TFTP_MTU_BLOCKSIZE;
@@ -466,9 +472,12 @@ TftpTimeout (void)
void
TftpStart (void)
{
-#ifdef CONFIG_TFTP_PORT
char *ep; /* Environment pointer */
-#endif
+
+ /* Allow the user to choose tftpblocksize */
+ if ((ep = getenv("tftpblocksize")) != NULL)
+ TftpBlkSizeOption = simple_strtol(ep, NULL, 10);
+ debug("tftp block size is %i\n", TftpBlkSizeOption);
TftpServerIP = NetServerIP;
if (BootFile[0] == '\0') {