[net-next 04/17] ixgbevf: provide 64 bit statistics
From: Jeff Kirsher <hidden>
Date: 2011-06-20 00:59:01
Subsystem:
networking drivers, the rest · Maintainers:
Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds
From: Stephen Hemminger <redacted> Compute statistics per ring using 64 bits, and provide network device stats in 64 bits. Signed-off-by: Stephen Hemminger <redacted> Acked-by: Greg Rose <redacted> Tested-by: Evan Swanson <redacted> Signed-off-by: Jeff Kirsher <redacted> --- drivers/net/ixgbevf/ixgbevf.h | 6 +++--- drivers/net/ixgbevf/ixgbevf_main.c | 33 ++++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ixgbevf/ixgbevf.h b/drivers/net/ixgbevf/ixgbevf.h
index a2bbbb3..f060840 100644
--- a/drivers/net/ixgbevf/ixgbevf.h
+++ b/drivers/net/ixgbevf/ixgbevf.h@@ -69,12 +69,12 @@ struct ixgbevf_ring { struct ixgbevf_rx_buffer *rx_buffer_info; }; + u64 total_bytes; + u64 total_packets; + u16 head; u16 tail; - unsigned int total_bytes; - unsigned int total_packets; - u16 reg_idx; /* holds the special value that gets the hardware register * offset associated with this ring, which is different * for DCB and RSS modes */
diff --git a/drivers/net/ixgbevf/ixgbevf_main.c b/drivers/net/ixgbevf/ixgbevf_main.c
index 721417e..c1f9fa6 100644
--- a/drivers/net/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ixgbevf/ixgbevf_main.c@@ -267,9 +267,6 @@ static bool ixgbevf_clean_tx_irq(struct ixgbevf_adapter *adapter, tx_ring->total_bytes += total_bytes; tx_ring->total_packets += total_packets; - netdev->stats.tx_bytes += total_bytes; - netdev->stats.tx_packets += total_packets; - return count < tx_ring->work_limit; }
@@ -597,8 +594,6 @@ next_desc: rx_ring->total_packets += total_rx_packets; rx_ring->total_bytes += total_rx_bytes; - adapter->netdev->stats.rx_bytes += total_rx_bytes; - adapter->netdev->stats.rx_packets += total_rx_packets; return cleaned; }
@@ -2288,10 +2283,6 @@ void ixgbevf_update_stats(struct ixgbevf_adapter *adapter) adapter->stats.vfgotc); UPDATE_VF_COUNTER_32bit(IXGBE_VFMPRC, adapter->stats.last_vfmprc, adapter->stats.vfmprc); - - /* Fill out the OS statistics structure */ - adapter->netdev->stats.multicast = adapter->stats.vfmprc - - adapter->stats.base_vfmprc; } /**
@@ -3248,11 +3239,35 @@ static void ixgbevf_shutdown(struct pci_dev *pdev) pci_disable_device(pdev); } +static struct rtnl_link_stats64 *ixgbevf_get_stats(struct net_device *netdev, + struct rtnl_link_stats64 *stats) +{ + struct ixgbevf_adapter *adapter = netdev_priv(netdev); + int i; + + ixgbevf_update_stats(adapter); + + stats->multicast = adapter->stats.vfmprc - adapter->stats.base_vfmprc; + + for (i = 0; i < adapter->num_rx_queues; i++) { + stats->rx_bytes += adapter->rx_ring[i].total_bytes; + stats->rx_packets += adapter->rx_ring[i].total_packets; + } + + for (i = 0; i < adapter->num_tx_queues; i++) { + stats->tx_bytes += adapter->tx_ring[i].total_bytes; + stats->tx_packets += adapter->tx_ring[i].total_packets; + } + + return stats; +} + static const struct net_device_ops ixgbe_netdev_ops = { .ndo_open = &ixgbevf_open, .ndo_stop = &ixgbevf_close, .ndo_start_xmit = &ixgbevf_xmit_frame, .ndo_set_rx_mode = &ixgbevf_set_rx_mode, + .ndo_get_stats64 = ixgbevf_get_stats, .ndo_set_multicast_list = &ixgbevf_set_rx_mode, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = &ixgbevf_set_mac,
--
1.7.5.4