src/dpdk/drivers/net/txgbe/base/txgbe_phy.c
s32 txgbe_setup_phy_link_tnx(struct txgbe_hw *hw)
{
	s32 err = 0;
	u16 autoneg_reg = TXGBE_MII_AUTONEG_REG;
	bool autoneg = false;
	u32 speed;

	DEBUGFUNC("txgbe_setup_phy_link_tnx");

	txgbe_get_copper_link_capabilities(hw, &speed, &autoneg);

	if (speed & TXGBE_LINK_SPEED_10GB_FULL) {
		/* Set or unset auto-negotiation 10G advertisement */
		hw->phy.read_reg(hw, TXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
				     TXGBE_MD_DEV_AUTO_NEG,
				     &autoneg_reg);

		autoneg_reg &= ~TXGBE_MII_10GBASE_T_ADVERTISE;
		if (hw->phy.autoneg_advertised & TXGBE_LINK_SPEED_10GB_FULL)
			autoneg_reg |= TXGBE_MII_10GBASE_T_ADVERTISE;

		hw->phy.write_reg(hw, TXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
				      TXGBE_MD_DEV_AUTO_NEG,
				      autoneg_reg);
	}

	if (speed & TXGBE_LINK_SPEED_1GB_FULL) {
		/* Set or unset auto-negotiation 1G advertisement */
		hw->phy.read_reg(hw, TXGBE_MII_AUTONEG_XNP_TX_REG,
				     TXGBE_MD_DEV_AUTO_NEG,
				     &autoneg_reg);

		autoneg_reg &= ~TXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
		if (hw->phy.autoneg_advertised & TXGBE_LINK_SPEED_1GB_FULL)
			autoneg_reg |= TXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;

		hw->phy.write_reg(hw, TXGBE_MII_AUTONEG_XNP_TX_REG,
				      TXGBE_MD_DEV_AUTO_NEG,
				      autoneg_reg);
	}

	if (speed & TXGBE_LINK_SPEED_100M_FULL) {
		/* Set or unset auto-negotiation 100M advertisement */
		hw->phy.read_reg(hw, TXGBE_MII_AUTONEG_ADVERTISE_REG,
				     TXGBE_MD_DEV_AUTO_NEG,
				     &autoneg_reg);

		autoneg_reg &= ~TXGBE_MII_100BASE_T_ADVERTISE;
		if (hw->phy.autoneg_advertised & TXGBE_LINK_SPEED_100M_FULL)
			autoneg_reg |= TXGBE_MII_100BASE_T_ADVERTISE;

		hw->phy.write_reg(hw, TXGBE_MII_AUTONEG_ADVERTISE_REG,
				      TXGBE_MD_DEV_AUTO_NEG,
				      autoneg_reg);
	}

	/* Blocked by MNG FW so don't reset PHY */
	if (txgbe_check_reset_blocked(hw))
		return err;

	/* Restart PHY auto-negotiation. */
	hw->phy.read_reg(hw, TXGBE_MD_AUTO_NEG_CONTROL,
			     TXGBE_MD_DEV_AUTO_NEG, &autoneg_reg);

	autoneg_reg |= TXGBE_MII_RESTART;

	hw->phy.write_reg(hw, TXGBE_MD_AUTO_NEG_CONTROL,
			      TXGBE_MD_DEV_AUTO_NEG, autoneg_reg);

	return err;
}
/**
 *  txgbe_setup_phy_link_tnx - Set and restart auto-neg
 *  @hw: pointer to hardware structure
 *
 *  Restart auto-negotiation and PHY and waits for completion.
 **/
Set and restart auto-neg
@hw: pointer to hardware structure

