Skip to content

Commit a080b47

Browse files
Michael Chankuba-moo
authored andcommitted
bnxt_en: Display the ring error counters under ethtool -S
The existing driver displays the sum of 4 ring counters under ethtool -S. These counters are in the array bnxt_sw_func_stats. These counters are summed at the time of ethtool -S and will be lost when the device is reset. Replace these counters with the new total ring error counters added in the last patch. These new counters are saved before reset. ethtool -S will now display the sum of the saved counters plus the current counters. Link: https://lore.kernel.org/netdev/CACKFLimD-bKmJ1tGZOLYRjWzEwxkri-Mw7iFme1x2Dr0twdCeg@mail.gmail.com/ Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com> Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Link: https://lore.kernel.org/r/20230817231911.165035-6-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 4c70dbe commit a080b47

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

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

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,15 @@ enum {
339339
RX_NETPOLL_DISCARDS,
340340
};
341341

342-
static struct {
343-
u64 counter;
344-
char string[ETH_GSTRING_LEN];
345-
} bnxt_sw_func_stats[] = {
346-
{0, "rx_total_discard_pkts"},
347-
{0, "tx_total_discard_pkts"},
348-
{0, "rx_total_netpoll_discards"},
342+
static const char *const bnxt_ring_err_stats_arr[] = {
343+
"rx_total_l4_csum_errors",
344+
"rx_total_resets",
345+
"rx_total_buf_errors",
346+
"rx_total_oom_discards",
347+
"rx_total_netpoll_discards",
348+
"rx_total_ring_discards",
349+
"tx_total_ring_discards",
350+
"total_missed_irqs",
349351
};
350352

351353
#define NUM_RING_RX_SW_STATS ARRAY_SIZE(bnxt_rx_sw_stats_str)
@@ -495,7 +497,7 @@ static const struct {
495497
BNXT_TX_STATS_PRI_ENTRIES(tx_packets),
496498
};
497499

498-
#define BNXT_NUM_SW_FUNC_STATS ARRAY_SIZE(bnxt_sw_func_stats)
500+
#define BNXT_NUM_RING_ERR_STATS ARRAY_SIZE(bnxt_ring_err_stats_arr)
499501
#define BNXT_NUM_PORT_STATS ARRAY_SIZE(bnxt_port_stats_arr)
500502
#define BNXT_NUM_STATS_PRI \
501503
(ARRAY_SIZE(bnxt_rx_bytes_pri_arr) + \
@@ -532,7 +534,7 @@ static int bnxt_get_num_stats(struct bnxt *bp)
532534
{
533535
int num_stats = bnxt_get_num_ring_stats(bp);
534536

535-
num_stats += BNXT_NUM_SW_FUNC_STATS;
537+
num_stats += BNXT_NUM_RING_ERR_STATS;
536538

537539
if (bp->flags & BNXT_FLAG_PORT_STATS)
538540
num_stats += BNXT_NUM_PORT_STATS;
@@ -583,18 +585,17 @@ static bool is_tx_ring(struct bnxt *bp, int ring_num)
583585
static void bnxt_get_ethtool_stats(struct net_device *dev,
584586
struct ethtool_stats *stats, u64 *buf)
585587
{
586-
u32 i, j = 0;
588+
struct bnxt_total_ring_err_stats ring_err_stats = {0};
587589
struct bnxt *bp = netdev_priv(dev);
590+
u64 *curr, *prev;
588591
u32 tpa_stats;
592+
u32 i, j = 0;
589593

590594
if (!bp->bnapi) {
591-
j += bnxt_get_num_ring_stats(bp) + BNXT_NUM_SW_FUNC_STATS;
595+
j += bnxt_get_num_ring_stats(bp);
592596
goto skip_ring_stats;
593597
}
594598

595-
for (i = 0; i < BNXT_NUM_SW_FUNC_STATS; i++)
596-
bnxt_sw_func_stats[i].counter = 0;
597-
598599
tpa_stats = bnxt_get_num_tpa_ring_stats(bp);
599600
for (i = 0; i < bp->cp_nr_rings; i++) {
600601
struct bnxt_napi *bnapi = bp->bnapi[i];
@@ -631,19 +632,16 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
631632
sw = (u64 *)&cpr->sw_stats.cmn;
632633
for (k = 0; k < NUM_RING_CMN_SW_STATS; j++, k++)
633634
buf[j] = sw[k];
634-
635-
bnxt_sw_func_stats[RX_TOTAL_DISCARDS].counter +=
636-
BNXT_GET_RING_STATS64(sw_stats, rx_discard_pkts);
637-
bnxt_sw_func_stats[TX_TOTAL_DISCARDS].counter +=
638-
BNXT_GET_RING_STATS64(sw_stats, tx_discard_pkts);
639-
bnxt_sw_func_stats[RX_NETPOLL_DISCARDS].counter +=
640-
cpr->sw_stats.rx.rx_netpoll_discards;
641635
}
642636

643-
for (i = 0; i < BNXT_NUM_SW_FUNC_STATS; i++, j++)
644-
buf[j] = bnxt_sw_func_stats[i].counter;
637+
bnxt_get_ring_err_stats(bp, &ring_err_stats);
645638

646639
skip_ring_stats:
640+
curr = &ring_err_stats.rx_total_l4_csum_errors;
641+
prev = &bp->ring_err_stats_prev.rx_total_l4_csum_errors;
642+
for (i = 0; i < BNXT_NUM_RING_ERR_STATS; i++, j++, curr++, prev++)
643+
buf[j] = *curr + *prev;
644+
647645
if (bp->flags & BNXT_FLAG_PORT_STATS) {
648646
u64 *port_stats = bp->port_stats.sw_stats;
649647

@@ -745,8 +743,8 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
745743
buf += ETH_GSTRING_LEN;
746744
}
747745
}
748-
for (i = 0; i < BNXT_NUM_SW_FUNC_STATS; i++) {
749-
strcpy(buf, bnxt_sw_func_stats[i].string);
746+
for (i = 0; i < BNXT_NUM_RING_ERR_STATS; i++) {
747+
strscpy(buf, bnxt_ring_err_stats_arr[i], ETH_GSTRING_LEN);
750748
buf += ETH_GSTRING_LEN;
751749
}
752750

0 commit comments

Comments
 (0)