Skip to content

Commit 3316d50

Browse files
Michael Chandavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9d8b5f0 commit 3316d50

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int bnxt_set_coalesce(struct net_device *dev,
137137
return rc;
138138
}
139139

140-
static const char * const bnxt_ring_stats_str[] = {
140+
static const char * const bnxt_ring_rx_stats_str[] = {
141141
"rx_ucast_packets",
142142
"rx_mcast_packets",
143143
"rx_bcast_packets",
@@ -146,6 +146,9 @@ static const char * const bnxt_ring_stats_str[] = {
146146
"rx_ucast_bytes",
147147
"rx_mcast_bytes",
148148
"rx_bcast_bytes",
149+
};
150+
151+
static const char * const bnxt_ring_tx_stats_str[] = {
149152
"tx_ucast_packets",
150153
"tx_mcast_packets",
151154
"tx_bcast_packets",
@@ -306,6 +309,11 @@ static struct {
306309
{0, "tx_total_discard_pkts"},
307310
};
308311

312+
#define NUM_RING_RX_SW_STATS ARRAY_SIZE(bnxt_rx_sw_stats_str)
313+
#define NUM_RING_CMN_SW_STATS ARRAY_SIZE(bnxt_cmn_sw_stats_str)
314+
#define NUM_RING_RX_HW_STATS ARRAY_SIZE(bnxt_ring_rx_stats_str)
315+
#define NUM_RING_TX_HW_STATS ARRAY_SIZE(bnxt_ring_tx_stats_str)
316+
309317
static const struct {
310318
long offset;
311319
char string[ETH_GSTRING_LEN];
@@ -485,13 +493,13 @@ static int bnxt_get_num_tpa_ring_stats(struct bnxt *bp)
485493

486494
static int bnxt_get_num_ring_stats(struct bnxt *bp)
487495
{
488-
int num_stats;
496+
int rx, tx, cmn;
489497

490-
num_stats = ARRAY_SIZE(bnxt_ring_stats_str) +
491-
ARRAY_SIZE(bnxt_rx_sw_stats_str) +
492-
ARRAY_SIZE(bnxt_cmn_sw_stats_str) +
493-
bnxt_get_num_tpa_ring_stats(bp);
494-
return num_stats * bp->cp_nr_rings;
498+
rx = NUM_RING_RX_HW_STATS + NUM_RING_RX_SW_STATS +
499+
bnxt_get_num_tpa_ring_stats(bp);
500+
tx = NUM_RING_TX_HW_STATS;
501+
cmn = NUM_RING_CMN_SW_STATS;
502+
return (rx + tx + cmn) * bp->cp_nr_rings;
495503
}
496504

497505
static int bnxt_get_num_stats(struct bnxt *bp)
@@ -537,7 +545,7 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
537545
{
538546
u32 i, j = 0;
539547
struct bnxt *bp = netdev_priv(dev);
540-
u32 stat_fields = ARRAY_SIZE(bnxt_ring_stats_str) +
548+
u32 stat_fields = NUM_RING_RX_HW_STATS + NUM_RING_TX_HW_STATS +
541549
bnxt_get_num_tpa_ring_stats(bp);
542550

543551
if (!bp->bnapi) {
@@ -559,11 +567,11 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
559567
buf[j] = le64_to_cpu(hw_stats[k]);
560568

561569
sw = (u64 *)&cpr->sw_stats.rx;
562-
for (k = 0; k < ARRAY_SIZE(bnxt_rx_sw_stats_str); j++, k++)
570+
for (k = 0; k < NUM_RING_RX_SW_STATS; j++, k++)
563571
buf[j] = sw[k];
564572

565573
sw = (u64 *)&cpr->sw_stats.cmn;
566-
for (k = 0; k < ARRAY_SIZE(bnxt_cmn_sw_stats_str); j++, k++)
574+
for (k = 0; k < NUM_RING_CMN_SW_STATS; j++, k++)
567575
buf[j] = sw[k];
568576

569577
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)
642650
switch (stringset) {
643651
case ETH_SS_STATS:
644652
for (i = 0; i < bp->cp_nr_rings; i++) {
645-
num_str = ARRAY_SIZE(bnxt_ring_stats_str);
653+
num_str = NUM_RING_RX_HW_STATS;
646654
for (j = 0; j < num_str; j++) {
647655
sprintf(buf, "[%d]: %s", i,
648-
bnxt_ring_stats_str[j]);
656+
bnxt_ring_rx_stats_str[j]);
649657
buf += ETH_GSTRING_LEN;
650658
}
651-
if (!BNXT_SUPPORTS_TPA(bp))
659+
num_str = NUM_RING_TX_HW_STATS;
660+
for (j = 0; j < num_str; j++) {
661+
sprintf(buf, "[%d]: %s", i,
662+
bnxt_ring_tx_stats_str[j]);
663+
buf += ETH_GSTRING_LEN;
664+
}
665+
num_str = bnxt_get_num_tpa_ring_stats(bp);
666+
if (!num_str)
652667
goto skip_tpa_stats;
653668

654-
if (bp->max_tpa_v2) {
655-
num_str = ARRAY_SIZE(bnxt_ring_tpa2_stats_str);
669+
if (bp->max_tpa_v2)
656670
str = bnxt_ring_tpa2_stats_str;
657-
} else {
658-
num_str = ARRAY_SIZE(bnxt_ring_tpa_stats_str);
671+
else
659672
str = bnxt_ring_tpa_stats_str;
660-
}
673+
661674
for (j = 0; j < num_str; j++) {
662675
sprintf(buf, "[%d]: %s", i, str[j]);
663676
buf += ETH_GSTRING_LEN;
664677
}
665678
skip_tpa_stats:
666-
num_str = ARRAY_SIZE(bnxt_rx_sw_stats_str);
679+
num_str = NUM_RING_RX_SW_STATS;
667680
for (j = 0; j < num_str; j++) {
668681
sprintf(buf, "[%d]: %s", i,
669682
bnxt_rx_sw_stats_str[j]);
670683
buf += ETH_GSTRING_LEN;
671684
}
672-
num_str = ARRAY_SIZE(bnxt_cmn_sw_stats_str);
685+
num_str = NUM_RING_CMN_SW_STATS;
673686
for (j = 0; j < num_str; j++) {
674687
sprintf(buf, "[%d]: %s", i,
675688
bnxt_cmn_sw_stats_str[j]);

0 commit comments

Comments
 (0)