Commit 1a29241e authored by Jie Wang's avatar Jie Wang Committed by Jiantao Xiao
Browse files

net: hns3: add wait until mac link down

mainline inclusion
from mainline-v6.5-rc6
commit 6265e242
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7WQZ1
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6265e242f7b95f2c1195b42ec912b84ad161470e



----------------------------------------------------------------------

In some configure flow of hns3 driver, for example, change mtu, it will
disable MAC through firmware before configuration. But firmware disables
MAC asynchronously. The rx traffic may be not stopped in this case.

So fixes it by waiting until mac link is down.

Fixes: a9775bb6 ("net: hns3: fix set and get link ksettings issue")
Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
Signed-off-by: default avatarJijie Shao <shaojijie@huawei.com>
Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/20230807113452.474224-4-shaojijie@huawei.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarJiantao Xiao <xiaojiantao1@h-partners.com>
parent 7049d4a3
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -7988,6 +7988,8 @@ static void hclge_enable_fd(struct hnae3_handle *handle, bool enable)

int hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable)
{
#define HCLGE_LINK_STATUS_WAIT_CNT  3

	struct hclge_desc desc;
	struct hclge_config_mac_mode_cmd *req =
		(struct hclge_config_mac_mode_cmd *)desc.data;
@@ -8012,13 +8014,19 @@ int hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable)
	req->txrx_pad_fcs_loop_en = cpu_to_le32(loop_en);

	ret = hclge_cmd_send(&hdev->hw, &desc, 1);
	if (ret)
	if (ret) {
		dev_err(&hdev->pdev->dev, "failed to %s mac, ret = %d.\n",
			enable ? "enable" : "disable", ret);

		return ret;
	}

	if (!enable)
		hclge_mac_link_status_wait(hdev, HCLGE_LINK_STATUS_DOWN,
					   HCLGE_LINK_STATUS_WAIT_CNT);

	return 0;
}

static int hclge_config_switch_param(struct hclge_dev *hdev, int vfid,
				     u8 switch_param, u8 param_mask)
{