FreeBSD/sys/dev/e1000/if_lem.c
/*********************************************************************
 *
 *  Setup the Legacy or MSI Interrupt handler
 *
 **********************************************************************/
Setup the Legacy or MSI Interrupt handler
Setup the Legacy or MSI Interrupt handler
int
lem_allocate_irq(struct adapter *adapter)
{
	device_t dev = adapter->dev;
	int error, rid = 0;
	E1000_WRITE_REG(&adapter->hw, E1000_IMC, 0xffffffff);
	adapter->res[0] = bus_alloc_resource_any(dev,
	    SYS_RES_IRQ, &rid, RF_SHAREABLE | RF_ACTIVE);
	if (adapter->res[0] == NULL) {
		device_printf(dev, "Unable to allocate bus resource: "
		    "interrupt\n");
		return (ENXIO);
	}
	if (lem_use_legacy_irq) {
		if ((error = bus_setup_intr(dev, adapter->res[0],
	    	    INTR_TYPE_NET | INTR_MPSAFE, NULL, lem_intr, adapter,
	    	    &adapter->tag[0])) != 0) {
			device_printf(dev,
			    "Failed to register interrupt handler");
			return (error);
		}
		return (0);
	}
	TASK_INIT(&adapter->rxtx_task, 0, lem_handle_rxtx, adapter);
	TASK_INIT(&adapter->link_task, 0, lem_handle_link, adapter);
	adapter->tq = taskqueue_create_fast("lem_taskq", M_NOWAIT,
	    taskqueue_thread_enqueue, &adapter->tq);
	taskqueue_start_threads(&adapter->tq, 1, PI_NET, "%s taskq",
	    device_get_nameunit(adapter->dev));
	if ((error = bus_setup_intr(dev, adapter->res[0],
	    INTR_TYPE_NET, lem_irq_fast, NULL, adapter,
	    &adapter->tag[0])) != 0) {
		device_printf(dev, "Failed to register fast interrupt "
			    "handler: %d\n", error);
		taskqueue_free(adapter->tq);
		adapter->tq = NULL;
		return (error);
	}
	return (0);
}
int lem_allocate_irq ( struct adapter * adapter ) { device_t dev = adapter -> dev ; int error , rid = 0 ; E1000_WRITE_REG ( & adapter -> hw , E1000_IMC , 0xffffffff ) ; adapter -> res [ 0 ] = bus_alloc_resource_any ( dev , SYS_RES_IRQ , & rid , RF_SHAREABLE | RF_ACTIVE ) ; if ( adapter -> res [ 0 ] == NULL ) { device_printf ( dev , " " " \n " ) ; return ( ENXIO ) ; } if ( lem_use_legacy_irq ) { if ( ( error = bus_setup_intr ( dev , adapter -> res [ 0 ] , INTR_TYPE_NET | INTR_MPSAFE , NULL , lem_intr , adapter , & adapter -> tag [ 0 ] ) ) != 0 ) { device_printf ( dev , " " ) ; return ( error ) ; } return ( 0 ) ; } TASK_INIT ( & adapter -> rxtx_task , 0 , lem_handle_rxtx , adapter ) ; TASK_INIT ( & adapter -> link_task , 0 , lem_handle_link , adapter ) ; adapter -> tq = taskqueue_create_fast ( " " , M_NOWAIT , taskqueue_thread_enqueue , & adapter -> tq ) ; taskqueue_start_threads ( & adapter -> tq , 1 , PI_NET , " " , device_get_nameunit ( adapter -> dev ) ) ; if ( ( error = bus_setup_intr ( dev , adapter -> res [ 0 ] , INTR_TYPE_NET , lem_irq_fast , NULL , adapter , & adapter -> tag [ 0 ] ) ) != 0 ) { device_printf ( dev , " " " \n " , error ) ; taskqueue_free ( adapter -> tq ) ; adapter -> tq = NULL ; return ( error ) ; } return ( 0 ) ; }
Setup the Legacy or MSI Interrupt handler
Setup the Legacy or MSI Interrupt handler
/* Manually turn off all interrupts */ /* We allocate a single interrupt resource */ /* Do Legacy setup? */ /*
	 * Use a Fast interrupt and the associated
	 * deferred processing contexts.
	 */