Skip to content

Commit 1cc9bc6

Browse files
Huazhong Tandavem330
authored andcommitted
net: hns3: split hclgevf_reset() into preparing and rebuilding part
hclgevf_reset() is a little bloated, and the process of VF FLR will be separated from the reset task later. So this patch splits hclgevf_reset() into hclgevf_reset_prepare() and hclge_reset_rebuild(), then FLR can also reuse these two functions. Also moves HNAE3_UP_CLIENT into hclgevf_reset_stack(). Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d4fa065 commit 1cc9bc6

File tree

1 file changed

+39
-42
lines changed

1 file changed

+39
-42
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,8 @@ static int hclgevf_reset_stack(struct hclgevf_dev *hdev)
15231523
/* clear handshake status with IMP */
15241524
hclgevf_reset_handshake(hdev, false);
15251525

1526-
return 0;
1526+
/* bring up the nic to enable TX/RX again */
1527+
return hclgevf_notify_client(hdev, HNAE3_UP_CLIENT);
15271528
}
15281529

15291530
static int hclgevf_reset_prepare_wait(struct hclgevf_dev *hdev)
@@ -1603,7 +1604,7 @@ static void hclgevf_reset_err_handle(struct hclgevf_dev *hdev)
16031604
}
16041605
}
16051606

1606-
static int hclgevf_reset(struct hclgevf_dev *hdev)
1607+
static int hclgevf_reset_prepare(struct hclgevf_dev *hdev)
16071608
{
16081609
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev);
16091610
int ret;
@@ -1613,62 +1614,64 @@ static int hclgevf_reset(struct hclgevf_dev *hdev)
16131614
*/
16141615
ae_dev->reset_type = hdev->reset_type;
16151616
hdev->rst_stats.rst_cnt++;
1616-
rtnl_lock();
16171617

1618+
rtnl_lock();
16181619
/* bring down the nic to stop any ongoing TX/RX */
16191620
ret = hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT);
1620-
if (ret)
1621-
goto err_reset_lock;
1622-
16231621
rtnl_unlock();
1624-
1625-
ret = hclgevf_reset_prepare_wait(hdev);
16261622
if (ret)
1627-
goto err_reset;
1623+
return ret;
16281624

1629-
/* check if VF could successfully fetch the hardware reset completion
1630-
* status from the hardware
1631-
*/
1632-
ret = hclgevf_reset_wait(hdev);
1633-
if (ret) {
1634-
/* can't do much in this situation, will disable VF */
1635-
dev_err(&hdev->pdev->dev,
1636-
"VF failed(=%d) to fetch H/W reset completion status\n",
1637-
ret);
1638-
goto err_reset;
1639-
}
1625+
return hclgevf_reset_prepare_wait(hdev);
1626+
}
1627+
1628+
static int hclgevf_reset_rebuild(struct hclgevf_dev *hdev)
1629+
{
1630+
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev);
1631+
int ret;
16401632

16411633
hdev->rst_stats.hw_rst_done_cnt++;
16421634

16431635
rtnl_lock();
1644-
16451636
/* now, re-initialize the nic client and ae device */
16461637
ret = hclgevf_reset_stack(hdev);
1638+
rtnl_unlock();
16471639
if (ret) {
16481640
dev_err(&hdev->pdev->dev, "failed to reset VF stack\n");
1649-
goto err_reset_lock;
1641+
return ret;
16501642
}
16511643

1652-
/* bring up the nic to enable TX/RX again */
1653-
ret = hclgevf_notify_client(hdev, HNAE3_UP_CLIENT);
1654-
if (ret)
1655-
goto err_reset_lock;
1656-
1657-
rtnl_unlock();
1658-
16591644
hdev->last_reset_time = jiffies;
16601645
ae_dev->reset_type = HNAE3_NONE_RESET;
16611646
hdev->rst_stats.rst_done_cnt++;
16621647
hdev->rst_stats.rst_fail_cnt = 0;
16631648
clear_bit(HCLGEVF_STATE_RST_FAIL, &hdev->state);
16641649

1665-
return ret;
1666-
err_reset_lock:
1667-
rtnl_unlock();
1650+
return 0;
1651+
}
1652+
1653+
static void hclgevf_reset(struct hclgevf_dev *hdev)
1654+
{
1655+
if (hclgevf_reset_prepare(hdev))
1656+
goto err_reset;
1657+
1658+
/* check if VF could successfully fetch the hardware reset completion
1659+
* status from the hardware
1660+
*/
1661+
if (hclgevf_reset_wait(hdev)) {
1662+
/* can't do much in this situation, will disable VF */
1663+
dev_err(&hdev->pdev->dev,
1664+
"failed to fetch H/W reset completion status\n");
1665+
goto err_reset;
1666+
}
1667+
1668+
if (hclgevf_reset_rebuild(hdev))
1669+
goto err_reset;
1670+
1671+
return;
1672+
16681673
err_reset:
16691674
hclgevf_reset_err_handle(hdev);
1670-
1671-
return ret;
16721675
}
16731676

16741677
static enum hnae3_reset_type hclgevf_get_reset_level(struct hclgevf_dev *hdev,
@@ -1802,8 +1805,6 @@ static void hclgevf_reset_service_task(struct hclgevf_dev *hdev)
18021805
{
18031806
#define HCLGEVF_MAX_RESET_ATTEMPTS_CNT 3
18041807

1805-
int ret;
1806-
18071808
if (!test_and_clear_bit(HCLGEVF_STATE_RST_SERVICE_SCHED, &hdev->state))
18081809
return;
18091810

@@ -1822,12 +1823,8 @@ static void hclgevf_reset_service_task(struct hclgevf_dev *hdev)
18221823
hdev->last_reset_time = jiffies;
18231824
while ((hdev->reset_type =
18241825
hclgevf_get_reset_level(hdev, &hdev->reset_pending))
1825-
!= HNAE3_NONE_RESET) {
1826-
ret = hclgevf_reset(hdev);
1827-
if (ret)
1828-
dev_err(&hdev->pdev->dev,
1829-
"VF stack reset failed %d.\n", ret);
1830-
}
1826+
!= HNAE3_NONE_RESET)
1827+
hclgevf_reset(hdev);
18311828
} else if (test_and_clear_bit(HCLGEVF_RESET_REQUESTED,
18321829
&hdev->reset_state)) {
18331830
/* we could be here when either of below happens:

0 commit comments

Comments
 (0)