Skip to content

Commit 9d8b5f0

Browse files
Michael Chandavem330
authored andcommitted
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: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 098286f commit 9d8b5f0

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
17661766

17671767
rc = -EIO;
17681768
if (rx_err & RX_CMPL_ERRORS_BUFFER_ERROR_MASK) {
1769-
bnapi->cp_ring.rx_buf_errors++;
1769+
bnapi->cp_ring.sw_stats.rx.rx_buf_errors++;
17701770
if (!(bp->flags & BNXT_FLAG_CHIP_P5)) {
17711771
netdev_warn(bp->dev, "RX buffer error %x\n",
17721772
rx_err);
@@ -1849,7 +1849,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
18491849
} else {
18501850
if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS) {
18511851
if (dev->features & NETIF_F_RXCSUM)
1852-
bnapi->cp_ring.rx_l4_csum_errors++;
1852+
bnapi->cp_ring.sw_stats.rx.rx_l4_csum_errors++;
18531853
}
18541854
}
18551855

@@ -10285,7 +10285,7 @@ static void bnxt_chk_missed_irq(struct bnxt *bp)
1028510285
bnxt_dbg_hwrm_ring_info_get(bp,
1028610286
DBG_RING_INFO_GET_REQ_RING_TYPE_L2_CMPL,
1028710287
fw_ring_id, &val[0], &val[1]);
10288-
cpr->missed_irqs++;
10288+
cpr->sw_stats.cmn.missed_irqs++;
1028910289
}
1029010290
}
1029110291
}

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,20 @@ struct bnxt_rx_ring_info {
910910
struct page_pool *page_pool;
911911
};
912912

913+
struct bnxt_rx_sw_stats {
914+
u64 rx_l4_csum_errors;
915+
u64 rx_buf_errors;
916+
};
917+
918+
struct bnxt_cmn_sw_stats {
919+
u64 missed_irqs;
920+
};
921+
922+
struct bnxt_sw_stats {
923+
struct bnxt_rx_sw_stats rx;
924+
struct bnxt_cmn_sw_stats cmn;
925+
};
926+
913927
struct bnxt_cp_ring_info {
914928
struct bnxt_napi *bnapi;
915929
u32 cp_raw_cons;
@@ -937,9 +951,8 @@ struct bnxt_cp_ring_info {
937951
struct ctx_hw_stats *hw_stats;
938952
dma_addr_t hw_stats_map;
939953
u32 hw_stats_ctx_id;
940-
u64 rx_l4_csum_errors;
941-
u64 rx_buf_errors;
942-
u64 missed_irqs;
954+
955+
struct bnxt_sw_stats sw_stats;
943956

944957
struct bnxt_ring_struct cp_ring_struct;
945958

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,12 @@ static const char * const bnxt_ring_tpa2_stats_str[] = {
171171
"rx_tpa_errors",
172172
};
173173

174-
static const char * const bnxt_ring_sw_stats_str[] = {
174+
static const char * const bnxt_rx_sw_stats_str[] = {
175175
"rx_l4_csum_errors",
176176
"rx_buf_errors",
177+
};
178+
179+
static const char * const bnxt_cmn_sw_stats_str[] = {
177180
"missed_irqs",
178181
};
179182

@@ -485,7 +488,8 @@ static int bnxt_get_num_ring_stats(struct bnxt *bp)
485488
int num_stats;
486489

487490
num_stats = ARRAY_SIZE(bnxt_ring_stats_str) +
488-
ARRAY_SIZE(bnxt_ring_sw_stats_str) +
491+
ARRAY_SIZE(bnxt_rx_sw_stats_str) +
492+
ARRAY_SIZE(bnxt_cmn_sw_stats_str) +
489493
bnxt_get_num_tpa_ring_stats(bp);
490494
return num_stats * bp->cp_nr_rings;
491495
}
@@ -548,13 +552,19 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
548552
struct bnxt_napi *bnapi = bp->bnapi[i];
549553
struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring;
550554
__le64 *hw_stats = (__le64 *)cpr->hw_stats;
555+
u64 *sw;
551556
int k;
552557

553558
for (k = 0; k < stat_fields; j++, k++)
554559
buf[j] = le64_to_cpu(hw_stats[k]);
555-
buf[j++] = cpr->rx_l4_csum_errors;
556-
buf[j++] = cpr->rx_buf_errors;
557-
buf[j++] = cpr->missed_irqs;
560+
561+
sw = (u64 *)&cpr->sw_stats.rx;
562+
for (k = 0; k < ARRAY_SIZE(bnxt_rx_sw_stats_str); j++, k++)
563+
buf[j] = sw[k];
564+
565+
sw = (u64 *)&cpr->sw_stats.cmn;
566+
for (k = 0; k < ARRAY_SIZE(bnxt_cmn_sw_stats_str); j++, k++)
567+
buf[j] = sw[k];
558568

559569
bnxt_sw_func_stats[RX_TOTAL_DISCARDS].counter +=
560570
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)
653663
buf += ETH_GSTRING_LEN;
654664
}
655665
skip_tpa_stats:
656-
num_str = ARRAY_SIZE(bnxt_ring_sw_stats_str);
666+
num_str = ARRAY_SIZE(bnxt_rx_sw_stats_str);
667+
for (j = 0; j < num_str; j++) {
668+
sprintf(buf, "[%d]: %s", i,
669+
bnxt_rx_sw_stats_str[j]);
670+
buf += ETH_GSTRING_LEN;
671+
}
672+
num_str = ARRAY_SIZE(bnxt_cmn_sw_stats_str);
657673
for (j = 0; j < num_str; j++) {
658674
sprintf(buf, "[%d]: %s", i,
659-
bnxt_ring_sw_stats_str[j]);
675+
bnxt_cmn_sw_stats_str[j]);
660676
buf += ETH_GSTRING_LEN;
661677
}
662678
}

0 commit comments

Comments
 (0)