[BACK]Return to mpivar.h CVS log [TXT][DIR] Up to [local] / sys / dev / ic

Annotation of sys/dev/ic/mpivar.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: mpivar.h,v 1.22 2007/03/17 10:25:39 dlg Exp $ */
                      2:
                      3: /*
                      4:  * Copyright (c) 2005 David Gwynne <dlg@openbsd.org>
                      5:  * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
                      6:  *
                      7:  * Permission to use, copy, modify, and distribute this software for any
                      8:  * purpose with or without fee is hereby granted, provided that the above
                      9:  * copyright notice and this permission notice appear in all copies.
                     10:  *
                     11:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     12:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     13:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     14:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     15:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     16:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     17:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     18:  */
                     19:
                     20:
                     21: /* #define MPI_DEBUG */
                     22: #ifdef MPI_DEBUG
                     23: extern uint32_t                        mpi_debug;
                     24: #define DPRINTF(x...)          do { if (mpi_debug) printf(x); } while(0)
                     25: #define DNPRINTF(n,x...)       do { if (mpi_debug & (n)) printf(x); } while(0)
                     26: #define        MPI_D_CMD               0x0001
                     27: #define        MPI_D_INTR              0x0002
                     28: #define        MPI_D_MISC              0x0004
                     29: #define        MPI_D_DMA               0x0008
                     30: #define        MPI_D_IOCTL             0x0010
                     31: #define        MPI_D_RW                0x0020
                     32: #define        MPI_D_MEM               0x0040
                     33: #define        MPI_D_CCB               0x0080
                     34: #define        MPI_D_PPR               0x0100
                     35: #define        MPI_D_RAID              0x0200
                     36: #define        MPI_D_EVT               0x0400
                     37: #else
                     38: #define DPRINTF(x...)
                     39: #define DNPRINTF(n,x...)
                     40: #endif
                     41:
                     42: #define MPI_REQUEST_SIZE       512
                     43: #define MPI_REPLY_SIZE         128
                     44: #define MPI_REPLY_COUNT                (PAGE_SIZE / MPI_REPLY_SIZE)
                     45:
                     46: /*
                     47:  * this is the max number of sge's we can stuff in a request frame:
                     48:  * sizeof(scsi_io) + sizeof(sense) + sizeof(sge) * 32 = MPI_REQUEST_SIZE
                     49:  */
                     50: #define MPI_MAX_SGL            36
                     51:
                     52: struct mpi_dmamem {
                     53:        bus_dmamap_t            mdm_map;
                     54:        bus_dma_segment_t       mdm_seg;
                     55:        size_t                  mdm_size;
                     56:        caddr_t                 mdm_kva;
                     57: };
                     58: #define MPI_DMA_MAP(_mdm)      ((_mdm)->mdm_map)
                     59: #define MPI_DMA_DVA(_mdm)      ((_mdm)->mdm_map->dm_segs[0].ds_addr)
                     60: #define MPI_DMA_KVA(_mdm)      ((void *)(_mdm)->mdm_kva)
                     61:
                     62: struct mpi_ccb_bundle {
                     63:        struct mpi_msg_scsi_io  mcb_io; /* sgl must follow */
                     64:        struct mpi_sge          mcb_sgl[MPI_MAX_SGL];
                     65:        struct scsi_sense_data  mcb_sense;
                     66: } __packed;
                     67:
                     68: struct mpi_softc;
                     69:
                     70: struct mpi_rcb {
                     71:        void                    *rcb_reply;
                     72:        u_int32_t               rcb_reply_dva;
                     73: };
                     74:
                     75: struct mpi_ccb {
                     76:        struct mpi_softc        *ccb_sc;
                     77:        int                     ccb_id;
                     78:
                     79:        struct scsi_xfer        *ccb_xs;
                     80:        bus_dmamap_t            ccb_dmamap;
                     81:
                     82:        bus_addr_t              ccb_offset;
                     83:        void                    *ccb_cmd;
                     84:        bus_addr_t              ccb_cmd_dva;
                     85:
                     86:        volatile enum {
                     87:                MPI_CCB_FREE,
                     88:                MPI_CCB_READY,
                     89:                MPI_CCB_QUEUED
                     90:        }                       ccb_state;
                     91:        void                    (*ccb_done)(struct mpi_ccb *);
                     92:        struct mpi_rcb          *ccb_rcb;
                     93:
                     94:        TAILQ_ENTRY(mpi_ccb)    ccb_link;
                     95: };
                     96:
                     97: TAILQ_HEAD(mpi_ccb_list, mpi_ccb);
                     98:
                     99: struct mpi_softc {
                    100:        struct device           sc_dev;
                    101:        struct scsi_link        sc_link;
                    102:
                    103:        int                     sc_flags;
                    104: #define MPI_F_SPI                      (1<<0)
                    105: #define MPI_F_RAID                     (1<<1)
                    106:
                    107:        struct scsibus_softc    *sc_scsibus;
                    108:
                    109:        bus_space_tag_t         sc_iot;
                    110:        bus_space_handle_t      sc_ioh;
                    111:        bus_size_t              sc_ios;
                    112:        bus_dma_tag_t           sc_dmat;
                    113:
                    114:        u_int8_t                sc_porttype;
                    115:        int                     sc_maxcmds;
                    116:        int                     sc_maxchdepth;
                    117:        int                     sc_first_sgl_len;
                    118:        int                     sc_chain_len;
                    119:        int                     sc_max_sgl_len;
                    120:
                    121:        int                     sc_buswidth;
                    122:        int                     sc_target;
                    123:        int                     sc_ioc_number;
                    124:
                    125:        struct mpi_dmamem       *sc_requests;
                    126:        struct mpi_ccb          *sc_ccbs;
                    127:        struct mpi_ccb_list     sc_ccb_free;
                    128:
                    129:        struct mpi_dmamem       *sc_replies;
                    130:        struct mpi_rcb          *sc_rcbs;
                    131:
                    132:        size_t                  sc_fw_len;
                    133:        struct mpi_dmamem       *sc_fw;
                    134: };
                    135:
                    136: int    mpi_attach(struct mpi_softc *);
                    137: void   mpi_detach(struct mpi_softc *);
                    138:
                    139: int    mpi_intr(void *);

CVSweb