Skip to content
Permalink
Browse files

net/bnxt: fix extended port counter statistics

[ upstream commit b02a39ba3ba043827fb91c175900aed0eddf0d2d ]

We were trying to fill in more rx extended stats than the size allocated
for stats causing segfault. Fixed this by adding an explicit check.
Rearranged the code to return statistic values in xstats_get as per the
names returned in xstats_get_names.

Fixes: f55e12f ("net/bnxt: support extended port counters")

Signed-off-by: Rahul Gupta <rahul.gupta@broadcom.com>
Signed-off-by: Santoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
  • Loading branch information
Santoshkumar Karanappa Rastapur authored and kevintraynor committed Jul 25, 2019
1 parent fc3912e commit 1c90b45f091380e985231d80b1d5a1de8bb364c3
Showing with 14 additions and 10 deletions.
  1. +14 −10 drivers/net/bnxt/bnxt_stats.c
@@ -426,8 +426,12 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
bnxt_hwrm_port_qstats(bp);
bnxt_hwrm_func_qstats_tx_drop(bp, 0xffff, &tx_drop_pkts);
bnxt_hwrm_ext_port_qstats(bp);
rx_port_stats_ext_cnt = bp->fw_rx_port_stats_ext_size / stat_size;
tx_port_stats_ext_cnt = bp->fw_tx_port_stats_ext_size / stat_size;
rx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_rx_ext_stats_strings),
(bp->fw_rx_port_stats_ext_size /
stat_size));
tx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_tx_ext_stats_strings),
(bp->fw_tx_port_stats_ext_size /
stat_size));

count = RTE_DIM(bnxt_rx_stats_strings) +
RTE_DIM(bnxt_tx_stats_strings) + 1/* For tx_drop_pkts */ +
@@ -462,22 +466,22 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
xstats[count].value = rte_le_to_cpu_64(tx_drop_pkts);
count++;

for (i = 0; i < tx_port_stats_ext_cnt; i++) {
uint64_t *tx_stats_ext = (uint64_t *)bp->hw_tx_port_stats_ext;
for (i = 0; i < rx_port_stats_ext_cnt; i++) {
uint64_t *rx_stats_ext = (uint64_t *)bp->hw_rx_port_stats_ext;

xstats[count].value = rte_le_to_cpu_64
(*(uint64_t *)((char *)tx_stats_ext +
bnxt_tx_ext_stats_strings[i].offset));
(*(uint64_t *)((char *)rx_stats_ext +
bnxt_rx_ext_stats_strings[i].offset));

count++;
}

for (i = 0; i < rx_port_stats_ext_cnt; i++) {
uint64_t *rx_stats_ext = (uint64_t *)bp->hw_rx_port_stats_ext;
for (i = 0; i < tx_port_stats_ext_cnt; i++) {
uint64_t *tx_stats_ext = (uint64_t *)bp->hw_tx_port_stats_ext;

xstats[count].value = rte_le_to_cpu_64
(*(uint64_t *)((char *)rx_stats_ext +
bnxt_rx_ext_stats_strings[i].offset));
(*(uint64_t *)((char *)tx_stats_ext +
bnxt_tx_ext_stats_strings[i].offset));

count++;
}

0 comments on commit 1c90b45

Please sign in to comment.
You can’t perform that action at this time.