src/dpdk/drivers/net/txgbe/base/txgbe_hw.c
s32 txgbe_get_link_capabilities_raptor(struct txgbe_hw *hw,
				      u32 *speed,
				      bool *autoneg)
{
	s32 status = 0;
	u32 autoc = 0;

	DEBUGFUNC("txgbe_get_link_capabilities_raptor");

	/* Check if 1G SFP module. */
	if (hw->phy.sfp_type == txgbe_sfp_type_1g_cu_core0 ||
	    hw->phy.sfp_type == txgbe_sfp_type_1g_cu_core1 ||
	    hw->phy.sfp_type == txgbe_sfp_type_1g_lx_core0 ||
	    hw->phy.sfp_type == txgbe_sfp_type_1g_lx_core1 ||
	    hw->phy.sfp_type == txgbe_sfp_type_1g_sx_core0 ||
	    hw->phy.sfp_type == txgbe_sfp_type_1g_sx_core1) {
		*speed = TXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		return 0;
	}

	/*
	 * 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 = hw->mac.autoc_read(hw);

	switch (autoc & TXGBE_AUTOC_LMS_MASK) {
	case TXGBE_AUTOC_LMS_1G_LINK_NO_AN:
		*speed = TXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = false;
		break;

	case TXGBE_AUTOC_LMS_10G_LINK_NO_AN:
		*speed = TXGBE_LINK_SPEED_10GB_FULL;
		*autoneg = false;
		break;

	case TXGBE_AUTOC_LMS_1G_AN:
		*speed = TXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		break;

	case TXGBE_AUTOC_LMS_10G:
		*speed = TXGBE_LINK_SPEED_10GB_FULL;
		*autoneg = false;
		break;

	case TXGBE_AUTOC_LMS_KX4_KX_KR:
	case TXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
		*speed = TXGBE_LINK_SPEED_UNKNOWN;
		if (autoc & TXGBE_AUTOC_KR_SUPP)
			*speed |= TXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & TXGBE_AUTOC_KX4_SUPP)
			*speed |= TXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & TXGBE_AUTOC_KX_SUPP)
			*speed |= TXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		break;

	case TXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
		*speed = TXGBE_LINK_SPEED_100M_FULL;
		if (autoc & TXGBE_AUTOC_KR_SUPP)
			*speed |= TXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & TXGBE_AUTOC_KX4_SUPP)
			*speed |= TXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & TXGBE_AUTOC_KX_SUPP)
			*speed |= TXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		break;

	case TXGBE_AUTOC_LMS_SGMII_1G_100M:
		*speed = TXGBE_LINK_SPEED_1GB_FULL |
			 TXGBE_LINK_SPEED_100M_FULL |
			 TXGBE_LINK_SPEED_10M_FULL;
		*autoneg = false;
		break;

	default:
		return TXGBE_ERR_LINK_SETUP;
	}

	if (hw->phy.multispeed_fiber) {
		*speed |= TXGBE_LINK_SPEED_10GB_FULL |
			  TXGBE_LINK_SPEED_1GB_FULL;

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

	return status;
}
/**
 *  txgbe_get_link_capabilities_raptor - 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 txgbe_get_link_capabilities_raptor(struct txgbe_hw *hw,
				      u32 *speed,
				      bool *autoneg)
{
	s32 status = 0;
	u32 autoc = 0;
	DEBUGFUNC("txgbe_get_link_capabilities_raptor");
	if (hw->phy.sfp_type == txgbe_sfp_type_1g_cu_core0 ||
	    hw->phy.sfp_type == txgbe_sfp_type_1g_cu_core1 ||
	    hw->phy.sfp_type == txgbe_sfp_type_1g_lx_core0 ||
	    hw->phy.sfp_type == txgbe_sfp_type_1g_lx_core1 ||
	    hw->phy.sfp_type == txgbe_sfp_type_1g_sx_core0 ||
	    hw->phy.sfp_type == txgbe_sfp_type_1g_sx_core1) {
		*speed = TXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		return 0;
	}
	if (hw->mac.orig_link_settings_stored)
		autoc = hw->mac.orig_autoc;
	else
		autoc = hw->mac.autoc_read(hw);
	switch (autoc & TXGBE_AUTOC_LMS_MASK) {
	case TXGBE_AUTOC_LMS_1G_LINK_NO_AN:
		*speed = TXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = false;
		break;
	case TXGBE_AUTOC_LMS_10G_LINK_NO_AN:
		*speed = TXGBE_LINK_SPEED_10GB_FULL;
		*autoneg = false;
		break;
	case TXGBE_AUTOC_LMS_1G_AN:
		*speed = TXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		break;
	case TXGBE_AUTOC_LMS_10G:
		*speed = TXGBE_LINK_SPEED_10GB_FULL;
		*autoneg = false;
		break;
	case TXGBE_AUTOC_LMS_KX4_KX_KR:
	case TXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
		*speed = TXGBE_LINK_SPEED_UNKNOWN;
		if (autoc & TXGBE_AUTOC_KR_SUPP)
			*speed |= TXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & TXGBE_AUTOC_KX4_SUPP)
			*speed |= TXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & TXGBE_AUTOC_KX_SUPP)
			*speed |= TXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		break;
	case TXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
		*speed = TXGBE_LINK_SPEED_100M_FULL;
		if (autoc & TXGBE_AUTOC_KR_SUPP)
			*speed |= TXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & TXGBE_AUTOC_KX4_SUPP)
			*speed |= TXGBE_LINK_SPEED_10GB_FULL;
		if (autoc & TXGBE_AUTOC_KX_SUPP)
			*speed |= TXGBE_LINK_SPEED_1GB_FULL;
		*autoneg = true;
		break;
	case TXGBE_AUTOC_LMS_SGMII_1G_100M:
		*speed = TXGBE_LINK_SPEED_1GB_FULL |
			 TXGBE_LINK_SPEED_100M_FULL |
			 TXGBE_LINK_SPEED_10M_FULL;
		*autoneg = false;
		break;
	default:
		return TXGBE_ERR_LINK_SETUP;
	}
	if (hw->phy.multispeed_fiber) {
		*speed |= TXGBE_LINK_SPEED_10GB_FULL |
			  TXGBE_LINK_SPEED_1GB_FULL;
		if (hw->phy.media_type == txgbe_media_type_fiber_qsfp)
			*autoneg = false;
		else
			*autoneg = true;
	}
	return status;
}
s32 txgbe_get_link_capabilities_raptor ( struct txgbe_hw * hw , u32 * speed , bool * autoneg ) { s32 status = 0 ; u32 autoc = 0 ; DEBUGFUNC ( " " ) ; if ( hw -> phy . sfp_type == txgbe_sfp_type_1g_cu_core0 || hw -> phy . sfp_type == txgbe_sfp_type_1g_cu_core1 || hw -> phy . sfp_type == txgbe_sfp_type_1g_lx_core0 || hw -> phy . sfp_type == txgbe_sfp_type_1g_lx_core1 || hw -> phy . sfp_type == txgbe_sfp_type_1g_sx_core0 || hw -> phy . sfp_type == txgbe_sfp_type_1g_sx_core1 ) { * speed = TXGBE_LINK_SPEED_1GB_FULL ; * autoneg = true ; return 0 ; } if ( hw -> mac . orig_link_settings_stored ) autoc = hw -> mac . orig_autoc ; else autoc = hw -> mac . autoc_read ( hw ) ; switch ( autoc & TXGBE_AUTOC_LMS_MASK ) { case TXGBE_AUTOC_LMS_1G_LINK_NO_AN : * speed = TXGBE_LINK_SPEED_1GB_FULL ; * autoneg = false ; break ; case TXGBE_AUTOC_LMS_10G_LINK_NO_AN : * speed = TXGBE_LINK_SPEED_10GB_FULL ; * autoneg = false ; break ; case TXGBE_AUTOC_LMS_1G_AN : * speed = TXGBE_LINK_SPEED_1GB_FULL ; * autoneg = true ; break ; case TXGBE_AUTOC_LMS_10G : * speed = TXGBE_LINK_SPEED_10GB_FULL ; * autoneg = false ; break ; case TXGBE_AUTOC_LMS_KX4_KX_KR : case TXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN : * speed = TXGBE_LINK_SPEED_UNKNOWN ; if ( autoc & TXGBE_AUTOC_KR_SUPP ) * speed |= TXGBE_LINK_SPEED_10GB_FULL ; if ( autoc & TXGBE_AUTOC_KX4_SUPP ) * speed |= TXGBE_LINK_SPEED_10GB_FULL ; if ( autoc & TXGBE_AUTOC_KX_SUPP ) * speed |= TXGBE_LINK_SPEED_1GB_FULL ; * autoneg = true ; break ; case TXGBE_AUTOC_LMS_KX4_KX_KR_SGMII : * speed = TXGBE_LINK_SPEED_100M_FULL ; if ( autoc & TXGBE_AUTOC_KR_SUPP ) * speed |= TXGBE_LINK_SPEED_10GB_FULL ; if ( autoc & TXGBE_AUTOC_KX4_SUPP ) * speed |= TXGBE_LINK_SPEED_10GB_FULL ; if ( autoc & TXGBE_AUTOC_KX_SUPP ) * speed |= TXGBE_LINK_SPEED_1GB_FULL ; * autoneg = true ; break ; case TXGBE_AUTOC_LMS_SGMII_1G_100M : * speed = TXGBE_LINK_SPEED_1GB_FULL | TXGBE_LINK_SPEED_100M_FULL | TXGBE_LINK_SPEED_10M_FULL ; * autoneg = false ; break ; default : return TXGBE_ERR_LINK_SETUP ; } if ( hw -> phy . multispeed_fiber ) { * speed |= TXGBE_LINK_SPEED_10GB_FULL | TXGBE_LINK_SPEED_1GB_FULL ; if ( hw -> phy . media_type == txgbe_media_type_fiber_qsfp ) * autoneg = false ; else * autoneg = true ; } return status ; }
txgbe_get_link_capabilities_raptor - Determines link capabilities
  @hw: pointer to hardware structure
  @speed: pointer to link speed
  @autoneg: true when autoneg or autotry is enabled
txgbe_get_link_capabilities_raptor - 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
		 */