From: Chiqijun chiqijun@huawei.com
driver inclusion category: bugfix bugzilla: 4472
-----------------------------------------------------------------------
When using the ip link command to configure the MAC for the VF in the PF, the status 4 will be returned when the MAC is set on the VF; when the PF driver receives the status 4 returned by the firmwre, the MAC setting failed and an error should be reported.
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_main.c | 7 +++- .../net/ethernet/huawei/hinic/hinic_nic_cfg.c | 41 ++++++++++++------- 2 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c index b5d0bdadf509..cf7b6ceef060 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_main.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c @@ -1305,8 +1305,11 @@ static int hinic_set_mac_addr(struct net_device *netdev, void *addr)
err = hinic_update_mac(nic_dev->hwdev, netdev->dev_addr, saddr->sa_data, 0, func_id); - if (err) - return err; + if (err) { + nicif_err(nic_dev, drv, netdev, "Failed to update mac, err: %d\n", + err); + return err == HINIC_PF_SET_VF_ALREADY ? -EPERM : err; + }
memcpy(netdev->dev_addr, saddr->sa_data, ETH_ALEN);
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c index a42dea0ad707..2b349e17260b 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c @@ -231,6 +231,23 @@ int hinic_get_fw_support_func(void *hwdev)
#define HINIC_ADD_VLAN_IN_MAC 0x8000 #define HINIC_VLAN_ID_MASK 0x7FFF +#define PF_SET_VF_MAC(hwdev, status) \ + (HINIC_FUNC_TYPE(hwdev) == TYPE_VF && \ + (status) == HINIC_PF_SET_VF_ALREADY) + +static int hinic_check_mac_status(struct hinic_hwdev *hwdev, u8 status, + u16 vlan_id) +{ + if ((status && status != HINIC_MGMT_STATUS_EXIST) || + (vlan_id & CHECK_IPSU_15BIT && status == HINIC_MGMT_STATUS_EXIST)) { + if (PF_SET_VF_MAC(hwdev, status)) + return 0; + + return -EINVAL; + } + + return 0; +}
int hinic_set_mac(void *hwdev, const u8 *mac_addr, u16 vlan_id, u16 func_id) { @@ -255,17 +272,14 @@ int hinic_set_mac(void *hwdev, const u8 *mac_addr, u16 vlan_id, u16 func_id) err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_MAC, &mac_info, sizeof(mac_info), &mac_info, &out_size); if (err || !out_size || - (mac_info.status && mac_info.status != HINIC_MGMT_STATUS_EXIST && - mac_info.status != HINIC_PF_SET_VF_ALREADY) || - (mac_info.vlan_id & CHECK_IPSU_15BIT && - mac_info.status == HINIC_MGMT_STATUS_EXIST)) { + hinic_check_mac_status(hwdev, mac_info.status, mac_info.vlan_id)) { nic_err(nic_hwdev->dev_hdl, "Failed to update MAC, err: %d, status: 0x%x, out size: 0x%x\n", err, mac_info.status, out_size); - return -EINVAL; + return -EIO; }
- if (mac_info.status == HINIC_PF_SET_VF_ALREADY) { + if (PF_SET_VF_MAC(nic_hwdev, mac_info.status)) { nic_warn(nic_hwdev->dev_hdl, "PF has already set VF mac, Ignore set operation\n"); return HINIC_PF_SET_VF_ALREADY; } @@ -302,13 +316,13 @@ int hinic_del_mac(void *hwdev, const u8 *mac_addr, u16 vlan_id, u16 func_id) err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_DEL_MAC, &mac_info, sizeof(mac_info), &mac_info, &out_size); if (err || !out_size || - (mac_info.status && mac_info.status != HINIC_PF_SET_VF_ALREADY)) { + (mac_info.status && !PF_SET_VF_MAC(nic_hwdev, mac_info.status))) { nic_err(nic_hwdev->dev_hdl, "Failed to delete MAC, err: %d, status: 0x%x, out size: 0x%x\n", err, mac_info.status, out_size); - return -EINVAL; + return -EIO; } - if (mac_info.status == HINIC_PF_SET_VF_ALREADY) { + if (PF_SET_VF_MAC(nic_hwdev, mac_info.status)) { nic_warn(nic_hwdev->dev_hdl, "PF has already set VF mac, Ignore delete operation\n"); return HINIC_PF_SET_VF_ALREADY; } @@ -343,17 +357,14 @@ int hinic_update_mac(void *hwdev, u8 *old_mac, u8 *new_mac, u16 vlan_id, &mac_info, sizeof(mac_info), &mac_info, &out_size); if (err || !out_size || - (mac_info.status && mac_info.status != HINIC_MGMT_STATUS_EXIST && - mac_info.status != HINIC_PF_SET_VF_ALREADY) || - (mac_info.vlan_id & CHECK_IPSU_15BIT && - mac_info.status == HINIC_MGMT_STATUS_EXIST)) { + hinic_check_mac_status(hwdev, mac_info.status, mac_info.vlan_id)) { nic_err(nic_hwdev->dev_hdl, "Failed to update MAC, err: %d, status: 0x%x, out size: 0x%x\n", err, mac_info.status, out_size); - return -EINVAL; + return -EIO; }
- if (mac_info.status == HINIC_PF_SET_VF_ALREADY) { + if (PF_SET_VF_MAC(nic_hwdev, mac_info.status)) { nic_warn(nic_hwdev->dev_hdl, "PF has already set VF MAC. Ignore update operation\n"); return HINIC_PF_SET_VF_ALREADY; }
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; }
From: Chiqijun chiqijun@huawei.com
driver inclusion category: bugfix bugzilla: 4472
-----------------------------------------------------------------------
Hardware rx csum offload is a chip-level configuration, and VF is not allowed to turn it off. The force packet drop configuration is at the port level, VF can only configure the corresponding port.
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_mbox.c | 2 ++ .../net/ethernet/huawei/hinic/hinic_nic_cfg.c | 29 ++++++++++++++++++- .../net/ethernet/huawei/hinic/hinic_nic_cfg.h | 2 ++ drivers/net/ethernet/huawei/hinic/hinic_rx.h | 2 -- 4 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_mbox.c b/drivers/net/ethernet/huawei/hinic/hinic_mbox.c index 24f119bb5938..c2a07565fc54 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_mbox.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_mbox.c @@ -589,6 +589,8 @@ bool hinic_mbox_check_cmd_valid(struct hinic_hwdev *hwdev, } }
+ sdk_err(hwdev->dev_hdl, "Unsupported vf cmd %d\n", cmd); + return false; }
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c index fbc7c9d1cb3c..921c8baef204 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c @@ -69,6 +69,32 @@ static bool check_func_table(struct hinic_hwdev *hwdev, u16 func_idx, return true; }
+static bool check_rxcsum_setting(struct hinic_hwdev *hwdev, u16 func_idx, + void *buf_in, u16 in_size) +{ + struct hinic_checksum_offload *rx_csum_cfg = NULL; + + if (!hinic_mbox_check_func_id_8B(hwdev, func_idx, buf_in, in_size)) + return false; + + rx_csum_cfg = buf_in; + if (rx_csum_cfg->rx_csum_offload != HINIC_RX_CSUM_OFFLOAD_EN) + return false; + + return true; +} + +static bool check_force_pkt_drop(struct hinic_hwdev *hwdev, u16 func_idx, + void *buf_in, u16 in_size) +{ + struct hinic_force_pkt_drop *pkt_drop = buf_in; + + if (pkt_drop->port != hinic_physical_port_id(hwdev)) + return false; + + return true; +} + struct vf_cmd_check_handle nic_cmd_support_vf[] = { {HINIC_PORT_CMD_VF_REGISTER, NULL}, {HINIC_PORT_CMD_VF_UNREGISTER, NULL}, @@ -88,7 +114,7 @@ struct vf_cmd_check_handle nic_cmd_support_vf[] = {
{HINIC_PORT_CMD_GET_LINK_STATE, hinic_mbox_check_func_id_8B}, {HINIC_PORT_CMD_SET_LRO, hinic_mbox_check_func_id_8B}, - {HINIC_PORT_CMD_SET_RX_CSUM, hinic_mbox_check_func_id_8B}, + {HINIC_PORT_CMD_SET_RX_CSUM, check_rxcsum_setting}, {HINIC_PORT_CMD_SET_RX_VLAN_OFFLOAD, hinic_mbox_check_func_id_8B},
{HINIC_PORT_CMD_GET_VPORT_STAT, hinic_mbox_check_func_id_8B}, @@ -139,6 +165,7 @@ struct vf_cmd_check_handle nic_cmd_support_vf[] = { {HINIC_PORT_CMD_SET_VHD_CFG, hinic_mbox_check_func_id_8B},
{HINIC_PORT_CMD_SET_VLAN_FILTER, hinic_mbox_check_func_id_8B}, + {HINIC_PORT_CMD_FORCE_PKT_DROP, check_force_pkt_drop}, };
int hinic_init_function_table(void *hwdev, u16 rx_buf_sz) diff --git a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.h b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.h index f0810b201d51..08bb4404e7cf 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.h +++ b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.h @@ -425,6 +425,8 @@ enum hinic_lro_en_status { #define HINIC_VLAN_FILTER_EN (1U << 0) #define HINIC_BROADCAST_FILTER_EX_EN (1U << 1)
+#define HINIC_RX_CSUM_OFFLOAD_EN 0xFFF + /* Set mac_vlan table */ int hinic_set_mac(void *hwdev, const u8 *mac_addr, u16 vlan_id, u16 func_id);
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.h b/drivers/net/ethernet/huawei/hinic/hinic_rx.h index 11c68c09835b..09f8784157cf 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_rx.h +++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.h @@ -27,8 +27,6 @@ #define HINIC_RX_CSUM_HW_CHECK_NONE BIT(7) #define HINIC_RX_CSUM_IPSU_OTHER_ERR BIT(8)
-#define HINIC_RX_CSUM_OFFLOAD_EN 0xFFF - #define HINIC_SUPPORT_LRO_ADAP_QPS_MAX 16 #define HINIC_RX_BUFFER_WRITE 16
From: Chiqijun chiqijun@huawei.com
driver inclusion category: bugfix bugzilla: 4472
-----------------------------------------------------------------------
During the loopback test, it cannot be guaranteed that the protocol stack will completely stop sending packets, which causes the loopback test packets and protocol stack packets to be sent at the same time, causing the loopback test to fail. This patch corrects it.
Signed-off-by: Chiqijun chiqijun@huawei.com Reviewed-by: Wangxiaoyun cloud.wangxiaoyun@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/huawei/hinic/hinic_ethtool.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c index aca9bd9a6624..ff6a3d7fe9ad 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c @@ -1928,6 +1928,7 @@ void hinic_lp_test(struct net_device *netdev, struct ethtool_test *eth_test, test_time = LP_DEFAULT_TIME;
netif_carrier_off(netdev); + netif_tx_disable(netdev);
if (!(test.flags & ETH_TEST_FL_EXTERNAL_LB)) { test_index = INTERNAL_LP_TEST; @@ -1977,6 +1978,7 @@ void hinic_lp_test(struct net_device *netdev, struct ethtool_test *eth_test, data[test_index] = 1; }
+ netif_tx_wake_all_queues(netdev); err = hinic_get_link_state(nic_dev->hwdev, &link_status); if (!err && link_status) netif_carrier_on(netdev);
From: Chiqijun chiqijun@huawei.com
driver inclusion category: bugfix bugzilla: 4472
-----------------------------------------------------------------------
When only hot activation of ucode, mgmt channel can still be used normally, otherwise it is not allowed to send commands to mgmt until the hot activation is completed.
Signed-off-by: Chiqijun chiqijun@huawei.com Reviewed-by: Wangxiaoyun cloud.wangxiaoyun@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/huawei/hinic/hinic_hwdev.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hwdev.c b/drivers/net/ethernet/huawei/hinic/hinic_hwdev.c index db6c468818ef..1178e53be9c6 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_hwdev.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_hwdev.c @@ -77,6 +77,7 @@ #define HINIC_MGMT_CHANNEL_STATUS_MASK 0x1 #define HINIC_ACTIVE_STATUS_MASK 0x80000000 #define HINIC_ACTIVE_STATUS_CLEAR 0x7FFFFFFF +#define HINIC_ACTIVE_UCODE 0x1F80 /* bit7~bit12 */
#define HINIC_GET_MGMT_CHANNEL_STATUS(val, member) \ (((val) >> HINIC_##member##_SHIFT) & HINIC_##member##_MASK) @@ -805,8 +806,11 @@ static int __func_send_mbox(struct hinic_hwdev *hwdev, enum hinic_mod_type mod, }
static int __pf_to_mgmt_pre_handle(struct hinic_hwdev *hwdev, - enum hinic_mod_type mod, u8 cmd) + enum hinic_mod_type mod, u8 cmd, + void *buf_in) { + struct hinic_update_active *active_info = buf_in; + if (hinic_get_mgmt_channel_status(hwdev)) { if (mod == HINIC_MOD_COMM || mod == HINIC_MOD_L2NIC || mod == HINIC_MOD_CFGM || mod == HINIC_MOD_HILINK) @@ -815,8 +819,12 @@ static int __pf_to_mgmt_pre_handle(struct hinic_hwdev *hwdev, return -EBUSY; }
- /* Set channel invalid, don't allowed to send other cmd */ - if (mod == HINIC_MOD_COMM && cmd == HINIC_MGMT_CMD_ACTIVATE_FW) { + /* When only hot activation of ucode, mgmt channel can still be used + * normally, otherwise it is not allowed to send commands to mgmt until + * the hot activation is completed + */ + if (mod == HINIC_MOD_COMM && cmd == HINIC_MGMT_CMD_ACTIVATE_FW && + (active_info->update_flag & ~HINIC_ACTIVE_UCODE)) { hinic_set_mgmt_channel_status(hwdev, true);
/* Sleep 2s wait other pf's mgmt messages to complete */ @@ -868,7 +876,7 @@ int hinic_pf_msg_to_mgmt_sync(void *hwdev, enum hinic_mod_type mod, u8 cmd, if (in_size > HINIC_MSG_TO_MGMT_MAX_LEN) return -EINVAL;
- err = __pf_to_mgmt_pre_handle(hwdev, mod, cmd); + err = __pf_to_mgmt_pre_handle(hwdev, mod, cmd, buf_in); if (err) return err;
From: Chiqijun chiqijun@huawei.com
driver inclusion category: bugfix bugzilla: 4472
-----------------------------------------------------------------------
update hinic version to 2.3.2.16
Signed-off-by: Chiqijun chiqijun@huawei.com Reviewed-by: Wangxiaoyun cloud.wangxiaoyun@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/huawei/hinic/hinic_nic_dev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_nic_dev.h b/drivers/net/ethernet/huawei/hinic/hinic_nic_dev.h index 33b2aca3ce4c..c7c78b2632da 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_nic_dev.h +++ b/drivers/net/ethernet/huawei/hinic/hinic_nic_dev.h @@ -30,7 +30,7 @@ #define HINIC_DRV_NAME "hinic" #define HINIC_CHIP_NAME "hinic"
-#define HINIC_DRV_VERSION "2.3.2.15" +#define HINIC_DRV_VERSION "2.3.2.16" struct vf_data_storage;
#define HINIC_FUNC_IS_VF(hwdev) (hinic_func_type(hwdev) == TYPE_VF)