src/dpdk/drivers/net/txgbe/base/txgbe_phy.c
u64 txgbe_autoc_read(struct txgbe_hw *hw)
{
	u64 autoc = 0;
	u32 sr_pcs_ctl;
	u32 sr_pma_ctl1;
	u32 sr_an_ctl;
	u32 sr_an_adv_reg2;

	if (hw->phy.multispeed_fiber) {
		autoc |= TXGBE_AUTOC_LMS_10G;
	} else if (hw->device_id == TXGBE_DEV_ID_RAPTOR_SFP ||
		   hw->device_id == TXGBE_DEV_ID_WX1820_SFP) {
		autoc |= TXGBE_AUTOC_LMS_10G |
			 TXGBE_AUTOC_10GS_SFI;
	} else if (hw->device_id == TXGBE_DEV_ID_RAPTOR_QSFP) {
		autoc = 0; /*TBD*/
	} else if (hw->device_id == TXGBE_DEV_ID_RAPTOR_XAUI) {
		autoc |= TXGBE_AUTOC_LMS_10G_LINK_NO_AN |
			 TXGBE_AUTOC_10G_XAUI;
		hw->phy.link_mode = TXGBE_PHYSICAL_LAYER_10GBASE_T;
	} else if (hw->device_id == TXGBE_DEV_ID_RAPTOR_SGMII) {
		autoc |= TXGBE_AUTOC_LMS_SGMII_1G_100M;
		hw->phy.link_mode = TXGBE_PHYSICAL_LAYER_1000BASE_T |
				TXGBE_PHYSICAL_LAYER_100BASE_TX;
	}

	if (hw->device_id != TXGBE_DEV_ID_RAPTOR_SGMII)
		return autoc;

	sr_pcs_ctl = rd32_epcs(hw, SR_XS_PCS_CTRL2);
	sr_pma_ctl1 = rd32_epcs(hw, SR_PMA_CTRL1);
	sr_an_ctl = rd32_epcs(hw, SR_AN_CTRL);
	sr_an_adv_reg2 = rd32_epcs(hw, SR_AN_MMD_ADV_REG2);

	if ((sr_pcs_ctl & SR_PCS_CTRL2_TYPE_SEL) == SR_PCS_CTRL2_TYPE_SEL_X &&
	    (sr_pma_ctl1 & SR_PMA_CTRL1_SS13) == SR_PMA_CTRL1_SS13_KX &&
	    (sr_an_ctl & SR_AN_CTRL_AN_EN) == 0) {
		/* 1G or KX - no backplane auto-negotiation */
		autoc |= TXGBE_AUTOC_LMS_1G_LINK_NO_AN |
			 TXGBE_AUTOC_1G_KX;
		hw->phy.link_mode = TXGBE_PHYSICAL_LAYER_1000BASE_KX;
	} else if ((sr_pcs_ctl & SR_PCS_CTRL2_TYPE_SEL) ==
		SR_PCS_CTRL2_TYPE_SEL_X &&
		(sr_pma_ctl1 & SR_PMA_CTRL1_SS13) == SR_PMA_CTRL1_SS13_KX4 &&
		(sr_an_ctl & SR_AN_CTRL_AN_EN) == 0) {
		autoc |= TXGBE_AUTOC_LMS_10G |
			 TXGBE_AUTOC_10G_KX4;
		hw->phy.link_mode = TXGBE_PHYSICAL_LAYER_10GBASE_KX4;
	} else if ((sr_pcs_ctl & SR_PCS_CTRL2_TYPE_SEL) ==
		SR_PCS_CTRL2_TYPE_SEL_R &&
		(sr_an_ctl & SR_AN_CTRL_AN_EN) == 0) {
		/* 10 GbE serial link (KR -no backplane auto-negotiation) */
		autoc |= TXGBE_AUTOC_LMS_10G |
			 TXGBE_AUTOC_10GS_KR;
		hw->phy.link_mode = TXGBE_PHYSICAL_LAYER_10GBASE_KR;
	} else if ((sr_an_ctl & SR_AN_CTRL_AN_EN)) {
		/* KX/KX4/KR backplane auto-negotiation enable */
		if (sr_an_adv_reg2 & SR_AN_MMD_ADV_REG2_BP_TYPE_KR)
			autoc |= TXGBE_AUTOC_10G_KR;
		if (sr_an_adv_reg2 & SR_AN_MMD_ADV_REG2_BP_TYPE_KX4)
			autoc |= TXGBE_AUTOC_10G_KX4;
		if (sr_an_adv_reg2 & SR_AN_MMD_ADV_REG2_BP_TYPE_KX)
			autoc |= TXGBE_AUTOC_1G_KX;
		autoc |= TXGBE_AUTOC_LMS_KX4_KX_KR;
		hw->phy.link_mode = TXGBE_PHYSICAL_LAYER_10GBASE_KR |
				TXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
				TXGBE_PHYSICAL_LAYER_1000BASE_KX;
	}

	return autoc;
}
/**
 *  txgbe_autoc_read - Hides MAC differences needed for AUTOC read
 *  @hw: pointer to hardware structure
 */
