[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <BL1PR11MB5288BAE1249799CD02FD281687C89@BL1PR11MB5288.namprd11.prod.outlook.com>
Date: Wed, 11 May 2022 10:09:49 +0000
From: "Palczewski, Mateusz" <mateusz.palczewski@...el.com>
To: Jakub Kicinski <kuba@...nel.org>,
"Nguyen, Anthony L" <anthony.l.nguyen@...el.com>
CC: "davem@...emloft.net" <davem@...emloft.net>,
"pabeni@...hat.com" <pabeni@...hat.com>,
"edumazet@...gle.com" <edumazet@...gle.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"sassmann@...hat.com" <sassmann@...hat.com>,
Sylwester Dziedziuch <sylwesterx.dziedziuch@...el.com>,
"Jankowski, Konrad0" <konrad0.jankowski@...el.com>
Subject: RE: [PATCH net-next 2/2] iavf: Add waiting for response from PF in
set mac
>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.
Powered by blists - more mailing lists