[RFC 1/5] net/txgbe: fix query handling in xstats_get

Jiawen Wu jiawenwu at trustnetic.com
Wed Oct 9 10:00:14 CEST 2024


> -----Original Message-----
> From: Stephen Hemminger <stephen at networkplumber.org>
> Sent: Wednesday, October 9, 2024 12:00 AM
> To: dev at dpdk.org
> Cc: Stephen Hemminger <stephen at networkplumber.org>; jiawenwu at trustnetic.com
> Subject: [RFC 1/5] net/txgbe: fix query handling in xstats_get
> 
> 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: jiawenwu at trustnetic.com
> 
> Signed-off-by: Stephen Hemminger <stephen at 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
> 
> 

Thanks!
Reviewed-by: Jiawen Wu <jiawenwu at trustnetic.com>



More information about the dev mailing list