All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH net-next 02/16] bnxt_en: Improve link up detection.
Date: Sun, 26 Jan 2020 04:02:56 -0500	[thread overview]
Message-ID: <1580029390-32760-3-git-send-email-michael.chan@broadcom.com> (raw)
In-Reply-To: <1580029390-32760-1-git-send-email-michael.chan@broadcom.com>

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 <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c         |  2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 198c69dc..4b6f746 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -9064,7 +9064,7 @@ static int bnxt_update_phy_setting(struct bnxt *bp)
 	/* The last close may have shutdown the link, so need to call
 	 * PHY_CFG to bring it back up.
 	 */
-	if (!netif_carrier_ok(bp->dev))
+	if (!bp->link_info.link_up)
 		update_link = true;
 
 	if (!bnxt_eee_config_ok(bp))
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index 08d56ec..6171fa8 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -1462,15 +1462,15 @@ static int bnxt_get_link_ksettings(struct net_device *dev,
 		ethtool_link_ksettings_add_link_mode(lk_ksettings,
 						     advertising, Autoneg);
 		base->autoneg = AUTONEG_ENABLE;
-		if (link_info->phy_link_status == BNXT_LINK_LINK)
+		base->duplex = DUPLEX_UNKNOWN;
+		if (link_info->phy_link_status == BNXT_LINK_LINK) {
 			bnxt_fw_to_ethtool_lp_adv(link_info, lk_ksettings);
+			if (link_info->duplex & BNXT_LINK_DUPLEX_FULL)
+				base->duplex = DUPLEX_FULL;
+			else
+				base->duplex = DUPLEX_HALF;
+		}
 		ethtool_speed = bnxt_fw_to_ethtool_speed(link_info->link_speed);
-		if (!netif_carrier_ok(dev))
-			base->duplex = DUPLEX_UNKNOWN;
-		else if (link_info->duplex & BNXT_LINK_DUPLEX_FULL)
-			base->duplex = DUPLEX_FULL;
-		else
-			base->duplex = DUPLEX_HALF;
 	} else {
 		base->autoneg = AUTONEG_DISABLE;
 		ethtool_speed =
@@ -2707,7 +2707,7 @@ static int bnxt_disable_an_for_lpbk(struct bnxt *bp,
 		return rc;
 
 	fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_1GB;
-	if (netif_carrier_ok(bp->dev))
+	if (bp->link_info.link_up)
 		fw_speed = bp->link_info.link_speed;
 	else if (fw_advertising & BNXT_LINK_SPEED_MSK_10GB)
 		fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_10GB;
-- 
2.5.1


  parent reply	other threads:[~2020-01-26  9:03 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-26  9:02 [PATCH net-next 00/16] bnxt_en: Updates for net-next Michael Chan
2020-01-26  9:02 ` [PATCH net-next 01/16] bnxt_en: Support ingress rate limiting with TC-offload Michael Chan
2020-01-27  0:12   ` Jakub Kicinski
2020-01-26  9:02 ` Michael Chan [this message]
2020-01-26  9:02 ` [PATCH net-next 03/16] bnxt_en: Improve bnxt_probe_phy() Michael Chan
2020-01-26  9:02 ` [PATCH net-next 04/16] bnxt_en: Remove the setting of dev_port Michael Chan
2020-01-26  9:02 ` [PATCH net-next 05/16] bnxt_en: Support UDP RSS hashing on 575XX chips Michael Chan
2020-01-26  9:03 ` [PATCH net-next 06/16] bnxt_en: Do not accept fragments for aRFS flow steering Michael Chan
2020-01-26  9:03 ` [PATCH net-next 07/16] bnxt_en: Periodically check and remove aged-out ntuple filters Michael Chan
2020-01-26  9:03 ` [PATCH net-next 08/16] bnxt_en: Disable workaround for lost interrupts on 575XX B0 and newer chips Michael Chan
2020-01-26  9:03 ` [PATCH net-next 09/16] bnxt_en: Refactor bnxt_dl_register() Michael Chan
2020-01-26 11:32   ` Jiri Pirko
2020-01-27  4:51     ` Vasundhara Volam
2020-01-26  9:03 ` [PATCH net-next 10/16] bnxt_en: Register devlink irrespective of firmware spec version Michael Chan
2020-01-26  9:03 ` [PATCH net-next 11/16] bnxt_en: Move devlink_register before registering netdev Michael Chan
2020-01-26  9:03 ` [PATCH net-next 12/16] bnxt_en: Add support to update progress of flash update Michael Chan
2020-01-26  9:03 ` [PATCH net-next 13/16] bnxt_en: Rename switch_id to dsn Michael Chan
2020-01-26  9:03 ` [PATCH net-next 14/16] devlink: add macros for "fw.roce" and "board.nvm_cfg" Michael Chan
2020-01-27  0:18   ` Jakub Kicinski
2020-01-27  5:42     ` Vasundhara Volam
2020-01-27 14:25       ` Jakub Kicinski
2020-01-26  9:03 ` [PATCH net-next 15/16] bnxt_en: Add support for devlink info command Michael Chan
2020-01-26  9:03 ` [PATCH net-next 16/16] devlink: document devlink info versions reported by bnxt_en driver Michael Chan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1580029390-32760-3-git-send-email-michael.chan@broadcom.com \
    --to=michael.chan@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.