Pārlūkot izejas kodu

[tcp] Profile transmit and receive datapaths

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 gadus atpakaļ
vecāks
revīzija
767f2acb98
1 mainītis faili ar 20 papildinājumiem un 0 dzēšanām
  1. 20
    0
      src/net/tcp.c

+ 20
- 0
src/net/tcp.c Parādīt failu

15
 #include <ipxe/open.h>
15
 #include <ipxe/open.h>
16
 #include <ipxe/uri.h>
16
 #include <ipxe/uri.h>
17
 #include <ipxe/netdevice.h>
17
 #include <ipxe/netdevice.h>
18
+#include <ipxe/profile.h>
18
 #include <ipxe/tcpip.h>
19
 #include <ipxe/tcpip.h>
19
 #include <ipxe/tcp.h>
20
 #include <ipxe/tcp.h>
20
 
21
 
155
  */
156
  */
156
 static LIST_HEAD ( tcp_conns );
157
 static LIST_HEAD ( tcp_conns );
157
 
158
 
159
+/** Transmit profiler */
160
+static struct profiler tcp_tx_profiler __profiler = { .name = "tcp.tx" };
161
+
162
+/** Receive profiler */
163
+static struct profiler tcp_rx_profiler __profiler = { .name = "tcp.rx" };
164
+
165
+/** Data transfer profiler */
166
+static struct profiler tcp_xfer_profiler __profiler = { .name = "tcp.xfer" };
167
+
158
 /* Forward declarations */
168
 /* Forward declarations */
159
 static struct interface_descriptor tcp_xfer_desc;
169
 static struct interface_descriptor tcp_xfer_desc;
160
 static void tcp_expired ( struct retry_timer *timer, int over );
170
 static void tcp_expired ( struct retry_timer *timer, int over );
502
 	uint32_t max_representable_win;
512
 	uint32_t max_representable_win;
503
 	int rc;
513
 	int rc;
504
 
514
 
515
+	/* Start profiling */
516
+	profile_start ( &tcp_tx_profiler );
517
+
505
 	/* If retransmission timer is already running, do nothing */
518
 	/* If retransmission timer is already running, do nothing */
506
 	if ( timer_running ( &tcp->timer ) )
519
 	if ( timer_running ( &tcp->timer ) )
507
 		return 0;
520
 		return 0;
613
 	/* Clear ACK-pending flag */
626
 	/* Clear ACK-pending flag */
614
 	tcp->flags &= ~TCP_ACK_PENDING;
627
 	tcp->flags &= ~TCP_ACK_PENDING;
615
 
628
 
629
+	profile_stop ( &tcp_tx_profiler );
616
 	return 0;
630
 	return 0;
617
 }
631
 }
618
 
632
 
966
 	tcp_rx_seq ( tcp, len );
980
 	tcp_rx_seq ( tcp, len );
967
 
981
 
968
 	/* Deliver data to application */
982
 	/* Deliver data to application */
983
+	profile_start ( &tcp_xfer_profiler );
969
 	if ( ( rc = xfer_deliver_iob ( &tcp->xfer, iobuf ) ) != 0 ) {
984
 	if ( ( rc = xfer_deliver_iob ( &tcp->xfer, iobuf ) ) != 0 ) {
970
 		DBGC ( tcp, "TCP %p could not deliver %08x..%08x: %s\n",
985
 		DBGC ( tcp, "TCP %p could not deliver %08x..%08x: %s\n",
971
 		       tcp, seq, ( seq + len ), strerror ( rc ) );
986
 		       tcp, seq, ( seq + len ), strerror ( rc ) );
972
 		return rc;
987
 		return rc;
973
 	}
988
 	}
989
+	profile_stop ( &tcp_xfer_profiler );
974
 
990
 
975
 	return 0;
991
 	return 0;
976
 }
992
 }
1156
 	size_t old_xfer_window;
1172
 	size_t old_xfer_window;
1157
 	int rc;
1173
 	int rc;
1158
 
1174
 
1175
+	/* Start profiling */
1176
+	profile_start ( &tcp_rx_profiler );
1177
+
1159
 	/* Sanity check packet */
1178
 	/* Sanity check packet */
1160
 	if ( iob_len ( iobuf ) < sizeof ( *tcphdr ) ) {
1179
 	if ( iob_len ( iobuf ) < sizeof ( *tcphdr ) ) {
1161
 		DBG ( "TCP packet too short at %zd bytes (min %zd bytes)\n",
1180
 		DBG ( "TCP packet too short at %zd bytes (min %zd bytes)\n",
1268
 	if ( tcp_xfer_window ( tcp ) != old_xfer_window )
1287
 	if ( tcp_xfer_window ( tcp ) != old_xfer_window )
1269
 		xfer_window_changed ( &tcp->xfer );
1288
 		xfer_window_changed ( &tcp->xfer );
1270
 
1289
 
1290
+	profile_stop ( &tcp_rx_profiler );
1271
 	return 0;
1291
 	return 0;
1272
 
1292
 
1273
  discard:
1293
  discard:

Notiek ielāde…
Atcelt
Saglabāt