src/dpdk/drivers/net/txgbe/base/txgbe_hw.c
s32 txgbe_reset_hw(struct txgbe_hw *hw)
{
	s32 status;
	u32 autoc;

	DEBUGFUNC("txgbe_reset_hw");

	/* Call adapter stop to disable tx/rx and clear interrupts */
	status = hw->mac.stop_hw(hw);
	if (status != 0)
		return status;

	/* flush pending Tx transactions */
	txgbe_clear_tx_pending(hw);

	/* Identify PHY and related function pointers */
	status = hw->phy.init(hw);
	if (status == TXGBE_ERR_SFP_NOT_SUPPORTED)
		return status;

	/* Setup SFP module if there is one present. */
	if (hw->phy.sfp_setup_needed) {
		status = hw->mac.setup_sfp(hw);
		hw->phy.sfp_setup_needed = false;
	}
	if (status == TXGBE_ERR_SFP_NOT_SUPPORTED)
		return status;

	/* Reset PHY */
	if (!hw->phy.reset_disable)
		hw->phy.reset(hw);

	/* remember AUTOC from before we reset */
	autoc = hw->mac.autoc_read(hw);

mac_reset_top:
	/*
	 * Issue global reset to the MAC.  Needs to be SW reset if link is up.
	 * If link reset is used when link is up, it might reset the PHY when
	 * mng is using it.  If link is down or the flag to force full link
	 * reset is set, then perform link reset.
	 */
	if (txgbe_mng_present(hw)) {
		txgbe_hic_reset(hw);
	} else {
		wr32(hw, TXGBE_RST, TXGBE_RST_LAN(hw->bus.lan_id));
		txgbe_flush(hw);
	}
	usec_delay(10);

	txgbe_reset_misc(hw);

	if (hw->bus.lan_id == 0) {
		status = txgbe_check_flash_load(hw,
				TXGBE_ILDRSTAT_SWRST_LAN0);
	} else {
		status = txgbe_check_flash_load(hw,
				TXGBE_ILDRSTAT_SWRST_LAN1);
	}
	if (status != 0)
		return status;

	msec_delay(50);

	/*
	 * Double resets are required for recovery from certain error
	 * conditions.  Between resets, it is necessary to stall to
	 * allow time for any pending HW events to complete.
	 */
	if (hw->mac.flags & TXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
		hw->mac.flags &= ~TXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
		goto mac_reset_top;
	}

	/*
	 * Store the original AUTOC/AUTOC2 values if they have not been
	 * stored off yet.  Otherwise restore the stored original
	 * values since the reset operation sets back to defaults.
	 */
	if (!hw->mac.orig_link_settings_stored) {
		hw->mac.orig_autoc = hw->mac.autoc_read(hw);
		hw->mac.autoc_write(hw, hw->mac.orig_autoc);
		hw->mac.orig_link_settings_stored = true;
	} else {
		hw->mac.orig_autoc = autoc;
	}

	/* Store the permanent mac address */
	hw->mac.get_mac_addr(hw, hw->mac.perm_addr);

	/*
	 * Store MAC address from RAR0, clear receive address registers, and
	 * clear the multicast table.  Also reset num_rar_entries to 128,
	 * since we modify this value when programming the SAN MAC address.
	 */
	hw->mac.num_rar_entries = 128;
	hw->mac.init_rx_addrs(hw);

	/* Store the permanent SAN mac address */
	hw->mac.get_san_mac_addr(hw, hw->mac.san_addr);

	/* Add the SAN MAC address to the RAR only if it's a valid address */
	if (txgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
		/* Save the SAN MAC RAR index */
		hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1;

		hw->mac.set_rar(hw, hw->mac.san_mac_rar_index,
				    hw->mac.san_addr, 0, true);

		/* clear VMDq pool/queue selection for this RAR */
		hw->mac.clear_vmdq(hw, hw->mac.san_mac_rar_index,
				       BIT_MASK32);

		/* Reserve the last RAR for the SAN MAC address */
		hw->mac.num_rar_entries--;
	}

	/* Store the alternative WWNN/WWPN prefix */
	hw->mac.get_wwn_prefix(hw, &hw->mac.wwnn_prefix,
				   &hw->mac.wwpn_prefix);

	return status;
}
/**
 *  txgbe_reset_hw - Perform hardware reset
 *  @hw: pointer to hardware structure
 *
 *  Resets the hardware by resetting the transmit and receive units, masks
 *  and clears all interrupts, perform a PHY reset, and perform a link (MAC)
 *  reset.
 **/
