The xstats_get function in this driver did not act the same as other drivers when queried. The correct check is to look at the requested number of stats and compare it to the available stats and if the request is too small, return the correct size.
Bugzilla ID: 1560 Fixes: 8b433d04adc9 ("net/ngbe: support device xstats") Cc: jiawe...@trustnetic.com Signed-off-by: Stephen Hemminger <step...@networkplumber.org> --- drivers/net/ngbe/ngbe_ethdev.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c index 6c45ffaad3..ee65829aa0 100644 --- a/drivers/net/ngbe/ngbe_ethdev.c +++ b/drivers/net/ngbe/ngbe_ethdev.c @@ -1693,19 +1693,16 @@ ngbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, struct ngbe_hw_stats *hw_stats = NGBE_DEV_STATS(dev); unsigned int i, count; - ngbe_read_stats_registers(hw, hw_stats); - - /* If this is a reset xstats is NULL, and we have cleared the - * registers by reading them. - */ count = ngbe_xstats_calc_num(dev); - if (xstats == NULL) + if (limit < count) return count; + ngbe_read_stats_registers(hw, hw_stats); + limit = min(limit, ngbe_xstats_calc_num(dev)); /* Extended stats from ngbe_hw_stats */ - for (i = 0; i < limit; i++) { + for (i = 0; i < count; i++) { uint32_t offset = 0; if (ngbe_get_offset_by_id(i, &offset)) { -- 2.45.2