src/dpdk/drivers/net/ixgbe/base/ixgbe_82599.c
s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
			       bool autoneg_wait_to_complete)
{
	u32 autoc_reg;
	u32 links_reg;
	u32 i;
	s32 status = IXGBE_SUCCESS;
	bool got_lock = false;

	DEBUGFUNC("ixgbe_start_mac_link_82599");


	/*  reset_pipeline requires us to hold this lock as it writes to
	 *  AUTOC.
	 */
	if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
		status = hw->mac.ops.acquire_swfw_sync(hw,
						       IXGBE_GSSR_MAC_CSR_SM);
		if (status != IXGBE_SUCCESS)
			goto out;

		got_lock = true;
	}

	/* Restart link */
	ixgbe_reset_pipeline_82599(hw);

	if (got_lock)
		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);

	/* Only poll for autoneg to complete if specified to do so */
	if (autoneg_wait_to_complete) {
		autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
		if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
		     IXGBE_AUTOC_LMS_KX4_KX_KR ||
		    (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
		     IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
		    (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
		     IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
			links_reg = 0; /* Just in case Autoneg time = 0 */
			for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
				links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
				if (links_reg & IXGBE_LINKS_KX_AN_COMP)
					break;
				msec_delay(100);
			}
			if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
				status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
				DEBUGOUT("Autoneg did not complete.\n");
			}
		}
	}

	/* Add delay to filter out noises during initial link setup */
	msec_delay(50);

out:
	return status;
}
/**
 * ixgbe_start_mac_link_82599 - Setup MAC link settings
 * @hw: pointer to hardware structure
 * @autoneg_wait_to_complete: true when waiting for completion is needed
 *
 * Configures link settings based on values in the ixgbe_hw struct.
 * Restarts the link.  Performs autonegotiation if needed.
 **/
Setup MAC link settings
@hw: pointer to hardware structure
@autoneg_wait_to_complete: true when waiting for completion is needed

Configures link settings based on values in the ixgbe_hw struct.
Restarts the link.  Performs autonegotiation if needed.
Setup MAC link settings @hw : pointer to hardware structure @autoneg_wait_to_complete : true when waiting for completion is needed Configures link settings based on values in the ixgbe_hw struct . Restarts the link . Performs autonegotiation if needed .
s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
			       bool autoneg_wait_to_complete)
{
	u32 autoc_reg;
	u32 links_reg;
	u32 i;
	s32 status = IXGBE_SUCCESS;
	bool got_lock = false;
	DEBUGFUNC("ixgbe_start_mac_link_82599");
	if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
		status = hw->mac.ops.acquire_swfw_sync(hw,
						       IXGBE_GSSR_MAC_CSR_SM);
		if (status != IXGBE_SUCCESS)
			goto out;
		got_lock = true;
	}
	ixgbe_reset_pipeline_82599(hw);
	if (got_lock)
		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
	if (autoneg_wait_to_complete) {
		autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
		if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
		     IXGBE_AUTOC_LMS_KX4_KX_KR ||
		    (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
		     IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
		    (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
		     IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
			links_reg = 0; 
			for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
				links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
				if (links_reg & IXGBE_LINKS_KX_AN_COMP)
					break;
				msec_delay(100);
			}
			if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
				status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;
				DEBUGOUT("Autoneg did not complete.\n");
			}
		}
	}
	msec_delay(50);
out:
	return status;
}
s32 ixgbe_start_mac_link_82599 ( struct ixgbe_hw * hw , bool autoneg_wait_to_complete ) { u32 autoc_reg ; u32 links_reg ; u32 i ; s32 status = IXGBE_SUCCESS ; bool got_lock = false ; DEBUGFUNC ( " " ) ; if ( ixgbe_verify_lesm_fw_enabled_82599 ( hw ) ) { status = hw -> mac . ops . acquire_swfw_sync ( hw , IXGBE_GSSR_MAC_CSR_SM ) ; if ( status != IXGBE_SUCCESS ) goto out ; got_lock = true ; } ixgbe_reset_pipeline_82599 ( hw ) ; if ( got_lock ) hw -> mac . ops . release_swfw_sync ( hw , IXGBE_GSSR_MAC_CSR_SM ) ; if ( autoneg_wait_to_complete ) { autoc_reg = IXGBE_READ_REG ( hw , IXGBE_AUTOC ) ; if ( ( autoc_reg & IXGBE_AUTOC_LMS_MASK ) == IXGBE_AUTOC_LMS_KX4_KX_KR || ( autoc_reg & IXGBE_AUTOC_LMS_MASK ) == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN || ( autoc_reg & IXGBE_AUTOC_LMS_MASK ) == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII ) { links_reg = 0 ; for ( i = 0 ; i < IXGBE_AUTO_NEG_TIME ; i ++ ) { links_reg = IXGBE_READ_REG ( hw , IXGBE_LINKS ) ; if ( links_reg & IXGBE_LINKS_KX_AN_COMP ) break ; msec_delay ( 100 ) ; } if ( ! ( links_reg & IXGBE_LINKS_KX_AN_COMP ) ) { status = IXGBE_ERR_AUTONEG_NOT_COMPLETE ; DEBUGOUT ( " \n " ) ; } } } msec_delay ( 50 ) ; out : return status ; }
ixgbe_start_mac_link_82599 - Setup MAC link settings
 @hw: pointer to hardware structure
 @autoneg_wait_to_complete: true when waiting for completion is needed
ixgbe_start_mac_link_82599 - Setup MAC link settings @hw : pointer to hardware structure @autoneg_wait_to_complete : true when waiting for completion is needed
/*  reset_pipeline requires us to hold this lock as it writes to
	 *  AUTOC.
	 */ /* Restart link */ /* Only poll for autoneg to complete if specified to do so */ /* Just in case Autoneg time = 0 */ /* Add delay to filter out noises during initial link setup */