提交 7786a996 编写于 作者: J Jian Shen 提交者: David S. Miller

net: hns3: fix selftest fail issue for fibre port with autoneg on

When doing selftest for fibre port with autoneg on, the MAC speed
may be incorrect, which may cause the selftest failed. This patch
fixes it by halting autoneg during the selftest.

Fixes: 22f48e24 ("net: hns3: add autoneg and change speed support for fibre port")
Signed-off-by: NJian Shen <shenjian15@huawei.com>
Signed-off-by: NPeng Li <lipeng321@huawei.com>
Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 2f8776f0
...@@ -264,6 +264,8 @@ struct hnae3_ae_dev { ...@@ -264,6 +264,8 @@ struct hnae3_ae_dev {
* get auto autonegotiation of pause frame use * get auto autonegotiation of pause frame use
* restart_autoneg() * restart_autoneg()
* restart autonegotiation * restart autonegotiation
* halt_autoneg()
* halt/resume autonegotiation when autonegotiation on
* get_coalesce_usecs() * get_coalesce_usecs()
* get usecs to delay a TX interrupt after a packet is sent * get usecs to delay a TX interrupt after a packet is sent
* get_rx_max_coalesced_frames() * get_rx_max_coalesced_frames()
...@@ -383,6 +385,7 @@ struct hnae3_ae_ops { ...@@ -383,6 +385,7 @@ struct hnae3_ae_ops {
int (*set_autoneg)(struct hnae3_handle *handle, bool enable); int (*set_autoneg)(struct hnae3_handle *handle, bool enable);
int (*get_autoneg)(struct hnae3_handle *handle); int (*get_autoneg)(struct hnae3_handle *handle);
int (*restart_autoneg)(struct hnae3_handle *handle); int (*restart_autoneg)(struct hnae3_handle *handle);
int (*halt_autoneg)(struct hnae3_handle *handle, bool halt);
void (*get_coalesce_usecs)(struct hnae3_handle *handle, void (*get_coalesce_usecs)(struct hnae3_handle *handle,
u32 *tx_usecs, u32 *rx_usecs); u32 *tx_usecs, u32 *rx_usecs);
......
...@@ -336,6 +336,13 @@ static void hns3_self_test(struct net_device *ndev, ...@@ -336,6 +336,13 @@ static void hns3_self_test(struct net_device *ndev,
h->ae_algo->ops->enable_vlan_filter(h, false); h->ae_algo->ops->enable_vlan_filter(h, false);
#endif #endif
/* Tell firmware to stop mac autoneg before loopback test start,
* otherwise loopback test may be failed when the port is still
* negotiating.
*/
if (h->ae_algo->ops->halt_autoneg)
h->ae_algo->ops->halt_autoneg(h, true);
set_bit(HNS3_NIC_STATE_TESTING, &priv->state); set_bit(HNS3_NIC_STATE_TESTING, &priv->state);
for (i = 0; i < HNS3_SELF_TEST_TYPE_NUM; i++) { for (i = 0; i < HNS3_SELF_TEST_TYPE_NUM; i++) {
...@@ -358,6 +365,9 @@ static void hns3_self_test(struct net_device *ndev, ...@@ -358,6 +365,9 @@ static void hns3_self_test(struct net_device *ndev,
clear_bit(HNS3_NIC_STATE_TESTING, &priv->state); clear_bit(HNS3_NIC_STATE_TESTING, &priv->state);
if (h->ae_algo->ops->halt_autoneg)
h->ae_algo->ops->halt_autoneg(h, false);
#if IS_ENABLED(CONFIG_VLAN_8021Q) #if IS_ENABLED(CONFIG_VLAN_8021Q)
if (dis_vlan_filter) if (dis_vlan_filter)
h->ae_algo->ops->enable_vlan_filter(h, true); h->ae_algo->ops->enable_vlan_filter(h, true);
......
...@@ -2315,6 +2315,17 @@ static int hclge_restart_autoneg(struct hnae3_handle *handle) ...@@ -2315,6 +2315,17 @@ static int hclge_restart_autoneg(struct hnae3_handle *handle)
return hclge_notify_client(hdev, HNAE3_UP_CLIENT); return hclge_notify_client(hdev, HNAE3_UP_CLIENT);
} }
static int hclge_halt_autoneg(struct hnae3_handle *handle, bool halt)
{
struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back;
if (hdev->hw.mac.support_autoneg && hdev->hw.mac.autoneg)
return hclge_set_autoneg_en(hdev, !halt);
return 0;
}
static int hclge_set_fec_hw(struct hclge_dev *hdev, u32 fec_mode) static int hclge_set_fec_hw(struct hclge_dev *hdev, u32 fec_mode)
{ {
struct hclge_config_fec_cmd *req; struct hclge_config_fec_cmd *req;
...@@ -9265,6 +9276,7 @@ static const struct hnae3_ae_ops hclge_ops = { ...@@ -9265,6 +9276,7 @@ static const struct hnae3_ae_ops hclge_ops = {
.set_autoneg = hclge_set_autoneg, .set_autoneg = hclge_set_autoneg,
.get_autoneg = hclge_get_autoneg, .get_autoneg = hclge_get_autoneg,
.restart_autoneg = hclge_restart_autoneg, .restart_autoneg = hclge_restart_autoneg,
.halt_autoneg = hclge_halt_autoneg,
.get_pauseparam = hclge_get_pauseparam, .get_pauseparam = hclge_get_pauseparam,
.set_pauseparam = hclge_set_pauseparam, .set_pauseparam = hclge_set_pauseparam,
.set_mtu = hclge_set_mtu, .set_mtu = hclge_set_mtu,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册