From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alessandro Rubini Date: Thu, 30 Jul 2009 11:25:57 +0200 Subject: [U-Boot] [PATCH 2/3 V2] tftp: get tftpblocksize from cfg file and env In-Reply-To: <8124a390e4cbcfee291c7583a585c9d030aadf7a.1248943812.git.rubini @unipv.it> References: <8124a390e4cbcfee291c7583a585c9d030aadf7a.1248943812.git.rubini@ unipv.it> Message-ID: <20090730092557.GA7470@mail.gnudd.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Raising 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 --- V2: fixed a damned typo in CONFIG_ names Also, I shortened the first line. Sorry for this bad V1. net/tftp.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/net/tftp.c b/net/tftp.c index b0f1cca..34b79c4 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -86,8 +86,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; @@ -475,9 +481,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') { -- 1.6.0.2