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 3ADE1A0471 for ; Thu, 18 Jul 2019 05:36:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 78016326C; Thu, 18 Jul 2019 05:36:27 +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 1CA1C2C17; Thu, 18 Jul 2019 05:36:24 +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 7174830C3A1; Wed, 17 Jul 2019 20:36:22 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 7174830C3A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1563420982; bh=hh/Eb4NpCX6ILvA/8nsF0tnkhxrRwBHZvrGsJ4RE5uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IY+B6Ee/5H77te5U+eztaoTAslZ3xzIOJHCG9B7fIXrQv9gY4wN6m3e3VQMEMhmBF v9AvPkxu9GFPLY9XWiROE3lf1ijyIVfWDjnHt17wcMsmtNzZrumdYwoCr3CJ/g6Utf LmeOMY5hs4zJ+g2cNMA+7BjgstNsJeZn0PS2B6jA= Received: from C02VPB22HTD6.wifi.broadcom.net (c02vpb22htd6.wifi.broadcom.net [10.122.43.105]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id AE404AC0761; Wed, 17 Jul 2019 20:36:21 -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:05:55 +0530 Message-Id: <20190718033616.37605-2-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 01/22] net/bnxt: fix to handle error case during port start 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. during port start, if bnxt_init_chip() return error bnxt_dev_start_op() invokes bnxt_shutdown_nic() which in turn calls bnxt_free_all_hwrm_resources() to free up resources. Hence remove the bnxt_free_all_hwrm_resources() from bnxt_init_chip() failure path. 2. fix to check the return value of rte_intr_enable() as this call can fail. 3. set bp->dev_stopped to 0 only when port start succeeds. 4. handle failure cases in bnxt_init_chip() routine to do proper cleanup and return correct error value. Fixes: b7778e8a1c00 ("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 | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index cd87d0dbc..7290c4c33 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -394,8 +394,9 @@ static int bnxt_init_chip(struct bnxt *bp) bp->rx_cp_nr_rings); return -ENOTSUP; } - if (rte_intr_efd_enable(intr_handle, intr_vector)) - return -1; + rc = rte_intr_efd_enable(intr_handle, intr_vector); + if (rc) + return rc; } if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) { @@ -406,7 +407,8 @@ static int bnxt_init_chip(struct bnxt *bp) if (intr_handle->intr_vec == NULL) { PMD_DRV_LOG(ERR, "Failed to allocate %d rx_queues" " intr_vec", bp->eth_dev->data->nb_rx_queues); - return -ENOMEM; + rc = -ENOMEM; + goto err_disable; } PMD_DRV_LOG(DEBUG, "intr_handle->intr_vec = %p " "intr_handle->nb_efd = %d intr_handle->max_intr = %d\n", @@ -421,12 +423,14 @@ static int bnxt_init_chip(struct bnxt *bp) } /* enable uio/vfio intr/eventfd mapping */ - rte_intr_enable(intr_handle); + rc = rte_intr_enable(intr_handle); + if (rc) + goto err_free; rc = bnxt_get_hwrm_link_config(bp, &new); if (rc) { PMD_DRV_LOG(ERR, "HWRM Get link config failure rc: %x\n", rc); - goto err_out; + goto err_free; } if (!bp->link_info.link_up) { @@ -434,16 +438,18 @@ static int bnxt_init_chip(struct bnxt *bp) if (rc) { PMD_DRV_LOG(ERR, "HWRM link config failure rc: %x\n", rc); - goto err_out; + goto err_free; } } bnxt_print_link_info(bp->eth_dev); return 0; +err_free: + rte_free(intr_handle->intr_vec); +err_disable: + rte_intr_efd_disable(intr_handle); err_out: - bnxt_free_all_hwrm_resources(bp); - /* Some of the error status returned by FW may not be from errno.h */ if (rc > 0) rc = -EIO; @@ -759,7 +765,6 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) "RxQ cnt %d > CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS %d\n", bp->rx_cp_nr_rings, RTE_ETHDEV_QUEUE_STAT_CNTRS); } - bp->dev_stopped = 0; rc = bnxt_init_chip(bp); if (rc) @@ -781,6 +786,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) eth_dev->tx_pkt_burst = bnxt_transmit_function(eth_dev); bnxt_enable_int(bp); bp->flags |= BNXT_FLAG_INIT_DONE; + bp->dev_stopped = 0; return 0; error: -- 2.20.1 (Apple Git-117)