src/dpdk/drivers/net/igc/base/igc_mac.c
s32 igc_check_for_fiber_link_generic(struct igc_hw *hw)
{
	struct igc_mac_info *mac = &hw->mac;
	u32 rxcw;
	u32 ctrl;
	u32 status;
	s32 ret_val;

	DEBUGFUNC("igc_check_for_fiber_link_generic");

	ctrl = IGC_READ_REG(hw, IGC_CTRL);
	status = IGC_READ_REG(hw, IGC_STATUS);
	rxcw = IGC_READ_REG(hw, IGC_RXCW);

	/* If we don't have link (auto-negotiation failed or link partner
	 * cannot auto-negotiate), the cable is plugged in (we have signal),
	 * and our link partner is not trying to auto-negotiate with us (we
	 * are receiving idles or data), we need to force link up. We also
	 * need to give auto-negotiation time to complete, in case the cable
	 * was just plugged in. The autoneg_failed flag does this.
	 */
	/* (ctrl & IGC_CTRL_SWDPIN1) == 1 == have signal */
	if ((ctrl & IGC_CTRL_SWDPIN1) && !(status & IGC_STATUS_LU) &&
	    !(rxcw & IGC_RXCW_C)) {
		if (!mac->autoneg_failed) {
			mac->autoneg_failed = true;
			return IGC_SUCCESS;
		}
		DEBUGOUT("NOT Rx'ing /C/, disable AutoNeg and force link.\n");

		/* Disable auto-negotiation in the TXCW register */
		IGC_WRITE_REG(hw, IGC_TXCW, (mac->txcw & ~IGC_TXCW_ANE));

		/* Force link-up and also force full-duplex. */
		ctrl = IGC_READ_REG(hw, IGC_CTRL);
		ctrl |= (IGC_CTRL_SLU | IGC_CTRL_FD);
		IGC_WRITE_REG(hw, IGC_CTRL, ctrl);

		/* Configure Flow Control after forcing link up. */
		ret_val = igc_config_fc_after_link_up_generic(hw);
		if (ret_val) {
			DEBUGOUT("Error configuring flow control\n");
			return ret_val;
		}
	} else if ((ctrl & IGC_CTRL_SLU) && (rxcw & IGC_RXCW_C)) {
		/* If we are forcing link and we are receiving /C/ ordered
		 * sets, re-enable auto-negotiation in the TXCW register
		 * and disable forced link in the Device Control register
		 * in an attempt to auto-negotiate with our link partner.
		 */
		DEBUGOUT("Rx'ing /C/, enable AutoNeg and stop forcing link.\n");
		IGC_WRITE_REG(hw, IGC_TXCW, mac->txcw);
		IGC_WRITE_REG(hw, IGC_CTRL, (ctrl & ~IGC_CTRL_SLU));

		mac->serdes_has_link = true;
	}

	return IGC_SUCCESS;
}
/**
 *  igc_check_for_fiber_link_generic - Check for link (Fiber)
 *  @hw: pointer to the HW structure
 *
 *  Checks for link up on the hardware.  If link is not up and we have
 *  a signal, then we need to force link up.
 **/
Check for link (Fiber)
@hw: pointer to the HW structure

