FreeBSD/sys/dev/e1000/if_em.c
/*********************************************************************
 *
 *  This routine disables all traffic on the adapter by issuing a
 *  global reset on the MAC and deallocates TX/RX buffers.
 *
 *  This routine should always be called with BOTH the CORE
 *  and TX locks.
 **********************************************************************/
This routine disables all traffic on the adapter by issuing a
global reset on the MAC and deallocates TX/RX buffers.

This routine should always be called with BOTH the CORE
and TX locks.
This routine disables all traffic on the adapter by issuing a global reset on the MAC and deallocates TX / RX buffers . This routine should always be called with BOTH the CORE and TX locks .
static void
em_stop(void *arg)
{
	struct adapter	*adapter = arg;
	if_t ifp = adapter->ifp;
	struct tx_ring	*txr = adapter->tx_rings;
	EM_CORE_LOCK_ASSERT(adapter);
	INIT_DEBUGOUT("em_stop: begin");
	em_disable_intr(adapter);
	callout_stop(&adapter->timer);
	if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, IFF_DRV_RUNNING);
	for (int i = 0; i < adapter->num_queues; i++, txr++) {
		EM_TX_LOCK(txr);
		txr->busy = EM_TX_IDLE;
		EM_TX_UNLOCK(txr);
	}
	if (adapter->hw.mac.type == e1000_pch_spt)
		em_flush_desc_rings(adapter);
	e1000_reset_hw(&adapter->hw);
	E1000_WRITE_REG(&adapter->hw, E1000_WUC, 0);
	e1000_led_off(&adapter->hw);
	e1000_cleanup_led(&adapter->hw);
}
static void em_stop ( void * arg ) { struct adapter * adapter = arg ; if_t ifp = adapter -> ifp ; struct tx_ring * txr = adapter -> tx_rings ; EM_CORE_LOCK_ASSERT ( adapter ) ; INIT_DEBUGOUT ( " " ) ; em_disable_intr ( adapter ) ; callout_stop ( & adapter -> timer ) ; if_setdrvflagbits ( ifp , IFF_DRV_OACTIVE , IFF_DRV_RUNNING ) ; for ( int i = 0 ; i < adapter -> num_queues ; i ++ , txr ++ ) { EM_TX_LOCK ( txr ) ; txr -> busy = EM_TX_IDLE ; EM_TX_UNLOCK ( txr ) ; } if ( adapter -> hw . mac . type == e1000_pch_spt ) em_flush_desc_rings ( adapter ) ; e1000_reset_hw ( & adapter -> hw ) ; E1000_WRITE_REG ( & adapter -> hw , E1000_WUC , 0 ) ; e1000_led_off ( & adapter -> hw ) ; e1000_cleanup_led ( & adapter -> hw ) ; }
This routine disables all traffic on the adapter by issuing a
  global reset on the MAC and deallocates TX/RX buffers.
This routine disables all traffic on the adapter by issuing a global reset on the MAC and deallocates TX / RX buffers .
/* Tell the stack that the interface is no longer active */ /* Disarm Hang Detection. */ /* I219 needs some special flushing to avoid hangs */