Browse Source

[netdevice] Profile common operations

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

+ 16
- 0
src/net/netdevice.c View File

34
 #include <ipxe/malloc.h>
34
 #include <ipxe/malloc.h>
35
 #include <ipxe/device.h>
35
 #include <ipxe/device.h>
36
 #include <ipxe/errortab.h>
36
 #include <ipxe/errortab.h>
37
+#include <ipxe/profile.h>
37
 #include <ipxe/vlan.h>
38
 #include <ipxe/vlan.h>
38
 #include <ipxe/netdevice.h>
39
 #include <ipxe/netdevice.h>
39
 
40
 
49
 /** List of open network devices, in reverse order of opening */
50
 /** List of open network devices, in reverse order of opening */
50
 static struct list_head open_net_devices = LIST_HEAD_INIT ( open_net_devices );
51
 static struct list_head open_net_devices = LIST_HEAD_INIT ( open_net_devices );
51
 
52
 
53
+/** Network polling profiler */
54
+static struct profiler net_poll_profiler __profiler = { .name = "net.poll" };
55
+
56
+/** Network receive profiler */
57
+static struct profiler net_rx_profiler __profiler = { .name = "net.rx" };
58
+
59
+/** Network transmit profiler */
60
+static struct profiler net_tx_profiler __profiler = { .name = "net.tx" };
61
+
52
 /** Default unknown link status code */
62
 /** Default unknown link status code */
53
 #define EUNKNOWN_LINK_STATUS __einfo_error ( EINFO_EUNKNOWN_LINK_STATUS )
63
 #define EUNKNOWN_LINK_STATUS __einfo_error ( EINFO_EUNKNOWN_LINK_STATUS )
54
 #define EINFO_EUNKNOWN_LINK_STATUS \
64
 #define EINFO_EUNKNOWN_LINK_STATUS \
227
 
237
 
228
 	DBGC2 ( netdev, "NETDEV %s transmitting %p (%p+%zx)\n",
238
 	DBGC2 ( netdev, "NETDEV %s transmitting %p (%p+%zx)\n",
229
 		netdev->name, iobuf, iobuf->data, iob_len ( iobuf ) );
239
 		netdev->name, iobuf, iobuf->data, iob_len ( iobuf ) );
240
+	profile_start ( &net_tx_profiler );
230
 
241
 
231
 	/* Enqueue packet */
242
 	/* Enqueue packet */
232
 	list_add_tail ( &iobuf->list, &netdev->tx_queue );
243
 	list_add_tail ( &iobuf->list, &netdev->tx_queue );
248
 	if ( ( rc = netdev->op->transmit ( netdev, iobuf ) ) != 0 )
259
 	if ( ( rc = netdev->op->transmit ( netdev, iobuf ) ) != 0 )
249
 		goto err;
260
 		goto err;
250
 
261
 
262
+	profile_stop ( &net_tx_profiler );
251
 	return 0;
263
 	return 0;
252
 
264
 
253
  err:
265
  err:
932
 	list_for_each_entry ( netdev, &net_devices, list ) {
944
 	list_for_each_entry ( netdev, &net_devices, list ) {
933
 
945
 
934
 		/* Poll for new packets */
946
 		/* Poll for new packets */
947
+		profile_start ( &net_poll_profiler );
935
 		netdev_poll ( netdev );
948
 		netdev_poll ( netdev );
949
+		profile_stop ( &net_poll_profiler );
936
 
950
 
937
 		/* Leave received packets on the queue if receive
951
 		/* Leave received packets on the queue if receive
938
 		 * queue processing is currently frozen.  This will
952
 		 * queue processing is currently frozen.  This will
949
 			DBGC2 ( netdev, "NETDEV %s processing %p (%p+%zx)\n",
963
 			DBGC2 ( netdev, "NETDEV %s processing %p (%p+%zx)\n",
950
 				netdev->name, iobuf, iobuf->data,
964
 				netdev->name, iobuf, iobuf->data,
951
 				iob_len ( iobuf ) );
965
 				iob_len ( iobuf ) );
966
+			profile_start ( &net_rx_profiler );
952
 
967
 
953
 			/* Remove link-layer header */
968
 			/* Remove link-layer header */
954
 			ll_protocol = netdev->ll_protocol;
969
 			ll_protocol = netdev->ll_protocol;
967
 				/* Record error for diagnosis */
982
 				/* Record error for diagnosis */
968
 				netdev_rx_err ( netdev, NULL, rc );
983
 				netdev_rx_err ( netdev, NULL, rc );
969
 			}
984
 			}
985
+			profile_stop ( &net_rx_profiler );
970
 		}
986
 		}
971
 	}
987
 	}
972
 }
988
 }

Loading…
Cancel
Save