Commit f109603a authored by Brett Creeley's avatar Brett Creeley Committed by Jeff Kirsher

ice: allow host to clear administratively set VF MAC

Currently a user is not allowed to clear a VF's administratively set MAC
on the PF. Fix this by allowing an all zero MAC address via "ip link set
${pf_eth} vf ${vf_id} mac 00:00:00:00:00:00".

An example use case for this would be issuing a "virsh shutdown"
command on a VM. The call to iproute mentioned above is part of this flow.
Without this change the driver incorrectly rejects clearing the VF's
administratively set MAC and prints unhelpful log messages.

Also, improve the comments surrounding this change.
Signed-off-by: default avatarBrett Creeley <brett.creeley@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 39884604
...@@ -3904,7 +3904,7 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) ...@@ -3904,7 +3904,7 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
if (ice_validate_vf_id(pf, vf_id)) if (ice_validate_vf_id(pf, vf_id))
return -EINVAL; return -EINVAL;
if (is_zero_ether_addr(mac) || is_multicast_ether_addr(mac)) { if (is_multicast_ether_addr(mac)) {
netdev_err(netdev, "%pM not a valid unicast address\n", mac); netdev_err(netdev, "%pM not a valid unicast address\n", mac);
return -EINVAL; return -EINVAL;
} }
...@@ -3924,15 +3924,21 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) ...@@ -3924,15 +3924,21 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
return -EINVAL; return -EINVAL;
} }
/* copy MAC into dflt_lan_addr and trigger a VF reset. The reset /* VF is notified of its new MAC via the PF's response to the
* flow will use the updated dflt_lan_addr and add a MAC filter * VIRTCHNL_OP_GET_VF_RESOURCES message after the VF has been reset
* using ice_add_mac. Also set pf_set_mac to indicate that the PF has
* set the MAC address for this VF.
*/ */
ether_addr_copy(vf->dflt_lan_addr.addr, mac); ether_addr_copy(vf->dflt_lan_addr.addr, mac);
vf->pf_set_mac = true; if (is_zero_ether_addr(mac)) {
netdev_info(netdev, "MAC on VF %d set to %pM. VF driver will be reinitialized\n", /* VF will send VIRTCHNL_OP_ADD_ETH_ADDR message with its MAC */
vf_id, mac); vf->pf_set_mac = false;
netdev_info(netdev, "Removing MAC on VF %d. VF driver will be reinitialized\n",
vf->vf_id);
} else {
/* PF will add MAC rule for the VF */
vf->pf_set_mac = true;
netdev_info(netdev, "Setting MAC %pM on VF %d. VF driver will be reinitialized\n",
mac, vf_id);
}
ice_vc_reset_vf(vf); ice_vc_reset_vf(vf);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment