Skip to content

Commit f708aba

Browse files
liuyonglong86Paolo Abeni
authored andcommitted
net: hns: fix fake link up on xge port
If a xge port just connect with an optical module and no fiber, it may have a fake link up because there may be interference on the hardware. This patch adds an anti-shake to avoid the problem. And the time of anti-shake is base on tests. Fixes: b917078 ("net: hns: Add ACPI support to check SFP present") Signed-off-by: Yonglong Liu <[email protected]> Signed-off-by: Jijie Shao <[email protected]> Reviewed-by: Wojciech Drewek <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 84757d0 commit f708aba

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,27 @@ static enum mac_mode hns_get_enet_interface(const struct hns_mac_cb *mac_cb)
6666
}
6767
}
6868

69+
static u32 hns_mac_link_anti_shake(struct mac_driver *mac_ctrl_drv)
70+
{
71+
#define HNS_MAC_LINK_WAIT_TIME 5
72+
#define HNS_MAC_LINK_WAIT_CNT 40
73+
74+
u32 link_status = 0;
75+
int i;
76+
77+
if (!mac_ctrl_drv->get_link_status)
78+
return link_status;
79+
80+
for (i = 0; i < HNS_MAC_LINK_WAIT_CNT; i++) {
81+
msleep(HNS_MAC_LINK_WAIT_TIME);
82+
mac_ctrl_drv->get_link_status(mac_ctrl_drv, &link_status);
83+
if (!link_status)
84+
break;
85+
}
86+
87+
return link_status;
88+
}
89+
6990
void hns_mac_get_link_status(struct hns_mac_cb *mac_cb, u32 *link_status)
7091
{
7192
struct mac_driver *mac_ctrl_drv;
@@ -83,6 +104,14 @@ void hns_mac_get_link_status(struct hns_mac_cb *mac_cb, u32 *link_status)
83104
&sfp_prsnt);
84105
if (!ret)
85106
*link_status = *link_status && sfp_prsnt;
107+
108+
/* for FIBER port, it may have a fake link up.
109+
* when the link status changes from down to up, we need to do
110+
* anti-shake. the anti-shake time is base on tests.
111+
* only FIBER port need to do this.
112+
*/
113+
if (*link_status && !mac_cb->link)
114+
*link_status = hns_mac_link_anti_shake(mac_ctrl_drv);
86115
}
87116

88117
mac_cb->link = *link_status;

0 commit comments

Comments
 (0)