DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wenzhuo Lu <wenzhuo.lu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 20/37] ixgbe/base: check link again after getting speed
Date: Wed, 24 Jun 2015 11:26:09 +0800	[thread overview]
Message-ID: <1435116386-12010-21-git-send-email-wenzhuo.lu@intel.com> (raw)
In-Reply-To: <1435116386-12010-1-git-send-email-wenzhuo.lu@intel.com>

Ensure link is still up after getting the speed, to ensure that the
speed read is valid.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 79 ++++++++++++++++++++++++++-----------
 1 file changed, 57 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c b/drivers/net/ixgbe/base/ixgbe_x550.c
index 2a7046c..a7e95d9 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1860,6 +1860,38 @@ STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
 }
 
 /**
+ * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
+ * @hw: address of hardware structure
+ * @link_up: address of boolean to indicate link status
+ *
+ * Returns error code if unable to get link status.
+ */
+STATIC s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
+{
+	u32 ret;
+	u16 autoneg_status;
+
+	*link_up = false;
+
+	/* read this twice back to back to indicate current status */
+	ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
+				   IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+				   &autoneg_status);
+	if (ret != IXGBE_SUCCESS)
+		return ret;
+
+	ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
+				   IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+				   &autoneg_status);
+	if (ret != IXGBE_SUCCESS)
+		return ret;
+
+	*link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
+
+	return IXGBE_SUCCESS;
+}
+
+/**
  *  ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
  *  @hw: pointer to hardware structure
  *
@@ -1936,33 +1968,34 @@ s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
  */
 s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
 {
-	u32 status;
-	u16 autoneg_status, speed;
 	ixgbe_link_speed force_speed;
+	bool link_up;
+	u32 status;
+	u16 speed;
 
 	if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
 		return IXGBE_ERR_CONFIG;
 
-	/* read this twice back to back to indicate current status */
-	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
-				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
-				      &autoneg_status);
-	if (status != IXGBE_SUCCESS)
-		return status;
-
-	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
-				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
-				      &autoneg_status);
+	/* If link is not up, then there is no setup necessary so return  */
+	status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
 	if (status != IXGBE_SUCCESS)
 		return status;
 
-	/* If link is not up, then there is no setup necessary so return  */
-	if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
+	if (!link_up)
 		return IXGBE_SUCCESS;
 
 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
 				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
 				      &speed);
+	if (status != IXGBE_SUCCESS)
+		return status;
+
+	/* If link is not still up, then no setup is necessary so return */
+	status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
+	if (status != IXGBE_SUCCESS)
+		return status;
+	if (!link_up)
+		return IXGBE_SUCCESS;
 
 	/* clear everything but the speed and duplex bits */
 	speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
@@ -2687,19 +2720,17 @@ void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
  **/
 s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
 {
-	u16 autoneg_status, an_10g_cntl_reg, autoneg_reg, speed;
+	u16 an_10g_cntl_reg, autoneg_reg, speed;
 	s32 status;
 	ixgbe_link_speed lcd_speed;
 	u32 save_autoneg;
+	bool link_up;
 
 	/* If blocked by MNG FW, then don't restart AN */
 	if (ixgbe_check_reset_blocked(hw))
 		return IXGBE_SUCCESS;
 
-	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
-				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
-				      &autoneg_status);
-
+	status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
 	if (status != IXGBE_SUCCESS)
 		return status;
 
@@ -2711,8 +2742,7 @@ s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
 	/* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
 	 * disabled, then force link down by entering low power mode.
 	 */
-	if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS) ||
-	    !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
+	if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
 	    !(hw->wol_enabled || ixgbe_mng_present(hw)))
 		return ixgbe_set_copper_phy_power(hw, FALSE);
 
@@ -2733,6 +2763,11 @@ s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
 	if (status != IXGBE_SUCCESS)
 		return status;
 
+	/* If no link now, speed is invalid so take link down */
+	status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
+	if (status != IXGBE_SUCCESS)
+		return ixgbe_set_copper_phy_power(hw, false);
+
 	/* clear everything but the speed bits */
 	speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
 
@@ -2746,7 +2781,7 @@ s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
 	/* Clear AN completed indication */
 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
 				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
-				      &autoneg_status);
+				      &autoneg_reg);
 
 	if (status != IXGBE_SUCCESS)
 		return status;
