net/qede/base: add stats counter for link state
authorRasesh Mody <rasesh.mody@cavium.com>
Mon, 9 Apr 2018 04:48:06 +0000 (21:48 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 13 Apr 2018 22:41:44 +0000 (00:41 +0200)
Add link_change_count counter to track number of link state transitions

Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
drivers/net/qede/base/ecore_dev_api.h
drivers/net/qede/base/ecore_l2.c

index aee11c0..f619683 100644 (file)
@@ -377,6 +377,7 @@ struct ecore_eth_stats_common {
        u64 tx_mac_mc_packets;
        u64 tx_mac_bc_packets;
        u64 tx_mac_ctrl_frames;
+       u64 link_change_count;
 };
 
 struct ecore_eth_stats_bb {
index bbcbbd0..0883fd3 100644 (file)
@@ -1948,6 +1948,11 @@ static void __ecore_get_vport_port_stats(struct ecore_hwfn *p_hwfn,
                p_ah->tx_1519_to_max_byte_packets =
                        port_stats.eth.u1.ah1.t1519_to_max;
        }
+
+       p_common->link_change_count = ecore_rd(p_hwfn, p_ptt,
+                                              p_hwfn->mcp_info->port_addr +
+                                              OFFSETOF(struct public_port,
+                                                       link_change_count));
 }
 
 void __ecore_get_vport_stats(struct ecore_hwfn *p_hwfn,
@@ -2064,11 +2069,14 @@ void ecore_reset_vport_stats(struct ecore_dev *p_dev)
 
        /* PORT statistics are not necessarily reset, so we need to
         * read and create a baseline for future statistics.
+        * Link change stat is maintained by MFW, return its value as is.
         */
        if (!p_dev->reset_stats)
                DP_INFO(p_dev, "Reset stats not allocated\n");
-       else
+       else {
                _ecore_get_vport_stats(p_dev, p_dev->reset_stats);
+               p_dev->reset_stats->common.link_change_count = 0;
+       }
 }
 
 void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn,