On 5/5/22 11:02, Chengwen Feng wrote:
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.

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

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

Signed-off-by: Chengwen Feng <fengcheng...@huawei.com>
---
  drivers/net/axgbe/axgbe_ethdev.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index 951da5cc26..f6a3a52430 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -1014,7 +1014,7 @@ axgbe_dev_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstat *stats,
        unsigned int i;
if (!stats)

I think the right condition is: n < AXGBE_XSTATS_COUNT
Otherwise the function break contract to return required
number of xstats if space is insufficient.

-               return 0;
+               return AXGBE_XSTATS_COUNT;
axgbe_read_mmc_stats(pdata);

Reply via email to