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 A3B9EA0471 for ; Thu, 18 Jul 2019 05:37:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3C65C1B9B3; Thu, 18 Jul 2019 05:36:43 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 725601B970; Thu, 18 Jul 2019 05:36:37 +0200 (CEST) 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 135B930C395; Wed, 17 Jul 2019 20:36:35 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 135B930C395 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1563420995; bh=cIm0Sb6mzFYp13lFgStrw4y22u1SCoJCuM62JP0bWp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ptYP6iNAc7O2MTh5MQIAAd9G+1RGzwyekW9sLUcPgcqLnPbzSOQHRBbO8U+6InJc+ fqt2YPRyGK3XcCYLJmGgduTDd2n7Vo9O3xWiaiXEA3BJX2o+OTKf7HBdMKHoxqCVzI y/fAnQc68fmAfS9eEH/NbTPZ2GVzP6im5JgLf+3A= Received: from C02VPB22HTD6.wifi.broadcom.net (c02vpb22htd6.wifi.broadcom.net [10.122.43.105]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id 219B4AC0761; Wed, 17 Jul 2019 20:36:33 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Kalesh AP , stable@dpdk.org, Somnath Kotur Date: Thu, 18 Jul 2019 09:06:00 +0530 Message-Id: <20190718033616.37605-7-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190718033616.37605-1-ajit.khaparde@broadcom.com> References: <20190718033616.37605-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 06/22] net/bnxt: fix failure path in dev init 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 1. bnxt_dev_init() invokes bnxt_dev_uninit() on failure. So there is no need to do individual function cleanups in failure path. 2. rearrange the check for primary process to remove an unwanted goto. 3. fix to invoke bnxt_hwrm_func_buf_unrgtr() in bnxt_dev_uninit() when it is needed. Fixes: b7778e8a1c00a7 ("net/bnxt: refactor to properly allocate resources for PF/VF") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur --- drivers/net/bnxt/bnxt_ethdev.c | 28 ++++++++++++++-------------- drivers/net/bnxt/bnxt_hwrm.c | 3 +++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 455d8a3bf..814770ada 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -3853,8 +3853,16 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) bp->dev_stopped = 1; + eth_dev->dev_ops = &bnxt_dev_ops; + eth_dev->rx_pkt_burst = &bnxt_recv_pkts; + eth_dev->tx_pkt_burst = &bnxt_xmit_pkts; + + /* + * For secondary processes, we don't initialise any further + * as primary has already done this work. + */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) - goto skip_init; + return 0; if (bnxt_vf_pciid(pci_dev->id.device_id)) bp->flags |= BNXT_FLAG_VF; @@ -3871,12 +3879,6 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) "Board initialization failed rc: %x\n", rc); goto error; } -skip_init: - eth_dev->dev_ops = &bnxt_dev_ops; - eth_dev->rx_pkt_burst = &bnxt_recv_pkts; - eth_dev->tx_pkt_burst = &bnxt_xmit_pkts; - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; rc = bnxt_alloc_hwrm_resources(bp); if (rc) { @@ -4021,21 +4023,16 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) rc = bnxt_alloc_mem(bp); if (rc) - goto error_free_int; + goto error_free; rc = bnxt_request_int(bp); if (rc) - goto error_free_int; + goto error_free; bnxt_init_nic(bp); return 0; -error_free_int: - bnxt_disable_int(bp); - bnxt_hwrm_func_buf_unrgtr(bp); - bnxt_free_int(bp); - bnxt_free_mem(bp); error_free: bnxt_dev_uninit(eth_dev); error: @@ -4055,6 +4052,9 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev) bnxt_disable_int(bp); bnxt_free_int(bp); bnxt_free_mem(bp); + + bnxt_hwrm_func_buf_unrgtr(bp); + if (bp->grp_info != NULL) { rte_free(bp->grp_info); bp->grp_info = NULL; diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 9c5e5ad77..27c4f2d88 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -3199,6 +3199,9 @@ int bnxt_hwrm_func_buf_unrgtr(struct bnxt *bp) struct hwrm_func_buf_unrgtr_input req = {.req_type = 0 }; struct hwrm_func_buf_unrgtr_output *resp = bp->hwrm_cmd_resp_addr; + if (!(BNXT_PF(bp) && bp->pdev->max_vfs)) + return 0; + HWRM_PREP(req, FUNC_BUF_UNRGTR, BNXT_USE_CHIMP_MB); rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB); -- 2.20.1 (Apple Git-117)