From: Chiqijun chiqijun@huawei.com
driver inclusion category: bugfix bugzilla: 4472
-----------------------------------------------------------------------
The driver initializes the MAC address of all VFs to 00:00:00:00:00:00, but when we attempts to restore the MAC address back to 00:00:00:00:00:00 after it was modified using "ip link", driver responds with "Invalid argument". Some users need to roll back the MAC configuration without destroying the VF, so the driver should allows users to use "ip link" with 00:00:00:00:00:00 to revert the MAC to the origin state.
Signed-off-by: Chiqijun chiqijun@huawei.com Reviewed-by: Wangxiaoyun cloud.wangxiaoyun@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../net/ethernet/huawei/hinic/hinic_nic_cfg.c | 18 +++++++++--------- .../net/ethernet/huawei/hinic/hinic_sriov.c | 15 +++++++++++---- 2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c index 2b349e17260b..fbc7c9d1cb3c 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c @@ -2848,25 +2848,25 @@ int hinic_set_vf_mac(void *hwdev, int vf, unsigned char *mac_addr) struct hinic_hwdev *hw_dev = (struct hinic_hwdev *)hwdev; struct hinic_nic_io *nic_io = hw_dev->nic_io; struct vf_data_storage *vf_info = nic_io->vf_infos + HW_VF_ID_TO_OS(vf); + int del_vf_mac = is_zero_ether_addr(mac_addr); u16 func_id; int err;
/* duplicate request, so just return success */ - if (vf_info->pf_set_mac && - !memcmp(vf_info->vf_mac_addr, mac_addr, ETH_ALEN)) + if (!memcmp(vf_info->vf_mac_addr, mac_addr, ETH_ALEN)) return 0;
- vf_info->pf_set_mac = true; - func_id = hinic_glb_pf_vf_offset(hw_dev) + vf; - err = hinic_update_mac(hw_dev, vf_info->vf_mac_addr, - mac_addr, 0, func_id); - if (err) { - vf_info->pf_set_mac = false; + if (del_vf_mac) + err = hinic_del_mac(hwdev, vf_info->vf_mac_addr, 0, func_id); + else + err = hinic_update_mac(hw_dev, vf_info->vf_mac_addr, + mac_addr, 0, func_id); + if (err) return err; - }
memcpy(vf_info->vf_mac_addr, mac_addr, ETH_ALEN); + vf_info->pf_set_mac = !del_vf_mac;
return 0; } diff --git a/drivers/net/ethernet/huawei/hinic/hinic_sriov.c b/drivers/net/ethernet/huawei/hinic/hinic_sriov.c index 9198f13ff9e1..d987a4671f36 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_sriov.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_sriov.c @@ -181,16 +181,23 @@ int hinic_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) }
sriov_info = hinic_get_sriov_info_by_pcidev(adapter->pdev); - if (!is_valid_ether_addr(mac) || /*lint !e574*/ + if (is_multicast_ether_addr(mac) || /*lint !e574*/ vf >= sriov_info->num_vfs) /*lint !e574*/ return -EINVAL;
err = hinic_set_vf_mac(sriov_info->hwdev, OS_VF_ID_TO_HW(vf), mac); - if (err) + if (err) { + nicif_info(adapter, drv, netdev, "Failed to set MAC %pM on VF %d\n", + mac, vf); return err; + }
- nic_info(&sriov_info->pdev->dev, "Setting MAC %pM on VF %d\n", mac, vf); - nic_info(&sriov_info->pdev->dev, "Reload the VF driver to make this change effective\n"); + if (is_zero_ether_addr(mac)) + nicif_info(adapter, drv, netdev, "Removing MAC on VF %d\n", vf); + else + nicif_info(adapter, drv, netdev, "Setting MAC %pM on VF %d\n", + mac, vf); + nicif_info(adapter, drv, netdev, "Reload the VF driver to make this change effective\n");
return 0; }