Skip to content

Commit 61f723e

Browse files
pkitszelanguy11
authored andcommitted
iavf: fix err handling for MAC replace
Defer removal of current primary MAC until a replacement is successfully added. Previous implementation would left filter list with no primary MAC. This was found while reading the code. The patch takes advantage of the fact that there can only be a single primary MAC filter at any time ([1] by Piotr) Piotr has also applied some review suggestions during our internal patch submittal process. [1] https://lore.kernel.org/netdev/20230614145302.902301-2-piotrx.gardocki@intel.com/ Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Piotr Gardocki <piotrx.gardocki@intel.com> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 98e9587 commit 61f723e

1 file changed

Lines changed: 19 additions & 23 deletions

File tree

drivers/net/ethernet/intel/iavf/iavf_main.c

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,40 +1007,36 @@ int iavf_replace_primary_mac(struct iavf_adapter *adapter,
10071007
const u8 *new_mac)
10081008
{
10091009
struct iavf_hw *hw = &adapter->hw;
1010-
struct iavf_mac_filter *f;
1010+
struct iavf_mac_filter *new_f;
1011+
struct iavf_mac_filter *old_f;
10111012

10121013
spin_lock_bh(&adapter->mac_vlan_list_lock);
10131014

1014-
list_for_each_entry(f, &adapter->mac_filter_list, list) {
1015-
f->is_primary = false;
1015+
new_f = iavf_add_filter(adapter, new_mac);
1016+
if (!new_f) {
1017+
spin_unlock_bh(&adapter->mac_vlan_list_lock);
1018+
return -ENOMEM;
10161019
}
10171020

1018-
f = iavf_find_filter(adapter, hw->mac.addr);
1019-
if (f) {
1020-
f->remove = true;
1021+
old_f = iavf_find_filter(adapter, hw->mac.addr);
1022+
if (old_f) {
1023+
old_f->is_primary = false;
1024+
old_f->remove = true;
10211025
adapter->aq_required |= IAVF_FLAG_AQ_DEL_MAC_FILTER;
10221026
}
1023-
1024-
f = iavf_add_filter(adapter, new_mac);
1025-
1026-
if (f) {
1027-
/* Always send the request to add if changing primary MAC
1028-
* even if filter is already present on the list
1029-
*/
1030-
f->is_primary = true;
1031-
f->add = true;
1032-
adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER;
1033-
ether_addr_copy(hw->mac.addr, new_mac);
1034-
}
1027+
/* Always send the request to add if changing primary MAC,
1028+
* even if filter is already present on the list
1029+
*/
1030+
new_f->is_primary = true;
1031+
new_f->add = true;
1032+
adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER;
1033+
ether_addr_copy(hw->mac.addr, new_mac);
10351034

10361035
spin_unlock_bh(&adapter->mac_vlan_list_lock);
10371036

10381037
/* schedule the watchdog task to immediately process the request */
1039-
if (f) {
1040-
mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0);
1041-
return 0;
1042-
}
1043-
return -ENOMEM;
1038+
mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0);
1039+
return 0;
10441040
}
10451041

10461042
/**

0 commit comments

Comments
 (0)