[NET]: Remove NETIF_F_INTERNAL_STATS, default to internal stats.
Herbert Xu conviced me that a new flag was overkill; every driver currently overrides get_stats, so we might as well make the internal one the default. If someone did fail to set get_stats, they would now get all 0 stats instead of "No statistics available". Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d16bfd0c77
commit
5a1b5898ee
5 changed files with 41 additions and 61 deletions
|
@ -109,9 +109,6 @@ static void appldata_get_net_sum_data(void *data)
|
|||
read_lock(&dev_base_lock);
|
||||
for (dev = dev_base; dev != NULL; dev = dev->next) {
|
||||
stats = dev->get_stats(dev);
|
||||
if (stats == NULL) {
|
||||
continue;
|
||||
}
|
||||
rx_packets += stats->rx_packets;
|
||||
tx_packets += stats->tx_packets;
|
||||
rx_bytes += stats->rx_bytes;
|
||||
|
|
|
@ -1360,13 +1360,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
|
|||
goto err_undo_flags;
|
||||
}
|
||||
|
||||
if (slave_dev->get_stats == NULL) {
|
||||
printk(KERN_NOTICE DRV_NAME
|
||||
": %s: the driver for slave device %s does not provide "
|
||||
"get_stats function, network statistics will be "
|
||||
"inaccurate.\n", bond_dev->name, slave_dev->name);
|
||||
}
|
||||
|
||||
new_slave = kzalloc(sizeof(struct slave), GFP_KERNEL);
|
||||
if (!new_slave) {
|
||||
res = -ENOMEM;
|
||||
|
@ -3641,33 +3634,31 @@ static struct net_device_stats *bond_get_stats(struct net_device *bond_dev)
|
|||
|
||||
bond_for_each_slave(bond, slave, i) {
|
||||
sstats = slave->dev->get_stats(slave->dev);
|
||||
if (sstats) {
|
||||
stats->rx_packets += sstats->rx_packets;
|
||||
stats->rx_bytes += sstats->rx_bytes;
|
||||
stats->rx_errors += sstats->rx_errors;
|
||||
stats->rx_dropped += sstats->rx_dropped;
|
||||
stats->rx_packets += sstats->rx_packets;
|
||||
stats->rx_bytes += sstats->rx_bytes;
|
||||
stats->rx_errors += sstats->rx_errors;
|
||||
stats->rx_dropped += sstats->rx_dropped;
|
||||
|
||||
stats->tx_packets += sstats->tx_packets;
|
||||
stats->tx_bytes += sstats->tx_bytes;
|
||||
stats->tx_errors += sstats->tx_errors;
|
||||
stats->tx_dropped += sstats->tx_dropped;
|
||||
stats->tx_packets += sstats->tx_packets;
|
||||
stats->tx_bytes += sstats->tx_bytes;
|
||||
stats->tx_errors += sstats->tx_errors;
|
||||
stats->tx_dropped += sstats->tx_dropped;
|
||||
|
||||
stats->multicast += sstats->multicast;
|
||||
stats->collisions += sstats->collisions;
|
||||
stats->multicast += sstats->multicast;
|
||||
stats->collisions += sstats->collisions;
|
||||
|
||||
stats->rx_length_errors += sstats->rx_length_errors;
|
||||
stats->rx_over_errors += sstats->rx_over_errors;
|
||||
stats->rx_crc_errors += sstats->rx_crc_errors;
|
||||
stats->rx_frame_errors += sstats->rx_frame_errors;
|
||||
stats->rx_fifo_errors += sstats->rx_fifo_errors;
|
||||
stats->rx_missed_errors += sstats->rx_missed_errors;
|
||||
stats->rx_length_errors += sstats->rx_length_errors;
|
||||
stats->rx_over_errors += sstats->rx_over_errors;
|
||||
stats->rx_crc_errors += sstats->rx_crc_errors;
|
||||
stats->rx_frame_errors += sstats->rx_frame_errors;
|
||||
stats->rx_fifo_errors += sstats->rx_fifo_errors;
|
||||
stats->rx_missed_errors += sstats->rx_missed_errors;
|
||||
|
||||
stats->tx_aborted_errors += sstats->tx_aborted_errors;
|
||||
stats->tx_carrier_errors += sstats->tx_carrier_errors;
|
||||
stats->tx_fifo_errors += sstats->tx_fifo_errors;
|
||||
stats->tx_heartbeat_errors += sstats->tx_heartbeat_errors;
|
||||
stats->tx_window_errors += sstats->tx_window_errors;
|
||||
}
|
||||
stats->tx_aborted_errors += sstats->tx_aborted_errors;
|
||||
stats->tx_carrier_errors += sstats->tx_carrier_errors;
|
||||
stats->tx_fifo_errors += sstats->tx_fifo_errors;
|
||||
stats->tx_heartbeat_errors += sstats->tx_heartbeat_errors;
|
||||
stats->tx_window_errors += sstats->tx_window_errors;
|
||||
}
|
||||
|
||||
read_unlock_bh(&bond->lock);
|
||||
|
|
|
@ -373,8 +373,6 @@ static __inline__ int led_get_net_activity(void)
|
|||
if (LOOPBACK(in_dev->ifa_list->ifa_local))
|
||||
continue;
|
||||
stats = dev->get_stats(dev);
|
||||
if (!stats)
|
||||
continue;
|
||||
rx_total += stats->rx_packets;
|
||||
tx_total += stats->tx_packets;
|
||||
}
|
||||
|
|
|
@ -325,7 +325,6 @@ struct net_device
|
|||
#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
|
||||
#define NETIF_F_GSO 2048 /* Enable software GSO. */
|
||||
#define NETIF_F_LLTX 4096 /* LockLess TX */
|
||||
#define NETIF_F_INTERNAL_STATS 8192 /* Use stats structure in net_device */
|
||||
|
||||
/* Segmentation offload features */
|
||||
#define NETIF_F_GSO_SHIFT 16
|
||||
|
|
|
@ -2101,26 +2101,23 @@ static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
|
|||
{
|
||||
struct net_device_stats *stats = dev->get_stats(dev);
|
||||
|
||||
if (stats) {
|
||||
seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
|
||||
"%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
|
||||
dev->name, stats->rx_bytes, stats->rx_packets,
|
||||
stats->rx_errors,
|
||||
stats->rx_dropped + stats->rx_missed_errors,
|
||||
stats->rx_fifo_errors,
|
||||
stats->rx_length_errors + stats->rx_over_errors +
|
||||
stats->rx_crc_errors + stats->rx_frame_errors,
|
||||
stats->rx_compressed, stats->multicast,
|
||||
stats->tx_bytes, stats->tx_packets,
|
||||
stats->tx_errors, stats->tx_dropped,
|
||||
stats->tx_fifo_errors, stats->collisions,
|
||||
stats->tx_carrier_errors +
|
||||
stats->tx_aborted_errors +
|
||||
stats->tx_window_errors +
|
||||
stats->tx_heartbeat_errors,
|
||||
stats->tx_compressed);
|
||||
} else
|
||||
seq_printf(seq, "%6s: No statistics available.\n", dev->name);
|
||||
seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
|
||||
"%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
|
||||
dev->name, stats->rx_bytes, stats->rx_packets,
|
||||
stats->rx_errors,
|
||||
stats->rx_dropped + stats->rx_missed_errors,
|
||||
stats->rx_fifo_errors,
|
||||
stats->rx_length_errors + stats->rx_over_errors +
|
||||
stats->rx_crc_errors + stats->rx_frame_errors,
|
||||
stats->rx_compressed, stats->multicast,
|
||||
stats->tx_bytes, stats->tx_packets,
|
||||
stats->tx_errors, stats->tx_dropped,
|
||||
stats->tx_fifo_errors, stats->collisions,
|
||||
stats->tx_carrier_errors +
|
||||
stats->tx_aborted_errors +
|
||||
stats->tx_window_errors +
|
||||
stats->tx_heartbeat_errors,
|
||||
stats->tx_compressed);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3257,11 +3254,9 @@ out:
|
|||
mutex_unlock(&net_todo_run_mutex);
|
||||
}
|
||||
|
||||
static struct net_device_stats *maybe_internal_stats(struct net_device *dev)
|
||||
static struct net_device_stats *internal_stats(struct net_device *dev)
|
||||
{
|
||||
if (dev->features & NETIF_F_INTERNAL_STATS)
|
||||
return &dev->stats;
|
||||
return NULL;
|
||||
return &dev->stats;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3299,7 +3294,7 @@ struct net_device *alloc_netdev(int sizeof_priv, const char *name,
|
|||
if (sizeof_priv)
|
||||
dev->priv = netdev_priv(dev);
|
||||
|
||||
dev->get_stats = maybe_internal_stats;
|
||||
dev->get_stats = internal_stats;
|
||||
setup(dev);
|
||||
strcpy(dev->name, name);
|
||||
return dev;
|
||||
|
|
Loading…
Reference in a new issue