Skip to content

Commit 7786a99

Browse files
IronShendavem330
authored andcommitted
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: 22f48e2 ("net: hns3: add autoneg and change speed support for fibre port") Signed-off-by: Jian Shen <[email protected]> Signed-off-by: Peng Li <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2f8776f commit 7786a99

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ struct hnae3_ae_dev {
264264
* get auto autonegotiation of pause frame use
265265
* restart_autoneg()
266266
* restart autonegotiation
267+
* halt_autoneg()
268+
* halt/resume autonegotiation when autonegotiation on
267269
* get_coalesce_usecs()
268270
* get usecs to delay a TX interrupt after a packet is sent
269271
* get_rx_max_coalesced_frames()
@@ -383,6 +385,7 @@ struct hnae3_ae_ops {
383385
int (*set_autoneg)(struct hnae3_handle *handle, bool enable);
384386
int (*get_autoneg)(struct hnae3_handle *handle);
385387
int (*restart_autoneg)(struct hnae3_handle *handle);
388+
int (*halt_autoneg)(struct hnae3_handle *handle, bool halt);
386389

387390
void (*get_coalesce_usecs)(struct hnae3_handle *handle,
388391
u32 *tx_usecs, u32 *rx_usecs);

drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,13 @@ static void hns3_self_test(struct net_device *ndev,
336336
h->ae_algo->ops->enable_vlan_filter(h, false);
337337
#endif
338338

339+
/* Tell firmware to stop mac autoneg before loopback test start,
340+
* otherwise loopback test may be failed when the port is still
341+
* negotiating.
342+
*/
343+
if (h->ae_algo->ops->halt_autoneg)
344+
h->ae_algo->ops->halt_autoneg(h, true);
345+
339346
set_bit(HNS3_NIC_STATE_TESTING, &priv->state);
340347

341348
for (i = 0; i < HNS3_SELF_TEST_TYPE_NUM; i++) {
@@ -358,6 +365,9 @@ static void hns3_self_test(struct net_device *ndev,
358365

359366
clear_bit(HNS3_NIC_STATE_TESTING, &priv->state);
360367

368+
if (h->ae_algo->ops->halt_autoneg)
369+
h->ae_algo->ops->halt_autoneg(h, false);
370+
361371
#if IS_ENABLED(CONFIG_VLAN_8021Q)
362372
if (dis_vlan_filter)
363373
h->ae_algo->ops->enable_vlan_filter(h, true);

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,6 +2315,17 @@ static int hclge_restart_autoneg(struct hnae3_handle *handle)
23152315
return hclge_notify_client(hdev, HNAE3_UP_CLIENT);
23162316
}
23172317

2318+
static int hclge_halt_autoneg(struct hnae3_handle *handle, bool halt)
2319+
{
2320+
struct hclge_vport *vport = hclge_get_vport(handle);
2321+
struct hclge_dev *hdev = vport->back;
2322+
2323+
if (hdev->hw.mac.support_autoneg && hdev->hw.mac.autoneg)
2324+
return hclge_set_autoneg_en(hdev, !halt);
2325+
2326+
return 0;
2327+
}
2328+
23182329
static int hclge_set_fec_hw(struct hclge_dev *hdev, u32 fec_mode)
23192330
{
23202331
struct hclge_config_fec_cmd *req;
@@ -9265,6 +9276,7 @@ static const struct hnae3_ae_ops hclge_ops = {
92659276
.set_autoneg = hclge_set_autoneg,
92669277
.get_autoneg = hclge_get_autoneg,
92679278
.restart_autoneg = hclge_restart_autoneg,
9279+
.halt_autoneg = hclge_halt_autoneg,
92689280
.get_pauseparam = hclge_get_pauseparam,
92699281
.set_pauseparam = hclge_set_pauseparam,
92709282
.set_mtu = hclge_set_mtu,

0 commit comments

Comments
 (0)