diff options
author | Michael Chan <michael.chan@broadcom.com> | 2020-05-04 04:50:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-05-04 10:44:11 -0700 |
commit | 3316d50905f0e551d4786767d827589960a8cb83 (patch) | |
tree | cefcf787750ffeb2e34539fd77ddd6e7a61bdca2 /drivers | |
parent | 9d8b5f05529c619b63d68b0dd26a1dfe35a4fab2 (diff) |
bnxt_en: Split HW ring statistics strings into RX and TX parts.
This will allow the RX and TX ring statistics to be separated if needed.
In the next patch, we'll be able to only display RX or TX statistcis if
the channel is RX only or TX only.
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index b2b43a7a9abb..85080f50bce5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -137,7 +137,7 @@ reset_coalesce: return rc; } -static const char * const bnxt_ring_stats_str[] = { +static const char * const bnxt_ring_rx_stats_str[] = { "rx_ucast_packets", "rx_mcast_packets", "rx_bcast_packets", @@ -146,6 +146,9 @@ static const char * const bnxt_ring_stats_str[] = { "rx_ucast_bytes", "rx_mcast_bytes", "rx_bcast_bytes", +}; + +static const char * const bnxt_ring_tx_stats_str[] = { "tx_ucast_packets", "tx_mcast_packets", "tx_bcast_packets", @@ -306,6 +309,11 @@ static struct { {0, "tx_total_discard_pkts"}, }; +#define NUM_RING_RX_SW_STATS ARRAY_SIZE(bnxt_rx_sw_stats_str) +#define NUM_RING_CMN_SW_STATS ARRAY_SIZE(bnxt_cmn_sw_stats_str) +#define NUM_RING_RX_HW_STATS ARRAY_SIZE(bnxt_ring_rx_stats_str) +#define NUM_RING_TX_HW_STATS ARRAY_SIZE(bnxt_ring_tx_stats_str) + static const struct { long offset; char string[ETH_GSTRING_LEN]; @@ -485,13 +493,13 @@ static int bnxt_get_num_tpa_ring_stats(struct bnxt *bp) static int bnxt_get_num_ring_stats(struct bnxt *bp) { - int num_stats; + int rx, tx, cmn; - num_stats = ARRAY_SIZE(bnxt_ring_stats_str) + - ARRAY_SIZE(bnxt_rx_sw_stats_str) + - ARRAY_SIZE(bnxt_cmn_sw_stats_str) + - bnxt_get_num_tpa_ring_stats(bp); - return num_stats * bp->cp_nr_rings; + rx = NUM_RING_RX_HW_STATS + NUM_RING_RX_SW_STATS + + bnxt_get_num_tpa_ring_stats(bp); + tx = NUM_RING_TX_HW_STATS; + cmn = NUM_RING_CMN_SW_STATS; + return (rx + tx + cmn) * bp->cp_nr_rings; } static int bnxt_get_num_stats(struct bnxt *bp) @@ -537,7 +545,7 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, { u32 i, j = 0; struct bnxt *bp = netdev_priv(dev); - u32 stat_fields = ARRAY_SIZE(bnxt_ring_stats_str) + + u32 stat_fields = NUM_RING_RX_HW_STATS + NUM_RING_TX_HW_STATS + bnxt_get_num_tpa_ring_stats(bp); if (!bp->bnapi) { @@ -559,11 +567,11 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, buf[j] = le64_to_cpu(hw_stats[k]); sw = (u64 *)&cpr->sw_stats.rx; - for (k = 0; k < ARRAY_SIZE(bnxt_rx_sw_stats_str); j++, k++) + for (k = 0; k < NUM_RING_RX_SW_STATS; j++, k++) buf[j] = sw[k]; sw = (u64 *)&cpr->sw_stats.cmn; - for (k = 0; k < ARRAY_SIZE(bnxt_cmn_sw_stats_str); j++, k++) + for (k = 0; k < NUM_RING_CMN_SW_STATS; j++, k++) buf[j] = sw[k]; bnxt_sw_func_stats[RX_TOTAL_DISCARDS].counter += @@ -642,34 +650,39 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf) switch (stringset) { case ETH_SS_STATS: for (i = 0; i < bp->cp_nr_rings; i++) { - num_str = ARRAY_SIZE(bnxt_ring_stats_str); + num_str = NUM_RING_RX_HW_STATS; for (j = 0; j < num_str; j++) { sprintf(buf, "[%d]: %s", i, - bnxt_ring_stats_str[j]); + bnxt_ring_rx_stats_str[j]); buf += ETH_GSTRING_LEN; } - if (!BNXT_SUPPORTS_TPA(bp)) + num_str = NUM_RING_TX_HW_STATS; + for (j = 0; j < num_str; j++) { + sprintf(buf, "[%d]: %s", i, + bnxt_ring_tx_stats_str[j]); + buf += ETH_GSTRING_LEN; + } + num_str = bnxt_get_num_tpa_ring_stats(bp); + if (!num_str) goto skip_tpa_stats; - if (bp->max_tpa_v2) { - num_str = ARRAY_SIZE(bnxt_ring_tpa2_stats_str); + if (bp->max_tpa_v2) str = bnxt_ring_tpa2_stats_str; - } else { - num_str = ARRAY_SIZE(bnxt_ring_tpa_stats_str); + else str = bnxt_ring_tpa_stats_str; - } + for (j = 0; j < num_str; j++) { sprintf(buf, "[%d]: %s", i, str[j]); buf += ETH_GSTRING_LEN; } skip_tpa_stats: - num_str = ARRAY_SIZE(bnxt_rx_sw_stats_str); + num_str = NUM_RING_RX_SW_STATS; for (j = 0; j < num_str; j++) { sprintf(buf, "[%d]: %s", i, bnxt_rx_sw_stats_str[j]); buf += ETH_GSTRING_LEN; } - num_str = ARRAY_SIZE(bnxt_cmn_sw_stats_str); + num_str = NUM_RING_CMN_SW_STATS; for (j = 0; j < num_str; j++) { sprintf(buf, "[%d]: %s", i, bnxt_cmn_sw_stats_str[j]); |