(no subject)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

(no subject)

Robin Getz
I was using this when I was looking at some other recent tftp performance,
and thought I would share. I really don't think it belongs, as it is
(a) trivial and (b) mostly debug... (but I'm trying out some more things
with git).

This adds the ability to make tftp a little quieter, which saves some
time printing hash marks on the console. It also has the ability to
print some download stats for debugging network issues.

Signed-off-by: Robin Getz <rgetz at blackfin.uclinux.org>

---
 net/tftp.c |   29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index 0fa7033..9544691 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -22,6 +22,16 @@
  /* (for checking the image size) */
 #define HASHES_PER_LINE 65 /* Number of "loading" hashes per line */
 
+#ifdef CONFIG_TFTP_QUIET
+#define puts_quiet(fmt)
+#else
+#define puts_quiet(fmt) puts(fmt);
+#endif
+
+#ifdef CONFIG_TFTP_TIME
+static ulong start_time, end_time;
+#endif
+
 /*
  * TFTP operations.
  */
@@ -340,9 +350,9 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
  printf ("\n\t %lu MB received\n\t ", TftpBlockWrapOffset>>20);
  } else {
  if (((TftpBlock - 1) % 10) == 0) {
- putc ('#');
+ puts_quiet("#");
  } else if ((TftpBlock % (10 * HASHES_PER_LINE)) == 0) {
- puts ("\n\t ");
+ puts_quiet("\n\t ");
  }
  }
 
@@ -432,7 +442,12 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
  * We received the whole thing.  Try to
  * run it.
  */
- puts ("\ndone\n");
+ puts_quiet("\ndone\n");
+#ifdef CONFIG_TFTP_TIME
+ end_time = get_timer(0);
+ printf("Time to download == %ld ms\n", end_time - start_time);
+ printf("Download rate = %lld bytes/second\n", (long long)(NetBootFileXferSize) * 1000 / (end_time - start_time));
+#endif
  NetState = NETLOOP_SUCCESS;
  }
  break;
@@ -460,7 +475,7 @@ TftpTimeout (void)
 #endif
  NetStartAgain ();
  } else {
- puts ("T ");
+ puts_quiet("T ");
  NetSetTimeout (TftpTimeoutMSecs, TftpTimeout);
  TftpSend ();
  }
@@ -530,7 +545,11 @@ TftpStart (void)
 
  printf ("Load address: 0x%lx\n", load_addr);
 
- puts ("Loading: *\b");
+ puts_quiet("Loading: *\b");
+
+#ifdef CONFIG_TFTP_TIME
+ start_time = get_timer(0);
+#endif
 
  TftpTimeoutMSecs = TftpRRQTimeoutMSecs;
  TftpTimeoutCountMax = TftpRRQTimeoutCountMax;
--
1.6.0.2