Subject: Re: [PATCH net-next 2/2] iavf: Add waiting for response from PF in set mac

From: Jakub Kicinski <[email-masked]>
Date: Tue, 10 May 2022 19:09:27 -0700

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;