Skip to content

Commit 8217f93

Browse files
Michael Changregkh
authored andcommitted
bnxt_en: Save ring error counters across reset
[ Upstream commit 4c70dbe ] Currently, the ring counters are stored in the per ring datastructure. During reset, all the rings are freed together with the associated datastructures. As a result, all the ring error counters will be reset to zero. Add logic to keep track of the total error counts of all the rings and save them before reset (including ifdown). The next patch will display these total ring error counters under ethtool -S. Link: https://lore.kernel.org/netdev/CACKFLimD-bKmJ1tGZOLYRjWzEwxkri-Mw7iFme1x2Dr0twdCeg@mail.gmail.com/ Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com> Reviewed-by: Andy Gospodarek <andrew.gospodarek@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-5-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Stable-dep-of: bd6781c ("bnxt_en: Fix wrong return value check in bnxt_close_nic()") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 53cacb8 commit 8217f93

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10708,8 +10708,10 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init,
1070810708
bnxt_free_skbs(bp);
1070910709

1071010710
/* Save ring stats before shutdown */
10711-
if (bp->bnapi && irq_re_init)
10711+
if (bp->bnapi && irq_re_init) {
1071210712
bnxt_get_ring_stats(bp, &bp->net_stats_prev);
10713+
bnxt_get_ring_err_stats(bp, &bp->ring_err_stats_prev);
10714+
}
1071310715
if (irq_re_init) {
1071410716
bnxt_free_irq(bp);
1071510717
bnxt_del_napi(bp);
@@ -10958,6 +10960,34 @@ bnxt_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
1095810960
clear_bit(BNXT_STATE_READ_STATS, &bp->state);
1095910961
}
1096010962

10963+
static void bnxt_get_one_ring_err_stats(struct bnxt *bp,
10964+
struct bnxt_total_ring_err_stats *stats,
10965+
struct bnxt_cp_ring_info *cpr)
10966+
{
10967+
struct bnxt_sw_stats *sw_stats = &cpr->sw_stats;
10968+
u64 *hw_stats = cpr->stats.sw_stats;
10969+
10970+
stats->rx_total_l4_csum_errors += sw_stats->rx.rx_l4_csum_errors;
10971+
stats->rx_total_resets += sw_stats->rx.rx_resets;
10972+
stats->rx_total_buf_errors += sw_stats->rx.rx_buf_errors;
10973+
stats->rx_total_oom_discards += sw_stats->rx.rx_oom_discards;
10974+
stats->rx_total_netpoll_discards += sw_stats->rx.rx_netpoll_discards;
10975+
stats->rx_total_ring_discards +=
10976+
BNXT_GET_RING_STATS64(hw_stats, rx_discard_pkts);
10977+
stats->tx_total_ring_discards +=
10978+
BNXT_GET_RING_STATS64(hw_stats, tx_discard_pkts);
10979+
stats->total_missed_irqs += sw_stats->cmn.missed_irqs;
10980+
}
10981+
10982+
void bnxt_get_ring_err_stats(struct bnxt *bp,
10983+
struct bnxt_total_ring_err_stats *stats)
10984+
{
10985+
int i;
10986+
10987+
for (i = 0; i < bp->cp_nr_rings; i++)
10988+
bnxt_get_one_ring_err_stats(bp, stats, &bp->bnapi[i]->cp_ring);
10989+
}
10990+
1096110991
static bool bnxt_mc_list_updated(struct bnxt *bp, u32 *rx_mask)
1096210992
{
1096310993
struct net_device *dev = bp->dev;

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,17 @@ struct bnxt_sw_stats {
950950
struct bnxt_cmn_sw_stats cmn;
951951
};
952952

953+
struct bnxt_total_ring_err_stats {
954+
u64 rx_total_l4_csum_errors;
955+
u64 rx_total_resets;
956+
u64 rx_total_buf_errors;
957+
u64 rx_total_oom_discards;
958+
u64 rx_total_netpoll_discards;
959+
u64 rx_total_ring_discards;
960+
u64 tx_total_ring_discards;
961+
u64 total_missed_irqs;
962+
};
963+
953964
struct bnxt_stats_mem {
954965
u64 *sw_stats;
955966
u64 *hw_masks;
@@ -2007,6 +2018,8 @@ struct bnxt {
20072018
u8 pri2cos_idx[8];
20082019
u8 pri2cos_valid;
20092020

2021+
struct bnxt_total_ring_err_stats ring_err_stats_prev;
2022+
20102023
u16 hwrm_max_req_len;
20112024
u16 hwrm_max_ext_req_len;
20122025
unsigned int hwrm_cmd_timeout;
@@ -2331,6 +2344,8 @@ int bnxt_half_open_nic(struct bnxt *bp);
23312344
void bnxt_half_close_nic(struct bnxt *bp);
23322345
void bnxt_reenable_sriov(struct bnxt *bp);
23332346
int bnxt_close_nic(struct bnxt *, bool, bool);
2347+
void bnxt_get_ring_err_stats(struct bnxt *bp,
2348+
struct bnxt_total_ring_err_stats *stats);
23342349
int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words,
23352350
u32 *reg_buf);
23362351
void bnxt_fw_exception(struct bnxt *bp);

0 commit comments

Comments
 (0)