Re: [PATCH net-next 1/3] net: enetc: change the statistics of ring to unsigned long type

From: Simon Horman
Date: Mon Jun 23 2025 - 12:32:31 EST


On Mon, Jun 23, 2025 at 01:49:59AM +0000, Wei Fang wrote:
> > > struct enetc_ring_stats {
> > > - unsigned int packets;
> > > - unsigned int bytes;
> > > - unsigned int rx_alloc_errs;
> > > - unsigned int xdp_drops;
> > > - unsigned int xdp_tx;
> > > - unsigned int xdp_tx_drops;
> > > - unsigned int xdp_redirect;
> > > - unsigned int xdp_redirect_failures;
> > > - unsigned int recycles;
> > > - unsigned int recycle_failures;
> > > - unsigned int win_drop;
> > > + unsigned long packets;
> > > + unsigned long bytes;
> > > + unsigned long rx_alloc_errs;
> > > + unsigned long xdp_drops;
> > > + unsigned long xdp_tx;
> > > + unsigned long xdp_tx_drops;
> > > + unsigned long xdp_redirect;
> > > + unsigned long xdp_redirect_failures;
> > > + unsigned long recycles;
> > > + unsigned long recycle_failures;
> > > + unsigned long win_drop;
> > > };
> >
> > Hi Wei fang,
> >
> > If the desire is for an unsigned 64 bit integer, then I think either u64 or unsigned
> > long long would be good choices.
> >
> > unsigned long may be 64bit or 32bit depending on the platform.
>
> The use of unsigned long is to keep it consistent with the statistical
> value type in struct net_device_stats. Because some statistics in
> net_device_stats come from enetc_ring_stats.
>
> #define NET_DEV_STAT(FIELD) \
> union { \
> unsigned long FIELD; \
> atomic_long_t __##FIELD; \
> }

Thanks, I understand. But in this case I think the patch description could
be reworded - unsigned int and unsigned long are the same thing on some
systems, and on such systems there is no overflow advantage of one over the
other.