netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Palczewski, Mateusz" <mateusz.palczewski@intel.com>
To: Jakub Kicinski <kuba@kernel.org>,
	"Nguyen, Anthony L" <anthony.l.nguyen@intel.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"edumazet@google.com" <edumazet@google.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"sassmann@redhat.com" <sassmann@redhat.com>,
	Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>,
	"Jankowski, Konrad0" <konrad0.jankowski@intel.com>
Subject: RE: [PATCH net-next 2/2] iavf: Add waiting for response from PF in set mac
Date: Wed, 11 May 2022 10:09:49 +0000	[thread overview]
Message-ID: <BL1PR11MB5288BAE1249799CD02FD281687C89@BL1PR11MB5288.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220510190927.56004f10@kernel.org>

>On Mon,  9 May 2022 10:35:47 -0700 Tony Nguyen wrote:
>> +static int iavf_set_mac(struct net_device *netdev, void *p) {
>> +	struct iavf_adapter *adapter = netdev_priv(netdev);
>> +	struct sockaddr *addr = p;
>> +	bool handle_mac = iavf_is_mac_set_handled(netdev, addr->sa_data);
>> +	int ret;
>> +
>> +	if (!is_valid_ether_addr(addr->sa_data))
>> +		return -EADDRNOTAVAIL;
>> +
>> +	ret = iavf_replace_primary_mac(adapter, addr->sa_data);
>> +
>> +	if (ret)
>> +		return ret;
>> +
>> +	/* If this is an initial set mac during VF spawn do not wait */
>> +	if (adapter->flags & IAVF_FLAG_INITIAL_MAC_SET) {
>> +		adapter->flags &= ~IAVF_FLAG_INITIAL_MAC_SET;
>> +		return 0;
>> +	}
>> +
>> +	ret = wait_event_interruptible_timeout(adapter->vc_waitqueue, 
>> +handle_mac, msecs_to_jiffies(2500));
>
>Passing in a value as a condition looks a little odd, are you sure this is what you want? Because you can rewrite this as:
>
>	if (handled_mac)
>		goto done;
>
>	ret = wait_eve..(wq, false, msecs...);
>	if (ret < 0)
>		...
>	if (!ret)
>		...
>
>done:
>	if (!ether_addr_equal(netdev->dev_addr, addr->sa_data))
>		return -EACCESS;
>	return 0;
>
Thanks for a tip, will work on rewriting this as You suggested and will test if everything still works fine.

      reply	other threads:[~2022-05-11 10:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09 17:35 [PATCH net-next 0/2][pull request] 40GbE Intel Wired LAN Driver Updates 2022-05-09 Tony Nguyen
2022-05-09 17:35 ` [PATCH net-next 1/2] i40e: Add VF VLAN pruning Tony Nguyen
2022-05-09 17:35 ` [PATCH net-next 2/2] iavf: Add waiting for response from PF in set mac Tony Nguyen
2022-05-11  2:09   ` Jakub Kicinski
2022-05-11 10:09     ` Palczewski, Mateusz [this message]

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=BL1PR11MB5288BAE1249799CD02FD281687C89@BL1PR11MB5288.namprd11.prod.outlook.com \
    --to=mateusz.palczewski@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=konrad0.jankowski@intel.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sassmann@redhat.com \
    --cc=sylwesterx.dziedziuch@intel.com \
    /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).