]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[tcp] Profile transmit and receive datapaths
authorMichael Brown <mcb30@ipxe.org>
Mon, 28 Apr 2014 11:30:57 +0000 (12:30 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 28 Apr 2014 11:30:57 +0000 (12:30 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/tcp.c

index 3fbcfd0c15aef3972167123bdf9aea8dca471dd7..1c48769ac6e55a10f3a579a3d43e83d917a8ec28 100644 (file)
@@ -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: