2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-11-22 17:41:55 +00:00

[netdevice] Profile common operations

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2014-04-27 21:51:03 +01:00
parent 7c44fd68f0
commit 2c820d684a

View File

@ -34,6 +34,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/malloc.h>
#include <ipxe/device.h>
#include <ipxe/errortab.h>
#include <ipxe/profile.h>
#include <ipxe/vlan.h>
#include <ipxe/netdevice.h>
@ -49,6 +50,15 @@ struct list_head net_devices = LIST_HEAD_INIT ( net_devices );
/** List of open network devices, in reverse order of opening */
static struct list_head open_net_devices = LIST_HEAD_INIT ( open_net_devices );
/** Network polling profiler */
static struct profiler net_poll_profiler __profiler = { .name = "net.poll" };
/** Network receive profiler */
static struct profiler net_rx_profiler __profiler = { .name = "net.rx" };
/** Network transmit profiler */
static struct profiler net_tx_profiler __profiler = { .name = "net.tx" };
/** Default unknown link status code */
#define EUNKNOWN_LINK_STATUS __einfo_error ( EINFO_EUNKNOWN_LINK_STATUS )
#define EINFO_EUNKNOWN_LINK_STATUS \
@ -227,6 +237,7 @@ int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf ) {
DBGC2 ( netdev, "NETDEV %s transmitting %p (%p+%zx)\n",
netdev->name, iobuf, iobuf->data, iob_len ( iobuf ) );
profile_start ( &net_tx_profiler );
/* Enqueue packet */
list_add_tail ( &iobuf->list, &netdev->tx_queue );
@ -248,6 +259,7 @@ int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf ) {
if ( ( rc = netdev->op->transmit ( netdev, iobuf ) ) != 0 )
goto err;
profile_stop ( &net_tx_profiler );
return 0;
err:
@ -932,7 +944,9 @@ void net_poll ( void ) {
list_for_each_entry ( netdev, &net_devices, list ) {
/* Poll for new packets */
profile_start ( &net_poll_profiler );
netdev_poll ( netdev );
profile_stop ( &net_poll_profiler );
/* Leave received packets on the queue if receive
* queue processing is currently frozen. This will
@ -949,6 +963,7 @@ void net_poll ( void ) {
DBGC2 ( netdev, "NETDEV %s processing %p (%p+%zx)\n",
netdev->name, iobuf, iobuf->data,
iob_len ( iobuf ) );
profile_start ( &net_rx_profiler );
/* Remove link-layer header */
ll_protocol = netdev->ll_protocol;
@ -967,6 +982,7 @@ void net_poll ( void ) {
/* Record error for diagnosis */
netdev_rx_err ( netdev, NULL, rc );
}
profile_stop ( &net_rx_profiler );
}
}
}