Subject: Re: [PATCH net-next 2/4] netdevsim: generalize taprio offload

From: Jakub Kicinski <[email-masked]>
Date: Tue, 10 Mar 2026 16:38:44 -0700

On Tue, 10 Mar 2026 19:06:29 +0100 Davide Caratti wrote:
> -static void nsim_taprio_stats(struct tc_taprio_qopt_stats *stats)
> -{
> -	stats->window_drops = 0;
> -	stats->tx_overruns = 0;
> -}
> +static LIST_HEAD(nsim_block_cb_list);
>  
> -static int nsim_setup_tc_taprio(struct net_device *dev,
> -				struct tc_taprio_qopt_offload *offload)
> -{
> -	int err = 0;
> -
> -	switch (offload->cmd) {
> -	case TAPRIO_CMD_REPLACE:
> -	case TAPRIO_CMD_DESTROY:
> -		break;
> -	case TAPRIO_CMD_STATS:
> -		nsim_taprio_stats(&offload->stats);
> -		break;
> -	default:
> -		err = -EOPNOTSUPP;
> -	}
> +#define QDISC_OFFLOAD_HANDLERS(X)					\
> +	X(taprio, tc_taprio_qopt_offload, cmd, TAPRIO_CMD_REPLACE,	\
> +	  TAPRIO_CMD_DESTROY, TAPRIO_CMD_STATS, stats)			\
>  
> -	return err;
> +#define QH(NAME, OL_TYPE, CMD_FLD, O_REPLACE, O_DESTROY, O_STATS, STATS_FLD) \
> +static int handle_##NAME(struct net_device *dev, struct OL_TYPE *offload) \
> +{									\
> +	switch (offload->CMD_FLD) {					\
> +	case O_REPLACE:							\
> +	case O_DESTROY:							\
> +		/* Do nothing, accept offload */			\
> +		return 0;						\
> +	case O_STATS:							\
> +		/* Zero out the requested stats block */		\
> +		memset(&offload->STATS_FLD, 0, sizeof(offload->STATS_FLD)); \
> +		return 0;						\
> +	default:							\
> +		return -EOPNOTSUPP;					\
> +	}								\
>  }
>  
> -static LIST_HEAD(nsim_block_cb_list);
> +QDISC_OFFLOAD_HANDLERS(QH)
> +#undef QH

Please just type the code in. These sort of macros are too ugly to live
in code I directly maintain, sorry.
-- 
pw-bot: cr