MSI(-X) interface RFC (was: MSI prototype)

Chuck Tuffli ctuffli at gmail.com
Wed Mar 1 11:58:13 PST 2006


On 2/26/06, Matthew Dillon <dillon at xxxxxxxxxxxxxxxxxxxx> wrote:
. ..
>     I was assuming bus_alloc_sub_resource() would be where the table entry
>     number is specified / allocated / reserved.  But bus_setup_intr() would
>     be responsible for actually installing it.

Ok, something like:

struct resource *
bus_alloc_sub_resource(struct resource *parent, int rid, u_long start
        u_long end, u_long count, u_int flags);

where the parameters have similar meanings to those previously defined
except that rid now specifies the table entry. For example,

    struct resource *parent, *msix[4];
    int     vec_start;
    void    *msix_h[4];

    /* E.g. #1 - allocate 4 MSI-X vectors */
    parent = bus_alloc_resource(dev, SYS_RES_MSIX, &vec_start,
            SYS_VECTOR_MIN, SYS_VECTOR_MAX, 4/* count */, RF_ACTIVE);
    /* how to assign every other MSI-X table entry a vector */
    for (i=0; i<4; i++) {
        msix[i] = bus_alloc_sub_resource(parent, 2*i, vec_start+i,
                vec_start+i, 1, 0);
        bus_setup_intr(dev, msix[i], 0, handler, handler_arg,
                &msix_h[i], NULL);
    }
. ..
    /* E.g. #2 - allocate 2 MSI-X vectors used for 4 table entries */
    parent = bus_alloc_resource(dev, SYS_RES_MSIX, &vec_start,
            SYS_VECTOR_MIN, SYS_VECTOR_MAX, 2/* count */, RF_ACTIVE);
    /* example of vector aliasing (each vector used multiple times) */
    for (i=0; i<4; i++) {
        msix[i] = bus_alloc_sub_resource(parent, i, vec_start+(i%2),
                vec_start+(i%2), 1, 0);
        bus_setup_intr(dev, msix[i], 0, handler, handler_arg,
                &msix_h[i], NULL);
    }

MSI would look similar to the above except the rid would always be
zero because MSI only has a single table entry. If a resource count is
greater than 1, bus_setup_intr will return an error.

---chuck






More information about the Kernel mailing list