aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Rose <gregory.v.rose@intel.com>2010-03-18 22:59:52 -0400
committerDavid S. Miller <davem@davemloft.net>2010-03-20 00:00:44 -0400
commit33bd9f601ea21c4389870e425ae4eaf210d49b95 (patch)
tree067d6e6dc6de15b4dc56064ad31b67770e98a9fa /drivers
parentfd3686a842717b890fbe3024b83a616c54d5dba0 (diff)
ixgbevf: Fix VF Stats accounting after reset
The counters in the 82599 Virtual Function are not clear on read. They accumulate to the maximum value and then roll over. They are also not cleared when the VF executes a soft reset, so it is possible they are non-zero when the driver loads and starts. This has all been accounted for in the code that keeps the stats up to date but there is one case that is not. When the PF driver is reset the counters in the VF are all reset to zero. This adds an additional accounting overhead into the VF driver when the PF is reset under its feet. This patch adds additional counters that are used by the VF driver to accumulate and save stats after a PF reset has been detected. Prior to this patch displaying the stats in the VF after the PF has reset would show bogus data. Signed-off-by: Greg Rose <gregory.v.rose@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ixgbevf/ethtool.c42
-rw-r--r--drivers/net/ixgbevf/ixgbevf_main.c68
-rw-r--r--drivers/net/ixgbevf/vf.h6
3 files changed, 78 insertions, 38 deletions
diff --git a/drivers/net/ixgbevf/ethtool.c b/drivers/net/ixgbevf/ethtool.c
index 399be0c34c36..6fdd651abcd1 100644
--- a/drivers/net/ixgbevf/ethtool.c
+++ b/drivers/net/ixgbevf/ethtool.c
@@ -46,22 +46,32 @@ struct ixgbe_stats {
46 int sizeof_stat; 46 int sizeof_stat;
47 int stat_offset; 47 int stat_offset;
48 int base_stat_offset; 48 int base_stat_offset;
49 int saved_reset_offset;
49}; 50};
50 51
51#define IXGBEVF_STAT(m, b) sizeof(((struct ixgbevf_adapter *)0)->m), \ 52#define IXGBEVF_STAT(m, b, r) sizeof(((struct ixgbevf_adapter *)0)->m), \
52 offsetof(struct ixgbevf_adapter, m), \ 53 offsetof(struct ixgbevf_adapter, m), \
53 offsetof(struct ixgbevf_adapter, b) 54 offsetof(struct ixgbevf_adapter, b), \
55 offsetof(struct ixgbevf_adapter, r)
54static struct ixgbe_stats ixgbe_gstrings_stats[] = { 56static struct ixgbe_stats ixgbe_gstrings_stats[] = {
55 {"rx_packets", IXGBEVF_STAT(stats.vfgprc, stats.base_vfgprc)}, 57 {"rx_packets", IXGBEVF_STAT(stats.vfgprc, stats.base_vfgprc,
56 {"tx_packets", IXGBEVF_STAT(stats.vfgptc, stats.base_vfgptc)}, 58 stats.saved_reset_vfgprc)},
57 {"rx_bytes", IXGBEVF_STAT(stats.vfgorc, stats.base_vfgorc)}, 59 {"tx_packets", IXGBEVF_STAT(stats.vfgptc, stats.base_vfgptc,
58 {"tx_bytes", IXGBEVF_STAT(stats.vfgotc, stats.base_vfgotc)}, 60 stats.saved_reset_vfgptc)},
59 {"tx_busy", IXGBEVF_STAT(tx_busy, zero_base)}, 61 {"rx_bytes", IXGBEVF_STAT(stats.vfgorc, stats.base_vfgorc,
60 {"multicast", IXGBEVF_STAT(stats.vfmprc, stats.base_vfmprc)}, 62 stats.saved_reset_vfgorc)},
61 {"rx_csum_offload_good", IXGBEVF_STAT(hw_csum_rx_good, zero_base)}, 63 {"tx_bytes", IXGBEVF_STAT(stats.vfgotc, stats.base_vfgotc,
62 {"rx_csum_offload_errors", IXGBEVF_STAT(hw_csum_rx_error, zero_base)}, 64 stats.saved_reset_vfgotc)},
63 {"tx_csum_offload_ctxt", IXGBEVF_STAT(hw_csum_tx_good, zero_base)}, 65 {"tx_busy", IXGBEVF_STAT(tx_busy, zero_base, zero_base)},
64 {"rx_header_split", IXGBEVF_STAT(rx_hdr_split, zero_base)}, 66 {"multicast", IXGBEVF_STAT(stats.vfmprc, stats.base_vfmprc,
67 stats.saved_reset_vfmprc)},
68 {"rx_csum_offload_good", IXGBEVF_STAT(hw_csum_rx_good, zero_base,
69 zero_base)},
70 {"rx_csum_offload_errors", IXGBEVF_STAT(hw_csum_rx_error, zero_base,
71 zero_base)},
72 {"tx_csum_offload_ctxt", IXGBEVF_STAT(hw_csum_tx_good, zero_base,
73 zero_base)},
74 {"rx_header_split", IXGBEVF_STAT(rx_hdr_split, zero_base, zero_base)},
65}; 75};
66 76
67#define IXGBE_QUEUE_STATS_LEN 0 77#define IXGBE_QUEUE_STATS_LEN 0
@@ -455,10 +465,14 @@ static void ixgbevf_get_ethtool_stats(struct net_device *netdev,
455 ixgbe_gstrings_stats[i].stat_offset; 465 ixgbe_gstrings_stats[i].stat_offset;
456 char *b = (char *)adapter + 466 char *b = (char *)adapter +
457 ixgbe_gstrings_stats[i].base_stat_offset; 467 ixgbe_gstrings_stats[i].base_stat_offset;
468 char *r = (char *)adapter +
469 ixgbe_gstrings_stats[i].saved_reset_offset;
458 data[i] = ((ixgbe_gstrings_stats[i].sizeof_stat == 470 data[i] = ((ixgbe_gstrings_stats[i].sizeof_stat ==
459 sizeof(u64)) ? *(u64 *)p : *(u32 *)p) - 471 sizeof(u64)) ? *(u64 *)p : *(u32 *)p) -
460 ((ixgbe_gstrings_stats[i].sizeof_stat == 472 ((ixgbe_gstrings_stats[i].sizeof_stat ==
461 sizeof(u64)) ? *(u64 *)b : *(u32 *)b); 473 sizeof(u64)) ? *(u64 *)b : *(u32 *)b) +
474 ((ixgbe_gstrings_stats[i].sizeof_stat ==
475 sizeof(u64)) ? *(u64 *)r : *(u32 *)r);
462 } 476 }
463} 477}
464 478
diff --git a/drivers/net/ixgbevf/ixgbevf_main.c b/drivers/net/ixgbevf/ixgbevf_main.c
index ca653c49b765..43927e1b3432 100644
--- a/drivers/net/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ixgbevf/ixgbevf_main.c
@@ -1610,6 +1610,44 @@ static inline void ixgbevf_rx_desc_queue_enable(struct ixgbevf_adapter *adapter,
1610 (adapter->rx_ring[rxr].count - 1)); 1610 (adapter->rx_ring[rxr].count - 1));
1611} 1611}
1612 1612
1613static void ixgbevf_save_reset_stats(struct ixgbevf_adapter *adapter)
1614{
1615 /* Only save pre-reset stats if there are some */
1616 if (adapter->stats.vfgprc || adapter->stats.vfgptc) {
1617 adapter->stats.saved_reset_vfgprc += adapter->stats.vfgprc -
1618 adapter->stats.base_vfgprc;
1619 adapter->stats.saved_reset_vfgptc += adapter->stats.vfgptc -
1620 adapter->stats.base_vfgptc;
1621 adapter->stats.saved_reset_vfgorc += adapter->stats.vfgorc -
1622 adapter->stats.base_vfgorc;
1623 adapter->stats.saved_reset_vfgotc += adapter->stats.vfgotc -
1624 adapter->stats.base_vfgotc;
1625 adapter->stats.saved_reset_vfmprc += adapter->stats.vfmprc -
1626 adapter->stats.base_vfmprc;
1627 }
1628}
1629
1630static void ixgbevf_init_last_counter_stats(struct ixgbevf_adapter *adapter)
1631{
1632 struct ixgbe_hw *hw = &adapter->hw;
1633
1634 adapter->stats.last_vfgprc = IXGBE_READ_REG(hw, IXGBE_VFGPRC);
1635 adapter->stats.last_vfgorc = IXGBE_READ_REG(hw, IXGBE_VFGORC_LSB);
1636 adapter->stats.last_vfgorc |=
1637 (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGORC_MSB))) << 32);
1638 adapter->stats.last_vfgptc = IXGBE_READ_REG(hw, IXGBE_VFGPTC);
1639 adapter->stats.last_vfgotc = IXGBE_READ_REG(hw, IXGBE_VFGOTC_LSB);
1640 adapter->stats.last_vfgotc |=
1641 (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGOTC_MSB))) << 32);
1642 adapter->stats.last_vfmprc = IXGBE_READ_REG(hw, IXGBE_VFMPRC);
1643
1644 adapter->stats.base_vfgprc = adapter->stats.last_vfgprc;
1645 adapter->stats.base_vfgorc = adapter->stats.last_vfgorc;
1646 adapter->stats.base_vfgptc = adapter->stats.last_vfgptc;
1647 adapter->stats.base_vfgotc = adapter->stats.last_vfgotc;
1648 adapter->stats.base_vfmprc = adapter->stats.last_vfmprc;
1649}
1650
1613static int ixgbevf_up_complete(struct ixgbevf_adapter *adapter) 1651static int ixgbevf_up_complete(struct ixgbevf_adapter *adapter)
1614{ 1652{
1615 struct net_device *netdev = adapter->netdev; 1653 struct net_device *netdev = adapter->netdev;
@@ -1656,6 +1694,9 @@ static int ixgbevf_up_complete(struct ixgbevf_adapter *adapter)
1656 /* enable transmits */ 1694 /* enable transmits */
1657 netif_tx_start_all_queues(netdev); 1695 netif_tx_start_all_queues(netdev);
1658 1696
1697 ixgbevf_save_reset_stats(adapter);
1698 ixgbevf_init_last_counter_stats(adapter);
1699
1659 /* bring the link up in the watchdog, this could race with our first 1700 /* bring the link up in the watchdog, this could race with our first
1660 * link up interrupt but shouldn't be a problem */ 1701 * link up interrupt but shouldn't be a problem */
1661 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; 1702 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
@@ -2228,27 +2269,6 @@ out:
2228 return err; 2269 return err;
2229} 2270}
2230 2271
2231static void ixgbevf_init_last_counter_stats(struct ixgbevf_adapter *adapter)
2232{
2233 struct ixgbe_hw *hw = &adapter->hw;
2234
2235 adapter->stats.last_vfgprc = IXGBE_READ_REG(hw, IXGBE_VFGPRC);
2236 adapter->stats.last_vfgorc = IXGBE_READ_REG(hw, IXGBE_VFGORC_LSB);
2237 adapter->stats.last_vfgorc |=
2238 (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGORC_MSB))) << 32);
2239 adapter->stats.last_vfgptc = IXGBE_READ_REG(hw, IXGBE_VFGPTC);
2240 adapter->stats.last_vfgotc = IXGBE_READ_REG(hw, IXGBE_VFGOTC_LSB);
2241 adapter->stats.last_vfgotc |=
2242 (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGOTC_MSB))) << 32);
2243 adapter->stats.last_vfmprc = IXGBE_READ_REG(hw, IXGBE_VFMPRC);
2244
2245 adapter->stats.base_vfgprc = adapter->stats.last_vfgprc;
2246 adapter->stats.base_vfgorc = adapter->stats.last_vfgorc;
2247 adapter->stats.base_vfgptc = adapter->stats.last_vfgptc;
2248 adapter->stats.base_vfgotc = adapter->stats.last_vfgotc;
2249 adapter->stats.base_vfmprc = adapter->stats.last_vfmprc;
2250}
2251
2252#define UPDATE_VF_COUNTER_32bit(reg, last_counter, counter) \ 2272#define UPDATE_VF_COUNTER_32bit(reg, last_counter, counter) \
2253 { \ 2273 { \
2254 u32 current_counter = IXGBE_READ_REG(hw, reg); \ 2274 u32 current_counter = IXGBE_READ_REG(hw, reg); \
@@ -2416,9 +2436,9 @@ static void ixgbevf_watchdog_task(struct work_struct *work)
2416 } 2436 }
2417 } 2437 }
2418 2438
2419pf_has_reset:
2420 ixgbevf_update_stats(adapter); 2439 ixgbevf_update_stats(adapter);
2421 2440
2441pf_has_reset:
2422 /* Force detection of hung controller every watchdog period */ 2442 /* Force detection of hung controller every watchdog period */
2423 adapter->detect_tx_hung = true; 2443 adapter->detect_tx_hung = true;
2424 2444
@@ -3390,8 +3410,6 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev,
3390 /* setup the private structure */ 3410 /* setup the private structure */
3391 err = ixgbevf_sw_init(adapter); 3411 err = ixgbevf_sw_init(adapter);
3392 3412
3393 ixgbevf_init_last_counter_stats(adapter);
3394
3395#ifdef MAX_SKB_FRAGS 3413#ifdef MAX_SKB_FRAGS
3396 netdev->features = NETIF_F_SG | 3414 netdev->features = NETIF_F_SG |
3397 NETIF_F_IP_CSUM | 3415 NETIF_F_IP_CSUM |
@@ -3449,6 +3467,8 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev,
3449 3467
3450 adapter->netdev_registered = true; 3468 adapter->netdev_registered = true;
3451 3469
3470 ixgbevf_init_last_counter_stats(adapter);
3471
3452 /* print the MAC address */ 3472 /* print the MAC address */
3453 hw_dbg(hw, "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", 3473 hw_dbg(hw, "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
3454 netdev->dev_addr[0], 3474 netdev->dev_addr[0],
diff --git a/drivers/net/ixgbevf/vf.h b/drivers/net/ixgbevf/vf.h
index 799600e92700..1f31b052d4b4 100644
--- a/drivers/net/ixgbevf/vf.h
+++ b/drivers/net/ixgbevf/vf.h
@@ -157,6 +157,12 @@ struct ixgbevf_hw_stats {
157 u64 vfgorc; 157 u64 vfgorc;
158 u64 vfgotc; 158 u64 vfgotc;
159 u64 vfmprc; 159 u64 vfmprc;
160
161 u64 saved_reset_vfgprc;
162 u64 saved_reset_vfgptc;
163 u64 saved_reset_vfgorc;
164 u64 saved_reset_vfgotc;
165 u64 saved_reset_vfmprc;
160}; 166};
161 167
162struct ixgbevf_info { 168struct ixgbevf_info {