From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5DE4AA0A0A for ; Thu, 20 May 2021 11:55:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4BBBC41104; Thu, 20 May 2021 11:55:34 +0200 (CEST) Received: from relay.smtp-ext.broadcom.com (lpdvacalvio01.broadcom.com [192.19.229.182]) by mails.dpdk.org (Postfix) with ESMTP id C6B5A40041 for ; Thu, 20 May 2021 11:55:32 +0200 (CEST) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 7FFF124328 for ; Thu, 20 May 2021 02:55:31 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 7FFF124328 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1621504532; bh=uHbyAHlDunUg7xTfAQQ8nrhS6wdm2pNUCqwFG9TtmwI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GJKZgQHmoJ8Xp9eiHu8tnSbijBVurr1iGm+ili4qT3RiTGDQgspyO7PyKgvFbirzC DCSw01vj2b2xOY0KlicqTJqBYFrsrHbXnrBOF3FISBWGt3/U7LagMs11TYfD3pw5R6 iV6aKg6fOKzlL9RrzksjOM3qdKK2TWRmXNrGBJu4= From: Kalesh A P To: stable@dpdk.org Date: Thu, 20 May 2021 15:46:54 +0530 Message-Id: <20210520101654.3214-10-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20210520101654.3214-1-kalesh-anakkur.purayil@broadcom.com> References: <20210520101654.3214-1-kalesh-anakkur.purayil@broadcom.com> Subject: [dpdk-stable] [PATCH 19.11 9/9] net/bnxt: fix xstats get X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Kalesh AP [ upstream commit eac4fc71cdaa6b68dbd0e4129e5751c712501693 ] Fix to return count in xstats get op in all cases. Driver was returning 0 if the 'xstats' parameter being passed to xstats_get_op was NULL. This won't work on some applications that rely on a valid count being passed even in this case so that it can allocate memory accordingly followed by a reissue of the xstats_get_op to get the actual stats populated by the driver. Fixes: 063e59ddd28e ("net/bnxt: fix crash in xstats get") Signed-off-by: Somnath Kotur Signed-off-by: Kalesh AP Reviewed-by: Lance Richardson Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_stats.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 84011fc..692b096 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -465,10 +465,13 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, if (rc) return rc; - if (xstats == NULL) - return 0; + stat_count = RTE_DIM(bnxt_rx_stats_strings) + + RTE_DIM(bnxt_tx_stats_strings) + 1/* For tx_drop_pkts */ + + RTE_DIM(bnxt_rx_ext_stats_strings) + + RTE_DIM(bnxt_tx_ext_stats_strings); - memset(xstats, 0, sizeof(*xstats)); + if (n < stat_count || xstats == NULL) + return stat_count; bnxt_hwrm_port_qstats(bp); bnxt_hwrm_func_qstats_tx_drop(bp, 0xffff, &tx_drop_pkts); @@ -480,14 +483,7 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, (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 */ + - RTE_DIM(bnxt_rx_ext_stats_strings) + - RTE_DIM(bnxt_tx_ext_stats_strings); - stat_count = count; - - if (n < count) - return count; + memset(xstats, 0, sizeof(*xstats)); count = 0; for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) { -- 2.10.1