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