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 40E35A0471 for ; Thu, 18 Jul 2019 05:38:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4091E1B9B2; Thu, 18 Jul 2019 05:37:01 +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 0EA004CE4; Thu, 18 Jul 2019 05:36:51 +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 A47CD30C395; Wed, 17 Jul 2019 20:36:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com A47CD30C395 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1563421008; bh=FnckzRO6dOB5WTiBnM6zWisbobKydFhPhrJnlypwepM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kY4PzCVkc/TJi7nYVteZSfctUlIiAc0qJeSKwXgBIhUimCQ0eZ2cJ+bTtT1hIN5ex SqqAIvidOdPBzrxvINQkeSnOkRsSG7pkcEzbsbzc3TOw3Wb47+jM+Kmthd8M7OadBq 1D6WuxlpDQPt5bYR6okgLf170X+qk4X4TBhHH06I= Received: from C02VPB22HTD6.wifi.broadcom.net (c02vpb22htd6.wifi.broadcom.net [10.122.43.105]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id 16BF7AC0761; Wed, 17 Jul 2019 20:36:47 -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:06 +0530 Message-Id: <20190718033616.37605-13-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 12/22] net/bnxt: fix to return standard error codes 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 Fixed the return values of few routines to return standard error code. Also fixed few error logs to more meaningful one. Fixes: 804e746c7b7338 ("net/bnxt: add hardware resource manager init code") Fixes: e3d8f1e6a665f9 ("net/bnxt: cache address of doorbell to subsequent access") Fixes: 19e6af01bb36d7 ("net/bnxt: support get/set EEPROM") Fixes: b7435d660a8cde ("net/bnxt: add ntuple filtering support") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur --- drivers/net/bnxt/bnxt_ethdev.c | 46 +++++++--------------------------- drivers/net/bnxt/bnxt_hwrm.c | 30 +++++++++------------- 2 files changed, 21 insertions(+), 55 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index fe7837df2..dd127cd6f 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -2161,7 +2161,7 @@ bnxt_ethertype_filter(struct rte_eth_dev *dev, filter1 = bnxt_get_l2_filter(bp, bfilter, vnic0); if (filter1 == NULL) { - ret = -1; + ret = -EINVAL; goto cleanup; } bfilter->enables |= @@ -2355,7 +2355,7 @@ bnxt_cfg_ntuple_filter(struct bnxt *bp, vnic0 = &bp->vnic_info[0]; filter1 = STAILQ_FIRST(&vnic0->filter); if (filter1 == NULL) { - ret = -1; + ret = -EINVAL; goto free_filter; } @@ -3297,7 +3297,6 @@ bnxt_set_eeprom_op(struct rte_eth_dev *dev, return bnxt_hwrm_flash_nvram(bp, type, ordinal, ext, attr, in_eeprom->data, in_eeprom->length); - return 0; } /* @@ -3400,48 +3399,21 @@ bool bnxt_stratus_device(struct bnxt *bp) static int bnxt_init_board(struct rte_eth_dev *eth_dev) { - struct bnxt *bp = eth_dev->data->dev_private; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); - int rc; + struct bnxt *bp = eth_dev->data->dev_private; /* enable device (incl. PCI PM wakeup), and bus-mastering */ - if (!pci_dev->mem_resource[0].addr) { - PMD_DRV_LOG(ERR, - "Cannot find PCI device base address, aborting\n"); - rc = -ENODEV; - goto init_err_disable; + bp->bar0 = (void *)pci_dev->mem_resource[0].addr; + bp->doorbell_base = (void *)pci_dev->mem_resource[2].addr; + if (!bp->bar0 || !bp->doorbell_base) { + PMD_DRV_LOG(ERR, "Unable to access Hardware\n"); + return -ENODEV; } bp->eth_dev = eth_dev; bp->pdev = pci_dev; - bp->bar0 = (void *)pci_dev->mem_resource[0].addr; - if (!bp->bar0) { - PMD_DRV_LOG(ERR, "Cannot map device registers, aborting\n"); - rc = -ENOMEM; - goto init_err_release; - } - - if (!pci_dev->mem_resource[2].addr) { - PMD_DRV_LOG(ERR, - "Cannot find PCI device BAR 2 address, aborting\n"); - rc = -ENODEV; - goto init_err_release; - } else { - bp->doorbell_base = (void *)pci_dev->mem_resource[2].addr; - } - return 0; - -init_err_release: - if (bp->bar0) - bp->bar0 = NULL; - if (bp->doorbell_base) - bp->doorbell_base = NULL; - -init_err_disable: - - return rc; } static int bnxt_alloc_ctx_mem_blk(__rte_unused struct bnxt *bp, @@ -3681,7 +3653,7 @@ int bnxt_alloc_ctx_mem(struct bnxt *bp) else ctx->flags |= BNXT_CTX_FLAG_INITED; - return 0; + return rc; } static int bnxt_alloc_stats_mem(struct bnxt *bp) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 9bd2fcb9f..fda5c7c1b 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -152,14 +152,11 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg, } if (i >= HWRM_CMD_TIMEOUT) { - PMD_DRV_LOG(ERR, "Error sending msg 0x%04x\n", - req->req_type); - goto err_ret; + PMD_DRV_LOG(ERR, "Error(timeout) sending msg 0x%04x\n", + req->req_type); + return -ETIMEDOUT; } return 0; - -err_ret: - return -1; } /* @@ -1220,7 +1217,7 @@ int bnxt_hwrm_ring_alloc(struct bnxt *bp, PMD_DRV_LOG(ERR, "hwrm alloc invalid ring type %d\n", ring_type); HWRM_UNLOCK(); - return -1; + return -EINVAL; } req.enables = rte_cpu_to_le_32(enables); @@ -2934,7 +2931,7 @@ int bnxt_hwrm_allocate_pf_only(struct bnxt *bp) if (!BNXT_PF(bp)) { PMD_DRV_LOG(ERR, "Attempt to allcoate VFs on a VF!\n"); - return -1; + return -EINVAL; } rc = bnxt_hwrm_func_qcaps(bp); @@ -2962,7 +2959,7 @@ int bnxt_hwrm_allocate_vfs(struct bnxt *bp, int num_vfs) if (!BNXT_PF(bp)) { PMD_DRV_LOG(ERR, "Attempt to allcoate VFs on a VF!\n"); - return -1; + return -EINVAL; } rc = bnxt_hwrm_func_qcaps(bp); @@ -3804,10 +3801,9 @@ int bnxt_hwrm_func_vf_vnic_query_and_config(struct bnxt *bp, uint16_t vf, vnic_id_sz = bp->pf.total_vnics * sizeof(*vnic_ids); vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz, RTE_CACHE_LINE_SIZE); - if (vnic_ids == NULL) { - rc = -ENOMEM; - return rc; - } + if (vnic_ids == NULL) + return -ENOMEM; + for (sz = 0; sz < vnic_id_sz; sz += getpagesize()) rte_mem_lock_page(((char *)vnic_ids) + sz); @@ -3874,10 +3870,8 @@ int bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(struct bnxt *bp, int vf) vnic_id_sz = bp->pf.total_vnics * sizeof(*vnic_ids); vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz, RTE_CACHE_LINE_SIZE); - if (vnic_ids == NULL) { - rc = -ENOMEM; - return rc; - } + if (vnic_ids == NULL) + return -ENOMEM; for (sz = 0; sz < vnic_id_sz; sz += getpagesize()) rte_mem_lock_page(((char *)vnic_ids) + sz); @@ -3908,7 +3902,7 @@ int bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(struct bnxt *bp, int vf) PMD_DRV_LOG(ERR, "No default VNIC\n"); exit: rte_free(vnic_ids); - return -1; + return rc; } int bnxt_hwrm_set_em_filter(struct bnxt *bp, -- 2.20.1 (Apple Git-117)