From: Huazhong Tan tanhuazhong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
hclge_reset_prepare_down() is only used to inform VF that PF is going to do function, then using hclge_func_reset_sync_vf() in hclge_reset_prepare_wait() to query whether VF is ready before asserting PF function reset. To make the code more readable, this patch uses a new function hclge_function_reset_notify_vf to do this job.
Signed-off-by: Huazhong Tan tanhuazhong@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 42 ++++++++++------------ 1 file changed, 19 insertions(+), 23 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 4168567..b9f4441 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3520,23 +3520,6 @@ static void hclge_clear_reset_cause(struct hclge_dev *hdev) hclge_enable_vector(&hdev->misc_vector, true); }
-static int hclge_reset_prepare_down(struct hclge_dev *hdev) -{ - int ret = 0; - - switch (hdev->reset_type) { - case HNAE3_FUNC_RESET: - /* fall through */ - case HNAE3_FLR_RESET: - ret = hclge_set_all_vf_rst(hdev, true); - break; - default: - break; - } - - return ret; -} - static void hclge_reset_handshake(struct hclge_dev *hdev, bool enable) { u32 reg_val; @@ -3550,6 +3533,19 @@ static void hclge_reset_handshake(struct hclge_dev *hdev, bool enable) hclge_write_dev(&hdev->hw, HCLGE_NIC_CSQ_DEPTH_REG, reg_val); }
+static int hclge_func_reset_notify_vf(struct hclge_dev *hdev) +{ + int ret; + + ret = hclge_set_all_vf_rst(hdev, true); + if (ret) + return ret; + + hclge_func_reset_sync_vf(hdev); + + return ret; +} + static int hclge_reset_prepare_wait(struct hclge_dev *hdev) { struct hnae3_handle *handle = &hdev->vport[0].nic; @@ -3558,7 +3554,9 @@ static int hclge_reset_prepare_wait(struct hclge_dev *hdev)
switch (hdev->reset_type) { case HNAE3_FUNC_RESET: - hclge_func_reset_sync_vf(hdev); + ret = hclge_func_reset_notify_vf(hdev); + if (ret) + return ret;
ret = hclge_func_reset_cmd(hdev, 0); if (ret) { @@ -3576,7 +3574,9 @@ static int hclge_reset_prepare_wait(struct hclge_dev *hdev) hdev->rst_stats.pf_rst_cnt++; break; case HNAE3_FLR_RESET: - hclge_func_reset_sync_vf(hdev); + ret = hclge_func_reset_notify_vf(hdev); + if (ret) + return ret; break; case HNAE3_IMP_RESET: if (handle && handle->ae_algo->ops->handle_imp_error) @@ -3714,10 +3714,6 @@ static int hclge_reset_prepare(struct hclge_dev *hdev) if (ret) return ret;
- ret = hclge_reset_prepare_down(hdev); - if (ret) - return ret; - rtnl_lock(); ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); rtnl_unlock();