Subject: Re: [EXTERNAL] Re: [net-next PATCH v5 1/6] octeontx2: Set appropriate PF, VF masks and shifts based on silicon

From: Jakub Kicinski <[email-masked]>
Date: Mon, 9 Dec 2024 13:25:25 -0800

On Mon, 9 Dec 2024 09:09:35 +0000 Subbaraya Sundeep Bhatta wrote:
> >On Wed, 4 Dec 2024 19:38:16 +0530 Sai Krishna wrote:  
> >> -#define RVU_PFVF_PF_SHIFT	10
> >> -#define RVU_PFVF_PF_MASK	0x3F
> >> -#define RVU_PFVF_FUNC_SHIFT	0
> >> -#define RVU_PFVF_FUNC_MASK	0x3FF
> >> +#define RVU_PFVF_PF_SHIFT	rvu_pcifunc_pf_shift
> >> +#define RVU_PFVF_PF_MASK	rvu_pcifunc_pf_mask
> >> +#define RVU_PFVF_FUNC_SHIFT	rvu_pcifunc_func_shift
> >> +#define RVU_PFVF_FUNC_MASK	rvu_pcifunc_func_mask  
> >
> >Why do you maintain these defines? Looks like an unnecessary
> >indirection.
> >
> >Given these are simple mask and shift values they probably have trivial
> >users. Start by adding helpers which perform the conversions using
> >those, then you can more easily update constants.
> 
> There are too many places these masks are used hence added this
> indirection.
> # grep RVU_PFVF_ drivers/* -inr | wc -l
> 135

Yes, I have checked before making the suggestion.
Add a helper first, you can use cocci to do the conversions.