FreeBSD/sys/dev/bxe/bxe.c
/*
 * Enables interrupts and attach to the ISR.
 *
 * When using multiple MSI/MSI-X vectors the first vector
 * is used for slowpath operations while all remaining
 * vectors are used for fastpath operations.  If only a
 * single MSI/MSI-X vector is used (SINGLE_ISR) then the
 * ISR must look for both slowpath and fastpath completions.
 */
Enables interrupts and attach to the ISR.
When using multiple MSI/MSI-X vectors the first vector
is used for slowpath operations while all remaining
vectors are used for fastpath operations.  If only a
single MSI/MSI-X vector is used (SINGLE_ISR) then the
ISR must look for both slowpath and fastpath completions.
Enables interrupts and attach to the ISR . When using multiple MSI / MSI - X vectors the first vector is used for slowpath operations while all remaining vectors are used for fastpath operations . If only a single MSI / MSI - X vector is used ( SINGLE_ISR ) then the ISR must look for both slowpath and fastpath completions .
static int
bxe_interrupt_attach(struct bxe_softc *sc)
{
    struct bxe_fastpath *fp;
    int rc = 0;
    int i;
    snprintf(sc->sp_tq_name, sizeof(sc->sp_tq_name),
             "bxe%d_sp_tq", sc->unit);
    TASK_INIT(&sc->sp_tq_task, 0, bxe_handle_sp_tq, sc);
    sc->sp_tq = taskqueue_create_fast(sc->sp_tq_name, M_NOWAIT,
                                      taskqueue_thread_enqueue,
                                      &sc->sp_tq);
    taskqueue_start_threads(&sc->sp_tq, 1, PWAIT, 
                            "%s", sc->sp_tq_name);
    for (i = 0; i < sc->num_queues; i++) {
        fp = &sc->fp[i];
        snprintf(fp->tq_name, sizeof(fp->tq_name),
                 "bxe%d_fp%d_tq", sc->unit, i);
        TASK_INIT(&fp->tq_task, 0, bxe_handle_fp_tq, fp);
        fp->tq = taskqueue_create_fast(fp->tq_name, M_NOWAIT,
                                       taskqueue_thread_enqueue,
                                       &fp->tq);
        taskqueue_start_threads(&fp->tq, 1, PI_NET, 
                                "%s", fp->tq_name);
    }
    if (sc->interrupt_mode == INTR_MODE_MSIX) {
        BLOGD(sc, DBG_LOAD, "Enabling slowpath MSI-X[0] vector\n");
        if ((rc = bus_setup_intr(sc->dev, sc->intr[0].resource,
                                 (INTR_TYPE_NET | INTR_MPSAFE),
                                 NULL, bxe_intr_sp, sc,
                                 &sc->intr[0].tag)) != 0) {
            BLOGE(sc, "Failed to allocate MSI-X[0] vector (%d)\n", rc);
            goto bxe_interrupt_attach_exit;
        }
        bus_describe_intr(sc->dev, sc->intr[0].resource,
                          sc->intr[0].tag, "sp");
        for (i = 0; i < sc->num_queues; i++) {
            fp = &sc->fp[i];
            BLOGD(sc, DBG_LOAD, "Enabling MSI-X[%d] vector\n", (i + 1));
            if ((rc = bus_setup_intr(sc->dev, sc->intr[i + 1].resource,
                                     (INTR_TYPE_NET | INTR_MPSAFE),
                                     NULL, bxe_intr_fp, fp,
                                     &sc->intr[i + 1].tag)) != 0) {
                BLOGE(sc, "Failed to allocate MSI-X[%d] vector (%d)\n",
                      (i + 1), rc);
                goto bxe_interrupt_attach_exit;
            }
            bus_describe_intr(sc->dev, sc->intr[i + 1].resource,
                              sc->intr[i + 1].tag, "fp%02d", i);
            if (sc->num_queues > 1) {
                bus_bind_intr(sc->dev, sc->intr[i + 1].resource, i);
            }
            fp->state = BXE_FP_STATE_IRQ;
        }
    } else if (sc->interrupt_mode == INTR_MODE_MSI) {
        BLOGD(sc, DBG_LOAD, "Enabling MSI[0] vector\n");
        if ((rc = bus_setup_intr(sc->dev, sc->intr[0].resource,
                                 (INTR_TYPE_NET | INTR_MPSAFE),
                                 NULL, bxe_intr_legacy, sc,
                                 &sc->intr[0].tag)) != 0) {
            BLOGE(sc, "Failed to allocate MSI[0] vector (%d)\n", rc);
            goto bxe_interrupt_attach_exit;
        }
    } else { 
        BLOGD(sc, DBG_LOAD, "Enabling INTx interrupts\n");
        if ((rc = bus_setup_intr(sc->dev, sc->intr[0].resource,
                                 (INTR_TYPE_NET | INTR_MPSAFE),
                                 NULL, bxe_intr_legacy, sc,
                                 &sc->intr[0].tag)) != 0) {
            BLOGE(sc, "Failed to allocate INTx interrupt (%d)\n", rc);
            goto bxe_interrupt_attach_exit;
        }
    }
bxe_interrupt_attach_exit:
    return (rc);
}
static int bxe_interrupt_attach ( struct bxe_softc * sc ) { struct bxe_fastpath * fp ; int rc = 0 ; int i ; snprintf ( sc -> sp_tq_name , sizeof ( sc -> sp_tq_name ) , " " , sc -> unit ) ; TASK_INIT ( & sc -> sp_tq_task , 0 , bxe_handle_sp_tq , sc ) ; sc -> sp_tq = taskqueue_create_fast ( sc -> sp_tq_name , M_NOWAIT , taskqueue_thread_enqueue , & sc -> sp_tq ) ; taskqueue_start_threads ( & sc -> sp_tq , 1 , PWAIT , " " , sc -> sp_tq_name ) ; for ( i = 0 ; i < sc -> num_queues ; i ++ ) { fp = & sc -> fp [ i ] ; snprintf ( fp -> tq_name , sizeof ( fp -> tq_name ) , " " , sc -> unit , i ) ; TASK_INIT ( & fp -> tq_task , 0 , bxe_handle_fp_tq , fp ) ; fp -> tq = taskqueue_create_fast ( fp -> tq_name , M_NOWAIT , taskqueue_thread_enqueue , & fp -> tq ) ; taskqueue_start_threads ( & fp -> tq , 1 , PI_NET , " " , fp -> tq_name ) ; } if ( sc -> interrupt_mode == INTR_MODE_MSIX ) { BLOGD ( sc , DBG_LOAD , " \n " ) ; if ( ( rc = bus_setup_intr ( sc -> dev , sc -> intr [ 0 ] . resource , ( INTR_TYPE_NET | INTR_MPSAFE ) , NULL , bxe_intr_sp , sc , & sc -> intr [ 0 ] . tag ) ) != 0 ) { BLOGE ( sc , " \n " , rc ) ; goto bxe_interrupt_attach_exit ; } bus_describe_intr ( sc -> dev , sc -> intr [ 0 ] . resource , sc -> intr [ 0 ] . tag , " " ) ; for ( i = 0 ; i < sc -> num_queues ; i ++ ) { fp = & sc -> fp [ i ] ; BLOGD ( sc , DBG_LOAD , " \n " , ( i + 1 ) ) ; if ( ( rc = bus_setup_intr ( sc -> dev , sc -> intr [ i + 1 ] . resource , ( INTR_TYPE_NET | INTR_MPSAFE ) , NULL , bxe_intr_fp , fp , & sc -> intr [ i + 1 ] . tag ) ) != 0 ) { BLOGE ( sc , " \n " , ( i + 1 ) , rc ) ; goto bxe_interrupt_attach_exit ; } bus_describe_intr ( sc -> dev , sc -> intr [ i + 1 ] . resource , sc -> intr [ i + 1 ] . tag , " " , i ) ; if ( sc -> num_queues > 1 ) { bus_bind_intr ( sc -> dev , sc -> intr [ i + 1 ] . resource , i ) ; } fp -> state = BXE_FP_STATE_IRQ ; } } else if ( sc -> interrupt_mode == INTR_MODE_MSI ) { BLOGD ( sc , DBG_LOAD , " \n " ) ; if ( ( rc = bus_setup_intr ( sc -> dev , sc -> intr [ 0 ] . resource , ( INTR_TYPE_NET | INTR_MPSAFE ) , NULL , bxe_intr_legacy , sc , & sc -> intr [ 0 ] . tag ) ) != 0 ) { BLOGE ( sc , " \n " , rc ) ; goto bxe_interrupt_attach_exit ; } } else { BLOGD ( sc , DBG_LOAD , " \n " ) ; if ( ( rc = bus_setup_intr ( sc -> dev , sc -> intr [ 0 ] . resource , ( INTR_TYPE_NET | INTR_MPSAFE ) , NULL , bxe_intr_legacy , sc , & sc -> intr [ 0 ] . tag ) ) != 0 ) { BLOGE ( sc , " \n " , rc ) ; goto bxe_interrupt_attach_exit ; } } bxe_interrupt_attach_exit : return ( rc ) ; }
Enables interrupts and attach to the ISR.
Enables interrupts and attach to the ISR .
/* lower priority */ /* higher priority */ /* setup interrupt handlers */ /*
         * Setup the interrupt handler. Note that we pass the driver instance
         * to the interrupt handler for the slowpath.
         */ /* bus_bind_intr(sc->dev, sc->intr[0].resource, 0); */ /* initialize the fastpath vectors (note the first was used for sp) */ /*
             * Setup the interrupt handler. Note that we pass the
             * fastpath context to the interrupt handler in this
             * case.
             */ /* bind the fastpath instance to a cpu */ /*
         * Setup the interrupt handler. Note that we pass the
         * driver instance to the interrupt handler which
         * will handle both the slowpath and fastpath.
         */ /* (sc->interrupt_mode == INTR_MODE_INTX) */ /*
         * Setup the interrupt handler. Note that we pass the
         * driver instance to the interrupt handler which
         * will handle both the slowpath and fastpath.
         */