summaryrefslogtreecommitdiffstats
path: root/src/net/tcp.c
diff options
context:
space:
mode:
authorMichael Brown2014-04-28 13:30:57 +0200
committerMichael Brown2014-04-28 13:30:57 +0200
commit767f2acb98a1ae2837d7ecf9ae3ed9d6c4a977b0 (patch)
tree0a06395685d0e6e27440586d8e51d60aa39f1b93 /src/net/tcp.c
parent[ipv4] Profile transmit and receive datapaths (diff)
downloadipxe-767f2acb98a1ae2837d7ecf9ae3ed9d6c4a977b0.tar.gz
ipxe-767f2acb98a1ae2837d7ecf9ae3ed9d6c4a977b0.tar.xz
ipxe-767f2acb98a1ae2837d7ecf9ae3ed9d6c4a977b0.zip
[tcp] Profile transmit and receive datapaths
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/tcp.c')
-rw-r--r--src/net/tcp.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/net/tcp.c b/src/net/tcp.c
index 3fbcfd0c..1c48769a 100644
--- a/src/net/tcp.c
+++ b/src/net/tcp.c
@@ -15,6 +15,7 @@
#include <ipxe/open.h>
#include <ipxe/uri.h>
#include <ipxe/netdevice.h>
+#include <ipxe/profile.h>
#include <ipxe/tcpip.h>
#include <ipxe/tcp.h>
@@ -155,6 +156,15 @@ struct tcp_rx_queued_header {
*/
static LIST_HEAD ( tcp_conns );
+/** Transmit profiler */
+static struct profiler tcp_tx_profiler __profiler = { .name = "tcp.tx" };
+
+/** Receive profiler */
+static struct profiler tcp_rx_profiler __profiler = { .name = "tcp.rx" };
+
+/** Data transfer profiler */
+static struct profiler tcp_xfer_profiler __profiler = { .name = "tcp.xfer" };
+
/* Forward declarations */
static struct interface_descriptor tcp_xfer_desc;
static void tcp_expired ( struct retry_timer *timer, int over );
@@ -502,6 +512,9 @@ static int tcp_xmit ( struct tcp_connection *tcp ) {
uint32_t max_representable_win;
int rc;
+ /* Start profiling */
+ profile_start ( &tcp_tx_profiler );
+
/* If retransmission timer is already running, do nothing */
if ( timer_running ( &tcp->timer ) )
return 0;
@@ -613,6 +626,7 @@ static int tcp_xmit ( struct tcp_connection *tcp ) {
/* Clear ACK-pending flag */
tcp->flags &= ~TCP_ACK_PENDING;
+ profile_stop ( &tcp_tx_profiler );
return 0;
}
@@ -966,11 +980,13 @@ static int tcp_rx_data ( struct tcp_connection *tcp, uint32_t seq,
tcp_rx_seq ( tcp, len );
/* Deliver data to application */
+ profile_start ( &tcp_xfer_profiler );
if ( ( rc = xfer_deliver_iob ( &tcp->xfer, iobuf ) ) != 0 ) {
DBGC ( tcp, "TCP %p could not deliver %08x..%08x: %s\n",
tcp, seq, ( seq + len ), strerror ( rc ) );
return rc;
}
+ profile_stop ( &tcp_xfer_profiler );
return 0;
}
@@ -1156,6 +1172,9 @@ static int tcp_rx ( struct io_buffer *iobuf,
size_t old_xfer_window;
int rc;
+ /* Start profiling */
+ profile_start ( &tcp_rx_profiler );
+
/* Sanity check packet */
if ( iob_len ( iobuf ) < sizeof ( *tcphdr ) ) {
DBG ( "TCP packet too short at %zd bytes (min %zd bytes)\n",
@@ -1268,6 +1287,7 @@ static int tcp_rx ( struct io_buffer *iobuf,
if ( tcp_xfer_window ( tcp ) != old_xfer_window )
xfer_window_changed ( &tcp->xfer );
+ profile_stop ( &tcp_rx_profiler );
return 0;
discard: