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

From: Wei Fang
Date: Sun Jun 22 2025 - 21:50:18 EST


> > 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; \
}