Hides MAC differences needed for AUTOC read
@hw: pointer to hardware structure
Hides MAC differences needed for AUTOC read @hw : pointer to hardware structure
u64 txgbe_autoc_read(struct txgbe_hw *hw)
{
	u64 autoc = 0;
	u32 sr_pcs_ctl;
	u32 sr_pma_ctl1;
	u32 sr_an_ctl;
	u32 sr_an_adv_reg2;
	if (hw->phy.multispeed_fiber) {
		autoc |= TXGBE_AUTOC_LMS_10G;
	} else if (hw->device_id == TXGBE_DEV_ID_RAPTOR_SFP ||
		   hw->device_id == TXGBE_DEV_ID_WX1820_SFP) {
		autoc |= TXGBE_AUTOC_LMS_10G |
			 TXGBE_AUTOC_10GS_SFI;
	} else if (hw->device_id == TXGBE_DEV_ID_RAPTOR_QSFP) {
		autoc = 0; 
	} else if (hw->device_id == TXGBE_DEV_ID_RAPTOR_XAUI) {
		autoc |= TXGBE_AUTOC_LMS_10G_LINK_NO_AN |
			 TXGBE_AUTOC_10G_XAUI;
		hw->phy.link_mode = TXGBE_PHYSICAL_LAYER_10GBASE_T;
	} else if (hw->device_id == TXGBE_DEV_ID_RAPTOR_SGMII) {
		autoc |= TXGBE_AUTOC_LMS_SGMII_1G_100M;
		hw->phy.link_mode = TXGBE_PHYSICAL_LAYER_1000BASE_T |
				TXGBE_PHYSICAL_LAYER_100BASE_TX;
	}
	if (hw->device_id != TXGBE_DEV_ID_RAPTOR_SGMII)
		return autoc;
	sr_pcs_ctl = rd32_epcs(hw, SR_XS_PCS_CTRL2);
	sr_pma_ctl1 = rd32_epcs(hw, SR_PMA_CTRL1);
	sr_an_ctl = rd32_epcs(hw, SR_AN_CTRL);
	sr_an_adv_reg2 = rd32_epcs(hw, SR_AN_MMD_ADV_REG2);
	if ((sr_pcs_ctl & SR_PCS_CTRL2_TYPE_SEL) == SR_PCS_CTRL2_TYPE_SEL_X &&
	    (sr_pma_ctl1 & SR_PMA_CTRL1_SS13) == SR_PMA_CTRL1_SS13_KX &&
	    (sr_an_ctl & SR_AN_CTRL_AN_EN) == 0) {
		autoc |= TXGBE_AUTOC_LMS_1G_LINK_NO_AN |
			 TXGBE_AUTOC_1G_KX;
		hw->phy.link_mode = TXGBE_PHYSICAL_LAYER_1000BASE_KX;
	} else if ((sr_pcs_ctl & SR_PCS_CTRL2_TYPE_SEL) ==
		SR_PCS_CTRL2_TYPE_SEL_X &&
		(sr_pma_ctl1 & SR_PMA_CTRL1_SS13) == SR_PMA_CTRL1_SS13_KX4 &&
		(sr_an_ctl & SR_AN_CTRL_AN_EN) == 0) {
		autoc |= TXGBE_AUTOC_LMS_10G |
			 TXGBE_AUTOC_10G_KX4;
		hw->phy.link_mode = TXGBE_PHYSICAL_LAYER_10GBASE_KX4;
	} else if ((sr_pcs_ctl & SR_PCS_CTRL2_TYPE_SEL) ==
		SR_PCS_CTRL2_TYPE_SEL_R &&
		(sr_an_ctl & SR_AN_CTRL_AN_EN) == 0) {
		autoc |= TXGBE_AUTOC_LMS_10G |
			 TXGBE_AUTOC_10GS_KR;
		hw->phy.link_mode = TXGBE_PHYSICAL_LAYER_10GBASE_KR;
	} else if ((sr_an_ctl & SR_AN_CTRL_AN_EN)) {
		if (sr_an_adv_reg2 & SR_AN_MMD_ADV_REG2_BP_TYPE_KR)
			autoc |= TXGBE_AUTOC_10G_KR;
		if (sr_an_adv_reg2 & SR_AN_MMD_ADV_REG2_BP_TYPE_KX4)
			autoc |= TXGBE_AUTOC_10G_KX4;
		if (sr_an_adv_reg2 & SR_AN_MMD_ADV_REG2_BP_TYPE_KX)
			autoc |= TXGBE_AUTOC_1G_KX;
		autoc |= TXGBE_AUTOC_LMS_KX4_KX_KR;
		hw->phy.link_mode = TXGBE_PHYSICAL_LAYER_10GBASE_KR |
				TXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
				TXGBE_PHYSICAL_LAYER_1000BASE_KX;
	}
	return autoc;
}
u64 txgbe_autoc_read ( struct txgbe_hw * hw ) { u64 autoc = 0 ; u32 sr_pcs_ctl ; u32 sr_pma_ctl1 ; u32 sr_an_ctl ; u32 sr_an_adv_reg2 ; if ( hw -> phy . multispeed_fiber ) { autoc |= TXGBE_AUTOC_LMS_10G ; } else if ( hw -> device_id == TXGBE_DEV_ID_RAPTOR_SFP || hw -> device_id == TXGBE_DEV_ID_WX1820_SFP ) { autoc |= TXGBE_AUTOC_LMS_10G | TXGBE_AUTOC_10GS_SFI ; } else if ( hw -> device_id == TXGBE_DEV_ID_RAPTOR_QSFP ) { autoc = 0 ; } else if ( hw -> device_id == TXGBE_DEV_ID_RAPTOR_XAUI ) { autoc |= TXGBE_AUTOC_LMS_10G_LINK_NO_AN | TXGBE_AUTOC_10G_XAUI ; hw -> phy . link_mode = TXGBE_PHYSICAL_LAYER_10GBASE_T ; } else if ( hw -> device_id == TXGBE_DEV_ID_RAPTOR_SGMII ) { autoc |= TXGBE_AUTOC_LMS_SGMII_1G_100M ; hw -> phy . link_mode = TXGBE_PHYSICAL_LAYER_1000BASE_T | TXGBE_PHYSICAL_LAYER_100BASE_TX ; } if ( hw -> device_id != TXGBE_DEV_ID_RAPTOR_SGMII ) return autoc ; sr_pcs_ctl = rd32_epcs ( hw , SR_XS_PCS_CTRL2 ) ; sr_pma_ctl1 = rd32_epcs ( hw , SR_PMA_CTRL1 ) ; sr_an_ctl = rd32_epcs ( hw , SR_AN_CTRL ) ; sr_an_adv_reg2 = rd32_epcs ( hw , SR_AN_MMD_ADV_REG2 ) ; if ( ( sr_pcs_ctl & SR_PCS_CTRL2_TYPE_SEL ) == SR_PCS_CTRL2_TYPE_SEL_X && ( sr_pma_ctl1 & SR_PMA_CTRL1_SS13 ) == SR_PMA_CTRL1_SS13_KX && ( sr_an_ctl & SR_AN_CTRL_AN_EN ) == 0 ) { autoc |= TXGBE_AUTOC_LMS_1G_LINK_NO_AN | TXGBE_AUTOC_1G_KX ; hw -> phy . link_mode = TXGBE_PHYSICAL_LAYER_1000BASE_KX ; } else if ( ( sr_pcs_ctl & SR_PCS_CTRL2_TYPE_SEL ) == SR_PCS_CTRL2_TYPE_SEL_X && ( sr_pma_ctl1 & SR_PMA_CTRL1_SS13 ) == SR_PMA_CTRL1_SS13_KX4 && ( sr_an_ctl & SR_AN_CTRL_AN_EN ) == 0 ) { autoc |= TXGBE_AUTOC_LMS_10G | TXGBE_AUTOC_10G_KX4 ; hw -> phy . link_mode = TXGBE_PHYSICAL_LAYER_10GBASE_KX4 ; } else if ( ( sr_pcs_ctl & SR_PCS_CTRL2_TYPE_SEL ) == SR_PCS_CTRL2_TYPE_SEL_R && ( sr_an_ctl & SR_AN_CTRL_AN_EN ) == 0 ) { autoc |= TXGBE_AUTOC_LMS_10G | TXGBE_AUTOC_10GS_KR ; hw -> phy . link_mode = TXGBE_PHYSICAL_LAYER_10GBASE_KR ; } else if ( ( sr_an_ctl & SR_AN_CTRL_AN_EN ) ) { if ( sr_an_adv_reg2 & SR_AN_MMD_ADV_REG2_BP_TYPE_KR ) autoc |= TXGBE_AUTOC_10G_KR ; if ( sr_an_adv_reg2 & SR_AN_MMD_ADV_REG2_BP_TYPE_KX4 ) autoc |= TXGBE_AUTOC_10G_KX4 ; if ( sr_an_adv_reg2 & SR_AN_MMD_ADV_REG2_BP_TYPE_KX ) autoc |= TXGBE_AUTOC_1G_KX ; autoc |= TXGBE_AUTOC_LMS_KX4_KX_KR ; hw -> phy . link_mode = TXGBE_PHYSICAL_LAYER_10GBASE_KR | TXGBE_PHYSICAL_LAYER_10GBASE_KX4 | TXGBE_PHYSICAL_LAYER_1000BASE_KX ; } return autoc ; }
txgbe_autoc_read - Hides MAC differences needed for AUTOC read
  @hw: pointer to hardware structure
txgbe_autoc_read - Hides MAC differences needed for AUTOC read @hw : pointer to hardware structure
/*TBD*/ /* 1G or KX - no backplane auto-negotiation */ /* 10 GbE serial link (KR -no backplane auto-negotiation) */ /* KX/KX4/KR backplane auto-negotiation enable */