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