root/dev/ic/mfivar.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


    1 /* $OpenBSD: mfivar.h,v 1.30 2007/03/22 16:55:31 deraadt Exp $ */
    2 /*
    3  * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
    4  *
    5  * Permission to use, copy, modify, and distribute this software for any
    6  * purpose with or without fee is hereby granted, provided that the above
    7  * copyright notice and this permission notice appear in all copies.
    8  *
    9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   16  */
   17 
   18 #include <sys/sensors.h>
   19 
   20 #define DEVNAME(_s)     ((_s)->sc_dev.dv_xname)
   21 
   22 /* #define MFI_DEBUG */
   23 #ifdef MFI_DEBUG
   24 extern uint32_t                 mfi_debug;
   25 #define DPRINTF(x...)           do { if (mfi_debug) printf(x); } while(0)
   26 #define DNPRINTF(n,x...)        do { if (mfi_debug & n) printf(x); } while(0)
   27 #define MFI_D_CMD               0x0001
   28 #define MFI_D_INTR              0x0002
   29 #define MFI_D_MISC              0x0004
   30 #define MFI_D_DMA               0x0008
   31 #define MFI_D_IOCTL             0x0010
   32 #define MFI_D_RW                0x0020
   33 #define MFI_D_MEM               0x0040
   34 #define MFI_D_CCB               0x0080
   35 #else
   36 #define DPRINTF(x...)
   37 #define DNPRINTF(n,x...)
   38 #endif
   39 
   40 struct mfi_mem {
   41         bus_dmamap_t            am_map;
   42         bus_dma_segment_t       am_seg;
   43         size_t                  am_size;
   44         caddr_t                 am_kva;
   45 };
   46 
   47 #define MFIMEM_MAP(_am)         ((_am)->am_map)
   48 #define MFIMEM_DVA(_am)         ((_am)->am_map->dm_segs[0].ds_addr)
   49 #define MFIMEM_KVA(_am)         ((void *)(_am)->am_kva)
   50 
   51 struct mfi_prod_cons {
   52         uint32_t                mpc_producer;
   53         uint32_t                mpc_consumer;
   54         uint32_t                mpc_reply_q[1]; /* compensate for 1 extra reply per spec */
   55 };
   56 
   57 struct mfi_ccb {
   58         struct mfi_softc        *ccb_sc;
   59 
   60         union mfi_frame         *ccb_frame;
   61         paddr_t                 ccb_pframe;
   62         uint32_t                ccb_frame_size;
   63         uint32_t                ccb_extra_frames;
   64 
   65         struct mfi_sense        *ccb_sense;
   66         paddr_t                 ccb_psense;
   67 
   68         bus_dmamap_t            ccb_dmamap;
   69 
   70         union mfi_sgl           *ccb_sgl;
   71 
   72         /* data for sgl */
   73         void                    *ccb_data;
   74         uint32_t                ccb_len;
   75 
   76         uint32_t                ccb_direction;
   77 #define MFI_DATA_NONE   0
   78 #define MFI_DATA_IN     1
   79 #define MFI_DATA_OUT    2
   80 
   81         struct scsi_xfer        *ccb_xs;
   82 
   83         void                    (*ccb_done)(struct mfi_ccb *);
   84 
   85         volatile enum {
   86                 MFI_CCB_FREE,
   87                 MFI_CCB_READY,
   88                 MFI_CCB_DONE
   89         }                       ccb_state;
   90         uint32_t                ccb_flags;
   91 #define MFI_CCB_F_ERR                   (1<<0)
   92         TAILQ_ENTRY(mfi_ccb)    ccb_link;
   93 };
   94 
   95 TAILQ_HEAD(mfi_ccb_list, mfi_ccb);
   96 
   97 struct mfi_softc {
   98         struct device           sc_dev;
   99         void                    *sc_ih;
  100         struct scsi_link        sc_link;
  101 
  102         u_int32_t               sc_flags;
  103 
  104         bus_space_tag_t         sc_iot;
  105         bus_space_handle_t      sc_ioh;
  106         bus_dma_tag_t           sc_dmat;
  107 
  108         /* mgmt lock */
  109         struct rwlock           sc_lock;
  110 
  111         /* save some useful information for logical drives that is missing
  112          * in sc_ld_list
  113          */
  114         struct {
  115                 uint32_t        ld_present;
  116                 char            ld_dev[16];     /* device name sd? */
  117         }                       sc_ld[MFI_MAX_LD];
  118 
  119         /* scsi ioctl from sd device */
  120         int                     (*sc_ioctl)(struct device *, u_long, caddr_t);
  121 
  122         /* firmware determined max, totals and other information*/
  123         uint32_t                sc_max_cmds;
  124         uint32_t                sc_max_sgl;
  125         uint32_t                sc_max_ld;
  126         uint32_t                sc_ld_cnt;
  127         /* XXX these struct should be local to mgmt function */
  128         struct mfi_ctrl_info    sc_info;
  129         struct mfi_ld_list      sc_ld_list;
  130         struct mfi_ld_details   sc_ld_details;
  131 
  132         /* all commands */
  133         struct mfi_ccb          *sc_ccb;
  134 
  135         /* producer/consumer pointers and reply queue */
  136         struct mfi_mem          *sc_pcq;
  137 
  138         /* frame memory */
  139         struct mfi_mem          *sc_frames;
  140         uint32_t                sc_frames_size;
  141 
  142         /* sense memory */
  143         struct mfi_mem          *sc_sense;
  144 
  145         struct mfi_ccb_list     sc_ccb_freeq;
  146 
  147         struct ksensor          *sc_sensors;
  148         struct ksensordev       sc_sensordev;
  149 };
  150 
  151 int     mfi_attach(struct mfi_softc *sc);
  152 int     mfi_intr(void *);

/* [<][>][^][v][top][bottom][index][help] */