Skip to content

Commit

Permalink
net: hns3: refactor hclge_mac_link_status_wait for interface reuse
Browse files Browse the repository at this point in the history
commit 08469da upstream.

Some nic configurations could only be performed after link is down. So this
patch refactor this API for reuse.

Signed-off-by: Jie Wang <wangjie125@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/20230807113452.474224-3-shaojijie@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Jie Wang authored and gregkh committed Aug 16, 2023
1 parent 758dbcf commit 667ce6a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
Expand Up @@ -72,6 +72,8 @@ static void hclge_restore_hw_table(struct hclge_dev *hdev);
static void hclge_sync_promisc_mode(struct hclge_dev *hdev);
static void hclge_sync_fd_table(struct hclge_dev *hdev);
static void hclge_update_fec_stats(struct hclge_dev *hdev);
static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret,
int wait_cnt);

static struct hnae3_ae_algo ae_algo;

Expand Down Expand Up @@ -7656,10 +7658,9 @@ static void hclge_phy_link_status_wait(struct hclge_dev *hdev,
} while (++i < HCLGE_PHY_LINK_STATUS_NUM);
}

static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret)
static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret,
int wait_cnt)
{
#define HCLGE_MAC_LINK_STATUS_NUM 100

int link_status;
int i = 0;
int ret;
Expand All @@ -7672,21 +7673,24 @@ static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret)
return 0;

msleep(HCLGE_LINK_STATUS_MS);
} while (++i < HCLGE_MAC_LINK_STATUS_NUM);
} while (++i < wait_cnt);
return -EBUSY;
}

static int hclge_mac_phy_link_status_wait(struct hclge_dev *hdev, bool en,
bool is_phy)
{
#define HCLGE_MAC_LINK_STATUS_NUM 100

int link_ret;

link_ret = en ? HCLGE_LINK_STATUS_UP : HCLGE_LINK_STATUS_DOWN;

if (is_phy)
hclge_phy_link_status_wait(hdev, link_ret);

return hclge_mac_link_status_wait(hdev, link_ret);
return hclge_mac_link_status_wait(hdev, link_ret,
HCLGE_MAC_LINK_STATUS_NUM);
}

static int hclge_set_app_loopback(struct hclge_dev *hdev, bool en)
Expand Down

0 comments on commit 667ce6a

Please sign in to comment.