[Intel-wired-lan] [EXTERNAL] RE: [PATCH net] i40e/iavf: Fix msg interface between VF and PF
Creeley, Brett
brett.creeley at intel.com
Tue Nov 5 16:55:32 UTC 2019
> -----Original Message-----
> From: Arkady Gilinsky <arkady.gilinsky at harmonicinc.com>
> Sent: Monday, November 4, 2019 9:24 PM
> To: Creeley, Brett <brett.creeley at intel.com>; intel-wired-lan at lists.osuosl.org; netdev at vger.kernel.org; Kirsher, Jeffrey T
> <jeffrey.t.kirsher at intel.com>
> Cc: Arkady Gilinsky <arcadyg at gmail.com>
> Subject: Re: [EXTERNAL] RE: [PATCH net] i40e/iavf: Fix msg interface between VF and PF
> > static bool i40e_vc_verify_vqs_bitmaps(struct virtchnl_queue_select *vqs)
> > {
> > /* this will catch any changes made to the virtchnl_queue_select bitmap */
> > if (sizeof(vqs->rx_queues) != sizeof(u32) ||
> > sizeof(vqs->tx_queues) != sizeof(u32))
> > return false;
> If so, then is it better to check the type of the fields in compile-time rather than in runtime ?
> Something like this:
> BUILD_BUG_ON(sizeof(vqs->rx_queues) != sizeof(u32));
> BUILD_BUG_ON(sizeof(vqs->tx_queues) != sizeof(u32));
> This is not required comparison each time when function is called and made code more optimized.
I don't think this is required with the change you suggested below.
> >
> > if ((vqs->rx_queues == 0 && vqs->tx_queues == 0) ||
> > hweight32(vqs->rx_queues) > I40E_MAX_VF_QUEUES ||
> > hweight32(vqs->tx_queues) > I40E_MAX_VF_QUEUES)
> > return false;
> Again, from optimization POV it is better to have constant changed than variable,
> since it is compile time and not run time action:
> if ((vqs->rx_queues == 0 && vqs->tx_queues == 0) ||
> vqs->rx_queues >= (BIT(I40E_MAX_VF_QUEUES)) ||
>
> vqs->tx_queues >= (BIT(I40E_MAX_VF_QUEUES)))
> return false;
This seems much better than my solution. It fixes the original issue, handles if the
vqs->[r|t]x_queues variables have changed in size, and the queue bitmap comparison
uses a constant. Thanks!
> > return true;
> > }
More information about the Intel-wired-lan
mailing list