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 47058A046B for ; Thu, 25 Jul 2019 07:05:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9DE361C26D; Thu, 25 Jul 2019 07:05:37 +0200 (CEST) Received: from relay.smtp.broadcom.com (unknown [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id 5090B1C25C for ; Thu, 25 Jul 2019 07:05:32 +0200 (CEST) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (bgccx-dev-host-lnx35.bec.broadcom.net [10.123.153.55]) by relay.smtp.broadcom.com (Postfix) with ESMTP id A73631BE6F2; Wed, 24 Jul 2019 22:05:30 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com A73631BE6F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1564031131; bh=1bWNG3ks01XHxiY1HGWqytdaaxCXahXiM+rljumfKI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k3LX6NfTTkbJOnNdGV+rHrwevdDpuaA2AhQ8vWcxU66kCmhsjbORItzscDKCnhUwc IwcSzjOpHyS5BHj4ZoHsHRHRSxw9shrvduuNo2OILAzVKNtiJ/UltR9NaFIbW+ZHzd c433llC9q/021gawODBfV66AuuQEnwqJakEHgAKw= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Thu, 25 Jul 2019 10:29:46 +0530 Message-Id: <20190725045949.27407-2-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20190725045949.27407-1-somnath.kotur@broadcom.com> References: <20190725045949.27407-1-somnath.kotur@broadcom.com> Subject: [dpdk-dev] [PATCH 1/4] net/bnxt: fix extended port counter statistics 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: Santoshkumar Karanappa Rastapur We were trying to fill in more rx extended stats than the size allocated for stats causing segfault. Fixed this by adding an explicit check. Rearranged the code to return statistic values in xstats_get as per the names returned in xstats_get_names. Fixes: f55e12f33416 ("net/bnxt: support extended port counters") Signed-off-by: Rahul Gupta Signed-off-by: Santoshkumar Karanappa Rastapur Signed-off-by: Somnath Kotur --- drivers/net/bnxt/bnxt_stats.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 4e74f8a..69ac2dd 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -427,8 +427,12 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, bnxt_hwrm_port_qstats(bp); bnxt_hwrm_func_qstats_tx_drop(bp, 0xffff, &tx_drop_pkts); bnxt_hwrm_ext_port_qstats(bp); - rx_port_stats_ext_cnt = bp->fw_rx_port_stats_ext_size / stat_size; - tx_port_stats_ext_cnt = bp->fw_tx_port_stats_ext_size / stat_size; + rx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_rx_ext_stats_strings), + (bp->fw_rx_port_stats_ext_size / + stat_size)); + tx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_tx_ext_stats_strings), + (bp->fw_tx_port_stats_ext_size / + stat_size)); count = RTE_DIM(bnxt_rx_stats_strings) + RTE_DIM(bnxt_tx_stats_strings) + 1/* For tx_drop_pkts */ + @@ -463,22 +467,22 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, xstats[count].value = rte_le_to_cpu_64(tx_drop_pkts); count++; - for (i = 0; i < tx_port_stats_ext_cnt; i++) { - uint64_t *tx_stats_ext = (uint64_t *)bp->hw_tx_port_stats_ext; + for (i = 0; i < rx_port_stats_ext_cnt; i++) { + uint64_t *rx_stats_ext = (uint64_t *)bp->hw_rx_port_stats_ext; xstats[count].value = rte_le_to_cpu_64 - (*(uint64_t *)((char *)tx_stats_ext + - bnxt_tx_ext_stats_strings[i].offset)); + (*(uint64_t *)((char *)rx_stats_ext + + bnxt_rx_ext_stats_strings[i].offset)); count++; } - for (i = 0; i < rx_port_stats_ext_cnt; i++) { - uint64_t *rx_stats_ext = (uint64_t *)bp->hw_rx_port_stats_ext; + for (i = 0; i < tx_port_stats_ext_cnt; i++) { + uint64_t *tx_stats_ext = (uint64_t *)bp->hw_tx_port_stats_ext; xstats[count].value = rte_le_to_cpu_64 - (*(uint64_t *)((char *)rx_stats_ext + - bnxt_rx_ext_stats_strings[i].offset)); + (*(uint64_t *)((char *)tx_stats_ext + + bnxt_tx_ext_stats_strings[i].offset)); count++; } -- 1.8.3.1