FreeBSD/sys/dev/e1000/if_igb.c
/*********************************************************************
 *
 *  Setup the Legacy or MSI Interrupt handler
 *
 **********************************************************************/
Setup the Legacy or MSI Interrupt handler
Setup the Legacy or MSI Interrupt handler
static int
igb_allocate_legacy(struct adapter *adapter)
{
	device_t		dev = adapter->dev;
	struct igb_queue	*que = adapter->queues;
#ifndef IGB_LEGACY_TX
	struct tx_ring		*txr = adapter->tx_rings;
#endif
	int			error, rid = 0;
	E1000_WRITE_REG(&adapter->hw, E1000_IMC, 0xffffffff);
	if (adapter->msix == 1)
		rid = 1;
	adapter->res = bus_alloc_resource_any(dev,
	    SYS_RES_IRQ, &rid, RF_SHAREABLE | RF_ACTIVE);
	if (adapter->res == NULL) {
		device_printf(dev, "Unable to allocate bus resource: "
		    "interrupt\n");
		return (ENXIO);
	}
#ifndef IGB_LEGACY_TX
	TASK_INIT(&txr->txq_task, 0, igb_deferred_mq_start, txr);
#endif
	TASK_INIT(&que->que_task, 0, igb_handle_que, que);
	TASK_INIT(&adapter->link_task, 0, igb_handle_link, adapter);
	que->tq = taskqueue_create_fast("igb_taskq", M_NOWAIT,
	    taskqueue_thread_enqueue, &que->tq);
	taskqueue_start_threads(&que->tq, 1, PI_NET, "%s taskq",
	    device_get_nameunit(adapter->dev));
	if ((error = bus_setup_intr(dev, adapter->res,
	    INTR_TYPE_NET | INTR_MPSAFE, igb_irq_fast, NULL,
	    adapter, &adapter->tag)) != 0) {
		device_printf(dev, "Failed to register fast interrupt "
			    "handler: %d\n", error);
		taskqueue_free(que->tq);
		que->tq = NULL;
		return (error);
	}
	return (0);
}
static int igb_allocate_legacy ( struct adapter * adapter ) { device_t dev = adapter -> dev ; struct igb_queue * que = adapter -> queues ; #ifndef IGB_LEGACY_TX struct tx_ring * txr = adapter -> tx_rings ; #endif int error , rid = 0 ; E1000_WRITE_REG ( & adapter -> hw , E1000_IMC , 0xffffffff ) ; if ( adapter -> msix == 1 ) rid = 1 ; adapter -> res = bus_alloc_resource_any ( dev , SYS_RES_IRQ , & rid , RF_SHAREABLE | RF_ACTIVE ) ; if ( adapter -> res == NULL ) { device_printf ( dev , " " " \n " ) ; return ( ENXIO ) ; } #ifndef IGB_LEGACY_TX TASK_INIT ( & txr -> txq_task , 0 , igb_deferred_mq_start , txr ) ; #endif TASK_INIT ( & que -> que_task , 0 , igb_handle_que , que ) ; TASK_INIT ( & adapter -> link_task , 0 , igb_handle_link , adapter ) ; que -> tq = taskqueue_create_fast ( " " , M_NOWAIT , taskqueue_thread_enqueue , & que -> tq ) ; taskqueue_start_threads ( & que -> tq , 1 , PI_NET , " " , device_get_nameunit ( adapter -> dev ) ) ; if ( ( error = bus_setup_intr ( dev , adapter -> res , INTR_TYPE_NET | INTR_MPSAFE , igb_irq_fast , NULL , adapter , & adapter -> tag ) ) != 0 ) { device_printf ( dev , " " " \n " , error ) ; taskqueue_free ( que -> tq ) ; que -> tq = NULL ; return ( error ) ; } return ( 0 ) ; }
Setup the Legacy or MSI Interrupt handler
Setup the Legacy or MSI Interrupt handler
/* Turn off all interrupts */ /* MSI RID is 1 */ /* We allocate a single interrupt resource */ /*
	 * Try allocating a fast interrupt and the associated deferred
	 * processing contexts.
	 */ /* Make tasklet for deferred link handling */