src/dpdk/drivers/net/txgbe/base/txgbe_hw.c
s32 txgbe_check_mac_link(struct txgbe_hw *hw, u32 *speed,
				 bool *link_up, bool link_up_wait_to_complete)
{
	u32 links_reg, links_orig;
	u32 i;

	DEBUGFUNC("txgbe_check_mac_link");

	/* If Crosstalk fix enabled do the sanity check of making sure
	 * the SFP+ cage is full.
	 */
	if (txgbe_need_crosstalk_fix(hw)) {
		u32 sfp_cage_full;

		switch (hw->mac.type) {
		case txgbe_mac_raptor:
			sfp_cage_full = !rd32m(hw, TXGBE_GPIODATA,
					TXGBE_GPIOBIT_2);
			break;
		default:
			/* sanity check - No SFP+ devices here */
			sfp_cage_full = false;
			break;
		}

		if (!sfp_cage_full) {
			*link_up = false;
			*speed = TXGBE_LINK_SPEED_UNKNOWN;
			return 0;
		}
	}

	/* clear the old state */
	links_orig = rd32(hw, TXGBE_PORTSTAT);

	links_reg = rd32(hw, TXGBE_PORTSTAT);

	if (links_orig != links_reg) {
		DEBUGOUT("LINKS changed from %08X to %08X\n",
			  links_orig, links_reg);
	}

	if (link_up_wait_to_complete) {
		for (i = 0; i < hw->mac.max_link_up_time; i++) {
			if (!(links_reg & TXGBE_PORTSTAT_UP)) {
				*link_up = false;
			} else {
				*link_up = true;
				break;
			}
			msec_delay(100);
			links_reg = rd32(hw, TXGBE_PORTSTAT);
		}
	} else {
		if (links_reg & TXGBE_PORTSTAT_UP)
			*link_up = true;
		else
			*link_up = false;
	}

	switch (links_reg & TXGBE_PORTSTAT_BW_MASK) {
	case TXGBE_PORTSTAT_BW_10G:
		*speed = TXGBE_LINK_SPEED_10GB_FULL;
		break;
	case TXGBE_PORTSTAT_BW_1G:
		*speed = TXGBE_LINK_SPEED_1GB_FULL;
		break;
	case TXGBE_PORTSTAT_BW_100M:
		*speed = TXGBE_LINK_SPEED_100M_FULL;
		break;
	default:
		*speed = TXGBE_LINK_SPEED_UNKNOWN;
	}

	return 0;
}
/**
 *  txgbe_check_mac_link - Determine link and speed status
 *  @hw: pointer to hardware structure
 *  @speed: pointer to link speed
 *  @link_up: true when link is up
 *  @link_up_wait_to_complete: bool used to wait for link up or not
 *
 *  Reads the links register to determine if link is up and the current speed
 **/
Determine link and speed status
@hw: pointer to hardware structure
@speed: pointer to link speed
@link_up: true when link is up
@link_up_wait_to_complete: bool used to wait for link up or not

