bnxt_en: Add PFC statistics.
authorMichael Chan <michael.chan@broadcom.com>
Sat, 3 Dec 2016 02:17:18 +0000 (21:17 -0500)
committerDavid S. Miller <davem@davemloft.net>
Mon, 5 Dec 2016 18:21:40 +0000 (13:21 -0500)
Report PFC statistics to ethtool -S and DCBNL.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

index 2a714cf919c2ab90e6219507efe1849f401106f6..b4abc1b505f7d305119045b7a4e26e8e3689e80f 100644 (file)
@@ -1124,6 +1124,13 @@ struct bnxt {
        u32                     lpi_tmr_hi;
 };
 
+#define BNXT_RX_STATS_OFFSET(counter)                  \
+       (offsetof(struct rx_port_stats, counter) / 8)
+
+#define BNXT_TX_STATS_OFFSET(counter)                  \
+       ((offsetof(struct tx_port_stats, counter) +     \
+         sizeof(struct rx_port_stats) + 512) / 8)
+
 #ifdef CONFIG_NET_RX_BUSY_POLL
 static inline void bnxt_enable_poll(struct bnxt_napi *bnapi)
 {
index f391b47262bb4d266170bbb80b3225cc0cd3eef1..fdf2d8caf7bfaae56b4b39c415feaa343f29d579 100644 (file)
@@ -347,8 +347,10 @@ static int bnxt_dcbnl_ieee_setets(struct net_device *dev, struct ieee_ets *ets)
 static int bnxt_dcbnl_ieee_getpfc(struct net_device *dev, struct ieee_pfc *pfc)
 {
        struct bnxt *bp = netdev_priv(dev);
+       __le64 *stats = (__le64 *)bp->hw_rx_port_stats;
        struct ieee_pfc *my_pfc = bp->ieee_pfc;
-       int rc;
+       long rx_off, tx_off;
+       int i, rc;
 
        pfc->pfc_cap = bp->max_lltc;
 
@@ -369,6 +371,16 @@ static int bnxt_dcbnl_ieee_getpfc(struct net_device *dev, struct ieee_pfc *pfc)
        pfc->mbc = my_pfc->mbc;
        pfc->delay = my_pfc->delay;
 
+       if (!stats)
+               return 0;
+
+       rx_off = BNXT_RX_STATS_OFFSET(rx_pfc_ena_frames_pri0);
+       tx_off = BNXT_TX_STATS_OFFSET(tx_pfc_ena_frames_pri0);
+       for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++, rx_off++, tx_off++) {
+               pfc->requests[i] = le64_to_cpu(*(stats + tx_off));
+               pfc->indications[i] = le64_to_cpu(*(stats + rx_off));
+       }
+
        return 0;
 }
 
index fa6125eb24afc576cddf2c1bd5128a0dda26fb18..784aa77610bc5756ee8a8d0efe9f37d5679cbf7a 100644 (file)
@@ -107,16 +107,9 @@ static int bnxt_set_coalesce(struct net_device *dev,
 
 #define BNXT_NUM_STATS 21
 
-#define BNXT_RX_STATS_OFFSET(counter)  \
-       (offsetof(struct rx_port_stats, counter) / 8)
-
 #define BNXT_RX_STATS_ENTRY(counter)   \
        { BNXT_RX_STATS_OFFSET(counter), __stringify(counter) }
 
-#define BNXT_TX_STATS_OFFSET(counter)                  \
-       ((offsetof(struct tx_port_stats, counter) +     \
-         sizeof(struct rx_port_stats) + 512) / 8)
-
 #define BNXT_TX_STATS_ENTRY(counter)   \
        { BNXT_TX_STATS_OFFSET(counter), __stringify(counter) }
 
@@ -150,6 +143,14 @@ static const struct {
        BNXT_RX_STATS_ENTRY(rx_tagged_frames),
        BNXT_RX_STATS_ENTRY(rx_double_tagged_frames),
        BNXT_RX_STATS_ENTRY(rx_good_frames),
+       BNXT_RX_STATS_ENTRY(rx_pfc_ena_frames_pri0),
+       BNXT_RX_STATS_ENTRY(rx_pfc_ena_frames_pri1),
+       BNXT_RX_STATS_ENTRY(rx_pfc_ena_frames_pri2),
+       BNXT_RX_STATS_ENTRY(rx_pfc_ena_frames_pri3),
+       BNXT_RX_STATS_ENTRY(rx_pfc_ena_frames_pri4),
+       BNXT_RX_STATS_ENTRY(rx_pfc_ena_frames_pri5),
+       BNXT_RX_STATS_ENTRY(rx_pfc_ena_frames_pri6),
+       BNXT_RX_STATS_ENTRY(rx_pfc_ena_frames_pri7),
        BNXT_RX_STATS_ENTRY(rx_undrsz_frames),
        BNXT_RX_STATS_ENTRY(rx_eee_lpi_events),
        BNXT_RX_STATS_ENTRY(rx_eee_lpi_duration),
@@ -179,6 +180,14 @@ static const struct {
        BNXT_TX_STATS_ENTRY(tx_fcs_err_frames),
        BNXT_TX_STATS_ENTRY(tx_err),
        BNXT_TX_STATS_ENTRY(tx_fifo_underruns),
+       BNXT_TX_STATS_ENTRY(tx_pfc_ena_frames_pri0),
+       BNXT_TX_STATS_ENTRY(tx_pfc_ena_frames_pri1),
+       BNXT_TX_STATS_ENTRY(tx_pfc_ena_frames_pri2),
+       BNXT_TX_STATS_ENTRY(tx_pfc_ena_frames_pri3),
+       BNXT_TX_STATS_ENTRY(tx_pfc_ena_frames_pri4),
+       BNXT_TX_STATS_ENTRY(tx_pfc_ena_frames_pri5),
+       BNXT_TX_STATS_ENTRY(tx_pfc_ena_frames_pri6),
+       BNXT_TX_STATS_ENTRY(tx_pfc_ena_frames_pri7),
        BNXT_TX_STATS_ENTRY(tx_eee_lpi_events),
        BNXT_TX_STATS_ENTRY(tx_eee_lpi_duration),
        BNXT_TX_STATS_ENTRY(tx_total_collisions),