Perform hardware reset
@hw: pointer to hardware structure

Resets the hardware by resetting the transmit and receive units, masks
and clears all interrupts, perform a PHY reset, and perform a link (MAC)
reset.
Perform hardware reset @hw : pointer to hardware structure Resets the hardware by resetting the transmit and receive units masks and clears all interrupts perform a PHY reset and perform a link ( MAC ) reset .
s32 txgbe_reset_hw(struct txgbe_hw *hw)
{
	s32 status;
	u32 autoc;
	DEBUGFUNC("txgbe_reset_hw");
	status = hw->mac.stop_hw(hw);
	if (status != 0)
		return status;
	txgbe_clear_tx_pending(hw);
	status = hw->phy.init(hw);
	if (status == TXGBE_ERR_SFP_NOT_SUPPORTED)
		return status;
	if (hw->phy.sfp_setup_needed) {
		status = hw->mac.setup_sfp(hw);
		hw->phy.sfp_setup_needed = false;
	}
	if (status == TXGBE_ERR_SFP_NOT_SUPPORTED)
		return status;
	if (!hw->phy.reset_disable)
		hw->phy.reset(hw);
	autoc = hw->mac.autoc_read(hw);
mac_reset_top:
	if (txgbe_mng_present(hw)) {
		txgbe_hic_reset(hw);
	} else {
		wr32(hw, TXGBE_RST, TXGBE_RST_LAN(hw->bus.lan_id));
		txgbe_flush(hw);
	}
	usec_delay(10);
	txgbe_reset_misc(hw);
	if (hw->bus.lan_id == 0) {
		status = txgbe_check_flash_load(hw,
				TXGBE_ILDRSTAT_SWRST_LAN0);
	} else {
		status = txgbe_check_flash_load(hw,
				TXGBE_ILDRSTAT_SWRST_LAN1);
	}
	if (status != 0)
		return status;
	msec_delay(50);
	if (hw->mac.flags & TXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
		hw->mac.flags &= ~TXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
		goto mac_reset_top;
	}
	if (!hw->mac.orig_link_settings_stored) {
		hw->mac.orig_autoc = hw->mac.autoc_read(hw);
		hw->mac.autoc_write(hw, hw->mac.orig_autoc);
		hw->mac.orig_link_settings_stored = true;
	} else {
		hw->mac.orig_autoc = autoc;
	}
	hw->mac.get_mac_addr(hw, hw->mac.perm_addr);
	hw->mac.num_rar_entries = 128;
	hw->mac.init_rx_addrs(hw);
	hw->mac.get_san_mac_addr(hw, hw->mac.san_addr);
	if (txgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
		hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1;
		hw->mac.set_rar(hw, hw->mac.san_mac_rar_index,
				    hw->mac.san_addr, 0, true);
		hw->mac.clear_vmdq(hw, hw->mac.san_mac_rar_index,
				       BIT_MASK32);
		hw->mac.num_rar_entries--;
	}
	hw->mac.get_wwn_prefix(hw, &hw->mac.wwnn_prefix,
				   &hw->mac.wwpn_prefix);
	return status;
}
s32 txgbe_reset_hw ( struct txgbe_hw * hw ) { s32 status ; u32 autoc ; DEBUGFUNC ( " " ) ; status = hw -> mac . stop_hw ( hw ) ; if ( status != 0 ) return status ; txgbe_clear_tx_pending ( hw ) ; status = hw -> phy . init ( hw ) ; if ( status == TXGBE_ERR_SFP_NOT_SUPPORTED ) return status ; if ( hw -> phy . sfp_setup_needed ) { status = hw -> mac . setup_sfp ( hw ) ; hw -> phy . sfp_setup_needed = false ; } if ( status == TXGBE_ERR_SFP_NOT_SUPPORTED ) return status ; if ( ! hw -> phy . reset_disable ) hw -> phy . reset ( hw ) ; autoc = hw -> mac . autoc_read ( hw ) ; mac_reset_top : if ( txgbe_mng_present ( hw ) ) { txgbe_hic_reset ( hw ) ; } else { wr32 ( hw , TXGBE_RST , TXGBE_RST_LAN ( hw -> bus . lan_id ) ) ; txgbe_flush ( hw ) ; } usec_delay ( 10 ) ; txgbe_reset_misc ( hw ) ; if ( hw -> bus . lan_id == 0 ) { status = txgbe_check_flash_load ( hw , TXGBE_ILDRSTAT_SWRST_LAN0 ) ; } else { status = txgbe_check_flash_load ( hw , TXGBE_ILDRSTAT_SWRST_LAN1 ) ; } if ( status != 0 ) return status ; msec_delay ( 50 ) ; if ( hw -> mac . flags & TXGBE_FLAGS_DOUBLE_RESET_REQUIRED ) { hw -> mac . flags &= ~ TXGBE_FLAGS_DOUBLE_RESET_REQUIRED ; goto mac_reset_top ; } if ( ! hw -> mac . orig_link_settings_stored ) { hw -> mac . orig_autoc = hw -> mac . autoc_read ( hw ) ; hw -> mac . autoc_write ( hw , hw -> mac . orig_autoc ) ; hw -> mac . orig_link_settings_stored = true ; } else { hw -> mac . orig_autoc = autoc ; } hw -> mac . get_mac_addr ( hw , hw -> mac . perm_addr ) ; hw -> mac . num_rar_entries = 128 ; hw -> mac . init_rx_addrs ( hw ) ; hw -> mac . get_san_mac_addr ( hw , hw -> mac . san_addr ) ; if ( txgbe_validate_mac_addr ( hw -> mac . san_addr ) == 0 ) { hw -> mac . san_mac_rar_index = hw -> mac . num_rar_entries - 1 ; hw -> mac . set_rar ( hw , hw -> mac . san_mac_rar_index , hw -> mac . san_addr , 0 , true ) ; hw -> mac . clear_vmdq ( hw , hw -> mac . san_mac_rar_index , BIT_MASK32 ) ; hw -> mac . num_rar_entries -- ; } hw -> mac . get_wwn_prefix ( hw , & hw -> mac . wwnn_prefix , & hw -> mac . wwpn_prefix ) ; return status ; }
txgbe_reset_hw - Perform hardware reset
  @hw: pointer to hardware structure
