src/dpdk/drivers/net/ixgbe/base/ixgbe_82599.c
s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
				      ixgbe_link_speed *speed,
				      bool *autoneg)
{
	s32 status = IXGBE_SUCCESS;
	u32 autoc = 0;

	DEBUGFUNC("ixgbe_get_link_capabilities_82599");


	/* Check if 1G SFP module. */
	if (hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_lha_core0 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_lha_core1 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
		*speed = IXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		goto out;
	}

	/*
	 * Determine link capabilities based on the stored value of AUTOC,
	 * which represents EEPROM defaults.  If AUTOC value has not
	 * been stored, use the current register values.
	 */
	if (hw->mac.orig_link_settings_stored)
		autoc = hw->mac.orig_autoc;
	else
		autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);

	switch (autoc & IXGBE_AUTOC_LMS_MASK) {
	case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
		*speed = IXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = false;
		break;

	case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
		*speed = IXGBE_LINK_SPEED_10GB_FULL;
		*autoneg = false;
		break;

	case IXGBE_AUTOC_LMS_1G_AN:
		*speed = IXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		break;

	case IXGBE_AUTOC_LMS_10G_SERIAL:
		*speed = IXGBE_LINK_SPEED_10GB_FULL;
		*autoneg = false;
		break;

	case IXGBE_AUTOC_LMS_KX4_KX_KR:
	case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
		*speed = IXGBE_LINK_SPEED_UNKNOWN;
		if (autoc & IXGBE_AUTOC_KR_SUPP)
			*speed |= IXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & IXGBE_AUTOC_KX4_SUPP)
			*speed |= IXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & IXGBE_AUTOC_KX_SUPP)
			*speed |= IXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		break;

	case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
		*speed = IXGBE_LINK_SPEED_100_FULL;
		if (autoc & IXGBE_AUTOC_KR_SUPP)
			*speed |= IXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & IXGBE_AUTOC_KX4_SUPP)
			*speed |= IXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & IXGBE_AUTOC_KX_SUPP)
			*speed |= IXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		break;

	case IXGBE_AUTOC_LMS_SGMII_1G_100M:
		*speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL;
		*autoneg = false;
		break;

	default:
		status = IXGBE_ERR_LINK_SETUP;
		goto out;
		break;
	}

	if (hw->phy.multispeed_fiber) {
		*speed |= IXGBE_LINK_SPEED_10GB_FULL |
			  IXGBE_LINK_SPEED_1GB_FULL;

		/* QSFP must not enable full auto-negotiation
		 * Limited autoneg is enabled at 1G
		 */
		if (hw->phy.media_type == ixgbe_media_type_fiber_qsfp)
			*autoneg = false;
		else
			*autoneg = true;
	}

out:
	return status;
}
/**
 * ixgbe_get_link_capabilities_82599 - Determines link capabilities
 * @hw: pointer to hardware structure
 * @speed: pointer to link speed
 * @autoneg: true when autoneg or autotry is enabled
 *
 * Determines the link capabilities by reading the AUTOC register.
 **/
Determines link capabilities
@hw: pointer to hardware structure
@speed: pointer to link speed
@autoneg: true when autoneg or autotry is enabled

Determines the link capabilities by reading the AUTOC register.
Determines link capabilities @hw : pointer to hardware structure @speed : pointer to link speed @autoneg : true when autoneg or autotry is enabled Determines the link capabilities by reading the AUTOC register .
s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
				      ixgbe_link_speed *speed,
				      bool *autoneg)
{
	s32 status = IXGBE_SUCCESS;
	u32 autoc = 0;
	DEBUGFUNC("ixgbe_get_link_capabilities_82599");
	if (hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_lha_core0 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_lha_core1 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
	    hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
		*speed = IXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		goto out;
	}
	if (hw->mac.orig_link_settings_stored)
		autoc = hw->mac.orig_autoc;
	else
		autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
	switch (autoc & IXGBE_AUTOC_LMS_MASK) {
	case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
		*speed = IXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = false;
		break;
	case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
		*speed = IXGBE_LINK_SPEED_10GB_FULL;
		*autoneg = false;
		break;
	case IXGBE_AUTOC_LMS_1G_AN:
		*speed = IXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		break;
	case IXGBE_AUTOC_LMS_10G_SERIAL:
		*speed = IXGBE_LINK_SPEED_10GB_FULL;
		*autoneg = false;
		break;
	case IXGBE_AUTOC_LMS_KX4_KX_KR:
	case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
		*speed = IXGBE_LINK_SPEED_UNKNOWN;
		if (autoc & IXGBE_AUTOC_KR_SUPP)
			*speed |= IXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & IXGBE_AUTOC_KX4_SUPP)
			*speed |= IXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & IXGBE_AUTOC_KX_SUPP)
			*speed |= IXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		break;
	case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
		*speed = IXGBE_LINK_SPEED_100_FULL;
		if (autoc & IXGBE_AUTOC_KR_SUPP)
			*speed |= IXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & IXGBE_AUTOC_KX4_SUPP)
			*speed |= IXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & IXGBE_AUTOC_KX_SUPP)
			*speed |= IXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		break;
	case IXGBE_AUTOC_LMS_SGMII_1G_100M:
		*speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL;
		*autoneg = false;
		break;
	default:
		status = IXGBE_ERR_LINK_SETUP;
		goto out;
		break;
	}
	if (hw->phy.multispeed_fiber) {
		*speed |= IXGBE_LINK_SPEED_10GB_FULL |
			  IXGBE_LINK_SPEED_1GB_FULL;
		if (hw->phy.media_type == ixgbe_media_type_fiber_qsfp)
			*autoneg = false;
		else
			*autoneg = true;
	}
