From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id B4E9C1B1C6 for ; Mon, 8 Jan 2018 21:24:43 +0100 (CET) Received: from nis-sj1-27.broadcom.com (nis-sj1-27.lvn.broadcom.net [10.75.144.136]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id DE6A430C02B; Mon, 8 Jan 2018 12:24:42 -0800 (PST) Received: from C02PT1RBG8WP.dhcp.broadcom.net (c02pt1rbg8wp.dhcp.broadcom.net [10.136.50.173]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id 7AEB9AC0741; Mon, 8 Jan 2018 12:24:42 -0800 (PST) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Mon, 8 Jan 2018 12:24:31 -0800 Message-Id: <20180108202437.56305-8-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.14.3 (Apple Git-98) In-Reply-To: <20180108202437.56305-1-ajit.khaparde@broadcom.com> References: <20180108202437.56305-1-ajit.khaparde@broadcom.com> Subject: [dpdk-dev] [PATCH 07/13] net/bnxt: check if initialization is done before accessing stats X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 20:24:44 -0000 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 --- drivers/net/bnxt/bnxt.h | 1 + drivers/net/bnxt/bnxt_ethdev.c | 2 ++ drivers/net/bnxt/bnxt_stats.c | 9 +++++++++ 3 files changed, 12 insertions(+) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 345750be7..7e3d7aefd 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 475faac2a..c2d158dea 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 2606e93c1..470c6438d 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); } -- 2.14.3 (Apple Git-98)