Re: [PATCH net-next 3/4] ice: use generic unrolled_count() macro

Maciej Fijalkowski
2025-02-10T12:31:17Z

On Thu, Feb 06, 2025 at 07:26:28PM +0100, Alexander Lobakin wrote:
> ice, same as i40e, has a custom loop unrolling macros for unrolling
> Tx descriptors filling on XSk xmit.
> Replace ice defs with generic unrolled_count(), which is also more
> convenient as it allows passing defines as its argument, not hardcoded
> values, while the loop declaration will still be usual for-loop.
>
> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>

Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

> ---
> drivers/net/ethernet/intel/ice/ice_xsk.h | 8 --------
> drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +++-
> 2 files changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.h b/drivers/net/ethernet/intel/ice/ice_xsk.h
> index 45adeb513253..8dc5d55e26c5 100644
> --- a/drivers/net/ethernet/intel/ice/ice_xsk.h
> +++ b/drivers/net/ethernet/intel/ice/ice_xsk.h
> @@ -7,14 +7,6 @@
>
> #define PKTS_PER_BATCH 8
>
> -#ifdef __clang__
> -#define loop_unrolled_for _Pragma("clang loop unroll_count(8)") for
> -#elif __GNUC__ >= 8
> -#define loop_unrolled_for _Pragma("GCC unroll 8") for
> -#else
> -#define loop_unrolled_for for
> -#endif
> -
> struct ice_vsi;
>
> #ifdef CONFIG_XDP_SOCKETS
> diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
> index 8975d2971bc3..a3a4eaa17739 100644
> --- a/drivers/net/ethernet/intel/ice/ice_xsk.c
> +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
> @@ -2,6 +2,7 @@
> /* Copyright (c) 2019, Intel Corporation. */
>
> #include <linux/bpf_trace.h>
> +#include <linux/unroll.h>
> #include <net/xdp_sock_drv.h>
> #include <net/xdp.h>
> #include "ice.h"
> @@ -989,7 +990,8 @@ static void ice_xmit_pkt_batch(struct ice_tx_ring *xdp_ring,
> struct ice_tx_desc *tx_desc;
> u32 i;
>
> - loop_unrolled_for(i = 0; i < PKTS_PER_BATCH; i++) {
> + unrolled_count(PKTS_PER_BATCH)
> + for (i = 0; i < PKTS_PER_BATCH; i++) {
> dma_addr_t dma;
>
> dma = xsk_buff_raw_get_dma(xsk_pool, descs[i].addr);
> --
> 2.48.1
>