aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf.h8
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c52
2 files changed, 48 insertions, 12 deletions
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
index 8857df4dd3b9..e6c9d1a927a9 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
@@ -34,6 +34,7 @@
34#include <linux/io.h> 34#include <linux/io.h>
35#include <linux/netdevice.h> 35#include <linux/netdevice.h>
36#include <linux/if_vlan.h> 36#include <linux/if_vlan.h>
37#include <linux/u64_stats_sync.h>
37 38
38#include "vf.h" 39#include "vf.h"
39 40
@@ -71,12 +72,13 @@ struct ixgbevf_ring {
71 struct ixgbevf_rx_buffer *rx_buffer_info; 72 struct ixgbevf_rx_buffer *rx_buffer_info;
72 }; 73 };
73 74
75 u64 total_bytes;
76 u64 total_packets;
77 struct u64_stats_sync syncp;
78
74 u16 head; 79 u16 head;
75 u16 tail; 80 u16 tail;
76 81
77 unsigned int total_bytes;
78 unsigned int total_packets;
79
80 u16 reg_idx; /* holds the special value that gets the hardware register 82 u16 reg_idx; /* holds the special value that gets the hardware register
81 * offset associated with this ring, which is different 83 * offset associated with this ring, which is different
82 * for DCB and RSS modes */ 84 * for DCB and RSS modes */
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 936532fa42ad..bc12dd8d474a 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -270,11 +270,10 @@ cont_loop:
270 IXGBE_WRITE_REG(hw, IXGBE_VTEICS, tx_ring->v_idx); 270 IXGBE_WRITE_REG(hw, IXGBE_VTEICS, tx_ring->v_idx);
271 } 271 }
272 272
273 u64_stats_update_begin(&tx_ring->syncp);
273 tx_ring->total_bytes += total_bytes; 274 tx_ring->total_bytes += total_bytes;
274 tx_ring->total_packets += total_packets; 275 tx_ring->total_packets += total_packets;
275 276 u64_stats_update_end(&tx_ring->syncp);
276 netdev->stats.tx_bytes += total_bytes;
277 netdev->stats.tx_packets += total_packets;
278 277
279 return count < tx_ring->work_limit; 278 return count < tx_ring->work_limit;
280} 279}
@@ -597,10 +596,10 @@ next_desc:
597 if (cleaned_count) 596 if (cleaned_count)
598 ixgbevf_alloc_rx_buffers(adapter, rx_ring, cleaned_count); 597 ixgbevf_alloc_rx_buffers(adapter, rx_ring, cleaned_count);
599 598
599 u64_stats_update_begin(&rx_ring->syncp);
600 rx_ring->total_packets += total_rx_packets; 600 rx_ring->total_packets += total_rx_packets;
601 rx_ring->total_bytes += total_rx_bytes; 601 rx_ring->total_bytes += total_rx_bytes;
602 adapter->netdev->stats.rx_bytes += total_rx_bytes; 602 u64_stats_update_end(&rx_ring->syncp);
603 adapter->netdev->stats.rx_packets += total_rx_packets;
604 603
605 return cleaned; 604 return cleaned;
606} 605}
@@ -2260,10 +2259,6 @@ void ixgbevf_update_stats(struct ixgbevf_adapter *adapter)
2260 adapter->stats.vfgotc); 2259 adapter->stats.vfgotc);
2261 UPDATE_VF_COUNTER_32bit(IXGBE_VFMPRC, adapter->stats.last_vfmprc, 2260 UPDATE_VF_COUNTER_32bit(IXGBE_VFMPRC, adapter->stats.last_vfmprc,
2262 adapter->stats.vfmprc); 2261 adapter->stats.vfmprc);
2263
2264 /* Fill out the OS statistics structure */
2265 adapter->netdev->stats.multicast = adapter->stats.vfmprc -
2266 adapter->stats.base_vfmprc;
2267} 2262}
2268 2263
2269/** 2264/**
@@ -3220,11 +3215,50 @@ static void ixgbevf_shutdown(struct pci_dev *pdev)
3220 pci_disable_device(pdev); 3215 pci_disable_device(pdev);
3221} 3216}
3222 3217
3218static struct rtnl_link_stats64 *ixgbevf_get_stats(struct net_device *netdev,
3219 struct rtnl_link_stats64 *stats)
3220{
3221 struct ixgbevf_adapter *adapter = netdev_priv(netdev);
3222 unsigned int start;
3223 u64 bytes, packets;
3224 const struct ixgbevf_ring *ring;
3225 int i;
3226
3227 ixgbevf_update_stats(adapter);
3228
3229 stats->multicast = adapter->stats.vfmprc - adapter->stats.base_vfmprc;
3230
3231 for (i = 0; i < adapter->num_rx_queues; i++) {
3232 ring = &adapter->rx_ring[i];
3233 do {
3234 start = u64_stats_fetch_begin_bh(&ring->syncp);
3235 bytes = ring->total_bytes;
3236 packets = ring->total_packets;
3237 } while (u64_stats_fetch_retry_bh(&ring->syncp, start));
3238 stats->rx_bytes += bytes;
3239 stats->rx_packets += packets;
3240 }
3241
3242 for (i = 0; i < adapter->num_tx_queues; i++) {
3243 ring = &adapter->tx_ring[i];
3244 do {
3245 start = u64_stats_fetch_begin_bh(&ring->syncp);
3246 bytes = ring->total_bytes;
3247 packets = ring->total_packets;
3248 } while (u64_stats_fetch_retry_bh(&ring->syncp, start));
3249 stats->tx_bytes += bytes;
3250 stats->tx_packets += packets;
3251 }
3252
3253 return stats;
3254}
3255
3223static const struct net_device_ops ixgbe_netdev_ops = { 3256static const struct net_device_ops ixgbe_netdev_ops = {
3224 .ndo_open = ixgbevf_open, 3257 .ndo_open = ixgbevf_open,
3225 .ndo_stop = ixgbevf_close, 3258 .ndo_stop = ixgbevf_close,
3226 .ndo_start_xmit = ixgbevf_xmit_frame, 3259 .ndo_start_xmit = ixgbevf_xmit_frame,
3227 .ndo_set_rx_mode = ixgbevf_set_rx_mode, 3260 .ndo_set_rx_mode = ixgbevf_set_rx_mode,
3261 .ndo_get_stats64 = ixgbevf_get_stats,
3228 .ndo_validate_addr = eth_validate_addr, 3262 .ndo_validate_addr = eth_validate_addr,
3229 .ndo_set_mac_address = ixgbevf_set_mac, 3263 .ndo_set_mac_address = ixgbevf_set_mac,
3230 .ndo_change_mtu = ixgbevf_change_mtu, 3264 .ndo_change_mtu = ixgbevf_change_mtu,