From: Kalesh AP Date: Sat, 8 Jun 2019 19:22:06 +0000 (+0400) Subject: net/bnxt: fix xstats X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a9586abdbcb3178b94570dd0af3646104f1154cd;p=dpdk.git net/bnxt: fix xstats 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: f55e12f33416 ("net/bnxt: support extended port counters") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Signed-off-by: Ajit Khaparde Reviewed-by: Lance Richardson --- diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 2254872390..ee88e9a163 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -3775,7 +3775,8 @@ skip_init: 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; @@ -3783,7 +3784,8 @@ skip_init: 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); diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index ad28887743..3cd5144ec1 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -415,6 +415,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);