Skip to content

Commit 3a70017

Browse files
SlawomirLabaanguy11
authored andcommitted
i40e: Fix MAC address setting for a VF via Host/VM
Fix MAC setting flow for the PF driver. Update the unicast VF's MAC address in VF structure if it is a new setting in i40e_vc_add_mac_addr_msg. When unicast MAC address gets deleted, record that and set the new unicast MAC address that is already waiting in the filter list. This logic is based on the order of messages arriving to the PF driver. Without this change the MAC address setting was interpreted incorrectly in the following use cases: 1) Print incorrect VF MAC or zero MAC ip link show dev $pf 2) Don't preserve MAC between driver reload rmmod iavf; modprobe iavf 3) Update VF MAC when macvlan was set ip link add link $vf address $mac $vf.1 type macvlan 4) Failed to update mac address when VF was trusted ip link set dev $vf address $mac This includes all other configurations including above commands. Fixes: f657a6e ("i40e: Fix VF driver MAC address configuration") Signed-off-by: Slawomir Laba <slawomirx.laba@intel.com> Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 989ef49 commit 3a70017

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,6 +2713,10 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
27132713
spin_unlock_bh(&vsi->mac_filter_hash_lock);
27142714
goto error_param;
27152715
}
2716+
if (is_valid_ether_addr(al->list[i].addr) &&
2717+
is_zero_ether_addr(vf->default_lan_addr.addr))
2718+
ether_addr_copy(vf->default_lan_addr.addr,
2719+
al->list[i].addr);
27162720
}
27172721
}
27182722
spin_unlock_bh(&vsi->mac_filter_hash_lock);
@@ -2740,6 +2744,7 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
27402744
{
27412745
struct virtchnl_ether_addr_list *al =
27422746
(struct virtchnl_ether_addr_list *)msg;
2747+
bool was_unimac_deleted = false;
27432748
struct i40e_pf *pf = vf->pf;
27442749
struct i40e_vsi *vsi = NULL;
27452750
i40e_status ret = 0;
@@ -2759,6 +2764,8 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
27592764
ret = I40E_ERR_INVALID_MAC_ADDR;
27602765
goto error_param;
27612766
}
2767+
if (ether_addr_equal(al->list[i].addr, vf->default_lan_addr.addr))
2768+
was_unimac_deleted = true;
27622769
}
27632770
vsi = pf->vsi[vf->lan_vsi_idx];
27642771

@@ -2779,10 +2786,25 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
27792786
dev_err(&pf->pdev->dev, "Unable to program VF %d MAC filters, error %d\n",
27802787
vf->vf_id, ret);
27812788

2789+
if (vf->trusted && was_unimac_deleted) {
2790+
struct i40e_mac_filter *f;
2791+
struct hlist_node *h;
2792+
u8 *macaddr = NULL;
2793+
int bkt;
2794+
2795+
/* set last unicast mac address as default */
2796+
spin_lock_bh(&vsi->mac_filter_hash_lock);
2797+
hash_for_each_safe(vsi->mac_filter_hash, bkt, h, f, hlist) {
2798+
if (is_valid_ether_addr(f->macaddr))
2799+
macaddr = f->macaddr;
2800+
}
2801+
if (macaddr)
2802+
ether_addr_copy(vf->default_lan_addr.addr, macaddr);
2803+
spin_unlock_bh(&vsi->mac_filter_hash_lock);
2804+
}
27822805
error_param:
27832806
/* send the response to the VF */
2784-
return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_DEL_ETH_ADDR,
2785-
ret);
2807+
return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_DEL_ETH_ADDR, ret);
27862808
}
27872809

27882810
/**

0 commit comments

Comments
 (0)