netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Creeley, Brett" <brett.creeley@intel.com>
To: Arkady Gilinsky <arkady.gilinsky@harmonicinc.com>,
	"intel-wired-lan@lists.osuosl.org"
	<intel-wired-lan@lists.osuosl.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"Kirsher, Jeffrey T" <jeffrey.t.kirsher@intel.com>
Cc: Arkady Gilinsky <arcadyg@gmail.com>
Subject: RE: [EXTERNAL] RE: [PATCH net] i40e/iavf: Fix msg interface between VF and PF
Date: Tue, 5 Nov 2019 16:55:32 +0000	[thread overview]
Message-ID: <3508A0C5D531054DBDD98909F6FA64FA11B39863@ORSMSX113.amr.corp.intel.com> (raw)
In-Reply-To: <1572931430.13810.227.camel@harmonicinc.com>

> -----Original Message-----
> From: Arkady Gilinsky <arkady.gilinsky@harmonicinc.com>
> Sent: Monday, November 4, 2019 9:24 PM
> To: Creeley, Brett <brett.creeley@intel.com>; intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; Kirsher, Jeffrey T
> <jeffrey.t.kirsher@intel.com>
> Cc: Arkady Gilinsky <arcadyg@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;
> > }


  reply	other threads:[~2019-11-05 16:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04  5:32 [PATCH net] i40e/iavf: Fix msg interface between VF and PF Arkady Gilinsky
2019-11-04 23:43 ` Creeley, Brett
2019-11-05  5:23   ` [EXTERNAL] " Arkady Gilinsky
2019-11-05 16:55     ` Creeley, Brett [this message]
2019-11-06  5:30       ` Arkady Gilinsky
2019-11-07 19:38         ` Jeff Kirsher
2019-11-08 16:43           ` Creeley, Brett
2019-11-12  7:33             ` Arkady Gilinsky
2019-11-13 18:47               ` Jeff Kirsher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3508A0C5D531054DBDD98909F6FA64FA11B39863@ORSMSX113.amr.corp.intel.com \
    --to=brett.creeley@intel.com \
    --cc=arcadyg@gmail.com \
    --cc=arkady.gilinsky@harmonicinc.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).