iavf: Fix lost VF MAC when repeatedly set same MAC
RFC PATCH v2 1/1 iavf: Fix lost VF MAC when repeatedly set same MAC
Since Intel iavf-4.6.1 from the official website, we found a a VF's MAC lost scenario when we repeatedly set the same MAC address to a VF NIC.
But I checked linux inbox iavf [1], the logic is same as iavf-4.5.3 in iavf_replace_primary_mac(), which not lost MAC.
Reproducer:
# eth4 is a VF NIC ip link set dev eth4 address fe:11:22:33:44:55 # set again ip link set dev eth4 address fe:11:22:33:44:55
iavf-4.6.1 ~ iavf-4.8.2:
If the new_mac is existed in mac_filter_list, in iavf_replace_primary_mac() we will set the same iavf_mac_filter with both f->add and f->remove is true, and in iavf_process_aq_command(), we handle iavf_del_ether_addrs() after iavf_add_ether_addrs(), so we will delete the MAC just after added it.
The linux inbox iavf:
First set old f->remove true, and later call iavf_add_filter() which auto set back f->remove false, so the mac_filter is not both f->add and f->remove true, so the MAC will not lost.
Could you confirm the issue of driver from official website? And try to fix it?
Thanks.
In the RFC, to avoid the lost issue, I simply reset f->remove to false for the mac_filter we will add.
Because the inbox driver does not have this issue, sorry about that the email is only sent to you guys without open list.
[1]: 35a2443d0910 ("iavf: Add waiting for response from PF in set mac")
---
v2:
- code: new_f->remove = false
--- iavf-4.8.2/src/iavf_main.c | 1 + 1 file changed, 1 insertion(+)
iavf-4.8.2/src/iavf_main.c +0 -0
@@ -1080,6 +1080,7 @@ int iavf_replace_primary_mac(struct iavf_adapter
*adapter,
*/
new_f->is_primary = true;
new_f->add = true;
+ new_f->remove = false;
adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER; ether_addr_copy(hw->mac.addr, new_mac);
}
Signature · 6 lines
2.17.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Hello Ding,
Thanks for the report. Intel is already aware of this issue and the fix should be available in the next release. The way we fixed that is that we're checking whether request from kernel is to change MAC address to the same address that's already applied. This way we're limiting the number of virtchnl calls. I think your patch is also valid, but one minor problem with it is that IAVF_FLAG_AQ_DEL_MAC_FILTER flag in aq_required is not being cleared. I'm pasting below our solution. We also have a plan to send this code to upstream, so the final solution might change if community will raise any concerns.
iavf_main.c +3 -0
@@ -1190,6 +1190,9 @@ int iavf_replace_primary_mac(struct iavf_adapter *adapter,struct iavf_hw *hw = &adapter->hw;struct iavf_mac_filter *new_f; +if (ether_addr_equal (new_mac, hw->mac.addr)) +return 0 ; +spin_lock_bh (&adapter->mac_vlan_list_lock); new_f =iavf_add_filter (adapter, new_mac);
Regards,
Piotr
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 5 lines · PiotrX
Hello Ding,
Thanks for the report. Intel is already aware of this issue and the fix should be available in the next release. The way we fixed that is that we're checking whether request from kernel is to change MAC address to the same address that's already applied. This way we're limiting the number of virtchnl calls. I think your patch is also valid, but one minor problem with it is that
IAVF_FLAG_AQ_DEL_MAC_FILTERflag inaq_requiredis not being cleared. I'm pasting below our solution. We also have a plan to send this code to upstream, so the final solution might change if community will raise any concerns.
Thanks for the reply.
Before the reply, I used to think that the commit 35a2443d0910 ("iavf: Add waiting for response from PF in set mac") removed the ether_addr_equal() in iavf_set_mac() intentionally, to make sure call virtchnl on every set mac.
iavf_main.c int iavf_replace_primary_mac(struct iavf_adapter *adapter, · line 1195
Quoted 11 lines
iavf_main.c +3
-0@@ -1190,6 +1190,9 @@ int iavf_replace_primary_mac(struct iavf_adapter *adapter, struct iavf_hw *hw = &adapter->hw; struct iavf_mac_filter *new_f; + if (ether_addr_equal(new_mac, hw->mac.addr)) + return 0; +
I also tried add back the ether_addr_equal() condition, but I added it in iavf_set_mac(), since I think that there is no need to wait_event_interruptible_timeout() if skipping queue_work().
Quoted 8 lines
iavf_main.c +0
-0spin_lock_bh(&adapter->mac_vlan_list_lock); new_f = iavf_add_filter(adapter, new_mac);Regards,
Piotr
Signature · 7 lines
Thanks, - Ding Hui _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan