All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Tony Nguyen <anthony.l.nguyen@intel.com>
Cc: davem@davemloft.net, pabeni@redhat.com, edumazet@google.com,
	Mateusz Palczewski <mateusz.palczewski@intel.com>,
	netdev@vger.kernel.org, sassmann@redhat.com,
	Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>,
	Konrad Jankowski <konrad0.jankowski@intel.com>
Subject: Re: [PATCH net-next 2/2] iavf: Add waiting for response from PF in set mac
Date: Tue, 10 May 2022 19:09:27 -0700	[thread overview]
Message-ID: <20220510190927.56004f10@kernel.org> (raw)
In-Reply-To: <20220509173547.562461-3-anthony.l.nguyen@intel.com>

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;

  reply	other threads:[~2022-05-11  2:09 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 [this message]
2022-05-11 10:09     ` Palczewski, Mateusz

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=20220510190927.56004f10@kernel.org \
    --to=kuba@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=konrad0.jankowski@intel.com \
    --cc=mateusz.palczewski@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.