-- 
1.9.3

  parent reply	other threads:[~2015-06-24  3:27 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-24  3:25 [dpdk-dev] [PATCH 00/37] update ixgbe base driver Wenzhuo Lu
2015-06-24  3:25 ` [dpdk-dev] [PATCH 01/37] ixgbe/base: update readme Wenzhuo Lu
2015-06-24  3:25 ` [dpdk-dev] [PATCH 02/37] ixgbe/base: update Low Power Link Up to use MAC ops link Wenzhuo Lu
2015-06-24  3:25 ` [dpdk-dev] [PATCH 03/37] ixgbe/base: fix 1G and 10G link stability for x550em SFP+ Wenzhuo Lu
2015-06-24  3:25 ` [dpdk-dev] [PATCH 04/37] ixgbe/base: update x550em SFP link setup Wenzhuo Lu
2015-06-24  3:25 ` [dpdk-dev] [PATCH 05/37] ixgbe/base: add shift define for EEE_SU.TEEE_DLY Wenzhuo Lu
2015-06-24  3:25 ` [dpdk-dev] [PATCH 06/37] ixgbe/base: add x550em identify SFP module support Wenzhuo Lu
2015-06-24  3:25 ` [dpdk-dev] [PATCH 07/37] ixgbe/base: fix potential warning Wenzhuo Lu
2015-06-24  3:25 ` [dpdk-dev] [PATCH 08/37] ixgbe/base: return err when SFP module is not present Wenzhuo Lu
2015-06-24  3:25 ` [dpdk-dev] [PATCH 09/37] ixgbe/base: power down the x550em PHY on overtemp events Wenzhuo Lu
2015-06-24  3:25 ` [dpdk-dev] [PATCH 10/37] ixgbe/base: restore advertised autoneg after setting LPLU Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 11/37] ixgbe/base: fix UniPHY link configuration Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 12/37] ixgbe/base: add macro for x550em bus speed fuse Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 13/37] ixgbe/base: add a new 82599 device ID Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 14/37] ixgbe/base: enable FEC when EEE is disabled Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 15/37] ixgbe/base: release semaphores in proper order Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 16/37] ixgbe/base: add wait helper for IOSF accesses Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 17/37] ixgbe/base: use a semaphore to serialize " Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 18/37] ixgbe/base: check for functional ucode Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 19/37] ixgbe/base: add KR/iXFI internal link mode support Wenzhuo Lu
2015-06-24  3:26 ` Wenzhuo Lu [this message]
2015-06-24  3:26 ` [dpdk-dev] [PATCH 21/37] ixgbe/base: config MDIO clock for x550em Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 22/37] ixgbe/base: add support for led_on and led_off for X557 PHY LEDs Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 23/37] ixgbe/base: update EEE/FEC support for device X550EM_X_KR Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 24/37] ixgbe/base: introduce array of mac-type-dependent values Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 25/37] ixgbe/base: use mvals array for I2C_*_BY_MAC values Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 26/37] ixgbe/base: use mvals array for *_GPI*_BY_MAC values Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 27/37] ixgbe/base: use mvals array for CIA*_BY_MAC values Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 28/37] ixgbe/base: add new mac-dependent values for x540, x550 Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 29/37] ixgbe/base: disable SW LPLU implementation for x557 V2 Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 30/37] ixgbe/base: remove FEC disablement for x550em Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 31/37] ixgbe/base: modify register definition code style Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 32/37] ixgbe/base: specific process for X550 and X550em when disabling PCIe master Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 33/37] ixgbe/base: fix flow control to be KR only Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 34/37] ixgbe/base: fix 5G and 2.5G speed description Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 35/37] ixgbe/base: force cs4227 LINE side to 10G SR mode Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 36/37] ixgbe/base: a minor optimization for max link up time Wenzhuo Lu
2015-06-24  3:26 ` [dpdk-dev] [PATCH 37/37] ixgbe/base: add support for new x550 PHY IDs Wenzhuo Lu
2015-06-25  1:24 ` [dpdk-dev] [PATCH 00/37] update ixgbe base driver Zhang, Helin
2015-06-26 11:27   ` Thomas Monjalon

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=1435116386-12010-21-git-send-email-wenzhuo.lu@intel.com \
    --to=wenzhuo.lu@intel.com \
    --cc=dev@dpdk.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).