Checks for link up on the hardware.  If link is not up and we have
a signal, then we need to force link up.
Check for link ( Fiber ) @hw : pointer to the HW structure Checks for link up on the hardware . If link is not up and we have a signal then we need to force link up .
s32 igc_check_for_fiber_link_generic(struct igc_hw *hw)
{
	struct igc_mac_info *mac = &hw->mac;
	u32 rxcw;
	u32 ctrl;
	u32 status;
	s32 ret_val;
	DEBUGFUNC("igc_check_for_fiber_link_generic");
	ctrl = IGC_READ_REG(hw, IGC_CTRL);
	status = IGC_READ_REG(hw, IGC_STATUS);
	rxcw = IGC_READ_REG(hw, IGC_RXCW);
	if ((ctrl & IGC_CTRL_SWDPIN1) && !(status & IGC_STATUS_LU) &&
	    !(rxcw & IGC_RXCW_C)) {
		if (!mac->autoneg_failed) {
			mac->autoneg_failed = true;
			return IGC_SUCCESS;
		}
		DEBUGOUT("NOT Rx'ing /C/, disable AutoNeg and force link.\n");
		IGC_WRITE_REG(hw, IGC_TXCW, (mac->txcw & ~IGC_TXCW_ANE));
		ctrl = IGC_READ_REG(hw, IGC_CTRL);
		ctrl |= (IGC_CTRL_SLU | IGC_CTRL_FD);
		IGC_WRITE_REG(hw, IGC_CTRL, ctrl);
		ret_val = igc_config_fc_after_link_up_generic(hw);
		if (ret_val) {
			DEBUGOUT("Error configuring flow control\n");
			return ret_val;
		}
	} else if ((ctrl & IGC_CTRL_SLU) && (rxcw & IGC_RXCW_C)) {
		DEBUGOUT("Rx'ing /C/, enable AutoNeg and stop forcing link.\n");
		IGC_WRITE_REG(hw, IGC_TXCW, mac->txcw);
		IGC_WRITE_REG(hw, IGC_CTRL, (ctrl & ~IGC_CTRL_SLU));
		mac->serdes_has_link = true;
	}
	return IGC_SUCCESS;
}
s32 igc_check_for_fiber_link_generic ( struct igc_hw * hw ) { struct igc_mac_info * mac = & hw -> mac ; u32 rxcw ; u32 ctrl ; u32 status ; s32 ret_val ; DEBUGFUNC ( " " ) ; ctrl = IGC_READ_REG ( hw , IGC_CTRL ) ; status = IGC_READ_REG ( hw , IGC_STATUS ) ; rxcw = IGC_READ_REG ( hw , IGC_RXCW ) ; if ( ( ctrl & IGC_CTRL_SWDPIN1 ) && ! ( status & IGC_STATUS_LU ) && ! ( rxcw & IGC_RXCW_C ) ) { if ( ! mac -> autoneg_failed ) { mac -> autoneg_failed = true ; return IGC_SUCCESS ; } DEBUGOUT ( " \n " ) ; IGC_WRITE_REG ( hw , IGC_TXCW , ( mac -> txcw & ~ IGC_TXCW_ANE ) ) ; ctrl = IGC_READ_REG ( hw , IGC_CTRL ) ; ctrl |= ( IGC_CTRL_SLU | IGC_CTRL_FD ) ; IGC_WRITE_REG ( hw , IGC_CTRL , ctrl ) ; ret_val = igc_config_fc_after_link_up_generic ( hw ) ; if ( ret_val ) { DEBUGOUT ( " \n " ) ; return ret_val ; } } else if ( ( ctrl & IGC_CTRL_SLU ) && ( rxcw & IGC_RXCW_C ) ) { DEBUGOUT ( " \n " ) ; IGC_WRITE_REG ( hw , IGC_TXCW , mac -> txcw ) ; IGC_WRITE_REG ( hw , IGC_CTRL , ( ctrl & ~ IGC_CTRL_SLU ) ) ; mac -> serdes_has_link = true ; } return IGC_SUCCESS ; }
igc_check_for_fiber_link_generic - Check for link (Fiber)
  @hw: pointer to the HW structure
igc_check_for_fiber_link_generic - Check for link ( Fiber ) @hw : pointer to the HW structure
/* If we don't have link (auto-negotiation failed or link partner
	 * cannot auto-negotiate), the cable is plugged in (we have signal),
	 * and our link partner is not trying to auto-negotiate with us (we
	 * are receiving idles or data), we need to force link up. We also
	 * need to give auto-negotiation time to complete, in case the cable
	 * was just plugged in. The autoneg_failed flag does this.
	 */ /* (ctrl & IGC_CTRL_SWDPIN1) == 1 == have signal */ /* Disable auto-negotiation in the TXCW register */ /* Force link-up and also force full-duplex. */ /* Configure Flow Control after forcing link up. */ /* If we are forcing link and we are receiving /C/ ordered
		 * sets, re-enable auto-negotiation in the TXCW register
		 * and disable forced link in the Device Control register
		 * in an attempt to auto-negotiate with our link partner.
		 */