out:
	return status;
}
s32 ixgbe_get_link_capabilities_82599 ( struct ixgbe_hw * hw , ixgbe_link_speed * speed , bool * autoneg ) { s32 status = IXGBE_SUCCESS ; u32 autoc = 0 ; DEBUGFUNC ( " " ) ; if ( hw -> phy . sfp_type == ixgbe_sfp_type_1g_cu_core0 || hw -> phy . sfp_type == ixgbe_sfp_type_1g_cu_core1 || hw -> phy . sfp_type == ixgbe_sfp_type_1g_lha_core0 || hw -> phy . sfp_type == ixgbe_sfp_type_1g_lha_core1 || hw -> phy . sfp_type == ixgbe_sfp_type_1g_lx_core0 || hw -> phy . sfp_type == ixgbe_sfp_type_1g_lx_core1 || hw -> phy . sfp_type == ixgbe_sfp_type_1g_sx_core0 || hw -> phy . sfp_type == ixgbe_sfp_type_1g_sx_core1 ) { * speed = IXGBE_LINK_SPEED_1GB_FULL ; * autoneg = true ; goto out ; } if ( hw -> mac . orig_link_settings_stored ) autoc = hw -> mac . orig_autoc ; else autoc = IXGBE_READ_REG ( hw , IXGBE_AUTOC ) ; switch ( autoc & IXGBE_AUTOC_LMS_MASK ) { case IXGBE_AUTOC_LMS_1G_LINK_NO_AN : * speed = IXGBE_LINK_SPEED_1GB_FULL ; * autoneg = false ; break ; case IXGBE_AUTOC_LMS_10G_LINK_NO_AN : * speed = IXGBE_LINK_SPEED_10GB_FULL ; * autoneg = false ; break ; case IXGBE_AUTOC_LMS_1G_AN : * speed = IXGBE_LINK_SPEED_1GB_FULL ; * autoneg = true ; break ; case IXGBE_AUTOC_LMS_10G_SERIAL : * speed = IXGBE_LINK_SPEED_10GB_FULL ; * autoneg = false ; break ; case IXGBE_AUTOC_LMS_KX4_KX_KR : case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN : * speed = IXGBE_LINK_SPEED_UNKNOWN ; if ( autoc & IXGBE_AUTOC_KR_SUPP ) * speed |= IXGBE_LINK_SPEED_10GB_FULL ; if ( autoc & IXGBE_AUTOC_KX4_SUPP ) * speed |= IXGBE_LINK_SPEED_10GB_FULL ; if ( autoc & IXGBE_AUTOC_KX_SUPP ) * speed |= IXGBE_LINK_SPEED_1GB_FULL ; * autoneg = true ; break ; case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII : * speed = IXGBE_LINK_SPEED_100_FULL ; if ( autoc & IXGBE_AUTOC_KR_SUPP ) * speed |= IXGBE_LINK_SPEED_10GB_FULL ; if ( autoc & IXGBE_AUTOC_KX4_SUPP ) * speed |= IXGBE_LINK_SPEED_10GB_FULL ; if ( autoc & IXGBE_AUTOC_KX_SUPP ) * speed |= IXGBE_LINK_SPEED_1GB_FULL ; * autoneg = true ; break ; case IXGBE_AUTOC_LMS_SGMII_1G_100M : * speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL ; * autoneg = false ; break ; default : status = IXGBE_ERR_LINK_SETUP ; goto out ; break ; } if ( hw -> phy . multispeed_fiber ) { * speed |= IXGBE_LINK_SPEED_10GB_FULL | IXGBE_LINK_SPEED_1GB_FULL ; if ( hw -> phy . media_type == ixgbe_media_type_fiber_qsfp ) * autoneg = false ; else * autoneg = true ; } out : return status ; }
ixgbe_get_link_capabilities_82599 - Determines link capabilities
 @hw: pointer to hardware structure
 @speed: pointer to link speed
 @autoneg: true when autoneg or autotry is enabled
ixgbe_get_link_capabilities_82599 - Determines link capabilities @hw : pointer to hardware structure @speed : pointer to link speed @autoneg : true when autoneg or autotry is enabled
/* Check if 1G SFP module. */ /*
	 * Determine link capabilities based on the stored value of AUTOC,
	 * which represents EEPROM defaults.  If AUTOC value has not
	 * been stored, use the current register values.
	 */ /* QSFP must not enable full auto-negotiation
		 * Limited autoneg is enabled at 1G
		 */