Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 150300
b: refs/heads/master
c: 7004bf2
h: refs/heads/master
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed May 18, 2009
1 parent 4e922b4 commit a78bfaf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ba98898eb3fc07ee54566fcc3626354a44355acb
refs/heads/master: 7004bf252c53da18f6b55103e0c92f777f846806
3 changes: 3 additions & 0 deletions trunk/include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@ struct netdev_queue {
* please use this field instead of dev->trans_start
*/
unsigned long trans_start;
unsigned long tx_bytes;
unsigned long tx_packets;
unsigned long tx_dropped;
} ____cacheline_aligned_in_smp;


Expand Down
23 changes: 20 additions & 3 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -4943,13 +4943,30 @@ void netdev_run_todo(void)
* the internal statistics structure is used.
*/
const struct net_device_stats *dev_get_stats(struct net_device *dev)
{
{
const struct net_device_ops *ops = dev->netdev_ops;

if (ops->ndo_get_stats)
return ops->ndo_get_stats(dev);
else
return &dev->stats;
else {
unsigned long tx_bytes = 0, tx_packets = 0, tx_dropped = 0;
struct net_device_stats *stats = &dev->stats;
unsigned int i;
struct netdev_queue *txq;

for (i = 0; i < dev->num_tx_queues; i++) {
txq = netdev_get_tx_queue(dev, i);
tx_bytes += txq->tx_bytes;
tx_packets += txq->tx_packets;
tx_dropped += txq->tx_dropped;
}
if (tx_bytes || tx_packets || tx_dropped) {
stats->tx_bytes = tx_bytes;
stats->tx_packets = tx_packets;
stats->tx_dropped = tx_dropped;
}
return stats;
}
}
EXPORT_SYMBOL(dev_get_stats);

Expand Down

0 comments on commit a78bfaf

Please sign in to comment.