From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
To: stable@dpdk.org
Subject: [dpdk-stable] [PATCH 19.11 9/9] net/bnxt: fix xstats get
Date: Thu, 20 May 2021 15:46:54 +0530 [thread overview]
Message-ID: <20210520101654.3214-10-kalesh-anakkur.purayil@broadcom.com> (raw)
In-Reply-To: <20210520101654.3214-1-kalesh-anakkur.purayil@broadcom.com>
From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
[ 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 <somnath.kotur@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
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
prev parent reply other threads:[~2021-05-20 9:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-20 10:16 [dpdk-stable] [PATCH 19.11 0/9] backports for 19.11.9 Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 1/9] net/bnxt: fix build failures after merging patches Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 2/9] net/bnxt: drop unused attribute Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 3/9] net/bnxt: fix double free in port start failure Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 4/9] net/bnxt: fix firmware fatal error handling Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 5/9] net/bnxt: fix memory allocation for command response Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 6/9] net/bnxt: fix timesync when PTP is not supported Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 7/9] net/bnxt: fix VF info allocation Kalesh A P
2021-05-20 10:16 ` [dpdk-stable] [PATCH 19.11 8/9] net/bnxt: fix PTP support for Thor Kalesh A P
2021-05-20 10:16 ` Kalesh A P [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210520101654.3214-10-kalesh-anakkur.purayil@broadcom.com \
--to=kalesh-anakkur.purayil@broadcom.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).