Browse Source

[ipv4] Profile transmit and receive datapaths

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 years ago
parent
commit
f65c81b1d0
1 changed files with 15 additions and 0 deletions
  1. 15
    0
      src/net/ipv4.c

+ 15
- 0
src/net/ipv4.c View File

@@ -16,6 +16,7 @@
16 16
 #include <ipxe/settings.h>
17 17
 #include <ipxe/fragment.h>
18 18
 #include <ipxe/ipstat.h>
19
+#include <ipxe/profile.h>
19 20
 
20 21
 /** @file
21 22
  *
@@ -41,6 +42,12 @@ ipv4_stats_family __ip_statistics_family ( IP_STATISTICS_IPV4 ) = {
41 42
 	.stats = &ipv4_stats,
42 43
 };
43 44
 
45
+/** Transmit profiler */
46
+static struct profiler ipv4_tx_profiler __profiler = { .name = "ipv4.tx" };
47
+
48
+/** Receive profiler */
49
+static struct profiler ipv4_rx_profiler __profiler = { .name = "ipv4.rx" };
50
+
44 51
 /**
45 52
  * Add IPv4 minirouting table entry
46 53
  *
@@ -263,6 +270,9 @@ static int ipv4_tx ( struct io_buffer *iobuf,
263 270
 	const void *ll_dest;
264 271
 	int rc;
265 272
 
273
+	/* Start profiling */
274
+	profile_start ( &ipv4_tx_profiler );
275
+
266 276
 	/* Update statistics */
267 277
 	ipv4_stats.out_requests++;
268 278
 
@@ -358,6 +368,7 @@ static int ipv4_tx ( struct io_buffer *iobuf,
358 368
 		}
359 369
 	}
360 370
 
371
+	profile_stop ( &ipv4_tx_profiler );
361 372
 	return 0;
362 373
 
363 374
  err:
@@ -430,6 +441,9 @@ static int ipv4_rx ( struct io_buffer *iobuf,
430 441
 	uint16_t pshdr_csum;
431 442
 	int rc;
432 443
 
444
+	/* Start profiling */
445
+	profile_start ( &ipv4_rx_profiler );
446
+
433 447
 	/* Update statistics */
434 448
 	ipv4_stats.in_receives++;
435 449
 	ipv4_stats.in_octets += iob_len ( iobuf );
@@ -528,6 +542,7 @@ static int ipv4_rx ( struct io_buffer *iobuf,
528 542
 		return rc;
529 543
 	}
530 544
 
545
+	profile_stop ( &ipv4_rx_profiler );
531 546
 	return 0;
532 547
 
533 548
  err_header:

Loading…
Cancel
Save