[PATCH net v1] net: stmmac: Fix queue statistics reading

Andrew Lunn andrew at lunn.ch
Sat Jan 14 07:10:02 PST 2023


On Sat, Jan 14, 2023 at 01:04:37PM +0100, Kurt Kanzenbach wrote:
> Correct queue statistics reading. All queue statistics are stored as unsigned
> long values. The retrieval for ethtool fetches these values as u64. However, on
> some systems the size of the counters are 32 bit.

> @@ -551,16 +551,16 @@ static void stmmac_get_per_qstats(struct stmmac_priv *priv, u64 *data)
>  		p = (char *)priv + offsetof(struct stmmac_priv,
>  					    xstats.txq_stats[q].tx_pkt_n);
>  		for (stat = 0; stat < STMMAC_TXQ_STATS; stat++) {
> -			*data++ = (*(u64 *)p);
> -			p += sizeof(u64 *);
> +			*data++ = (*(unsigned long *)p);
> +			p += sizeof(unsigned long);

As you said in the comment, the register is 32 bits. So maybe u32
would be better than unsigned long? And it would also avoid issues if
this code is every used on a 64 bit machine.

     Andrew



More information about the linux-arm-kernel mailing list