Skip to content

Commit 4c70dbe

Browse files
Michael Chankuba-moo
authored andcommitted
bnxt_en: Save ring error counters across reset
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>
1 parent d38c19b commit 4c70dbe

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

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

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

1068710687
/* Save ring stats before shutdown */
10688-
if (bp->bnapi && irq_re_init)
10688+
if (bp->bnapi && irq_re_init) {
1068910689
bnxt_get_ring_stats(bp, &bp->net_stats_prev);
10690+
bnxt_get_ring_err_stats(bp, &bp->ring_err_stats_prev);
10691+
}
1069010692
if (irq_re_init) {
1069110693
bnxt_free_irq(bp);
1069210694
bnxt_del_napi(bp);
@@ -10935,6 +10937,34 @@ bnxt_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
1093510937
clear_bit(BNXT_STATE_READ_STATS, &bp->state);
1093610938
}
1093710939

10940+
static void bnxt_get_one_ring_err_stats(struct bnxt *bp,
10941+
struct bnxt_total_ring_err_stats *stats,
10942+
struct bnxt_cp_ring_info *cpr)
10943+
{
10944+
struct bnxt_sw_stats *sw_stats = &cpr->sw_stats;
10945+
u64 *hw_stats = cpr->stats.sw_stats;
10946+
10947+
stats->rx_total_l4_csum_errors += sw_stats->rx.rx_l4_csum_errors;
10948+
stats->rx_total_resets += sw_stats->rx.rx_resets;
10949+
stats->rx_total_buf_errors += sw_stats->rx.rx_buf_errors;
10950+
stats->rx_total_oom_discards += sw_stats->rx.rx_oom_discards;
10951+
stats->rx_total_netpoll_discards += sw_stats->rx.rx_netpoll_discards;
10952+
stats->rx_total_ring_discards +=
10953+
BNXT_GET_RING_STATS64(hw_stats, rx_discard_pkts);
10954+
stats->tx_total_ring_discards +=
10955+
BNXT_GET_RING_STATS64(hw_stats, tx_discard_pkts);
10956+
stats->total_missed_irqs += sw_stats->cmn.missed_irqs;
10957+
}
10958+
10959+
void bnxt_get_ring_err_stats(struct bnxt *bp,
10960+
struct bnxt_total_ring_err_stats *stats)
10961+
{
10962+
int i;
10963+
10964+
for (i = 0; i < bp->cp_nr_rings; i++)
10965+
bnxt_get_one_ring_err_stats(bp, stats, &bp->bnapi[i]->cp_ring);
10966+
}
10967+
1093810968
static bool bnxt_mc_list_updated(struct bnxt *bp, u32 *rx_mask)
1093910969
{
1094010970
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
@@ -948,6 +948,17 @@ struct bnxt_sw_stats {
948948
struct bnxt_cmn_sw_stats cmn;
949949
};
950950

951+
struct bnxt_total_ring_err_stats {
952+
u64 rx_total_l4_csum_errors;
953+
u64 rx_total_resets;
954+
u64 rx_total_buf_errors;
955+
u64 rx_total_oom_discards;
956+
u64 rx_total_netpoll_discards;
957+
u64 rx_total_ring_discards;
958+
u64 tx_total_ring_discards;
959+
u64 total_missed_irqs;
960+
};
961+
951962
struct bnxt_stats_mem {
952963
u64 *sw_stats;
953964
u64 *hw_masks;
@@ -2018,6 +2029,8 @@ struct bnxt {
20182029
u8 pri2cos_idx[8];
20192030
u8 pri2cos_valid;
20202031

2032+
struct bnxt_total_ring_err_stats ring_err_stats_prev;
2033+
20212034
u16 hwrm_max_req_len;
20222035
u16 hwrm_max_ext_req_len;
20232036
unsigned int hwrm_cmd_timeout;
@@ -2344,6 +2357,8 @@ int bnxt_half_open_nic(struct bnxt *bp);
23442357
void bnxt_half_close_nic(struct bnxt *bp);
23452358
void bnxt_reenable_sriov(struct bnxt *bp);
23462359
int bnxt_close_nic(struct bnxt *, bool, bool);
2360+
void bnxt_get_ring_err_stats(struct bnxt *bp,
2361+
struct bnxt_total_ring_err_stats *stats);
23472362
int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words,
23482363
u32 *reg_buf);
23492364
void bnxt_fw_exception(struct bnxt *bp);

0 commit comments

Comments
 (0)