FreeBSD/sys/dev/ixl/if_ixlv.c
/*********************************************************************
 *
 *  Setup MSIX Interrupt resources and handlers for the VSI queues
 *
 **********************************************************************/
Setup MSIX Interrupt resources and handlers for the VSI queues
Setup MSIX Interrupt resources and handlers for the VSI queues
static int
ixlv_assign_msix(struct ixlv_sc *sc)
{
	device_t	dev = sc->dev;
	struct 		ixl_vsi *vsi = &sc->vsi;
	struct 		ixl_queue *que = vsi->queues;
	struct		tx_ring	 *txr;
	int 		error, rid, vector = 1;
#ifdef	RSS
	cpuset_t	cpu_mask;
#endif
	for (int i = 0; i < vsi->num_queues; i++, vector++, que++) {
		int cpu_id = i;
		rid = vector + 1;
		txr = &que->txr;
		que->res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
		    RF_SHAREABLE | RF_ACTIVE);
		if (que->res == NULL) {
			device_printf(dev,"Unable to allocate"
		    	    " bus resource: que interrupt [%d]\n", vector);
			return (ENXIO);
		}
		error = bus_setup_intr(dev, que->res,
		    INTR_TYPE_NET | INTR_MPSAFE, NULL,
		    ixlv_msix_que, que, &que->tag);
		if (error) {
			que->res = NULL;
			device_printf(dev, "Failed to register que handler");
			return (error);
		}
		bus_describe_intr(dev, que->res, que->tag, "que %d", i);
#ifdef RSS
		cpu_id = rss_getcpu(i % rss_getnumbuckets());
#endif
		bus_bind_intr(dev, que->res, cpu_id);
		que->msix = vector;
		TASK_INIT(&que->tx_task, 0, ixl_deferred_mq_start, que);
		TASK_INIT(&que->task, 0, ixlv_handle_que, que);
		que->tq = taskqueue_create_fast("ixlv_que", M_NOWAIT,
		    taskqueue_thread_enqueue, &que->tq);
#ifdef RSS
		CPU_SETOF(cpu_id, &cpu_mask);
		taskqueue_start_threads_cpuset(&que->tq, 1, PI_NET,
		    &cpu_mask, "%s (bucket %d)",
		    device_get_nameunit(dev), cpu_id);
#else
                taskqueue_start_threads(&que->tq, 1, PI_NET,
                    "%s que", device_get_nameunit(dev));
#endif
	}
	return (0);
}
static int ixlv_assign_msix ( struct ixlv_sc * sc ) { device_t dev = sc -> dev ; struct ixl_vsi * vsi = & sc -> vsi ; struct ixl_queue * que = vsi -> queues ; struct tx_ring * txr ; int error , rid , vector = 1 ; #ifdef RSS cpuset_t cpu_mask ; #endif for ( int i = 0 ; i < vsi -> num_queues ; i ++ , vector ++ , que ++ ) { int cpu_id = i ; rid = vector + 1 ; txr = & que -> txr ; que -> res = bus_alloc_resource_any ( dev , SYS_RES_IRQ , & rid , RF_SHAREABLE | RF_ACTIVE ) ; if ( que -> res == NULL ) { device_printf ( dev , " " " \n " , vector ) ; return ( ENXIO ) ; } error = bus_setup_intr ( dev , que -> res , INTR_TYPE_NET | INTR_MPSAFE , NULL , ixlv_msix_que , que , & que -> tag ) ; if ( error ) { que -> res = NULL ; device_printf ( dev , " " ) ; return ( error ) ; } bus_describe_intr ( dev , que -> res , que -> tag , " " , i ) ; #ifdef RSS cpu_id = rss_getcpu ( i % rss_getnumbuckets ( ) ) ; #endif bus_bind_intr ( dev , que -> res , cpu_id ) ; que -> msix = vector ; TASK_INIT ( & que -> tx_task , 0 , ixl_deferred_mq_start , que ) ; TASK_INIT ( & que -> task , 0 , ixlv_handle_que , que ) ; que -> tq = taskqueue_create_fast ( " " , M_NOWAIT , taskqueue_thread_enqueue , & que -> tq ) ; #ifdef RSS CPU_SETOF ( cpu_id , & cpu_mask ) ; taskqueue_start_threads_cpuset ( & que -> tq , 1 , PI_NET , & cpu_mask , " " , device_get_nameunit ( dev ) , cpu_id ) ; #else taskqueue_start_threads ( & que -> tq , 1 , PI_NET , " " , device_get_nameunit ( dev ) ) ; #endif } return ( 0 ) ; }
Setup MSIX Interrupt resources and handlers for the VSI queues
Setup MSIX Interrupt resources and handlers for the VSI queues
/* Set the handler function */ /* Bind the vector to a CPU */