src/dpdk/drivers/net/ixgbe/base/ixgbe_x550.c
s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
{
	u16 an_10g_cntl_reg, autoneg_reg, speed;
	s32 status;
	ixgbe_link_speed lcd_speed;
	u32 save_autoneg;
	bool link_up;

	/* SW LPLU not required on later HW revisions. */
	if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
	    (IXGBE_FUSES0_REV_MASK &
	     IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
		return IXGBE_SUCCESS;

	/* If blocked by MNG FW, then don't restart AN */
	if (ixgbe_check_reset_blocked(hw))
		return IXGBE_SUCCESS;

	status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
	if (status != IXGBE_SUCCESS)
		return status;

	status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);

	if (status != IXGBE_SUCCESS)
		return status;

	/* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
	 * disabled, then force link down by entering low power mode.
	 */
	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);

	/* Determine LCD */
	status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);

	if (status != IXGBE_SUCCESS)
		return status;

	/* If no valid LCD link speed, then force link down and exit. */
	if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
		return ixgbe_set_copper_phy_power(hw, FALSE);

	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 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;

	/* If current speed is already LCD, then exit. */
	if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
	     (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
	    ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
	     (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
		return status;

	/* 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_reg);

	if (status != IXGBE_SUCCESS)
		return status;

	status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
			     IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
			     &an_10g_cntl_reg);

	if (status != IXGBE_SUCCESS)
		return status;

	status = hw->phy.ops.read_reg(hw,
			     IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
			     IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
			     &autoneg_reg);

	if (status != IXGBE_SUCCESS)
		return status;

	save_autoneg = hw->phy.autoneg_advertised;

	/* Setup link at least common link speed */
	status = hw->mac.ops.setup_link(hw, lcd_speed, false);

	/* restore autoneg from before setting lplu speed */
	hw->phy.autoneg_advertised = save_autoneg;

	return status;
}
/**
 * ixgbe_enter_lplu_x550em - Transition to low power states
 * @hw: pointer to hardware structure
 *
 * Configures Low Power Link Up on transition to low power states
 * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
 * X557 PHY immediately prior to entering LPLU.
 **/
Transition to low power states
@hw: pointer to hardware structure

Configures Low Power Link Up on transition to low power states
(from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
X557 PHY immediately prior to entering LPLU.
Transition to low power states @hw : pointer to hardware structure Configures Low Power Link Up on transition to low power states ( from D0 to non - D0 ) . Link is required to enter LPLU so avoid resetting the X557 PHY immediately prior to entering LPLU .
s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
{
	u16 an_10g_cntl_reg, autoneg_reg, speed;
	s32 status;
	ixgbe_link_speed lcd_speed;
	u32 save_autoneg;
	bool link_up;
	if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
	    (IXGBE_FUSES0_REV_MASK &
	     IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
		return IXGBE_SUCCESS;
	if (ixgbe_check_reset_blocked(hw))
		return IXGBE_SUCCESS;
	status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
	if (status != IXGBE_SUCCESS)
		return status;
	status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
	if (status != IXGBE_SUCCESS)
		return status;
	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);
	status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
	if (status != IXGBE_SUCCESS)
		return status;
	if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
		return ixgbe_set_copper_phy_power(hw, FALSE);
	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;
	status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
	if (status != IXGBE_SUCCESS)
		return ixgbe_set_copper_phy_power(hw, false);
	speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
	if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
	     (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
	    ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
	     (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
		return status;
	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
				      &autoneg_reg);
	if (status != IXGBE_SUCCESS)
		return status;
	status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
			     IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
			     &an_10g_cntl_reg);
	if (status != IXGBE_SUCCESS)
		return status;
	status = hw->phy.ops.read_reg(hw,
			     IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
			     IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
			     &autoneg_reg);
	if (status != IXGBE_SUCCESS)
		return status;
	save_autoneg = hw->phy.autoneg_advertised;
	status = hw->mac.ops.setup_link(hw, lcd_speed, false);
	hw->phy.autoneg_advertised = save_autoneg;
	return status;
}
s32 ixgbe_enter_lplu_t_x550em ( struct ixgbe_hw * hw ) { u16 an_10g_cntl_reg , autoneg_reg , speed ; s32 status ; ixgbe_link_speed lcd_speed ; u32 save_autoneg ; bool link_up ; if ( ( hw -> mac . type == ixgbe_mac_X550EM_x ) && ( IXGBE_FUSES0_REV_MASK & IXGBE_READ_REG ( hw , IXGBE_FUSES0_GROUP ( 0 ) ) ) ) return IXGBE_SUCCESS ; if ( ixgbe_check_reset_blocked ( hw ) ) return IXGBE_SUCCESS ; status = ixgbe_ext_phy_t_x550em_get_link ( hw , & link_up ) ; if ( status != IXGBE_SUCCESS ) return status ; status = ixgbe_read_eeprom ( hw , NVM_INIT_CTRL_3 , & hw -> eeprom . ctrl_word_3 ) ; if ( status != IXGBE_SUCCESS ) return status ; 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 ) ; status = ixgbe_get_lcd_t_x550em ( hw , & lcd_speed ) ; if ( status != IXGBE_SUCCESS ) return status ; if ( lcd_speed == IXGBE_LINK_SPEED_UNKNOWN ) return ixgbe_set_copper_phy_power ( hw , FALSE ) ; 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 ; status = ixgbe_ext_phy_t_x550em_get_link ( hw , & link_up ) ; if ( status != IXGBE_SUCCESS ) return ixgbe_set_copper_phy_power ( hw , false ) ; speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK ; if ( ( ( speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB ) && ( lcd_speed == IXGBE_LINK_SPEED_1GB_FULL ) ) || ( ( speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB ) && ( lcd_speed == IXGBE_LINK_SPEED_10GB_FULL ) ) ) return status ; status = hw -> phy . ops . read_reg ( hw , IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM , IXGBE_MDIO_AUTO_NEG_DEV_TYPE , & autoneg_reg ) ; if ( status != IXGBE_SUCCESS ) return status ; status = hw -> phy . ops . read_reg ( hw , IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG , IXGBE_MDIO_AUTO_NEG_DEV_TYPE , & an_10g_cntl_reg ) ; if ( status != IXGBE_SUCCESS ) return status ; status = hw -> phy . ops . read_reg ( hw , IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG , IXGBE_MDIO_AUTO_NEG_DEV_TYPE , & autoneg_reg ) ; if ( status != IXGBE_SUCCESS ) return status ; save_autoneg = hw -> phy . autoneg_advertised ; status = hw -> mac . ops . setup_link ( hw , lcd_speed , false ) ; hw -> phy . autoneg_advertised = save_autoneg ; return status ; }
ixgbe_enter_lplu_x550em - Transition to low power states
 @hw: pointer to hardware structure
ixgbe_enter_lplu_x550em - Transition to low power states @hw : pointer to hardware structure
/* SW LPLU not required on later HW revisions. */ /* If blocked by MNG FW, then don't restart AN */ /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
	 * disabled, then force link down by entering low power mode.
	 */ /* Determine LCD */ /* If no valid LCD link speed, then force link down and exit. */ /* If no link now, speed is invalid so take link down */ /* clear everything but the speed bits */ /* If current speed is already LCD, then exit. */ /* Clear AN completed indication */ /* Setup link at least common link speed */ /* restore autoneg from before setting lplu speed */