bnx2x: add PFC statistics
authorBarak Witkowski <barak@broadcom.com>
Mon, 5 Dec 2011 21:52:22 +0000 (21:52 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Dec 2011 18:06:04 +0000 (13:06 -0500)
Add Priority flow control counters for ethtool -S.

Signed-off-by: Barak Witkowski <barak@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h

index 6c7bd638d6edc1846eaac16d6a1220e936b3ca46..32af052a96aa62fae535aa646b794aad43cd2b18 100644 (file)
@@ -1266,6 +1266,7 @@ struct bnx2x {
 #define NO_ISCSI_OOO_FLAG              (1 << 13)
 #define NO_ISCSI_FLAG                  (1 << 14)
 #define NO_FCOE_FLAG                   (1 << 15)
+#define BC_SUPPORTS_PFC_STATS          (1 << 17)
 
 #define NO_ISCSI(bp)           ((bp)->flags & NO_ISCSI_FLAG)
 #define NO_ISCSI_OOO(bp)       ((bp)->flags & NO_ISCSI_OOO_FLAG)
index c679ed9d3035bc6a39a365fb757f537b811e97ce..e64bdf6f99560a4dfb89287c56feecb785c526bd 100644 (file)
@@ -107,6 +107,10 @@ static const struct {
                                4, STATS_FLAGS_PORT, "rx_filtered_packets" },
        { STATS_OFFSET32(mf_tag_discard),
                                4, STATS_FLAGS_PORT, "rx_mf_tag_discard" },
+       { STATS_OFFSET32(pfc_frames_received_hi),
+                               8, STATS_FLAGS_PORT, "pfc_frames_received" },
+       { STATS_OFFSET32(pfc_frames_sent_hi),
+                               8, STATS_FLAGS_PORT, "pfc_frames_sent" },
        { STATS_OFFSET32(brb_drop_hi),
                                8, STATS_FLAGS_PORT, "rx_brb_discard" },
        { STATS_OFFSET32(brb_truncate_hi),
index fc754cb6cc0fbf95967f40ba37ae4aca0b50b049..79b6e43b45124219577e9663e95ce632bee47a0a 100644 (file)
@@ -1247,6 +1247,7 @@ struct drv_func_mb {
        #define DRV_MSG_CODE_VRFY_SPECIFIC_PHY_OPT_MDL  0xa1000000
        #define REQ_BC_VER_4_VRFY_SPECIFIC_PHY_OPT_MDL  0x00050234
        #define REQ_BC_VER_4_SFP_TX_DISABLE_SUPPORTED   0x00070014
+       #define REQ_BC_VER_4_PFC_STATS_SUPPORTED        0x00070201
 
        #define DRV_MSG_CODE_DCBX_ADMIN_PMF_MSG         0xb0000000
        #define DRV_MSG_CODE_DCBX_PMF_DRV_OK            0xb2000000
@@ -2501,14 +2502,18 @@ struct mac_stx {
 #define MAC_STX_IDX_MAX                     2
 
 struct host_port_stats {
-       u32            host_port_stats_start;
+       u32            host_port_stats_counter;
 
        struct mac_stx mac_stx[MAC_STX_IDX_MAX];
 
        u32            brb_drop_hi;
        u32            brb_drop_lo;
 
-       u32            host_port_stats_end;
+       u32            not_used; /* obsolete */
+       u32            pfc_frames_tx_hi;
+       u32            pfc_frames_tx_lo;
+       u32            pfc_frames_rx_hi;
+       u32            pfc_frames_rx_lo;
 };
 
 
index 2213e0be5e635cc9cb2b5638b44c8cc61fc4df89..052ab9996b5660ece7877678b520854ba98e7bec 100644 (file)
@@ -8827,6 +8827,8 @@ static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp)
        bp->link_params.feature_config_flags |=
                (val >= REQ_BC_VER_4_SFP_TX_DISABLE_SUPPORTED) ?
                FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED : 0;
+       bp->flags |= (val >= REQ_BC_VER_4_PFC_STATS_SUPPORTED) ?
+                       BC_SUPPORTS_PFC_STATS : 0;
 
        pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_PMC, &pmc);
        bp->flags |= (pmc & PCI_PM_CAP_PME_D3cold) ? 0 : NO_WOL_FLAG;
index 3034f0e319387d97a78a1932bc55c17e4e5c2627..c9435456294f2c3bd26366758c4f41b2987da430 100644 (file)
@@ -540,6 +540,25 @@ static void bnx2x_bmac_stats_update(struct bnx2x *bp)
                UPDATE_STAT64(tx_stat_gterr,
                                tx_stat_dot3statsinternalmactransmiterrors);
                UPDATE_STAT64(tx_stat_gtufl, tx_stat_mac_ufl);
+
+               /* collect PFC stats */
+               DIFF_64(diff.hi, new->tx_stat_gtpp_hi,
+                       pstats->pfc_frames_tx_hi,
+                       diff.lo, new->tx_stat_gtpp_lo,
+                       pstats->pfc_frames_tx_lo);
+               pstats->pfc_frames_tx_hi = new->tx_stat_gtpp_hi;
+               pstats->pfc_frames_tx_lo = new->tx_stat_gtpp_lo;
+               ADD_64(pstats->pfc_frames_tx_hi, diff.hi,
+                       pstats->pfc_frames_tx_lo, diff.lo);
+
+               DIFF_64(diff.hi, new->rx_stat_grpp_hi,
+                       pstats->pfc_frames_rx_hi,
+                       diff.lo, new->rx_stat_grpp_lo,
+                       pstats->pfc_frames_rx_lo);
+               pstats->pfc_frames_rx_hi = new->rx_stat_grpp_hi;
+               pstats->pfc_frames_rx_lo = new->rx_stat_grpp_lo;
+               ADD_64(pstats->pfc_frames_rx_hi, diff.hi,
+                       pstats->pfc_frames_rx_lo, diff.lo);
        }
 
        estats->pause_frames_received_hi =
@@ -551,6 +570,15 @@ static void bnx2x_bmac_stats_update(struct bnx2x *bp)
                                pstats->mac_stx[1].tx_stat_outxoffsent_hi;
        estats->pause_frames_sent_lo =
                                pstats->mac_stx[1].tx_stat_outxoffsent_lo;
+
+       estats->pfc_frames_received_hi =
+                               pstats->pfc_frames_rx_hi;
+       estats->pfc_frames_received_lo =
+                               pstats->pfc_frames_rx_lo;
+       estats->pfc_frames_sent_hi =
+                               pstats->pfc_frames_tx_hi;
+       estats->pfc_frames_sent_lo =
+                               pstats->pfc_frames_tx_lo;
 }
 
 static void bnx2x_mstat_stats_update(struct bnx2x *bp)
@@ -571,6 +599,11 @@ static void bnx2x_mstat_stats_update(struct bnx2x *bp)
        ADD_STAT64(stats_tx.tx_gtxpf, tx_stat_outxoffsent);
        ADD_STAT64(stats_tx.tx_gtxpf, tx_stat_flowcontroldone);
 
+       /* collect pfc stats */
+       ADD_64(pstats->pfc_frames_tx_hi, new->stats_tx.tx_gtxpp_hi,
+               pstats->pfc_frames_tx_lo, new->stats_tx.tx_gtxpp_lo);
+       ADD_64(pstats->pfc_frames_rx_hi, new->stats_rx.rx_grxpp_hi,
+               pstats->pfc_frames_rx_lo, new->stats_rx.rx_grxpp_lo);
 
        ADD_STAT64(stats_tx.tx_gt64, tx_stat_etherstatspkts64octets);
        ADD_STAT64(stats_tx.tx_gt127,
@@ -628,6 +661,15 @@ static void bnx2x_mstat_stats_update(struct bnx2x *bp)
                                pstats->mac_stx[1].tx_stat_outxoffsent_hi;
        estats->pause_frames_sent_lo =
                                pstats->mac_stx[1].tx_stat_outxoffsent_lo;
+
+       estats->pfc_frames_received_hi =
+                               pstats->pfc_frames_rx_hi;
+       estats->pfc_frames_received_lo =
+                               pstats->pfc_frames_rx_lo;
+       estats->pfc_frames_sent_hi =
+                               pstats->pfc_frames_tx_hi;
+       estats->pfc_frames_sent_lo =
+                               pstats->pfc_frames_tx_lo;
 }
 
 static void bnx2x_emac_stats_update(struct bnx2x *bp)
@@ -740,7 +782,7 @@ static int bnx2x_hw_stats_update(struct bnx2x *bp)
        estats->brb_drop_hi = pstats->brb_drop_hi;
        estats->brb_drop_lo = pstats->brb_drop_lo;
 
-       pstats->host_port_stats_start = ++pstats->host_port_stats_end;
+       pstats->host_port_stats_counter++;
 
        if (!BP_NOMCP(bp)) {
                u32 nig_timer_max =
index 5d8ce2f6afef13779aad7442e147d8dab7ba6aa9..683deb053109d817aa578906f4f6874c0ec994b5 100644 (file)
@@ -193,6 +193,12 @@ struct bnx2x_eth_stats {
        u32 total_tpa_aggregated_frames_lo;
        u32 total_tpa_bytes_hi;
        u32 total_tpa_bytes_lo;
+
+       /* PFC */
+       u32 pfc_frames_received_hi;
+       u32 pfc_frames_received_lo;
+       u32 pfc_frames_sent_hi;
+       u32 pfc_frames_sent_lo;
 };