FreeBSD/Linux Kernel Cross Reference
sys/dev/ic/mfivar.h
1 /* $OpenBSD: mfivar.h,v 1.28 2006/08/31 18:18:46 marco 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 <dev/sysmon/sysmonvar.h>
19 #include <sys/envsys.h>
20
21 #define DEVNAME(_s) ((_s)->sc_dev.dv_xname)
22
23 // #define MFI_DEBUG
24 #ifdef MFI_DEBUG
25 extern uint32_t mfi_debug;
26 #define DPRINTF(x...) do { if (mfi_debug) printf(x); } while(0)
27 #define DNPRINTF(n,x...) do { if (mfi_debug & n) printf(x); } while(0)
28 #define MFI_D_CMD 0x0001
29 #define MFI_D_INTR 0x0002
30 #define MFI_D_MISC 0x0004
31 #define MFI_D_DMA 0x0008
32 #define MFI_D_IOCTL 0x0010
33 #define MFI_D_RW 0x0020
34 #define MFI_D_MEM 0x0040
35 #define MFI_D_CCB 0x0080
36 #else
37 #define DPRINTF(x...)
38 #define DNPRINTF(n,x...)
39 #endif
40
41 struct mfi_mem {
42 bus_dmamap_t am_map;
43 bus_dma_segment_t am_seg;
44 size_t am_size;
45 caddr_t am_kva;
46 };
47
48 #define MFIMEM_MAP(_am) ((_am)->am_map)
49 #define MFIMEM_DVA(_am) ((_am)->am_map->dm_segs[0].ds_addr)
50 #define MFIMEM_KVA(_am) ((void *)(_am)->am_kva)
51
52 struct mfi_prod_cons {
53 uint32_t mpc_producer;
54 uint32_t mpc_consumer;
55 uint32_t mpc_reply_q[1]; /* compensate for 1 extra reply per spec */
56 };
57
58 struct mfi_ccb {
59 struct mfi_softc *ccb_sc;
60
61 union mfi_frame *ccb_frame;
62 paddr_t ccb_pframe;
63 uint32_t ccb_frame_size;
64 uint32_t ccb_extra_frames;
65
66 struct mfi_sense *ccb_sense;
67 paddr_t ccb_psense;
68
69 bus_dmamap_t ccb_dmamap;
70
71 union mfi_sgl *ccb_sgl;
72
73 /* data for sgl */
74 void *ccb_data;
75 uint32_t ccb_len;
76
77 uint32_t ccb_direction;
78 #define MFI_DATA_NONE 0
79 #define MFI_DATA_IN 1
80 #define MFI_DATA_OUT 2
81
82 struct scsipi_xfer *ccb_xs;
83
84 void (*ccb_done)(struct mfi_ccb *);
85
86 volatile enum {
87 MFI_CCB_FREE,
88 MFI_CCB_READY,
89 MFI_CCB_DONE
90 } ccb_state;
91 uint32_t ccb_flags;
92 #define MFI_CCB_F_ERR (1<<0)
93 TAILQ_ENTRY(mfi_ccb) ccb_link;
94 };
95
96 TAILQ_HEAD(mfi_ccb_list, mfi_ccb);
97
98 struct mfi_softc {
99 struct device sc_dev;
100 struct scsipi_channel sc_chan;
101 struct scsipi_adapter sc_adapt;
102
103 void *sc_ih;
104
105 u_int32_t sc_flags;
106
107 bus_space_tag_t sc_iot;
108 bus_space_handle_t sc_ioh;
109 bus_dma_tag_t sc_dmat;
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 sysmon_envsys sc_envsys;
148 #define sc_ranges sc_envsys.sme_ranges
149 #define sc_sensor_info sc_envsys.sme_sensor_info
150 #define sc_sensor_data sc_envsys.sme_sensor_data
151
152 };
153
154 int mfi_attach(struct mfi_softc *sc);
155 int mfi_intr(void *);
Cache object: bbe3da74e16019e608ed411435abfdd5
|