Subject: Re: [PATCH v2 net-next 2/2] net: mvneta: add support for page_pool_get_stats

From: Lorenzo Bianconi <[email-masked]>
Date: Fri, 8 Apr 2022 19:14:22 +0200

> > @@ -4732,9 +4732,13 @@ static void mvneta_ethtool_get_strings(struct net_device *netdev, u32 sset,
> >  	if (sset == ETH_SS_STATS) {
> >  		int i;
> >  
> > -		for (i = 0; i < ARRAY_SIZE(mvneta_statistics); i++)
> > -			memcpy(data + i * ETH_GSTRING_LEN,
> > -			       mvneta_statistics[i].name, ETH_GSTRING_LEN);
> > +		for (i = 0; i < ARRAY_SIZE(mvneta_statistics); i++) {
> > +			memcpy(data, mvneta_statistics[i].name,
> > +			       ETH_GSTRING_LEN);
> > +			data += ETH_GSTRING_LEN;
> > +		}
> 
> You don't need to touch this loop, you can just do:

ack, it was just to avoid a long line, I will fix it.

> 
> > +
> > +		page_pool_ethtool_stats_get_strings(data +
> 				ETH_GSTRING_LEN * ARRAY_SIZE(mvneta_staticstics)));
> >  	}
> >  }
> >  
> > @@ -5392,6 +5412,14 @@ static int mvneta_probe(struct platform_device *pdev)
> >  	pp->rxq_def = rxq_def;
> >  	pp->indir[0] = rxq_def;
> >  
> > +	stats_len = ARRAY_SIZE(mvneta_statistics) +
> > +		    page_pool_ethtool_stats_get_count();
> > +	pp->ethtool_stats = devm_kzalloc(&pdev->dev,
> > +					 sizeof(*pp->ethtool_stats) * stats_len,
> > +					 GFP_KERNEL);
> 
> Why do you do this? The page_pool stats are never stored in
> pp->ethtool_stats.

ops, I need to drop this, thanks.

Regards,
Lorenzo

> 	Andrew