FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_setup_msix:	Allocate MSI-x vectors
 * @sc:					adapter soft state
 */
Allocate MSI-x vectors
@sc:                                 adapter soft state
Allocate MSI - x vectors @sc : adapter soft state
static int
mrsas_setup_msix(struct mrsas_softc *sc)
{
	int i;
	for (i = 0; i < sc->msix_vectors; i++) {
		sc->irq_context[i].sc = sc;
		sc->irq_context[i].MSIxIndex = i;
		sc->irq_id[i] = i + 1;
		sc->mrsas_irq[i] = bus_alloc_resource_any
		    (sc->mrsas_dev, SYS_RES_IRQ, &sc->irq_id[i]
		    ,RF_ACTIVE);
		if (sc->mrsas_irq[i] == NULL) {
			device_printf(sc->mrsas_dev, "Can't allocate MSI-x\n");
			goto irq_alloc_failed;
		}
		if (bus_setup_intr(sc->mrsas_dev,
		    sc->mrsas_irq[i],
		    INTR_MPSAFE | INTR_TYPE_CAM,
		    NULL, mrsas_isr, &sc->irq_context[i],
		    &sc->intr_handle[i])) {
			device_printf(sc->mrsas_dev,
			    "Cannot set up MSI-x interrupt handler\n");
			goto irq_alloc_failed;
		}
	}
	return SUCCESS;
irq_alloc_failed:
	mrsas_teardown_intr(sc);
	return (FAIL);
}
static int mrsas_setup_msix ( struct mrsas_softc * sc ) { int i ; for ( i = 0 ; i < sc -> msix_vectors ; i ++ ) { sc -> irq_context [ i ] . sc = sc ; sc -> irq_context [ i ] . MSIxIndex = i ; sc -> irq_id [ i ] = i + 1 ; sc -> mrsas_irq [ i ] = bus_alloc_resource_any ( sc -> mrsas_dev , SYS_RES_IRQ , & sc -> irq_id [ i ] , RF_ACTIVE ) ; if ( sc -> mrsas_irq [ i ] == NULL ) { device_printf ( sc -> mrsas_dev , " \n " ) ; goto irq_alloc_failed ; } if ( bus_setup_intr ( sc -> mrsas_dev , sc -> mrsas_irq [ i ] , INTR_MPSAFE | INTR_TYPE_CAM , NULL , mrsas_isr , & sc -> irq_context [ i ] , & sc -> intr_handle [ i ] ) ) { device_printf ( sc -> mrsas_dev , " \n " ) ; goto irq_alloc_failed ; } } return SUCCESS ; irq_alloc_failed : mrsas_teardown_intr ( sc ) ; return ( FAIL ) ; }
mrsas_setup_msix:    Allocate MSI-x vectors
 @sc:                                 adapter soft state
mrsas_setup_msix : Allocate MSI - x vectors @sc : adapter soft state