Skip to content

Commit

Permalink
net/bnxt: fix xstats
Browse files Browse the repository at this point in the history
[ upstream commit a9586ab ]

If the HWRM_PORT_QSTATS_EXT fails to initialize
fw_rx_port_stats_ext_size or fw_tx_port_stats_ext_size,
the driver can end up passing junk statistics to the application.

Instead of relying on the application to initialize the xstats
buffer before calling the xstats_get dev_op, memset xstats
with zeros to avoid returning or displaying incorrect statistics.

Also fixed the buffer starting offset.

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

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
  • Loading branch information
Kalesh AP authored and kevintraynor committed Jun 24, 2019
1 parent 0e449f4 commit a9aa6bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/bnxt/bnxt_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3349,15 +3349,17 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
goto skip_ext_stats;

bp->hw_rx_port_stats_ext = (void *)
(bp->hw_rx_port_stats + sizeof(struct rx_port_stats));
((uint8_t *)bp->hw_rx_port_stats +
sizeof(struct rx_port_stats));
bp->hw_rx_port_stats_ext_map = bp->hw_rx_port_stats_map +
sizeof(struct rx_port_stats);
bp->flags |= BNXT_FLAG_EXT_RX_PORT_STATS;


if (bp->hwrm_spec_code < HWRM_SPEC_CODE_1_9_2) {
bp->hw_tx_port_stats_ext = (void *)
(bp->hw_tx_port_stats + sizeof(struct tx_port_stats));
((uint8_t *)bp->hw_tx_port_stats +
sizeof(struct tx_port_stats));
bp->hw_tx_port_stats_ext_map =
bp->hw_tx_port_stats_map +
sizeof(struct tx_port_stats);
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/bnxt/bnxt_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
unsigned int stat_size = sizeof(uint64_t);
unsigned int stat_count;

memset(xstats, 0, sizeof(*xstats));

bnxt_hwrm_port_qstats(bp);
bnxt_hwrm_func_qstats_tx_drop(bp, 0xffff, &tx_drop_pkts);
bnxt_hwrm_ext_port_qstats(bp);
Expand Down

0 comments on commit a9aa6bf

Please sign in to comment.