Restart auto-negotiation and PHY and waits for completion.
Set and restart auto - neg @hw : pointer to hardware structure Restart auto - negotiation and PHY and waits for completion .
s32 txgbe_setup_phy_link_tnx(struct txgbe_hw *hw)
{
	s32 err = 0;
	u16 autoneg_reg = TXGBE_MII_AUTONEG_REG;
	bool autoneg = false;
	u32 speed;
	DEBUGFUNC("txgbe_setup_phy_link_tnx");
	txgbe_get_copper_link_capabilities(hw, &speed, &autoneg);
	if (speed & TXGBE_LINK_SPEED_10GB_FULL) {
		hw->phy.read_reg(hw, TXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
				     TXGBE_MD_DEV_AUTO_NEG,
				     &autoneg_reg);
		autoneg_reg &= ~TXGBE_MII_10GBASE_T_ADVERTISE;
		if (hw->phy.autoneg_advertised & TXGBE_LINK_SPEED_10GB_FULL)
			autoneg_reg |= TXGBE_MII_10GBASE_T_ADVERTISE;
		hw->phy.write_reg(hw, TXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
				      TXGBE_MD_DEV_AUTO_NEG,
				      autoneg_reg);
	}
	if (speed & TXGBE_LINK_SPEED_1GB_FULL) {
		hw->phy.read_reg(hw, TXGBE_MII_AUTONEG_XNP_TX_REG,
				     TXGBE_MD_DEV_AUTO_NEG,
				     &autoneg_reg);
		autoneg_reg &= ~TXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
		if (hw->phy.autoneg_advertised & TXGBE_LINK_SPEED_1GB_FULL)
			autoneg_reg |= TXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
		hw->phy.write_reg(hw, TXGBE_MII_AUTONEG_XNP_TX_REG,
				      TXGBE_MD_DEV_AUTO_NEG,
				      autoneg_reg);
	}
	if (speed & TXGBE_LINK_SPEED_100M_FULL) {
		hw->phy.read_reg(hw, TXGBE_MII_AUTONEG_ADVERTISE_REG,
				     TXGBE_MD_DEV_AUTO_NEG,
				     &autoneg_reg);
		autoneg_reg &= ~TXGBE_MII_100BASE_T_ADVERTISE;
		if (hw->phy.autoneg_advertised & TXGBE_LINK_SPEED_100M_FULL)
			autoneg_reg |= TXGBE_MII_100BASE_T_ADVERTISE;
		hw->phy.write_reg(hw, TXGBE_MII_AUTONEG_ADVERTISE_REG,
				      TXGBE_MD_DEV_AUTO_NEG,
				      autoneg_reg);
	}
	if (txgbe_check_reset_blocked(hw))
		return err;
	hw->phy.read_reg(hw, TXGBE_MD_AUTO_NEG_CONTROL,
			     TXGBE_MD_DEV_AUTO_NEG, &autoneg_reg);
	autoneg_reg |= TXGBE_MII_RESTART;
	hw->phy.write_reg(hw, TXGBE_MD_AUTO_NEG_CONTROL,
			      TXGBE_MD_DEV_AUTO_NEG, autoneg_reg);
	return err;
}
s32 txgbe_setup_phy_link_tnx ( struct txgbe_hw * hw ) { s32 err = 0 ; u16 autoneg_reg = TXGBE_MII_AUTONEG_REG ; bool autoneg = false ; u32 speed ; DEBUGFUNC ( " " ) ; txgbe_get_copper_link_capabilities ( hw , & speed , & autoneg ) ; if ( speed & TXGBE_LINK_SPEED_10GB_FULL ) { hw -> phy . read_reg ( hw , TXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG , TXGBE_MD_DEV_AUTO_NEG , & autoneg_reg ) ; autoneg_reg &= ~ TXGBE_MII_10GBASE_T_ADVERTISE ; if ( hw -> phy . autoneg_advertised & TXGBE_LINK_SPEED_10GB_FULL ) autoneg_reg |= TXGBE_MII_10GBASE_T_ADVERTISE ; hw -> phy . write_reg ( hw , TXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG , TXGBE_MD_DEV_AUTO_NEG , autoneg_reg ) ; } if ( speed & TXGBE_LINK_SPEED_1GB_FULL ) { hw -> phy . read_reg ( hw , TXGBE_MII_AUTONEG_XNP_TX_REG , TXGBE_MD_DEV_AUTO_NEG , & autoneg_reg ) ; autoneg_reg &= ~ TXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX ; if ( hw -> phy . autoneg_advertised & TXGBE_LINK_SPEED_1GB_FULL ) autoneg_reg |= TXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX ; hw -> phy . write_reg ( hw , TXGBE_MII_AUTONEG_XNP_TX_REG , TXGBE_MD_DEV_AUTO_NEG , autoneg_reg ) ; } if ( speed & TXGBE_LINK_SPEED_100M_FULL ) { hw -> phy . read_reg ( hw , TXGBE_MII_AUTONEG_ADVERTISE_REG , TXGBE_MD_DEV_AUTO_NEG , & autoneg_reg ) ; autoneg_reg &= ~ TXGBE_MII_100BASE_T_ADVERTISE ; if ( hw -> phy . autoneg_advertised & TXGBE_LINK_SPEED_100M_FULL ) autoneg_reg |= TXGBE_MII_100BASE_T_ADVERTISE ; hw -> phy . write_reg ( hw , TXGBE_MII_AUTONEG_ADVERTISE_REG , TXGBE_MD_DEV_AUTO_NEG , autoneg_reg ) ; } if ( txgbe_check_reset_blocked ( hw ) ) return err ; hw -> phy . read_reg ( hw , TXGBE_MD_AUTO_NEG_CONTROL , TXGBE_MD_DEV_AUTO_NEG , & autoneg_reg ) ; autoneg_reg |= TXGBE_MII_RESTART ; hw -> phy . write_reg ( hw , TXGBE_MD_AUTO_NEG_CONTROL , TXGBE_MD_DEV_AUTO_NEG , autoneg_reg ) ; return err ; }
txgbe_setup_phy_link_tnx - Set and restart auto-neg
  @hw: pointer to hardware structure
txgbe_setup_phy_link_tnx - Set and restart auto - neg @hw : pointer to hardware structure
/* Set or unset auto-negotiation 10G advertisement */ /* Set or unset auto-negotiation 1G advertisement */ /* Set or unset auto-negotiation 100M advertisement */ /* Blocked by MNG FW so don't reset PHY */ /* Restart PHY auto-negotiation. */