Re: [PATCH net-next 3/3] net: xilinx: axienet: Add statistics support

Andrew Lunn
2024-06-11T00:26:57Z

> +static u64 axienet_stat(struct axienet_local *lp, enum temac_stat stat)
> +{
> + return u64_stats_read(&lp->hw_stats[stat]);
> +}
> @@ -1695,6 +1760,35 @@ axienet_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
> stats->tx_packets = u64_stats_read(&lp->tx_packets);
> stats->tx_bytes = u64_stats_read(&lp->tx_bytes);
> } while (u64_stats_fetch_retry(&lp->tx_stat_sync, start));
> +
> + if (!(lp->features & XAE_FEATURE_STATS))
> + return;
> +
> + do {
> + start = u64_stats_fetch_begin(&lp->hw_stat_sync);
> + stats->rx_length_errors =
> + axienet_stat(lp, STAT_RX_LENGTH_ERRORS);

I'm i reading this correctly. You are returning the counters from the
last refresh period. What is that? 2.5Gbps would wrapper around a 32
byte counter in 13 seconds. I hope these statistics are not 13 seconds
out of date?

Since axienet_stats_update() also uses the lp->hw_stat_sync, i don't
see why you cannot read the hardware counter value and update to the
latest value.

Andrew