Skip to content

Commit 83d8f5e

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Improve link up detection.
In bnxt_update_phy_setting(), ethtool_get_link_ksettings() and bnxt_disable_an_for_lpbk(), we inconsistently use netif_carrier_ok() to determine link. Instead, we should use bp->link_info.link_up which has the true link state. The netif_carrier state may be off during self-test and while the device is being reset and may not always reflect the true link state. By always using bp->link_info.link_up, the code is now more consistent and more correct. Some unnecessary link toggles are now prevented with this patch. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent db038b1 commit 83d8f5e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9064,7 +9064,7 @@ static int bnxt_update_phy_setting(struct bnxt *bp)
90649064
/* The last close may have shutdown the link, so need to call
90659065
* PHY_CFG to bring it back up.
90669066
*/
9067-
if (!netif_carrier_ok(bp->dev))
9067+
if (!bp->link_info.link_up)
90689068
update_link = true;
90699069

90709070
if (!bnxt_eee_config_ok(bp))

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,15 +1462,15 @@ static int bnxt_get_link_ksettings(struct net_device *dev,
14621462
ethtool_link_ksettings_add_link_mode(lk_ksettings,
14631463
advertising, Autoneg);
14641464
base->autoneg = AUTONEG_ENABLE;
1465-
if (link_info->phy_link_status == BNXT_LINK_LINK)
1465+
base->duplex = DUPLEX_UNKNOWN;
1466+
if (link_info->phy_link_status == BNXT_LINK_LINK) {
14661467
bnxt_fw_to_ethtool_lp_adv(link_info, lk_ksettings);
1468+
if (link_info->duplex & BNXT_LINK_DUPLEX_FULL)
1469+
base->duplex = DUPLEX_FULL;
1470+
else
1471+
base->duplex = DUPLEX_HALF;
1472+
}
14671473
ethtool_speed = bnxt_fw_to_ethtool_speed(link_info->link_speed);
1468-
if (!netif_carrier_ok(dev))
1469-
base->duplex = DUPLEX_UNKNOWN;
1470-
else if (link_info->duplex & BNXT_LINK_DUPLEX_FULL)
1471-
base->duplex = DUPLEX_FULL;
1472-
else
1473-
base->duplex = DUPLEX_HALF;
14741474
} else {
14751475
base->autoneg = AUTONEG_DISABLE;
14761476
ethtool_speed =
@@ -2707,7 +2707,7 @@ static int bnxt_disable_an_for_lpbk(struct bnxt *bp,
27072707
return rc;
27082708

27092709
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_1GB;
2710-
if (netif_carrier_ok(bp->dev))
2710+
if (bp->link_info.link_up)
27112711
fw_speed = bp->link_info.link_speed;
27122712
else if (fw_advertising & BNXT_LINK_SPEED_MSK_10GB)
27132713
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_10GB;

0 commit comments

Comments
 (0)