[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.
This commit is contained in:
Michael Brown
2008-11-08 02:18:30 +00:00
parent 46f43d8ea7
commit 9a52ba0cfa
5 changed files with 104 additions and 31 deletions

View File

@@ -58,6 +58,25 @@ void ifclose ( struct net_device *netdev ) {
netdev_close ( 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
*
@@ -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" );
}
/**