From: Ajit Khaparde Date: Mon, 8 Jan 2018 20:24:31 +0000 (-0800) Subject: net/bnxt: check initialization before accessing stats X-Git-Tag: spdx-start~372 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ed2ced6fe92706bfcbc7e64f553955c3951aa223;p=dpdk.git net/bnxt: check initialization before accessing stats Maintain state of PMD initialization and check it before checking stats. In certain cases, we might end up accessing stats before the required HWRM commands are processed by FW. Signed-off-by: Ajit Khaparde --- diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 345750be7b..7e3d7aefdc 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -245,6 +245,7 @@ struct bnxt { #define BNXT_FLAG_UPDATE_HASH (1 << 5) #define BNXT_FLAG_PTP_SUPPORTED (1 << 6) #define BNXT_FLAG_MULTI_HOST (1 << 7) +#define BNXT_FLAG_INIT_DONE (1 << 31) #define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF)) #define BNXT_VF(bp) ((bp)->flags & BNXT_FLAG_VF) #define BNXT_NPAR(bp) ((bp)->port_partition_type) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 475faac2a2..c2d158deaf 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -590,6 +590,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) if (rc) goto error; + bp->flags |= BNXT_FLAG_INIT_DONE; return 0; error: @@ -635,6 +636,7 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev) } bnxt_set_hwrm_link_config(bp, false); bnxt_hwrm_port_clr_stats(bp); + bp->flags &= ~BNXT_FLAG_INIT_DONE; bnxt_shutdown_nic(bp); bp->dev_stopped = 1; } diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 2606e93c1a..470c6438d5 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -236,6 +236,10 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, struct bnxt *bp = eth_dev->data->dev_private; memset(bnxt_stats, 0, sizeof(*bnxt_stats)); + if (!(bp->flags & BNXT_FLAG_INIT_DONE)) { + RTE_LOG(ERR, PMD, "Device Initialization not complete!\n"); + return 0; + } for (i = 0; i < bp->rx_cp_nr_rings; i++) { struct bnxt_rx_queue *rxq = bp->rx_queues[i]; @@ -267,6 +271,11 @@ void bnxt_stats_reset_op(struct rte_eth_dev *eth_dev) { struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + if (!(bp->flags & BNXT_FLAG_INIT_DONE)) { + RTE_LOG(ERR, PMD, "Device Initialization not complete!\n"); + return; + } + bnxt_clear_all_hwrm_stat_ctxs(bp); rte_atomic64_clear(&bp->rx_mbuf_alloc_fail); }