diff options
author | Michael Brown <mcb30@ipxe.org> | 2021-01-22 21:05:07 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2021-01-22 21:05:07 +0000 |
commit | 8ef22d819b688e17d7e20380631caed29acc9d63 (patch) | |
tree | d1b0fa6f4499a5c04573ec4a8bd86a115f62a471 | |
parent | b99477b3fa6d4063314a313f62b7ae784bcbe710 (diff) | |
download | ipxe-8ef22d819b688e17d7e20380631caed29acc9d63.zip ipxe-8ef22d819b688e17d7e20380631caed29acc9d63.tar.gz ipxe-8ef22d819b688e17d7e20380631caed29acc9d63.tar.bz2 |
[tftp] Allow for profiling of client and server turnaround times
Provide some visibility into the turnaround times on both client and
server sides as perceived by iPXE, to assist in debugging inexplicably
slow TFTP transfers.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r-- | src/net/udp/tftp.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c index a0dac1e..3073e68 100644 --- a/src/net/udp/tftp.c +++ b/src/net/udp/tftp.c @@ -43,6 +43,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include <ipxe/settings.h> #include <ipxe/dhcp.h> #include <ipxe/uri.h> +#include <ipxe/profile.h> #include <ipxe/tftp.h> /** @file @@ -158,6 +159,14 @@ enum { /** Maximum number of MTFTP open requests before falling back to TFTP */ #define MTFTP_MAX_TIMEOUTS 3 +/** Client profiler */ +static struct profiler tftp_client_profiler __profiler = + { .name = "tftp.client" }; + +/** Server profiler */ +static struct profiler tftp_server_profiler __profiler = + { .name = "tftp.server" }; + /** * Free TFTP request * @@ -802,6 +811,10 @@ static int tftp_rx_data ( struct tftp_request *tftp, } block += ( ntohs ( data->block ) - 1 ); + /* Stop profiling server turnaround if applicable */ + if ( block ) + profile_stop ( &tftp_server_profiler ); + /* Extract data */ offset = ( block * tftp->blksize ); iob_pull ( iobuf, sizeof ( *data ) ); @@ -834,6 +847,12 @@ static int tftp_rx_data ( struct tftp_request *tftp, /* Acknowledge block */ tftp_send_packet ( tftp ); + /* Stop profiling client turnaround */ + profile_stop ( &tftp_client_profiler ); + + /* Start profiling server turnaround */ + profile_start ( &tftp_server_profiler ); + /* If all blocks have been received, finish. */ if ( bitmap_full ( &tftp->bitmap ) ) tftp_done ( tftp, 0 ); @@ -906,7 +925,10 @@ static int tftp_rx ( struct tftp_request *tftp, struct tftp_common *common = iobuf->data; size_t len = iob_len ( iobuf ); int rc = -EINVAL; - + + /* Start profiling client turnaround */ + profile_start ( &tftp_client_profiler ); + /* Sanity checks */ if ( len < sizeof ( *common ) ) { DBGC ( tftp, "TFTP %p received underlength packet length " |