Skip to content

Commit

Permalink
bnxt_en: Refactor the software ring counters.
Browse files Browse the repository at this point in the history
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: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Michael Chan authored and David S. Miller committed May 4, 2020
1 parent 098286f commit 9d8b5f0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
6 changes: 3 additions & 3 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,

rc = -EIO;
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)) {
netdev_warn(bp->dev, "RX buffer error %x\n",
rx_err);
Expand Down Expand Up @@ -1849,7 +1849,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
} else {
if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS) {
if (dev->features & NETIF_F_RXCSUM)
bnapi->cp_ring.rx_l4_csum_errors++;
bnapi->cp_ring.sw_stats.rx.rx_l4_csum_errors++;
}
}

Expand Down Expand Up @@ -10285,7 +10285,7 @@ static void bnxt_chk_missed_irq(struct bnxt *bp)
bnxt_dbg_hwrm_ring_info_get(bp,
DBG_RING_INFO_GET_REQ_RING_TYPE_L2_CMPL,
fw_ring_id, &val[0], &val[1]);
cpr->missed_irqs++;
cpr->sw_stats.cmn.missed_irqs++;
}
}
}
Expand Down
19 changes: 16 additions & 3 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.h
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,20 @@ struct bnxt_rx_ring_info {
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_napi *bnapi;
u32 cp_raw_cons;
Expand Down Expand Up @@ -937,9 +951,8 @@ struct bnxt_cp_ring_info {
struct ctx_hw_stats *hw_stats;
dma_addr_t hw_stats_map;
u32 hw_stats_ctx_id;
u64 rx_l4_csum_errors;
u64 rx_buf_errors;
u64 missed_irqs;

struct bnxt_sw_stats sw_stats;

struct bnxt_ring_struct cp_ring_struct;

Expand Down
30 changes: 23 additions & 7 deletions drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,12 @@ static const char * const bnxt_ring_tpa2_stats_str[] = {
"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_buf_errors",
};

static const char * const bnxt_cmn_sw_stats_str[] = {
"missed_irqs",
};

Expand Down Expand Up @@ -485,7 +488,8 @@ static int bnxt_get_num_ring_stats(struct bnxt *bp)
int num_stats;

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);
return num_stats * bp->cp_nr_rings;
}
Expand Down Expand Up @@ -548,13 +552,19 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
struct bnxt_napi *bnapi = bp->bnapi[i];
struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring;
__le64 *hw_stats = (__le64 *)cpr->hw_stats;
u64 *sw;
int k;

for (k = 0; k < stat_fields; j++, k++)
buf[j] = le64_to_cpu(hw_stats[k]);
buf[j++] = cpr->rx_l4_csum_errors;
buf[j++] = cpr->rx_buf_errors;
buf[j++] = cpr->missed_irqs;

sw = (u64 *)&cpr->sw_stats.rx;
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 +=
le64_to_cpu(cpr->hw_stats->rx_discard_pkts);
Expand Down Expand Up @@ -653,10 +663,16 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
buf += ETH_GSTRING_LEN;
}
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++) {
sprintf(buf, "[%d]: %s", i,
bnxt_ring_sw_stats_str[j]);
bnxt_cmn_sw_stats_str[j]);
buf += ETH_GSTRING_LEN;
}
}
Expand Down

0 comments on commit 9d8b5f0

Please sign in to comment.