Re: [PATCH net v2 1/2] octeontx2-pf: Fix aura BPID assignment when CONFIG_DCB is enabled

Jakub Kicinski <[email protected]>
Newsgroups gmane.linux.network,gmane.linux.kernel
Message-ID <[email protected]>
On Thu,  6 Aug 2026 08:26:50 -0700 Jakub Kicinski wrote:
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > index 3d253132a17f0..b4691472d2a3e 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > @@ -1132,10 +1132,10 @@ int otx2_cq_init(struct otx2_nic *pfvf, u16 qidx)
> >  		if (!is_otx2_lbkvf(pfvf->pdev)) {
> >  			/* Enable receive CQ backpressure */
> >  			aq->cq.bp_ena = 1;
> > -#ifdef CONFIG_DCB
> > -			aq->cq.bpid = pfvf->bpid[pfvf->queue_to_pfc_map[qidx]];
> > -#else
> >  			aq->cq.bpid = pfvf->bpid[0];
> > +#ifdef CONFIG_DCB
> > +			if (pfvf->queue_to_pfc_map)
> > +				aq->cq.bpid = pfvf->bpid[pfvf->queue_to_pfc_map[qidx]];
> >  #endif  
> 
> [Severity: Low]
> This isn't a bug, but the same #ifdef CONFIG_DCB plus NULL test idiom now
> appears in three places: cn20k_aura_bpid_idx(), otx2_cq_init() and
> otx2_aura_aq_init().  cn20k_aura_bpid_idx() already encapsulates exactly this
> logic.  Would it be cleaner to generalize it into a single accessor, say
> otx2_get_bpid_idx(pfvf, qidx), and use it from all three sites?
> 
> Alternatively, could queue_to_pfc_map simply be allocated unconditionally
> (it is only pfvf->hw.rx_queues bytes) instead of being tied to dcbnl_ops

AI is getting better I guess. I was going to suggest this as well.
Please avoid hiding struct members under ifdefs unless there's a major
size win on the structures. If you care about runtime cost you can use
IS_ENABLED() inside the if () condition and compiler will eliminate it.
No ifdefs needed at that point.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.