From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 74C5FA0352; Mon, 4 Nov 2019 23:50:50 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3726D3772; Mon, 4 Nov 2019 23:50:37 +0100 (CET) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 67868316B for ; Mon, 4 Nov 2019 23:50:32 +0100 (CET) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 4B9E830C10D; Mon, 4 Nov 2019 14:47:44 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 4B9E830C10D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1572907664; bh=Nl5siO4ugW8nW1RL1mGQwWswIu2anmrw4wgDD1gmDdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E2pgd4xOXVQJm4rAgyg7BUr+xWuNpb6viFRDauHNtdLjJfbeZCdN5tKRBNzow0Xrb Vsy2I6C+onpztWQ0yBbVtN2C9AIcjeVUvzD8IO7iXQl9bQFvO6Nqbb4T/l7hDumREI VcRg8uue1pV6lF6iTS5eHbLuxP38+GQqg5/hJykM= Received: from C02VPB22HTD6.wifi.broadcom.net (c02vpb22htd6.wifi.broadcom.net [10.69.74.102]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 40A98140090; Mon, 4 Nov 2019 14:50:30 -0800 (PST) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Kalesh AP , Santoshkumar Karanappa Rastapur Date: Mon, 4 Nov 2019 14:50:25 -0800 Message-Id: <20191104225026.97569-5-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20191104225026.97569-1-ajit.khaparde@broadcom.com> References: <20191104100240.28974-1-kalesh-anakkur.purayil@broadcom.com> <20191104225026.97569-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 4/5] net/bnxt: fix a failure case during initialization 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Kalesh AP During initialization sequence in bnxt_alloc_mem() if bnxt_alloc_async_cp_ring() fails, driver invokes bnxt_free_mem() which in turn call bnxt_free_vnic_mem() which causes the error logs "bnxt_free_vnic_mem(): VNIC is not freed yet!". This is because vnic memory is allocated but not initialized yet. Fix this by moving bnxt_init_vnics() from bnxt_init_nic() to bnxt_alloc_vnic_mem(). Also get rid of bnxt_init_nic() as the initialization is done in respective functions now. Fixes: 1bf01f5135f8 ("net/bnxt: prevent device access when device is in reset") Signed-off-by: Kalesh AP Reviewed-by: Santoshkumar Karanappa Rastapur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_ethdev.c | 18 ------------------ drivers/net/bnxt/bnxt_filter.c | 3 ++- drivers/net/bnxt/bnxt_filter.h | 1 - drivers/net/bnxt/bnxt_ring.c | 5 ++--- drivers/net/bnxt/bnxt_ring.h | 1 - drivers/net/bnxt/bnxt_vnic.c | 5 +++-- drivers/net/bnxt/bnxt_vnic.h | 1 - 7 files changed, 7 insertions(+), 27 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 3acf66d59..b9b055e71 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -479,22 +479,6 @@ static int bnxt_shutdown_nic(struct bnxt *bp) return 0; } -static int bnxt_init_nic(struct bnxt *bp) -{ - int rc; - - if (BNXT_HAS_RING_GRPS(bp)) { - rc = bnxt_init_ring_grps(bp); - if (rc) - return rc; - } - - bnxt_init_vnics(bp); - bnxt_init_filters(bp); - - return 0; -} - /* * Device configuration and status function */ @@ -4665,8 +4649,6 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev) if (rc) return rc; - bnxt_init_nic(bp); - rc = bnxt_request_int(bp); if (rc) return rc; diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c index 7e29468b7..da1a6c24a 100644 --- a/drivers/net/bnxt/bnxt_filter.c +++ b/drivers/net/bnxt/bnxt_filter.c @@ -61,7 +61,7 @@ struct bnxt_filter_info *bnxt_alloc_vf_filter(struct bnxt *bp, uint16_t vf) return filter; } -void bnxt_init_filters(struct bnxt *bp) +static void bnxt_init_filters(struct bnxt *bp) { struct bnxt_filter_info *filter; int i, max_filters; @@ -171,6 +171,7 @@ int bnxt_alloc_filter_mem(struct bnxt *bp) return -ENOMEM; } bp->filter_info = filter_mem; + bnxt_init_filters(bp); return 0; } diff --git a/drivers/net/bnxt/bnxt_filter.h b/drivers/net/bnxt/bnxt_filter.h index 7415b3612..9db3e7487 100644 --- a/drivers/net/bnxt/bnxt_filter.h +++ b/drivers/net/bnxt/bnxt_filter.h @@ -81,7 +81,6 @@ struct bnxt_filter_info { struct bnxt_filter_info *bnxt_alloc_filter(struct bnxt *bp); struct bnxt_filter_info *bnxt_alloc_vf_filter(struct bnxt *bp, uint16_t vf); -void bnxt_init_filters(struct bnxt *bp); void bnxt_free_all_filters(struct bnxt *bp); void bnxt_free_filter_mem(struct bnxt *bp); int bnxt_alloc_filter_mem(struct bnxt *bp); diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c index 0a182d3a8..ea46fa9bc 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -38,15 +38,13 @@ void bnxt_free_ring(struct bnxt_ring *ring) * Ring groups */ -int bnxt_init_ring_grps(struct bnxt *bp) +static void bnxt_init_ring_grps(struct bnxt *bp) { unsigned int i; for (i = 0; i < bp->max_ring_grps; i++) memset(&bp->grp_info[i], (uint8_t)HWRM_NA_SIGNATURE, sizeof(struct bnxt_ring_grp_info)); - - return 0; } int bnxt_alloc_ring_grps(struct bnxt *bp) @@ -76,6 +74,7 @@ int bnxt_alloc_ring_grps(struct bnxt *bp) "Failed to alloc grp info tbl.\n"); return -ENOMEM; } + bnxt_init_ring_grps(bp); } return 0; diff --git a/drivers/net/bnxt/bnxt_ring.h b/drivers/net/bnxt/bnxt_ring.h index 833118391..48a39d788 100644 --- a/drivers/net/bnxt/bnxt_ring.h +++ b/drivers/net/bnxt/bnxt_ring.h @@ -65,7 +65,6 @@ struct bnxt_tx_ring_info; struct bnxt_rx_ring_info; struct bnxt_cp_ring_info; void bnxt_free_ring(struct bnxt_ring *ring); -int bnxt_init_ring_grps(struct bnxt *bp); int bnxt_alloc_ring_grps(struct bnxt *bp); int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx, struct bnxt_tx_queue *txq, diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c index 2f0ed1026..412a53dc0 100644 --- a/drivers/net/bnxt/bnxt_vnic.c +++ b/drivers/net/bnxt/bnxt_vnic.c @@ -35,7 +35,7 @@ void prandom_bytes(void *dest_ptr, size_t len) } } -void bnxt_init_vnics(struct bnxt *bp) +static void bnxt_init_vnics(struct bnxt *bp) { struct bnxt_vnic_info *vnic; uint16_t max_vnics; @@ -52,7 +52,6 @@ void bnxt_init_vnics(struct bnxt *bp) vnic->hash_mode = HWRM_VNIC_RSS_CFG_INPUT_HASH_MODE_FLAGS_DEFAULT; - prandom_bytes(vnic->rss_hash_key, HW_HASH_KEY_SIZE); STAILQ_INIT(&vnic->filter); STAILQ_INIT(&vnic->flow_list); STAILQ_INSERT_TAIL(&bp->free_vnic_list, vnic, next); @@ -179,6 +178,7 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp) HW_HASH_KEY_SIZE); vnic->mc_list_dma_addr = vnic->rss_hash_key_dma_addr + HW_HASH_KEY_SIZE; + prandom_bytes(vnic->rss_hash_key, HW_HASH_KEY_SIZE); } return 0; @@ -220,6 +220,7 @@ int bnxt_alloc_vnic_mem(struct bnxt *bp) return -ENOMEM; } bp->vnic_info = vnic_mem; + bnxt_init_vnics(bp); return 0; } diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h index 4f760e0b0..a372b899b 100644 --- a/drivers/net/bnxt/bnxt_vnic.h +++ b/drivers/net/bnxt/bnxt_vnic.h @@ -58,7 +58,6 @@ struct bnxt_vnic_info { }; struct bnxt; -void bnxt_init_vnics(struct bnxt *bp); int bnxt_free_vnic(struct bnxt *bp, struct bnxt_vnic_info *vnic, int pool); struct bnxt_vnic_info *bnxt_alloc_vnic(struct bnxt *bp); -- 2.21.0 (Apple Git-122)