diff mbox series

[v4,6/9] net/axgbe: adjust return value of xstats-get ops

Message ID 20220513025357.52275-7-fengchengwen@huawei.com (mailing list archive)
State New
Delegated to: Andrew Rybchenko
Headers show
Series bugfix for ethdev telemetry | expand


Context Check Description
ci/checkpatch success coding style OK

Commit Message

fengchengwen May 13, 2022, 2:53 a.m. UTC
Many user (e.g. telemetry) invokes rte_eth_xstats_get(port_id, NULL, 0)
to retrieve the required number of elements, but currently axgbe PMD
returns zero when xstats is NULL.

In the previous patch, the framework defines that the required number
of entries should be returned when n is lower than the required number
of entries, and makes sure xstats must not be NULL when n is non-zero.

This patch removes the logic of "return zero when xstats is NULL", and
adds the logic of "return the required number of entries when n is
lower than the required number of entries".

Fixes: 9d1ef6b2e731 ("net/axgbe: add xstats")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
 drivers/net/axgbe/axgbe_ethdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series


diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index 951da5cc26..e6822fa711 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -1013,18 +1013,18 @@  axgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats,
 	struct axgbe_port *pdata = dev->data->dev_private;
 	unsigned int i;
-	if (!stats)
-		return 0;
-	for (i = 0; i < n && i < AXGBE_XSTATS_COUNT; i++) {
+	for (i = 0; i < AXGBE_XSTATS_COUNT; i++) {
 		stats[i].id = i;
 		stats[i].value = *(u64 *)((uint8_t *)&pdata->mmc_stats +
-	return i;
 static int