diff options
author | Michael Brown <mcb30@etherboot.org> | 2008-11-08 02:18:30 +0000 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2008-11-08 05:30:30 +0000 |
commit | 9a52ba0cfac0fffb39b5a4c148ec7641bcc38381 (patch) | |
tree | 12059ca7f75d37d1b62ffa550798fa8233834590 /src/usr | |
parent | 46f43d8ea763ca2a9d4d1b87db589bb7dcc978bf (diff) | |
download | ipxe-9a52ba0cfac0fffb39b5a4c148ec7641bcc38381.tar.gz |
[netdevice] Retain and report detailed error breakdowns
netdev_rx_err() and netdev_tx_complete_err() get passed the error
code, but currently use it only in debug messages.
Retain error numbers and frequencey counts for up to
NETDEV_MAX_UNIQUE_ERRORS (4) different errors for each of TX and RX.
This allows the "ifstat" command to report the reasons for TX/RX
errors in most cases, even in non-debug builds.
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/ifmgmt.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/usr/ifmgmt.c b/src/usr/ifmgmt.c index 9c88ab531..72d86137b 100644 --- a/src/usr/ifmgmt.c +++ b/src/usr/ifmgmt.c @@ -59,6 +59,25 @@ void ifclose ( struct net_device *netdev ) { } /** + * Print network device error breakdown + * + * @v stats Network device statistics + * @v prefix Message prefix + */ +static void ifstat_errors ( struct net_device_stats *stats, + const char *prefix ) { + unsigned int i; + + for ( i = 0 ; i < ( sizeof ( stats->errors ) / + sizeof ( stats->errors[0] ) ) ; i++ ) { + if ( stats->errors[i].count ) + printf ( " [%s: %d x \"%s\"]\n", prefix, + stats->errors[i].count, + strerror ( stats->errors[i].rc ) ); + } +} + +/** * Print status of network device * * @v netdev Network device @@ -69,8 +88,10 @@ void ifstat ( struct net_device *netdev ) { netdev->name, netdev_hwaddr ( netdev ), netdev->dev->name, ( ( netdev->state & NETDEV_OPEN ) ? "open" : "closed" ), ( netdev_link_ok ( netdev ) ? "up" : "down" ), - netdev->stats.tx_ok, netdev->stats.tx_err, - netdev->stats.rx_ok, netdev->stats.rx_err ); + netdev->tx_stats.good, netdev->tx_stats.bad, + netdev->rx_stats.good, netdev->rx_stats.bad ); + ifstat_errors ( &netdev->tx_stats, "TXE" ); + ifstat_errors ( &netdev->rx_stats, "RXE" ); } /** |