Commit d4fa0656 authored by Huazhong Tan's avatar Huazhong Tan Committed by David S. Miller

net: hns3: split hclge_reset() into preparing and rebuilding part

hclge_reset() is a little bloated, and the process of PF FLR will
be separated from the reset task later. So this patch splits
hclge_reset() into hclge_reset_prepare() and hclge_reset_rebuild(),
then FLR can also reuse these two functions.

BTW, since hclge_clear_reset_cause() and hclge_reset_prepare_up()
will not affect the device, so in hclge_reset_rebuild(), these
functions are called without rtnl_lock.
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6821af8b
...@@ -3782,10 +3782,9 @@ static int hclge_reset_stack(struct hclge_dev *hdev) ...@@ -3782,10 +3782,9 @@ static int hclge_reset_stack(struct hclge_dev *hdev)
return hclge_notify_client(hdev, HNAE3_RESTORE_CLIENT); return hclge_notify_client(hdev, HNAE3_RESTORE_CLIENT);
} }
static void hclge_reset(struct hclge_dev *hdev) static int hclge_reset_prepare(struct hclge_dev *hdev)
{ {
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev);
enum hnae3_reset_type reset_level;
int ret; int ret;
/* Initialize ae_dev reset status as well, in case enet layer wants to /* Initialize ae_dev reset status as well, in case enet layer wants to
...@@ -3796,45 +3795,45 @@ static void hclge_reset(struct hclge_dev *hdev) ...@@ -3796,45 +3795,45 @@ static void hclge_reset(struct hclge_dev *hdev)
/* perform reset of the stack & ae device for a client */ /* perform reset of the stack & ae device for a client */
ret = hclge_notify_roce_client(hdev, HNAE3_DOWN_CLIENT); ret = hclge_notify_roce_client(hdev, HNAE3_DOWN_CLIENT);
if (ret) if (ret)
goto err_reset; return ret;
ret = hclge_reset_prepare_down(hdev); ret = hclge_reset_prepare_down(hdev);
if (ret) if (ret)
goto err_reset; return ret;
rtnl_lock(); rtnl_lock();
ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT);
if (ret)
goto err_reset_lock;
rtnl_unlock(); rtnl_unlock();
ret = hclge_reset_prepare_wait(hdev);
if (ret) if (ret)
goto err_reset; return ret;
if (hclge_reset_wait(hdev)) return hclge_reset_prepare_wait(hdev);
goto err_reset; }
static int hclge_reset_rebuild(struct hclge_dev *hdev)
{
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev);
enum hnae3_reset_type reset_level;
int ret;
hdev->rst_stats.hw_reset_done_cnt++; hdev->rst_stats.hw_reset_done_cnt++;
ret = hclge_notify_roce_client(hdev, HNAE3_UNINIT_CLIENT); ret = hclge_notify_roce_client(hdev, HNAE3_UNINIT_CLIENT);
if (ret) if (ret)
goto err_reset; return ret;
rtnl_lock(); rtnl_lock();
ret = hclge_reset_stack(hdev); ret = hclge_reset_stack(hdev);
rtnl_unlock();
if (ret) if (ret)
goto err_reset_lock; return ret;
hclge_clear_reset_cause(hdev); hclge_clear_reset_cause(hdev);
ret = hclge_reset_prepare_up(hdev); ret = hclge_reset_prepare_up(hdev);
if (ret) if (ret)
goto err_reset_lock; return ret;
rtnl_unlock();
ret = hclge_notify_roce_client(hdev, HNAE3_INIT_CLIENT); ret = hclge_notify_roce_client(hdev, HNAE3_INIT_CLIENT);
/* ignore RoCE notify error if it fails HCLGE_RESET_MAX_FAIL_CNT - 1 /* ignore RoCE notify error if it fails HCLGE_RESET_MAX_FAIL_CNT - 1
...@@ -3842,19 +3841,17 @@ static void hclge_reset(struct hclge_dev *hdev) ...@@ -3842,19 +3841,17 @@ static void hclge_reset(struct hclge_dev *hdev)
*/ */
if (ret && if (ret &&
hdev->rst_stats.reset_fail_cnt < HCLGE_RESET_MAX_FAIL_CNT - 1) hdev->rst_stats.reset_fail_cnt < HCLGE_RESET_MAX_FAIL_CNT - 1)
goto err_reset; return ret;
rtnl_lock(); rtnl_lock();
ret = hclge_notify_client(hdev, HNAE3_UP_CLIENT); ret = hclge_notify_client(hdev, HNAE3_UP_CLIENT);
if (ret)
goto err_reset_lock;
rtnl_unlock(); rtnl_unlock();
if (ret)
return ret;
ret = hclge_notify_roce_client(hdev, HNAE3_UP_CLIENT); ret = hclge_notify_roce_client(hdev, HNAE3_UP_CLIENT);
if (ret) if (ret)
goto err_reset; return ret;
hdev->last_reset_time = jiffies; hdev->last_reset_time = jiffies;
hdev->rst_stats.reset_fail_cnt = 0; hdev->rst_stats.reset_fail_cnt = 0;
...@@ -3871,10 +3868,22 @@ static void hclge_reset(struct hclge_dev *hdev) ...@@ -3871,10 +3868,22 @@ static void hclge_reset(struct hclge_dev *hdev)
if (reset_level != HNAE3_NONE_RESET) if (reset_level != HNAE3_NONE_RESET)
set_bit(reset_level, &hdev->reset_request); set_bit(reset_level, &hdev->reset_request);
return 0;
}
static void hclge_reset(struct hclge_dev *hdev)
{
if (hclge_reset_prepare(hdev))
goto err_reset;
if (hclge_reset_wait(hdev))
goto err_reset;
if (hclge_reset_rebuild(hdev))
goto err_reset;
return; return;
err_reset_lock:
rtnl_unlock();
err_reset: err_reset:
if (hclge_reset_err_handle(hdev)) if (hclge_reset_err_handle(hdev))
hclge_reset_task_schedule(hdev); hclge_reset_task_schedule(hdev);
......
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