Skip to content

Commit

Permalink
bnx2x: add PFC statistics
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Barak Witkowski authored and David S. Miller committed Dec 6, 2011
1 parent f0a98ae commit 0e898dd
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 3 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
9 changes: 7 additions & 2 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
};


Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
44 changes: 43 additions & 1 deletion drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 =
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};


Expand Down

0 comments on commit 0e898dd

Please sign in to comment.