Commit 9d8b5f05 authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

bnxt_en: Refactor the software ring counters.

We currently have 3 software ring counters, rx_l4_csum_errors,
rx_buf_errors, and missed_irqs.  The 1st two are RX counters and the
last one is a common counter.  Organize them into 2 structures
bnxt_rx_sw_stats and bnxt_cmn_sw_stats.
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 098286ff
...@@ -1766,7 +1766,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, ...@@ -1766,7 +1766,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
rc = -EIO; rc = -EIO;
if (rx_err & RX_CMPL_ERRORS_BUFFER_ERROR_MASK) { if (rx_err & RX_CMPL_ERRORS_BUFFER_ERROR_MASK) {
bnapi->cp_ring.rx_buf_errors++; bnapi->cp_ring.sw_stats.rx.rx_buf_errors++;
if (!(bp->flags & BNXT_FLAG_CHIP_P5)) { if (!(bp->flags & BNXT_FLAG_CHIP_P5)) {
netdev_warn(bp->dev, "RX buffer error %x\n", netdev_warn(bp->dev, "RX buffer error %x\n",
rx_err); rx_err);
...@@ -1849,7 +1849,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, ...@@ -1849,7 +1849,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
} else { } else {
if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS) { if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS) {
if (dev->features & NETIF_F_RXCSUM) if (dev->features & NETIF_F_RXCSUM)
bnapi->cp_ring.rx_l4_csum_errors++; bnapi->cp_ring.sw_stats.rx.rx_l4_csum_errors++;
} }
} }
...@@ -10285,7 +10285,7 @@ static void bnxt_chk_missed_irq(struct bnxt *bp) ...@@ -10285,7 +10285,7 @@ static void bnxt_chk_missed_irq(struct bnxt *bp)
bnxt_dbg_hwrm_ring_info_get(bp, bnxt_dbg_hwrm_ring_info_get(bp,
DBG_RING_INFO_GET_REQ_RING_TYPE_L2_CMPL, DBG_RING_INFO_GET_REQ_RING_TYPE_L2_CMPL,
fw_ring_id, &val[0], &val[1]); fw_ring_id, &val[0], &val[1]);
cpr->missed_irqs++; cpr->sw_stats.cmn.missed_irqs++;
} }
} }
} }
......
...@@ -910,6 +910,20 @@ struct bnxt_rx_ring_info { ...@@ -910,6 +910,20 @@ struct bnxt_rx_ring_info {
struct page_pool *page_pool; struct page_pool *page_pool;
}; };
struct bnxt_rx_sw_stats {
u64 rx_l4_csum_errors;
u64 rx_buf_errors;
};
struct bnxt_cmn_sw_stats {
u64 missed_irqs;
};
struct bnxt_sw_stats {
struct bnxt_rx_sw_stats rx;
struct bnxt_cmn_sw_stats cmn;
};
struct bnxt_cp_ring_info { struct bnxt_cp_ring_info {
struct bnxt_napi *bnapi; struct bnxt_napi *bnapi;
u32 cp_raw_cons; u32 cp_raw_cons;
...@@ -937,9 +951,8 @@ struct bnxt_cp_ring_info { ...@@ -937,9 +951,8 @@ struct bnxt_cp_ring_info {
struct ctx_hw_stats *hw_stats; struct ctx_hw_stats *hw_stats;
dma_addr_t hw_stats_map; dma_addr_t hw_stats_map;
u32 hw_stats_ctx_id; u32 hw_stats_ctx_id;
u64 rx_l4_csum_errors;
u64 rx_buf_errors; struct bnxt_sw_stats sw_stats;
u64 missed_irqs;
struct bnxt_ring_struct cp_ring_struct; struct bnxt_ring_struct cp_ring_struct;
......
...@@ -171,9 +171,12 @@ static const char * const bnxt_ring_tpa2_stats_str[] = { ...@@ -171,9 +171,12 @@ static const char * const bnxt_ring_tpa2_stats_str[] = {
"rx_tpa_errors", "rx_tpa_errors",
}; };
static const char * const bnxt_ring_sw_stats_str[] = { static const char * const bnxt_rx_sw_stats_str[] = {
"rx_l4_csum_errors", "rx_l4_csum_errors",
"rx_buf_errors", "rx_buf_errors",
};
static const char * const bnxt_cmn_sw_stats_str[] = {
"missed_irqs", "missed_irqs",
}; };
...@@ -485,7 +488,8 @@ static int bnxt_get_num_ring_stats(struct bnxt *bp) ...@@ -485,7 +488,8 @@ static int bnxt_get_num_ring_stats(struct bnxt *bp)
int num_stats; int num_stats;
num_stats = ARRAY_SIZE(bnxt_ring_stats_str) + num_stats = ARRAY_SIZE(bnxt_ring_stats_str) +
ARRAY_SIZE(bnxt_ring_sw_stats_str) + ARRAY_SIZE(bnxt_rx_sw_stats_str) +
ARRAY_SIZE(bnxt_cmn_sw_stats_str) +
bnxt_get_num_tpa_ring_stats(bp); bnxt_get_num_tpa_ring_stats(bp);
return num_stats * bp->cp_nr_rings; return num_stats * bp->cp_nr_rings;
} }
...@@ -548,13 +552,19 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, ...@@ -548,13 +552,19 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
struct bnxt_napi *bnapi = bp->bnapi[i]; struct bnxt_napi *bnapi = bp->bnapi[i];
struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring;
__le64 *hw_stats = (__le64 *)cpr->hw_stats; __le64 *hw_stats = (__le64 *)cpr->hw_stats;
u64 *sw;
int k; int k;
for (k = 0; k < stat_fields; j++, k++) for (k = 0; k < stat_fields; j++, k++)
buf[j] = le64_to_cpu(hw_stats[k]); buf[j] = le64_to_cpu(hw_stats[k]);
buf[j++] = cpr->rx_l4_csum_errors;
buf[j++] = cpr->rx_buf_errors; sw = (u64 *)&cpr->sw_stats.rx;
buf[j++] = cpr->missed_irqs; for (k = 0; k < ARRAY_SIZE(bnxt_rx_sw_stats_str); 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++)
buf[j] = sw[k];
bnxt_sw_func_stats[RX_TOTAL_DISCARDS].counter += bnxt_sw_func_stats[RX_TOTAL_DISCARDS].counter +=
le64_to_cpu(cpr->hw_stats->rx_discard_pkts); le64_to_cpu(cpr->hw_stats->rx_discard_pkts);
...@@ -653,10 +663,16 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf) ...@@ -653,10 +663,16 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
buf += ETH_GSTRING_LEN; buf += ETH_GSTRING_LEN;
} }
skip_tpa_stats: skip_tpa_stats:
num_str = ARRAY_SIZE(bnxt_ring_sw_stats_str); num_str = ARRAY_SIZE(bnxt_rx_sw_stats_str);
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);
for (j = 0; j < num_str; j++) { for (j = 0; j < num_str; j++) {
sprintf(buf, "[%d]: %s", i, sprintf(buf, "[%d]: %s", i,
bnxt_ring_sw_stats_str[j]); bnxt_cmn_sw_stats_str[j]);
buf += ETH_GSTRING_LEN; buf += ETH_GSTRING_LEN;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment