aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/gianfar.c10
-rw-r--r--drivers/net/gianfar.h10
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c23
-rw-r--r--drivers/net/macvtap.c2
-rw-r--r--include/linux/netdevice.h5
-rw-r--r--net/core/dev.c29
-rw-r--r--net/sched/sch_teql.c26
7 files changed, 52 insertions, 53 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 45c4b7bfcf39..f1d4b450e797 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -433,7 +433,6 @@ static void gfar_init_mac(struct net_device *ndev)
433static struct net_device_stats *gfar_get_stats(struct net_device *dev) 433static struct net_device_stats *gfar_get_stats(struct net_device *dev)
434{ 434{
435 struct gfar_private *priv = netdev_priv(dev); 435 struct gfar_private *priv = netdev_priv(dev);
436 struct netdev_queue *txq;
437 unsigned long rx_packets = 0, rx_bytes = 0, rx_dropped = 0; 436 unsigned long rx_packets = 0, rx_bytes = 0, rx_dropped = 0;
438 unsigned long tx_packets = 0, tx_bytes = 0; 437 unsigned long tx_packets = 0, tx_bytes = 0;
439 int i = 0; 438 int i = 0;
@@ -449,9 +448,8 @@ static struct net_device_stats *gfar_get_stats(struct net_device *dev)
449 dev->stats.rx_dropped = rx_dropped; 448 dev->stats.rx_dropped = rx_dropped;
450 449
451 for (i = 0; i < priv->num_tx_queues; i++) { 450 for (i = 0; i < priv->num_tx_queues; i++) {
452 txq = netdev_get_tx_queue(dev, i); 451 tx_bytes += priv->tx_queue[i]->stats.tx_bytes;
453 tx_bytes += txq->tx_bytes; 452 tx_packets += priv->tx_queue[i]->stats.tx_packets;
454 tx_packets += txq->tx_packets;
455 } 453 }
456 454
457 dev->stats.tx_bytes = tx_bytes; 455 dev->stats.tx_bytes = tx_bytes;
@@ -2108,8 +2106,8 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2108 } 2106 }
2109 2107
2110 /* Update transmit stats */ 2108 /* Update transmit stats */
2111 txq->tx_bytes += skb->len; 2109 tx_queue->stats.tx_bytes += skb->len;
2112 txq->tx_packets ++; 2110 tx_queue->stats.tx_packets++;
2113 2111
2114 txbdp = txbdp_start = tx_queue->cur_tx; 2112 txbdp = txbdp_start = tx_queue->cur_tx;
2115 lstatus = txbdp->lstatus; 2113 lstatus = txbdp->lstatus;
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 68984eb88ae0..54de4135e932 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -907,12 +907,21 @@ enum {
907 MQ_MG_MODE 907 MQ_MG_MODE
908}; 908};
909 909
910/*
911 * Per TX queue stats
912 */
913struct tx_q_stats {
914 unsigned long tx_packets;
915 unsigned long tx_bytes;
916};
917
910/** 918/**
911 * struct gfar_priv_tx_q - per tx queue structure 919 * struct gfar_priv_tx_q - per tx queue structure
912 * @txlock: per queue tx spin lock 920 * @txlock: per queue tx spin lock
913 * @tx_skbuff:skb pointers 921 * @tx_skbuff:skb pointers
914 * @skb_curtx: to be used skb pointer 922 * @skb_curtx: to be used skb pointer
915 * @skb_dirtytx:the last used skb pointer 923 * @skb_dirtytx:the last used skb pointer
924 * @stats: bytes/packets stats
916 * @qindex: index of this queue 925 * @qindex: index of this queue
917 * @dev: back pointer to the dev structure 926 * @dev: back pointer to the dev structure
918 * @grp: back pointer to the group to which this queue belongs 927 * @grp: back pointer to the group to which this queue belongs
@@ -934,6 +943,7 @@ struct gfar_priv_tx_q {
934 struct txbd8 *tx_bd_base; 943 struct txbd8 *tx_bd_base;
935 struct txbd8 *cur_tx; 944 struct txbd8 *cur_tx;
936 struct txbd8 *dirty_tx; 945 struct txbd8 *dirty_tx;
946 struct tx_q_stats stats;
937 struct net_device *dev; 947 struct net_device *dev;
938 struct gfar_priv_grp *grp; 948 struct gfar_priv_grp *grp;
939 u16 skb_curtx; 949 u16 skb_curtx;
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index a060610a42db..602078b84892 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -6667,8 +6667,6 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
6667 struct ixgbe_adapter *adapter, 6667 struct ixgbe_adapter *adapter,
6668 struct ixgbe_ring *tx_ring) 6668 struct ixgbe_ring *tx_ring)
6669{ 6669{
6670 struct net_device *netdev = tx_ring->netdev;
6671 struct netdev_queue *txq;
6672 unsigned int first; 6670 unsigned int first;
6673 unsigned int tx_flags = 0; 6671 unsigned int tx_flags = 0;
6674 u8 hdr_len = 0; 6672 u8 hdr_len = 0;
@@ -6765,9 +6763,6 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
6765 /* add the ATR filter if ATR is on */ 6763 /* add the ATR filter if ATR is on */
6766 if (test_bit(__IXGBE_TX_FDIR_INIT_DONE, &tx_ring->state)) 6764 if (test_bit(__IXGBE_TX_FDIR_INIT_DONE, &tx_ring->state))
6767 ixgbe_atr(tx_ring, skb, tx_flags, protocol); 6765 ixgbe_atr(tx_ring, skb, tx_flags, protocol);
6768 txq = netdev_get_tx_queue(netdev, tx_ring->queue_index);
6769 txq->tx_bytes += skb->len;
6770 txq->tx_packets++;
6771 ixgbe_tx_queue(tx_ring, tx_flags, count, skb->len, hdr_len); 6766 ixgbe_tx_queue(tx_ring, tx_flags, count, skb->len, hdr_len);
6772 ixgbe_maybe_stop_tx(tx_ring, DESC_NEEDED); 6767 ixgbe_maybe_stop_tx(tx_ring, DESC_NEEDED);
6773 6768
@@ -6925,8 +6920,6 @@ static struct rtnl_link_stats64 *ixgbe_get_stats64(struct net_device *netdev,
6925 struct ixgbe_adapter *adapter = netdev_priv(netdev); 6920 struct ixgbe_adapter *adapter = netdev_priv(netdev);
6926 int i; 6921 int i;
6927 6922
6928 /* accurate rx/tx bytes/packets stats */
6929 dev_txq_stats_fold(netdev, stats);
6930 rcu_read_lock(); 6923 rcu_read_lock();
6931 for (i = 0; i < adapter->num_rx_queues; i++) { 6924 for (i = 0; i < adapter->num_rx_queues; i++) {
6932 struct ixgbe_ring *ring = ACCESS_ONCE(adapter->rx_ring[i]); 6925 struct ixgbe_ring *ring = ACCESS_ONCE(adapter->rx_ring[i]);
@@ -6943,6 +6936,22 @@ static struct rtnl_link_stats64 *ixgbe_get_stats64(struct net_device *netdev,
6943 stats->rx_bytes += bytes; 6936 stats->rx_bytes += bytes;
6944 } 6937 }
6945 } 6938 }
6939
6940 for (i = 0; i < adapter->num_tx_queues; i++) {
6941 struct ixgbe_ring *ring = ACCESS_ONCE(adapter->tx_ring[i]);
6942 u64 bytes, packets;
6943 unsigned int start;
6944
6945 if (ring) {
6946 do {
6947 start = u64_stats_fetch_begin_bh(&ring->syncp);
6948 packets = ring->stats.packets;
6949 bytes = ring->stats.bytes;
6950 } while (u64_stats_fetch_retry_bh(&ring->syncp, start));
6951 stats->tx_packets += packets;
6952 stats->tx_bytes += bytes;
6953 }
6954 }
6946 rcu_read_unlock(); 6955 rcu_read_unlock();
6947 /* following stats updated by ixgbe_watchdog_task() */ 6956 /* following stats updated by ixgbe_watchdog_task() */
6948 stats->multicast = netdev->stats.multicast; 6957 stats->multicast = netdev->stats.multicast;
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 21845affea13..5933621ac3ff 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -585,7 +585,7 @@ err:
585 rcu_read_lock_bh(); 585 rcu_read_lock_bh();
586 vlan = rcu_dereference(q->vlan); 586 vlan = rcu_dereference(q->vlan);
587 if (vlan) 587 if (vlan)
588 netdev_get_tx_queue(vlan->dev, 0)->tx_dropped++; 588 vlan->dev->stats.tx_dropped++;
589 rcu_read_unlock_bh(); 589 rcu_read_unlock_bh();
590 590
591 return err; 591 return err;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index be4957cf6511..d971346b0340 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -520,9 +520,6 @@ struct netdev_queue {
520 * please use this field instead of dev->trans_start 520 * please use this field instead of dev->trans_start
521 */ 521 */
522 unsigned long trans_start; 522 unsigned long trans_start;
523 u64 tx_bytes;
524 u64 tx_packets;
525 u64 tx_dropped;
526} ____cacheline_aligned_in_smp; 523} ____cacheline_aligned_in_smp;
527 524
528static inline int netdev_queue_numa_node_read(const struct netdev_queue *q) 525static inline int netdev_queue_numa_node_read(const struct netdev_queue *q)
@@ -2265,8 +2262,6 @@ extern void dev_load(struct net *net, const char *name);
2265extern void dev_mcast_init(void); 2262extern void dev_mcast_init(void);
2266extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, 2263extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
2267 struct rtnl_link_stats64 *storage); 2264 struct rtnl_link_stats64 *storage);
2268extern void dev_txq_stats_fold(const struct net_device *dev,
2269 struct rtnl_link_stats64 *stats);
2270 2265
2271extern int netdev_max_backlog; 2266extern int netdev_max_backlog;
2272extern int netdev_tstamp_prequeue; 2267extern int netdev_tstamp_prequeue;
diff --git a/net/core/dev.c b/net/core/dev.c
index a3ef808b5e36..83507c265e48 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5523,34 +5523,6 @@ void netdev_run_todo(void)
5523 } 5523 }
5524} 5524}
5525 5525
5526/**
5527 * dev_txq_stats_fold - fold tx_queues stats
5528 * @dev: device to get statistics from
5529 * @stats: struct rtnl_link_stats64 to hold results
5530 */
5531void dev_txq_stats_fold(const struct net_device *dev,
5532 struct rtnl_link_stats64 *stats)
5533{
5534 u64 tx_bytes = 0, tx_packets = 0, tx_dropped = 0;
5535 unsigned int i;
5536 struct netdev_queue *txq;
5537
5538 for (i = 0; i < dev->num_tx_queues; i++) {
5539 txq = netdev_get_tx_queue(dev, i);
5540 spin_lock_bh(&txq->_xmit_lock);
5541 tx_bytes += txq->tx_bytes;
5542 tx_packets += txq->tx_packets;
5543 tx_dropped += txq->tx_dropped;
5544 spin_unlock_bh(&txq->_xmit_lock);
5545 }
5546 if (tx_bytes || tx_packets || tx_dropped) {
5547 stats->tx_bytes = tx_bytes;
5548 stats->tx_packets = tx_packets;
5549 stats->tx_dropped = tx_dropped;
5550 }
5551}
5552EXPORT_SYMBOL(dev_txq_stats_fold);
5553
5554/* Convert net_device_stats to rtnl_link_stats64. They have the same 5526/* Convert net_device_stats to rtnl_link_stats64. They have the same
5555 * fields in the same order, with only the type differing. 5527 * fields in the same order, with only the type differing.
5556 */ 5528 */
@@ -5594,7 +5566,6 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
5594 netdev_stats_to_stats64(storage, ops->ndo_get_stats(dev)); 5566 netdev_stats_to_stats64(storage, ops->ndo_get_stats(dev));
5595 } else { 5567 } else {
5596 netdev_stats_to_stats64(storage, &dev->stats); 5568 netdev_stats_to_stats64(storage, &dev->stats);
5597 dev_txq_stats_fold(dev, storage);
5598 } 5569 }
5599 storage->rx_dropped += atomic_long_read(&dev->rx_dropped); 5570 storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
5600 return storage; 5571 return storage;
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index af9360d1f6eb..84ce48eadff4 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -59,6 +59,10 @@ struct teql_master
59 struct net_device *dev; 59 struct net_device *dev;
60 struct Qdisc *slaves; 60 struct Qdisc *slaves;
61 struct list_head master_list; 61 struct list_head master_list;
62 unsigned long tx_bytes;
63 unsigned long tx_packets;
64 unsigned long tx_errors;
65 unsigned long tx_dropped;
62}; 66};
63 67
64struct teql_sched_data 68struct teql_sched_data
@@ -274,7 +278,6 @@ static inline int teql_resolve(struct sk_buff *skb,
274static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev) 278static netdev_tx_t teql_master_xmit(struct sk_buff *skb, struct net_device *dev)
275{ 279{
276 struct teql_master *master = netdev_priv(dev); 280 struct teql_master *master = netdev_priv(dev);
277 struct netdev_queue *txq = netdev_get_tx_queue(dev, 0);
278 struct Qdisc *start, *q; 281 struct Qdisc *start, *q;
279 int busy; 282 int busy;
280 int nores; 283 int nores;
@@ -314,8 +317,8 @@ restart:
314 __netif_tx_unlock(slave_txq); 317 __netif_tx_unlock(slave_txq);
315 master->slaves = NEXT_SLAVE(q); 318 master->slaves = NEXT_SLAVE(q);
316 netif_wake_queue(dev); 319 netif_wake_queue(dev);
317 txq->tx_packets++; 320 master->tx_packets++;
318 txq->tx_bytes += length; 321 master->tx_bytes += length;
319 return NETDEV_TX_OK; 322 return NETDEV_TX_OK;
320 } 323 }
321 __netif_tx_unlock(slave_txq); 324 __netif_tx_unlock(slave_txq);
@@ -342,10 +345,10 @@ restart:
342 netif_stop_queue(dev); 345 netif_stop_queue(dev);
343 return NETDEV_TX_BUSY; 346 return NETDEV_TX_BUSY;
344 } 347 }
345 dev->stats.tx_errors++; 348 master->tx_errors++;
346 349
347drop: 350drop:
348 txq->tx_dropped++; 351 master->tx_dropped++;
349 dev_kfree_skb(skb); 352 dev_kfree_skb(skb);
350 return NETDEV_TX_OK; 353 return NETDEV_TX_OK;
351} 354}
@@ -398,6 +401,18 @@ static int teql_master_close(struct net_device *dev)
398 return 0; 401 return 0;
399} 402}
400 403
404static struct rtnl_link_stats64 *teql_master_stats64(struct net_device *dev,
405 struct rtnl_link_stats64 *stats)
406{
407 struct teql_master *m = netdev_priv(dev);
408
409 stats->tx_packets = m->tx_packets;
410 stats->tx_bytes = m->tx_bytes;
411 stats->tx_errors = m->tx_errors;
412 stats->tx_dropped = m->tx_dropped;
413 return stats;
414}
415
401static int teql_master_mtu(struct net_device *dev, int new_mtu) 416static int teql_master_mtu(struct net_device *dev, int new_mtu)
402{ 417{
403 struct teql_master *m = netdev_priv(dev); 418 struct teql_master *m = netdev_priv(dev);
@@ -422,6 +437,7 @@ static const struct net_device_ops teql_netdev_ops = {
422 .ndo_open = teql_master_open, 437 .ndo_open = teql_master_open,
423 .ndo_stop = teql_master_close, 438 .ndo_stop = teql_master_close,
424 .ndo_start_xmit = teql_master_xmit, 439 .ndo_start_xmit = teql_master_xmit,
440 .ndo_get_stats64 = teql_master_stats64,
425 .ndo_change_mtu = teql_master_mtu, 441 .ndo_change_mtu = teql_master_mtu,
426}; 442};
427 443