txgbe_reset_hw - Perform hardware reset @hw : pointer to hardware structure
/* Call adapter stop to disable tx/rx and clear interrupts */ /* flush pending Tx transactions */ /* Identify PHY and related function pointers */ /* Setup SFP module if there is one present. */ /* Reset PHY */ /* remember AUTOC from before we reset */ /*
	 * Issue global reset to the MAC.  Needs to be SW reset if link is up.
	 * If link reset is used when link is up, it might reset the PHY when
	 * mng is using it.  If link is down or the flag to force full link
	 * reset is set, then perform link reset.
	 */ /*
	 * Double resets are required for recovery from certain error
	 * conditions.  Between resets, it is necessary to stall to
	 * allow time for any pending HW events to complete.
	 */ /*
	 * Store the original AUTOC/AUTOC2 values if they have not been
	 * stored off yet.  Otherwise restore the stored original
	 * values since the reset operation sets back to defaults.
	 */ /* Store the permanent mac address */ /*
	 * Store MAC address from RAR0, clear receive address registers, and
	 * clear the multicast table.  Also reset num_rar_entries to 128,
	 * since we modify this value when programming the SAN MAC address.
	 */ /* Store the permanent SAN mac address */ /* Add the SAN MAC address to the RAR only if it's a valid address */ /* Save the SAN MAC RAR index */ /* clear VMDq pool/queue selection for this RAR */ /* Reserve the last RAR for the SAN MAC address */ /* Store the alternative WWNN/WWPN prefix */