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 BF15DA3160 for ; Thu, 10 Oct 2019 03:42:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7E9151E882; Thu, 10 Oct 2019 03:42:14 +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 E14671DFF2; Thu, 10 Oct 2019 03:42:00 +0200 (CEST) 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 AE92430C127; Wed, 9 Oct 2019 18:40:24 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com AE92430C127 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1570671624; bh=B5Cjj8AtYlkMNQ/qM2Je8jrKIKHuWX3JoYHP40YTzRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K+xbpZpdWIx7f9fa6kTo/SZVyMvo9vOik0rxPfmGzcFrA/eGWbsrw/h7a1uKz21Zs dqjAUjZ6oDXWD4Su92vYjHPkko0uQ7p9XzfhD5fx86BhVxPv2RQJaBcVhaF+2gRGNV PMGCVLFrUd/OGkl2TUowExSU/odngIYIZK3d+VXI= Received: from localhost.localdomain (unknown [10.230.30.225]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id ED77314008C; Wed, 9 Oct 2019 18:41:56 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Kalesh AP , stable@dpdk.org, Somnath Kotur Date: Wed, 9 Oct 2019 18:41:42 -0700 Message-Id: <20191010014153.64908-2-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20191010014153.64908-1-ajit.khaparde@broadcom.com> References: <167a2652-7ad6-e02a-8a02-01f828bcba8c@intel.com> <20191010014153.64908-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 01/12] net/bnxt: fix return checks and return values 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 This patch fixes few checks and few return values while getting and clearing device statistics. 1. Fixed to return standard error code. 2. Clubbed few error checks 3. Removed an unnecessary return check Fixes: bfb9c2260be2 ("net/bnxt: support xstats get/reset") Fixes: 88920136688c ("net/bnxt: support xstats get by id") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_stats.c | 36 +++++++++++------------------------ 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 21012e1fee..f486a5634b 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -360,7 +360,7 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, memset(bnxt_stats, 0, sizeof(*bnxt_stats)); if (!(bp->flags & BNXT_FLAG_INIT_DONE)) { PMD_DRV_LOG(ERR, "Device Initialization not complete!\n"); - return -1; + return -EIO; } num_q_stats = RTE_MIN(bp->rx_cp_nr_rings, @@ -390,9 +390,8 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, if (unlikely(rc)) return rc; } + rc = bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats); - if (unlikely(rc)) - return rc; return rc; } @@ -573,30 +572,17 @@ int bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev) if (ret) return ret; - if (bp->flags & BNXT_FLAG_PORT_STATS && BNXT_SINGLE_PF(bp)) { - ret = bnxt_hwrm_port_clr_stats(bp); - if (ret != 0) { - PMD_DRV_LOG(ERR, "Operation failed: %s\n", - strerror(-ret)); - return ret; - } - } - - ret = 0; - - if (BNXT_VF(bp)) { - PMD_DRV_LOG(ERR, "Operation not supported on a VF device\n"); - ret = -ENOTSUP; - } - if (!BNXT_SINGLE_PF(bp)) { - PMD_DRV_LOG(ERR, "Operation not supported on a MF device\n"); - ret = -ENOTSUP; - } - if (!(bp->flags & BNXT_FLAG_PORT_STATS)) { + if (BNXT_VF(bp) || !BNXT_SINGLE_PF(bp) || + !(bp->flags & BNXT_FLAG_PORT_STATS)) { PMD_DRV_LOG(ERR, "Operation not supported\n"); ret = -ENOTSUP; } + ret = bnxt_hwrm_port_clr_stats(bp); + if (ret != 0) + PMD_DRV_LOG(ERR, "Failed to reset xstats: %s\n", + strerror(-ret)); + return ret; } @@ -625,7 +611,7 @@ int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t *ids, for (i = 0; i < limit; i++) { if (ids[i] >= stat_cnt) { PMD_DRV_LOG(ERR, "id value isn't valid"); - return -1; + return -EINVAL; } values[i] = values_copy[ids[i]]; } @@ -659,7 +645,7 @@ int bnxt_dev_xstats_get_names_by_id_op(struct rte_eth_dev *dev, for (i = 0; i < limit; i++) { if (ids[i] >= stat_cnt) { PMD_DRV_LOG(ERR, "id value isn't valid"); - return -1; + return -EINVAL; } strcpy(xstats_names[i].name, xstats_names_copy[ids[i]].name); -- 2.20.1 (Apple Git-117)