| From 6dfcec3521bd12b9b9ae4d99ee118d976e054d65 Mon Sep 17 00:00:00 2001 |
| From: Jian Shen <shenjian15@huawei.com> |
| Date: Thu, 20 Jun 2019 16:52:35 +0800 |
| Subject: [PATCH] net: hns3: fix selftest fail issue for fibre port with |
| autoneg on |
| |
| commit 7786a9969a1594d834ec55bc7ef8768909726170 upstream. |
| |
| 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: 22f48e24a23d ("net: hns3: add autoneg and change speed support for fibre port") |
| Signed-off-by: Jian Shen <shenjian15@huawei.com> |
| Signed-off-by: Peng Li <lipeng321@huawei.com> |
| Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> |
| Signed-off-by: David S. Miller <davem@davemloft.net> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h |
| index b43ef9f0857d..0178de087fc0 100644 |
| --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h |
| +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h |
| @@ -273,6 +273,8 @@ struct hnae3_ae_dev { |
| * get auto autonegotiation of pause frame use |
| * restart_autoneg() |
| * restart autonegotiation |
| + * halt_autoneg() |
| + * halt/resume autonegotiation when autonegotiation on |
| * get_coalesce_usecs() |
| * get usecs to delay a TX interrupt after a packet is sent |
| * get_rx_max_coalesced_frames() |
| @@ -388,6 +390,7 @@ struct hnae3_ae_ops { |
| int (*set_autoneg)(struct hnae3_handle *handle, bool enable); |
| int (*get_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, |
| u32 *tx_usecs, u32 *rx_usecs); |
| diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c |
| index 24fce343e7fc..411d6c9bc9f0 100644 |
| --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c |
| +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c |
| @@ -329,6 +329,13 @@ static void hns3_self_test(struct net_device *ndev, |
| h->ae_algo->ops->enable_vlan_filter(h, false); |
| #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); |
| |
| for (i = 0; i < HNS3_SELF_TEST_TYPE_NUM; i++) { |
| @@ -351,6 +358,9 @@ static void hns3_self_test(struct net_device *ndev, |
| |
| 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 (dis_vlan_filter) |
| h->ae_algo->ops->enable_vlan_filter(h, true); |
| diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c |
| index e0dfaee38683..417f465dd9a9 100644 |
| --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c |
| +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c |
| @@ -2336,6 +2336,17 @@ static int hclge_restart_autoneg(struct hnae3_handle *handle) |
| 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) |
| { |
| struct hclge_config_fec_cmd *req; |
| @@ -8921,6 +8932,7 @@ static const struct hnae3_ae_ops hclge_ops = { |
| .set_autoneg = hclge_set_autoneg, |
| .get_autoneg = hclge_get_autoneg, |
| .restart_autoneg = hclge_restart_autoneg, |
| + .halt_autoneg = hclge_halt_autoneg, |
| .get_pauseparam = hclge_get_pauseparam, |
| .set_pauseparam = hclge_set_pauseparam, |
| .set_mtu = hclge_set_mtu, |
| -- |
| 2.27.0 |
| |