FreeBSD/sys/dev/e1000/if_lem.c
/*********************************************************************
 *
 *  Initialize the hardware to a configuration
 *  as specified by the adapter structure.
 *
 **********************************************************************/
Initialize the hardware to a configuration
as specified by the adapter structure.
Initialize the hardware to a configuration as specified by the adapter structure .
static int
lem_hardware_init(struct adapter *adapter)
{
	device_t dev = adapter->dev;
	u16 	rx_buffer_size;
	INIT_DEBUGOUT("lem_hardware_init: begin");
	e1000_reset_hw(&adapter->hw);
	adapter->tx_fifo_head = 0;
	rx_buffer_size = ((E1000_READ_REG(&adapter->hw, E1000_PBA) &
	    0xffff) << 10 );
	adapter->hw.fc.high_water = rx_buffer_size -
	    roundup2(adapter->max_frame_size, 1024);
	adapter->hw.fc.low_water = adapter->hw.fc.high_water - 1500;
	adapter->hw.fc.pause_time = EM_FC_PAUSE_TIME;
	adapter->hw.fc.send_xon = TRUE;
        if ((lem_fc_setting >= 0) && (lem_fc_setting < 4))
                adapter->hw.fc.requested_mode = lem_fc_setting;
        else
                adapter->hw.fc.requested_mode = e1000_fc_none;
	if (e1000_init_hw(&adapter->hw) < 0) {
		device_printf(dev, "Hardware Initialization Failed\n");
		return (EIO);
	}
	e1000_check_for_link(&adapter->hw);
	return (0);
}
static int lem_hardware_init ( struct adapter * adapter ) { device_t dev = adapter -> dev ; u16 rx_buffer_size ; INIT_DEBUGOUT ( " " ) ; e1000_reset_hw ( & adapter -> hw ) ; adapter -> tx_fifo_head = 0 ; rx_buffer_size = ( ( E1000_READ_REG ( & adapter -> hw , E1000_PBA ) & 0xffff ) << 10 ) ; adapter -> hw . fc . high_water = rx_buffer_size - roundup2 ( adapter -> max_frame_size , 1024 ) ; adapter -> hw . fc . low_water = adapter -> hw . fc . high_water - 1500 ; adapter -> hw . fc . pause_time = EM_FC_PAUSE_TIME ; adapter -> hw . fc . send_xon = TRUE ; if ( ( lem_fc_setting >= 0 ) && ( lem_fc_setting < 4 ) ) adapter -> hw . fc . requested_mode = lem_fc_setting ; else adapter -> hw . fc . requested_mode = e1000_fc_none ; if ( e1000_init_hw ( & adapter -> hw ) < 0 ) { device_printf ( dev , " \n " ) ; return ( EIO ) ; } e1000_check_for_link ( & adapter -> hw ) ; return ( 0 ) ; }
Initialize the hardware to a configuration
  as specified by the adapter structure.
Initialize the hardware to a configuration as specified by the adapter structure .
/* Issue a global reset */ /* When hardware is reset, fifo_head is also reset */ /*
	 * These parameters control the automatic generation (Tx) and
	 * response (Rx) to Ethernet PAUSE frames.
	 * - High water mark should allow for at least two frames to be
	 *   received after sending an XOFF.
	 * - Low water mark works best when it is very near the high water mark.
	 *   This allows the receiver to restart by sending XON when it has
	 *   drained a bit. Here we use an arbitrary value of 1500 which will
	 *   restart after one full frame is pulled from the buffer. There
	 *   could be several smaller frames in the buffer and if so they will
	 *   not trigger the XON until their total number reduces the buffer
	 *   by 1500.
	 * - The pause time is fairly large at 1000 x 512ns = 512 usec.
	 */ /* Set Flow control, use the tunable location if sane */