Subject: Re: [PATCH v3 net-next 1/2] net: page_pool: introduce ethtool stats

From: Lorenzo Bianconi <[email-masked]>
Date: Mon, 11 Apr 2022 14:27:10 +0200

> > diff --git a/include/net/page_pool.h b/include/net/page_pool.h
> > index ea5fb70e5101..94b2d666db03 100644
> > --- a/include/net/page_pool.h
> > +++ b/include/net/page_pool.h
> > @@ -117,6 +117,10 @@ struct page_pool_stats {
> >  	struct page_pool_recycle_stats recycle_stats;
> >  };
> >  
> > +int page_pool_ethtool_stats_get_count(void);
> > +u8 *page_pool_ethtool_stats_get_strings(u8 *data);
> > +u64 *page_pool_ethtool_stats_get(u64 *data, struct page_pool_stats *stats);
> > +
> >  /*
> >   * Drivers that wish to harvest page pool stats and report them to users
> >   * (perhaps via ethtool, debugfs, or another mechanism) can allocate a
> 
> You could also add stub function here for when the page pool
> statistics are disabled. We can then avoid all the messy #ifdef in the
> drivers.
> 
> > +u64 *page_pool_ethtool_stats_get(u64 *data, struct page_pool_stats *stats)
> > +{
> > +	int i;
> > +
> > +	for (i = 0; i < ARRAY_SIZE(pp_stats); i++) {
> > +		*data++ = stats->alloc_stats.fast;
> > +		*data++ = stats->alloc_stats.slow;
> > +		*data++ = stats->alloc_stats.slow_high_order;
> > +		*data++ = stats->alloc_stats.empty;
> > +		*data++ = stats->alloc_stats.refill;
> > +		*data++ = stats->alloc_stats.waive;
> > +		*data++ = stats->recycle_stats.cached;
> > +		*data++ = stats->recycle_stats.cache_full;
> > +		*data++ = stats->recycle_stats.ring;
> > +		*data++ = stats->recycle_stats.ring_full;
> > +		*data++ = stats->recycle_stats.released_refcnt;
> > +	}
> > +
> > +	return data;
> 
> What is the purpose of the loop?

ops sorry, you are right. I will fix it.

Regards,
Lorenzo

>      Andrew