Reads the links register to determine if link is up and the current speed
Determine link and speed status @hw : pointer to hardware structure @speed : pointer to link speed @link_up : true when link is up @link_up_wait_to_complete : bool used to wait for link up or not Reads the links register to determine if link is up and the current speed
s32 txgbe_check_mac_link(struct txgbe_hw *hw, u32 *speed,
				 bool *link_up, bool link_up_wait_to_complete)
{
	u32 links_reg, links_orig;
	u32 i;
	DEBUGFUNC("txgbe_check_mac_link");
	if (txgbe_need_crosstalk_fix(hw)) {
		u32 sfp_cage_full;
		switch (hw->mac.type) {
		case txgbe_mac_raptor:
			sfp_cage_full = !rd32m(hw, TXGBE_GPIODATA,
					TXGBE_GPIOBIT_2);
			break;
		default:
			sfp_cage_full = false;
			break;
		}
		if (!sfp_cage_full) {
			*link_up = false;
			*speed = TXGBE_LINK_SPEED_UNKNOWN;
			return 0;
		}
	}
	links_orig = rd32(hw, TXGBE_PORTSTAT);
	links_reg = rd32(hw, TXGBE_PORTSTAT);
	if (links_orig != links_reg) {
		DEBUGOUT("LINKS changed from %08X to %08X\n",
			  links_orig, links_reg);
	}
	if (link_up_wait_to_complete) {
		for (i = 0; i < hw->mac.max_link_up_time; i++) {
			if (!(links_reg & TXGBE_PORTSTAT_UP)) {
				*link_up = false;
			} else {
				*link_up = true;
				break;
			}
			msec_delay(100);
			links_reg = rd32(hw, TXGBE_PORTSTAT);
		}
	} else {
		if (links_reg & TXGBE_PORTSTAT_UP)
			*link_up = true;
		else
			*link_up = false;
	}
	switch (links_reg & TXGBE_PORTSTAT_BW_MASK) {
	case TXGBE_PORTSTAT_BW_10G:
		*speed = TXGBE_LINK_SPEED_10GB_FULL;
		break;
	case TXGBE_PORTSTAT_BW_1G:
		*speed = TXGBE_LINK_SPEED_1GB_FULL;
		break;
	case TXGBE_PORTSTAT_BW_100M:
		*speed = TXGBE_LINK_SPEED_100M_FULL;
		break;
	default:
		*speed = TXGBE_LINK_SPEED_UNKNOWN;
	}
	return 0;
}
s32 txgbe_check_mac_link ( struct txgbe_hw * hw , u32 * speed , bool * link_up , bool link_up_wait_to_complete ) { u32 links_reg , links_orig ; u32 i ; DEBUGFUNC ( " " ) ; if ( txgbe_need_crosstalk_fix ( hw ) ) { u32 sfp_cage_full ; switch ( hw -> mac . type ) { case txgbe_mac_raptor : sfp_cage_full = ! rd32m ( hw , TXGBE_GPIODATA , TXGBE_GPIOBIT_2 ) ; break ; default : sfp_cage_full = false ; break ; } if ( ! sfp_cage_full ) { * link_up = false ; * speed = TXGBE_LINK_SPEED_UNKNOWN ; return 0 ; } } links_orig = rd32 ( hw , TXGBE_PORTSTAT ) ; links_reg = rd32 ( hw , TXGBE_PORTSTAT ) ; if ( links_orig != links_reg ) { DEBUGOUT ( " \n " , links_orig , links_reg ) ; } if ( link_up_wait_to_complete ) { for ( i = 0 ; i < hw -> mac . max_link_up_time ; i ++ ) { if ( ! ( links_reg & TXGBE_PORTSTAT_UP ) ) { * link_up = false ; } else { * link_up = true ; break ; } msec_delay ( 100 ) ; links_reg = rd32 ( hw , TXGBE_PORTSTAT ) ; } } else { if ( links_reg & TXGBE_PORTSTAT_UP ) * link_up = true ; else * link_up = false ; } switch ( links_reg & TXGBE_PORTSTAT_BW_MASK ) { case TXGBE_PORTSTAT_BW_10G : * speed = TXGBE_LINK_SPEED_10GB_FULL ; break ; case TXGBE_PORTSTAT_BW_1G : * speed = TXGBE_LINK_SPEED_1GB_FULL ; break ; case TXGBE_PORTSTAT_BW_100M : * speed = TXGBE_LINK_SPEED_100M_FULL ; break ; default : * speed = TXGBE_LINK_SPEED_UNKNOWN ; } return 0 ; }
txgbe_check_mac_link - Determine link and speed status
  @hw: pointer to hardware structure
  @speed: pointer to link speed
  @link_up: true when link is up
  @link_up_wait_to_complete: bool used to wait for link up or not
txgbe_check_mac_link - Determine link and speed status @hw : pointer to hardware structure @speed : pointer to link speed @link_up : true when link is up @link_up_wait_to_complete : bool used to wait for link up or not
/* If Crosstalk fix enabled do the sanity check of making sure
	 * the SFP+ cage is full.
	 */ /* sanity check - No SFP+ devices here */ /* clear the old state */