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: 91fe49c87d76 ("net/txgbe: support device xstats") Cc: jiawe...@trustnetic.com Signed-off-by: Stephen Hemminger <step...@networkplumber.org> --- drivers/net/txgbe/txgbe_ethdev.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 2834468764..ee829d9120 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -2547,19 +2547,13 @@ txgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev); unsigned int i, count; - txgbe_read_stats_registers(hw, hw_stats); - - /* If this is a reset xstats is NULL, and we have cleared the - * registers by reading them. - */ count = txgbe_xstats_calc_num(dev); - if (xstats == NULL) + if (limit < count) return count; - limit = min(limit, txgbe_xstats_calc_num(dev)); - + txgbe_read_stats_registers(hw, hw_stats); /* Extended stats from txgbe_hw_stats */ - for (i = 0; i < limit; i++) { + for (i = 0; i < count; i++) { uint32_t offset = 0; if (txgbe_get_offset_by_id(i, &offset)) { -- 2.45.2