[PATCH v3 04/10] net/ipn3ke: adjust retval when xstats is null of get xstats

Chengwen Feng fengchengwen at huawei.com
Thu May 5 10:02:27 CEST 2022


Many user (e.g. telemetry) invokes rte_eth_xstats_get(port_id, NULL, 0)
to retrieve the required number of elements, but currently ipn3ke PMD
returns zero when xstats is NULL.

This patch adjusts that the return value was the required number of
elements when stats is NULL.

Fixes: 5a6d883878db ("net/ipn3ke: implement statistics")
Cc: stable at dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
---
 drivers/net/ipn3ke/ipn3ke_representor.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c b/drivers/net/ipn3ke/ipn3ke_representor.c
index c9dde1d82e..9646370b5d 100644
--- a/drivers/net/ipn3ke/ipn3ke_representor.c
+++ b/drivers/net/ipn3ke/ipn3ke_representor.c
@@ -2218,9 +2218,6 @@ ipn3ke_rpst_xstats_get
 	struct ipn3ke_rpst_hw_port_stats hw_stats;
 	struct rte_eth_stats stats;
 
-	if (!xstats)
-		return 0;
-
 	if (!ethdev) {
 		IPN3KE_AFU_PMD_ERR("ethernet device to get statistics is NULL");
 		return -EINVAL;
@@ -2258,7 +2255,7 @@ ipn3ke_rpst_xstats_get
 	port_id = atoi(ch);
 
 	count = ipn3ke_rpst_xstats_calc_num();
-	if (n < count)
+	if (xstats == NULL || n < count)
 		return count;
 
 	if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_25GE_25GAUI) {
-- 
2.33.0



More information about the dev mailing list