> -----Original Message----- > From: Keller, Jacob E <[email protected]> > Sent: Tuesday, November 4, 2025 2:07 AM > To: Loktionov, Aleksandr <[email protected]>; Lobakin, > Aleksander <[email protected]>; Nguyen, Anthony L > <[email protected]>; Kitszel, Przemyslaw > <[email protected]> > Cc: [email protected]; [email protected]; Keller, > Jacob E <[email protected]> > Subject: [PATCH iwl-next 8/9] ice: shorten ring stat names and add > accessors > > The ice Tx/Rx hotpath has a few statistics counters for tracking > unexpected events. These values are stored as u64 but are not > accumulated using the u64_stats API. This could result in load/tear > stores on some architectures. > Even some 64-bit architectures could have issues since the fields are > not read or written using ACCESS_ONCE or READ_ONCE. > > A following change is going to refactor the stats accumulator code to > use the u64_stats API for all of these stats, and to use > u64_stats_read and u64_stats_inc properly to prevent load/store tears > on all architectures. > > Using u64_stats_inc and the syncp pointer is slightly verbose and > would be duplicated in a number of places in the Tx and Rx hot path. > Add accessor macros for the cases where only a single stat value is > touched at once. To keep lines short, also shorten the stats names and > convert ice_txq_stats and ice_rxq_stats to struct_group. > > This will ease the transition to properly using the u64_stats API in > the following change. > > Signed-off-by: Jacob Keller <[email protected]> > --- > drivers/net/ethernet/intel/ice/ice_txrx.h | 52 > +++++++++++++++++++-------- > drivers/net/ethernet/intel/ice/ice_txrx_lib.h | 2 +- > drivers/net/ethernet/intel/ice/ice_main.c | 12 +++---- > drivers/net/ethernet/intel/ice/ice_txrx.c | 14 ++++---- > drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 2 +- > drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +-- > 6 files changed, 55 insertions(+), 31 deletions(-) > > diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.h > b/drivers/net/ethernet/intel/ice/ice_txrx.h > index 8586d5bebac7..cf3656dc560c 100644 > --- a/drivers/net/ethernet/intel/ice/ice_txrx.h > +++ b/drivers/net/ethernet/intel/ice/ice_txrx.h > @@ -129,18 +129,6 @@ struct ice_tx_offload_params { > u8 header_len; > }; > > -struct ice_txq_stats { > - u64 restart_q; > - u64 tx_busy; > - u64 tx_linearize; > -}; > - > -struct ice_rxq_stats { > - u64 non_eop_descs; > - u64 alloc_page_failed; > - u64 alloc_buf_failed; > -}; > - > struct ice_ring_stats { > struct rcu_head rcu; /* to avoid race on free */ > struct u64_stats_sync syncp; > @@ -148,12 +136,48 @@ struct ice_ring_stats { > u64 pkts; > u64 bytes; > union { > - struct ice_txq_stats tx_stats; > - struct ice_rxq_stats rx_stats; > + struct_group(tx, > + u64 tx_restart_q; > + u64 tx_busy; > + u64 tx_linearize; > + ); > + struct_group(rx, > + u64 rx_non_eop_descs; > + u64 rx_page_failed; > + u64 rx_buf_failed; > + ); > }; > ); > }; > > +/** > + * ice_stats_read - Read a single ring stat value > + * @stats: pointer to ring_stats structure for a queue > + * @member: the ice_ring_stats member to read > + * > + * Shorthand for reading a single 64-bit stat value from struct > + * ice_ring_stats. > + * > + * Return: the value of the requested stat. > + */ > +#define ice_stats_read(stats, member) ({ \ > + struct ice_ring_stats *__stats = (stats); \ > + __stats->member; \ > +}) > + > +/** > + * ice_stats_inc - Increment a single ring stat value > + * @stats: pointer to the ring_stats structure for a queue > + * @member: the ice_string_stats member to increment > + *
"ice_string_stats" -> "ice_ring_stats" ... > -- > 2.51.0.rc1.197.g6d975e95c9d7
