arcmsrvar.h revision 1.12.8.3 1 1.12.8.3 skrll /* $NetBSD: arcmsrvar.h,v 1.12.8.3 2008/09/04 08:46:44 skrll Exp $ */
2 1.12.8.2 skrll /* Derived from $OpenBSD: arc.c,v 1.68 2007/10/27 03:28:27 dlg Exp $ */
3 1.12.8.2 skrll
4 1.12.8.2 skrll /*
5 1.12.8.2 skrll * Copyright (c) 2007 Juan Romero Pardines <xtraeme (at) netbsd.org>
6 1.12.8.2 skrll * Copyright (c) 2006 David Gwynne <dlg (at) openbsd.org>
7 1.12.8.2 skrll *
8 1.12.8.2 skrll * Permission to use, copy, modify, and distribute this software for any
9 1.12.8.2 skrll * purpose with or without fee is hereby granted, provided that the above
10 1.12.8.2 skrll * copyright notice and this permission notice appear in all copies.
11 1.12.8.2 skrll *
12 1.12.8.2 skrll * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 1.12.8.2 skrll * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 1.12.8.2 skrll * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 1.12.8.2 skrll * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 1.12.8.2 skrll * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 1.12.8.2 skrll * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 1.12.8.2 skrll * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 1.12.8.2 skrll */
20 1.12.8.2 skrll
21 1.12.8.2 skrll #ifndef _PCI_ARCMSRVAR_H_
22 1.12.8.2 skrll #define _PCI_ARCMSRVAR_H_
23 1.12.8.2 skrll
24 1.12.8.2 skrll #define ARC_PCI_BAR PCI_MAPREG_START
25 1.12.8.2 skrll
26 1.12.8.2 skrll #define ARC_REG_INB_MSG0 0x0010
27 1.12.8.2 skrll #define ARC_REG_INB_MSG0_NOP (0x00000000)
28 1.12.8.2 skrll #define ARC_REG_INB_MSG0_GET_CONFIG (0x00000001)
29 1.12.8.2 skrll #define ARC_REG_INB_MSG0_SET_CONFIG (0x00000002)
30 1.12.8.2 skrll #define ARC_REG_INB_MSG0_ABORT_CMD (0x00000003)
31 1.12.8.2 skrll #define ARC_REG_INB_MSG0_STOP_BGRB (0x00000004)
32 1.12.8.2 skrll #define ARC_REG_INB_MSG0_FLUSH_CACHE (0x00000005)
33 1.12.8.2 skrll #define ARC_REG_INB_MSG0_START_BGRB (0x00000006)
34 1.12.8.2 skrll #define ARC_REG_INB_MSG0_CHK331PENDING (0x00000007)
35 1.12.8.2 skrll #define ARC_REG_INB_MSG0_SYNC_TIMER (0x00000008)
36 1.12.8.2 skrll #define ARC_REG_INB_MSG1 0x0014
37 1.12.8.2 skrll #define ARC_REG_OUTB_ADDR0 0x0018
38 1.12.8.2 skrll #define ARC_REG_OUTB_ADDR1 0x001c
39 1.12.8.2 skrll #define ARC_REG_OUTB_ADDR1_FIRMWARE_OK (1<<31)
40 1.12.8.2 skrll #define ARC_REG_INB_DOORBELL 0x0020
41 1.12.8.2 skrll #define ARC_REG_INB_DOORBELL_WRITE_OK (1<<0)
42 1.12.8.2 skrll #define ARC_REG_INB_DOORBELL_READ_OK (1<<1)
43 1.12.8.2 skrll #define ARC_REG_OUTB_DOORBELL 0x002c
44 1.12.8.2 skrll #define ARC_REG_OUTB_DOORBELL_WRITE_OK (1<<0)
45 1.12.8.2 skrll #define ARC_REG_OUTB_DOORBELL_READ_OK (1<<1)
46 1.12.8.2 skrll #define ARC_REG_INTRSTAT 0x0030
47 1.12.8.2 skrll #define ARC_REG_INTRSTAT_MSG0 (1<<0)
48 1.12.8.2 skrll #define ARC_REG_INTRSTAT_MSG1 (1<<1)
49 1.12.8.2 skrll #define ARC_REG_INTRSTAT_DOORBELL (1<<2)
50 1.12.8.2 skrll #define ARC_REG_INTRSTAT_POSTQUEUE (1<<3)
51 1.12.8.2 skrll #define ARC_REG_INTRSTAT_PCI (1<<4)
52 1.12.8.2 skrll #define ARC_REG_INTRMASK 0x0034
53 1.12.8.2 skrll #define ARC_REG_INTRMASK_MSG0 (1<<0)
54 1.12.8.2 skrll #define ARC_REG_INTRMASK_MSG1 (1<<1)
55 1.12.8.2 skrll #define ARC_REG_INTRMASK_DOORBELL (1<<2)
56 1.12.8.2 skrll #define ARC_REG_INTRMASK_POSTQUEUE (1<<3)
57 1.12.8.2 skrll #define ARC_REG_INTRMASK_PCI (1<<4)
58 1.12.8.2 skrll #define ARC_REG_POST_QUEUE 0x0040
59 1.12.8.2 skrll #define ARC_REG_POST_QUEUE_ADDR_SHIFT 5
60 1.12.8.2 skrll #define ARC_REG_POST_QUEUE_IAMBIOS (1<<30)
61 1.12.8.2 skrll #define ARC_REG_POST_QUEUE_BIGFRAME (1<<31)
62 1.12.8.2 skrll #define ARC_REG_REPLY_QUEUE 0x0044
63 1.12.8.2 skrll #define ARC_REG_REPLY_QUEUE_ADDR_SHIFT 5
64 1.12.8.2 skrll #define ARC_REG_REPLY_QUEUE_ERR (1<<28)
65 1.12.8.2 skrll #define ARC_REG_REPLY_QUEUE_IAMBIOS (1<<30)
66 1.12.8.2 skrll #define ARC_REG_MSGBUF 0x0a00
67 1.12.8.2 skrll #define ARC_REG_MSGBUF_LEN 1024
68 1.12.8.2 skrll #define ARC_REG_IOC_WBUF_LEN 0x0e00
69 1.12.8.2 skrll #define ARC_REG_IOC_WBUF 0x0e04
70 1.12.8.2 skrll #define ARC_REG_IOC_RBUF_LEN 0x0f00
71 1.12.8.2 skrll #define ARC_REG_IOC_RBUF 0x0f04
72 1.12.8.2 skrll #define ARC_REG_IOC_RWBUF_MAXLEN 124 /* for both RBUF and WBUF */
73 1.12.8.2 skrll
74 1.12.8.2 skrll struct arc_msg_firmware_info {
75 1.12.8.2 skrll uint32_t signature;
76 1.12.8.2 skrll #define ARC_FWINFO_SIGNATURE_GET_CONFIG (0x87974060)
77 1.12.8.2 skrll uint32_t request_len;
78 1.12.8.2 skrll uint32_t queue_len;
79 1.12.8.2 skrll uint32_t sdram_size;
80 1.12.8.2 skrll uint32_t sata_ports;
81 1.12.8.2 skrll uint8_t vendor[40];
82 1.12.8.2 skrll uint8_t model[8];
83 1.12.8.2 skrll uint8_t fw_version[16];
84 1.12.8.2 skrll uint8_t device_map[16];
85 1.12.8.2 skrll } __packed;
86 1.12.8.2 skrll
87 1.12.8.2 skrll struct arc_msg_scsicmd {
88 1.12.8.2 skrll uint8_t bus;
89 1.12.8.2 skrll uint8_t target;
90 1.12.8.2 skrll uint8_t lun;
91 1.12.8.2 skrll uint8_t function;
92 1.12.8.2 skrll
93 1.12.8.2 skrll uint8_t cdb_len;
94 1.12.8.2 skrll uint8_t sgl_len;
95 1.12.8.2 skrll uint8_t flags;
96 1.12.8.2 skrll #define ARC_MSG_SCSICMD_FLAG_SGL_BSIZE_512 (1<<0)
97 1.12.8.2 skrll #define ARC_MSG_SCSICMD_FLAG_FROM_BIOS (1<<1)
98 1.12.8.2 skrll #define ARC_MSG_SCSICMD_FLAG_WRITE (1<<2)
99 1.12.8.2 skrll #define ARC_MSG_SCSICMD_FLAG_SIMPLEQ (0x00)
100 1.12.8.2 skrll #define ARC_MSG_SCSICMD_FLAG_HEADQ (0x08)
101 1.12.8.2 skrll #define ARC_MSG_SCSICMD_FLAG_ORDERQ (0x10)
102 1.12.8.2 skrll uint8_t reserved;
103 1.12.8.2 skrll
104 1.12.8.2 skrll uint32_t context;
105 1.12.8.2 skrll uint32_t data_len;
106 1.12.8.2 skrll
107 1.12.8.2 skrll #define ARC_MSG_CDBLEN 16
108 1.12.8.2 skrll uint8_t cdb[ARC_MSG_CDBLEN];
109 1.12.8.2 skrll
110 1.12.8.2 skrll uint8_t status;
111 1.12.8.2 skrll #define ARC_MSG_STATUS_SELTIMEOUT 0xf0
112 1.12.8.2 skrll #define ARC_MSG_STATUS_ABORTED 0xf1
113 1.12.8.2 skrll #define ARC_MSG_STATUS_INIT_FAIL 0xf2
114 1.12.8.2 skrll #define ARC_MSG_SENSELEN 15
115 1.12.8.2 skrll uint8_t sense_data[ARC_MSG_SENSELEN];
116 1.12.8.2 skrll
117 1.12.8.2 skrll /* followed by an sgl */
118 1.12.8.2 skrll } __packed;
119 1.12.8.2 skrll
120 1.12.8.2 skrll struct arc_sge {
121 1.12.8.2 skrll uint32_t sg_hdr;
122 1.12.8.2 skrll #define ARC_SGE_64BIT (1<<24)
123 1.12.8.2 skrll uint32_t sg_lo_addr;
124 1.12.8.2 skrll uint32_t sg_hi_addr;
125 1.12.8.2 skrll } __packed;
126 1.12.8.2 skrll
127 1.12.8.2 skrll #define ARC_MAX_TARGET 16
128 1.12.8.2 skrll #define ARC_MAX_LUN 8
129 1.12.8.2 skrll #define ARC_MAX_IOCMDLEN 512
130 1.12.8.2 skrll #define ARC_BLOCKSIZE 512
131 1.12.8.2 skrll
132 1.12.8.2 skrll /*
133 1.12.8.2 skrll * the firmware deals with up to 256 or 512 byte command frames.
134 1.12.8.2 skrll */
135 1.12.8.2 skrll
136 1.12.8.2 skrll /*
137 1.12.8.2 skrll * sizeof(struct arc_msg_scsicmd) + (sizeof(struct arc_sge) * 38) == 508.
138 1.12.8.2 skrll */
139 1.12.8.2 skrll #define ARC_SGL_MAXLEN 38
140 1.12.8.2 skrll /*
141 1.12.8.2 skrll * sizeof(struct arc_msg_scsicmd) + (sizeof(struct arc_sge) * 17) == 252.
142 1.12.8.2 skrll */
143 1.12.8.2 skrll #define ARC_SGL_256LEN 17
144 1.12.8.2 skrll
145 1.12.8.2 skrll struct arc_io_cmd {
146 1.12.8.2 skrll struct arc_msg_scsicmd cmd;
147 1.12.8.2 skrll struct arc_sge sgl[ARC_SGL_MAXLEN];
148 1.12.8.2 skrll } __packed;
149 1.12.8.2 skrll
150 1.12.8.2 skrll /*
151 1.12.8.2 skrll * definitions of the firmware commands sent via the doorbells.
152 1.12.8.2 skrll */
153 1.12.8.2 skrll struct arc_fw_hdr {
154 1.12.8.2 skrll uint8_t byte1;
155 1.12.8.2 skrll uint8_t byte2;
156 1.12.8.2 skrll uint8_t byte3;
157 1.12.8.2 skrll } __packed;
158 1.12.8.2 skrll
159 1.12.8.2 skrll struct arc_fw_bufhdr {
160 1.12.8.2 skrll struct arc_fw_hdr hdr;
161 1.12.8.2 skrll uint16_t len;
162 1.12.8.2 skrll } __packed;
163 1.12.8.2 skrll
164 1.12.8.2 skrll /* Firmware command codes */
165 1.12.8.2 skrll #define ARC_FW_CHECK_PASS 0x14 /* opcode + 1 byte length + password */
166 1.12.8.2 skrll #define ARC_FW_GETEVENTS 0x1a /* opcode + 1 byte for page 0/1/2/3 */
167 1.12.8.2 skrll #define ARC_FW_GETHWMON 0x1b /* opcode + arc_fw_hwmon */
168 1.12.8.2 skrll #define ARC_FW_RAIDINFO 0x20 /* opcode + raid# */
169 1.12.8.2 skrll #define ARC_FW_VOLINFO 0x21 /* opcode + vol# */
170 1.12.8.2 skrll #define ARC_FW_DISKINFO 0x22 /* opcode + physdisk# */
171 1.12.8.2 skrll #define ARC_FW_SYSINFO 0x23 /* opcode. reply is fw_sysinfo */
172 1.12.8.2 skrll #define ARC_FW_CLEAREVENTS 0x24 /* opcode only */
173 1.12.8.2 skrll #define ARC_FW_MUTE_ALARM 0x30 /* opcode only */
174 1.12.8.2 skrll #define ARC_FW_SET_ALARM 0x31 /* opcode + 1 byte for setting */
175 1.12.8.2 skrll #define ARC_FW_SET_ALARM_DISABLE 0x00
176 1.12.8.2 skrll #define ARC_FW_SET_ALARM_ENABLE 0x01
177 1.12.8.2 skrll #define ARC_FW_SET_PASS 0x32 /* opcode + 1 byte length + password */
178 1.12.8.2 skrll #define ARC_FW_REBUILD_PRIO 0x34 /* Rebuild priority for disks */
179 1.12.8.2 skrll #define ARC_FW_REBUILD_PRIO_ULTRALOW (1<<0)
180 1.12.8.2 skrll #define ARC_FW_REBUILD_PRIO_LOW (1<<1)
181 1.12.8.2 skrll #define ARC_FW_REBUILD_PRIO_NORMAL (1<<2)
182 1.12.8.2 skrll #define ARC_FW_REBUILD_PRIO_HIGH (1<<3)
183 1.12.8.2 skrll #define ARC_FW_SET_MAXATA_MODE 0x35 /* opcode + 1 byte mode */
184 1.12.8.2 skrll #define ARC_FW_SET_MAXATA_MODE_133 (1<<0)
185 1.12.8.2 skrll #define ARC_FW_SET_MAXATA_MODE_100 (1<<1)
186 1.12.8.2 skrll #define ARC_FW_SET_MAXATA_MODE_66 (1<<2)
187 1.12.8.2 skrll #define ARC_FW_SET_MAXATA_MODE_33 (1<<3)
188 1.12.8.2 skrll #define ARC_FW_NOP 0x38 /* opcode only */
189 1.12.8.2 skrll /*
190 1.12.8.2 skrll * Structure for ARC_FW_CREATE_PASSTHRU:
191 1.12.8.2 skrll *
192 1.12.8.2 skrll * byte 2 command code 0x40
193 1.12.8.2 skrll * byte 3 device #
194 1.12.8.2 skrll * byte 4 scsi channel (0/1)
195 1.12.8.2 skrll * byte 5 scsi id (0/15)
196 1.12.8.2 skrll * byte 6 scsi lun (0/7)
197 1.12.8.2 skrll * byte 7 tagged queue (1 enabled)
198 1.12.8.2 skrll * byte 8 cache mode (1 enabled)
199 1.12.8.2 skrll * byte 9 max speed ((0/1/2/3/4 -> 33/66/100/133/150)
200 1.12.8.2 skrll */
201 1.12.8.2 skrll #define ARC_FW_CREATE_PASSTHRU 0x40
202 1.12.8.2 skrll #define ARC_FW_DELETE_PASSTHRU 0x42 /* opcode + device# */
203 1.12.8.2 skrll
204 1.12.8.2 skrll /*
205 1.12.8.2 skrll * Structure for ARC_FW_CREATE_RAIDSET:
206 1.12.8.2 skrll *
207 1.12.8.2 skrll * byte 2 command code 0x50
208 1.12.8.2 skrll * byte 3-6 device mask
209 1.12.8.2 skrll * byte 7-22 raidset name (byte 7 == 0 use default)
210 1.12.8.2 skrll */
211 1.12.8.2 skrll #define ARC_FW_CREATE_RAIDSET 0x50
212 1.12.8.2 skrll #define ARC_FW_DELETE_RAIDSET 0x51 /* opcode + raidset# */
213 1.12.8.2 skrll #define ARC_FW_CREATE_HOTSPARE 0x54 /* opcode + 4 bytes device mask */
214 1.12.8.2 skrll #define ARC_FW_DELETE_HOTSPARE 0x55 /* opcode + 4 bytes device mask */
215 1.12.8.2 skrll
216 1.12.8.2 skrll /*
217 1.12.8.2 skrll * Structure for ARC_FW_CREATE_VOLUME/ARC_FW_MODIFY_VOLUME:
218 1.12.8.2 skrll *
219 1.12.8.2 skrll * byte 2 command code 0x60
220 1.12.8.2 skrll * byte 3 raidset#
221 1.12.8.2 skrll * byte 4-19 volume set name (byte 4 == 0 use default)
222 1.12.8.2 skrll * byte 20-27 volume capacity in blocks
223 1.12.8.2 skrll * byte 28 raid level
224 1.12.8.2 skrll * byte 29 stripe size
225 1.12.8.2 skrll * byte 30 channel
226 1.12.8.2 skrll * byte 31 ID
227 1.12.8.2 skrll * byte 32 LUN
228 1.12.8.2 skrll * byte 33 1 enable tag queuing
229 1.12.8.2 skrll * byte 33 1 enable cache
230 1.12.8.2 skrll * byte 35 speed 0/1/2/3/4 -> 33/66/100/133/150
231 1.12.8.2 skrll * byte 36 1 for quick init (only for CREATE_VOLUME)
232 1.12.8.2 skrll */
233 1.12.8.2 skrll #define ARC_FW_CREATE_VOLUME 0x60
234 1.12.8.2 skrll #define ARC_FW_MODIFY_VOLUME 0x61
235 1.12.8.2 skrll #define ARC_FW_DELETE_VOLUME 0x62 /* opcode + vol# */
236 1.12.8.2 skrll #define ARC_FW_START_CHECKVOL 0x63 /* opcode + vol# */
237 1.12.8.2 skrll #define ARC_FW_STOP_CHECKVOL 0x64 /* opcode only */
238 1.12.8.2 skrll
239 1.12.8.2 skrll /* Status codes for the firmware command codes */
240 1.12.8.2 skrll #define ARC_FW_CMD_OK 0x41
241 1.12.8.2 skrll #define ARC_FW_CMD_RAIDINVAL 0x42
242 1.12.8.2 skrll #define ARC_FW_CMD_VOLINVAL 0x43
243 1.12.8.2 skrll #define ARC_FW_CMD_NORAID 0x44
244 1.12.8.2 skrll #define ARC_FW_CMD_NOVOLUME 0x45
245 1.12.8.2 skrll #define ARC_FW_CMD_NOPHYSDRV 0x46
246 1.12.8.2 skrll #define ARC_FW_CMD_PARAM_ERR 0x47
247 1.12.8.2 skrll #define ARC_FW_CMD_UNSUPPORTED 0x48
248 1.12.8.2 skrll #define ARC_FW_CMD_DISKCFG_CHGD 0x49
249 1.12.8.2 skrll #define ARC_FW_CMD_PASS_INVAL 0x4a
250 1.12.8.2 skrll #define ARC_FW_CMD_NODISKSPACE 0x4b
251 1.12.8.2 skrll #define ARC_FW_CMD_CHECKSUM_ERR 0x4c
252 1.12.8.2 skrll #define ARC_FW_CMD_PASS_REQD 0x4d
253 1.12.8.2 skrll
254 1.12.8.2 skrll struct arc_fw_hwmon {
255 1.12.8.2 skrll uint8_t nfans;
256 1.12.8.2 skrll uint8_t nvoltages;
257 1.12.8.2 skrll uint8_t ntemps;
258 1.12.8.2 skrll uint8_t npower;
259 1.12.8.2 skrll uint16_t fan0; /* RPM */
260 1.12.8.2 skrll uint16_t fan1; /* RPM */
261 1.12.8.2 skrll uint16_t voltage_orig0; /* original value * 1000 */
262 1.12.8.2 skrll uint16_t voltage_val0; /* value */
263 1.12.8.2 skrll uint16_t voltage_orig1; /* original value * 1000 */
264 1.12.8.2 skrll uint16_t voltage_val1; /* value */
265 1.12.8.2 skrll uint16_t voltage_orig2;
266 1.12.8.2 skrll uint16_t voltage_val2;
267 1.12.8.2 skrll uint8_t temp0;
268 1.12.8.2 skrll uint8_t temp1;
269 1.12.8.2 skrll uint8_t pwr_indicator; /* (bit0 : power#0, bit1 : power#1) */
270 1.12.8.2 skrll uint8_t ups_indicator;
271 1.12.8.2 skrll } __packed;
272 1.12.8.2 skrll
273 1.12.8.2 skrll struct arc_fw_comminfo {
274 1.12.8.2 skrll uint8_t baud_rate;
275 1.12.8.2 skrll uint8_t data_bits;
276 1.12.8.2 skrll uint8_t stop_bits;
277 1.12.8.2 skrll uint8_t parity;
278 1.12.8.2 skrll uint8_t flow_control;
279 1.12.8.2 skrll } __packed;
280 1.12.8.2 skrll
281 1.12.8.2 skrll struct arc_fw_scsiattr {
282 1.12.8.2 skrll uint8_t channel; /* channel for SCSI target (0/1) */
283 1.12.8.2 skrll uint8_t target;
284 1.12.8.2 skrll uint8_t lun;
285 1.12.8.2 skrll uint8_t tagged;
286 1.12.8.2 skrll uint8_t cache;
287 1.12.8.2 skrll uint8_t speed;
288 1.12.8.2 skrll } __packed;
289 1.12.8.2 skrll
290 1.12.8.2 skrll struct arc_fw_raidinfo {
291 1.12.8.2 skrll uint8_t set_name[16];
292 1.12.8.2 skrll uint32_t capacity;
293 1.12.8.2 skrll uint32_t capacity2;
294 1.12.8.2 skrll uint32_t fail_mask;
295 1.12.8.2 skrll uint8_t device_array[32];
296 1.12.8.2 skrll uint8_t member_devices;
297 1.12.8.2 skrll uint8_t new_member_devices;
298 1.12.8.2 skrll uint8_t raid_state;
299 1.12.8.2 skrll uint8_t volumes;
300 1.12.8.2 skrll uint8_t volume_list[16];
301 1.12.8.2 skrll uint8_t reserved1[3];
302 1.12.8.2 skrll uint8_t free_segments;
303 1.12.8.2 skrll uint32_t raw_stripes[8];
304 1.12.8.2 skrll uint8_t reserved2[12];
305 1.12.8.2 skrll } __packed;
306 1.12.8.2 skrll
307 1.12.8.2 skrll struct arc_fw_volinfo {
308 1.12.8.2 skrll uint8_t set_name[16];
309 1.12.8.2 skrll uint32_t capacity;
310 1.12.8.2 skrll uint32_t capacity2;
311 1.12.8.2 skrll uint32_t fail_mask;
312 1.12.8.2 skrll uint32_t stripe_size; /* in blocks */
313 1.12.8.2 skrll uint32_t new_fail_mask;
314 1.12.8.2 skrll uint32_t new_stripe_size;
315 1.12.8.2 skrll uint32_t volume_status;
316 1.12.8.2 skrll #define ARC_FW_VOL_STATUS_NORMAL 0x00
317 1.12.8.2 skrll #define ARC_FW_VOL_STATUS_INITTING (1<<0)
318 1.12.8.2 skrll #define ARC_FW_VOL_STATUS_FAILED (1<<1)
319 1.12.8.2 skrll #define ARC_FW_VOL_STATUS_MIGRATING (1<<2)
320 1.12.8.2 skrll #define ARC_FW_VOL_STATUS_REBUILDING (1<<3)
321 1.12.8.2 skrll #define ARC_FW_VOL_STATUS_NEED_INIT (1<<4)
322 1.12.8.2 skrll #define ARC_FW_VOL_STATUS_NEED_MIGRATE (1<<5)
323 1.12.8.2 skrll #define ARC_FW_VOL_STATUS_INIT_FLAG (1<<6)
324 1.12.8.2 skrll #define ARC_FW_VOL_STATUS_NEED_REGEN (1<<7)
325 1.12.8.2 skrll #define ARC_FW_VOL_STATUS_CHECKING (1<<8)
326 1.12.8.2 skrll #define ARC_FW_VOL_STATUS_NEED_CHECK (1<<9)
327 1.12.8.2 skrll uint32_t progress;
328 1.12.8.2 skrll struct arc_fw_scsiattr scsi_attr;
329 1.12.8.2 skrll uint8_t member_disks;
330 1.12.8.2 skrll uint8_t raid_level;
331 1.12.8.2 skrll #define ARC_FW_VOL_RAIDLEVEL_0 0x00
332 1.12.8.2 skrll #define ARC_FW_VOL_RAIDLEVEL_1 0x01
333 1.12.8.2 skrll #define ARC_FW_VOL_RAIDLEVEL_3 0x02
334 1.12.8.2 skrll #define ARC_FW_VOL_RAIDLEVEL_5 0x03
335 1.12.8.2 skrll #define ARC_FW_VOL_RAIDLEVEL_6 0x04
336 1.12.8.2 skrll #define ARC_FW_VOL_RAIDLEVEL_PASSTHRU 0x05
337 1.12.8.2 skrll uint8_t new_member_disks;
338 1.12.8.2 skrll uint8_t new_raid_level;
339 1.12.8.2 skrll uint8_t raid_set_number;
340 1.12.8.2 skrll uint8_t reserved[5];
341 1.12.8.2 skrll } __packed;
342 1.12.8.2 skrll
343 1.12.8.2 skrll struct arc_fw_diskinfo {
344 1.12.8.2 skrll uint8_t model[40];
345 1.12.8.2 skrll uint8_t serial[20];
346 1.12.8.2 skrll uint8_t firmware_rev[8];
347 1.12.8.2 skrll uint32_t capacity;
348 1.12.8.2 skrll uint32_t capacity2;
349 1.12.8.2 skrll uint8_t device_state;
350 1.12.8.3 skrll #define ARC_FW_DISK_INITIALIZED 0x88 /* disk has been initialized */
351 1.12.8.2 skrll #define ARC_FW_DISK_RAIDMEMBER 0x89 /* disk is member of a raid set */
352 1.12.8.2 skrll #define ARC_FW_DISK_PASSTHRU 0x8b /* pass through disk */
353 1.12.8.2 skrll #define ARC_FW_DISK_HOTSPARE 0xa9 /* hotspare disk */
354 1.12.8.2 skrll #define ARC_FW_DISK_UNUSED 0xc9 /* free/unused disk */
355 1.12.8.2 skrll uint8_t pio_mode;
356 1.12.8.2 skrll uint8_t current_udma_mode;
357 1.12.8.2 skrll uint8_t udma_mode;
358 1.12.8.2 skrll uint8_t drive_select;
359 1.12.8.2 skrll uint8_t raid_number; /* 0xff unowned */
360 1.12.8.2 skrll struct arc_fw_scsiattr scsi_attr;
361 1.12.8.2 skrll uint8_t reserved[40];
362 1.12.8.2 skrll } __packed;
363 1.12.8.2 skrll
364 1.12.8.2 skrll struct arc_fw_sysinfo {
365 1.12.8.2 skrll uint8_t vendor_name[40];
366 1.12.8.2 skrll uint8_t serial_number[16];
367 1.12.8.2 skrll uint8_t firmware_version[16];
368 1.12.8.2 skrll uint8_t boot_version[16];
369 1.12.8.2 skrll uint8_t mb_version[16];
370 1.12.8.2 skrll uint8_t model_name[8];
371 1.12.8.2 skrll
372 1.12.8.2 skrll uint8_t local_ip[4];
373 1.12.8.2 skrll uint8_t current_ip[4];
374 1.12.8.2 skrll
375 1.12.8.2 skrll uint32_t time_tick;
376 1.12.8.2 skrll uint32_t cpu_speed;
377 1.12.8.2 skrll uint32_t icache;
378 1.12.8.2 skrll uint32_t dcache;
379 1.12.8.2 skrll uint32_t scache;
380 1.12.8.2 skrll uint32_t memory_size;
381 1.12.8.2 skrll uint32_t memory_speed;
382 1.12.8.2 skrll uint32_t events;
383 1.12.8.2 skrll
384 1.12.8.2 skrll uint8_t gsiMacAddress[6];
385 1.12.8.2 skrll uint8_t gsiDhcp;
386 1.12.8.2 skrll
387 1.12.8.2 skrll uint8_t alarm;
388 1.12.8.2 skrll uint8_t channel_usage;
389 1.12.8.2 skrll uint8_t max_ata_mode;
390 1.12.8.2 skrll uint8_t sdram_ecc;
391 1.12.8.2 skrll uint8_t rebuild_priority;
392 1.12.8.2 skrll struct arc_fw_comminfo comm_a;
393 1.12.8.2 skrll struct arc_fw_comminfo comm_b;
394 1.12.8.2 skrll uint8_t ide_channels;
395 1.12.8.2 skrll uint8_t scsi_host_channels;
396 1.12.8.2 skrll uint8_t ide_host_channels;
397 1.12.8.2 skrll uint8_t max_volume_set;
398 1.12.8.2 skrll uint8_t max_raid_set;
399 1.12.8.2 skrll uint8_t ether_port;
400 1.12.8.2 skrll uint8_t raid6_engine;
401 1.12.8.2 skrll uint8_t reserved[75];
402 1.12.8.2 skrll } __packed;
403 1.12.8.2 skrll
404 1.12.8.2 skrll /*
405 1.12.8.2 skrll * autconf(9) glue.
406 1.12.8.2 skrll */
407 1.12.8.2 skrll struct arc_ccb;
408 1.12.8.2 skrll TAILQ_HEAD(arc_ccb_list, arc_ccb);
409 1.12.8.2 skrll
410 1.12.8.2 skrll struct arc_softc {
411 1.12.8.2 skrll struct device sc_dev;
412 1.12.8.2 skrll struct scsipi_channel sc_chan;
413 1.12.8.2 skrll struct scsipi_adapter sc_adapter;
414 1.12.8.2 skrll
415 1.12.8.2 skrll pci_chipset_tag_t sc_pc;
416 1.12.8.2 skrll pcitag_t sc_tag;
417 1.12.8.2 skrll
418 1.12.8.2 skrll bus_space_tag_t sc_iot;
419 1.12.8.2 skrll bus_space_handle_t sc_ioh;
420 1.12.8.2 skrll bus_size_t sc_ios;
421 1.12.8.2 skrll bus_dma_tag_t sc_dmat;
422 1.12.8.2 skrll
423 1.12.8.2 skrll void *sc_ih;
424 1.12.8.2 skrll
425 1.12.8.2 skrll void *sc_shutdownhook;
426 1.12.8.2 skrll
427 1.12.8.2 skrll int sc_req_count;
428 1.12.8.2 skrll
429 1.12.8.2 skrll struct arc_dmamem *sc_requests;
430 1.12.8.2 skrll struct arc_ccb *sc_ccbs;
431 1.12.8.2 skrll struct arc_ccb_list sc_ccb_free;
432 1.12.8.2 skrll
433 1.12.8.2 skrll volatile int sc_talking;
434 1.12.8.2 skrll struct lock sc_lock;
435 1.12.8.2 skrll
436 1.12.8.3 skrll size_t sc_maxraidset; /* max raid sets */
437 1.12.8.3 skrll size_t sc_maxvolset; /* max volume sets */
438 1.12.8.3 skrll size_t sc_cchans; /* connected channels */
439 1.12.8.3 skrll
440 1.12.8.2 skrll struct device *sc_scsibus_dv;
441 1.12.8.2 skrll };
442 1.12.8.2 skrll
443 1.12.8.2 skrll /*
444 1.12.8.2 skrll * interface for scsi midlayer to talk to.
445 1.12.8.2 skrll */
446 1.12.8.2 skrll void arc_scsi_cmd(struct scsipi_channel *, scsipi_adapter_req_t, void *);
447 1.12.8.2 skrll
448 1.12.8.2 skrll /*
449 1.12.8.2 skrll * code to deal with getting bits in and out of the bus space.
450 1.12.8.2 skrll */
451 1.12.8.2 skrll uint32_t arc_read(struct arc_softc *, bus_size_t);
452 1.12.8.2 skrll void arc_read_region(struct arc_softc *, bus_size_t, void *,
453 1.12.8.2 skrll size_t);
454 1.12.8.2 skrll void arc_write(struct arc_softc *, bus_size_t, uint32_t);
455 1.12.8.2 skrll void arc_write_region(struct arc_softc *, bus_size_t, void *,
456 1.12.8.2 skrll size_t);
457 1.12.8.2 skrll int arc_wait_eq(struct arc_softc *, bus_size_t, uint32_t,
458 1.12.8.2 skrll uint32_t);
459 1.12.8.2 skrll int arc_wait_ne(struct arc_softc *, bus_size_t, uint32_t,
460 1.12.8.2 skrll uint32_t);
461 1.12.8.2 skrll int arc_msg0(struct arc_softc *, uint32_t);
462 1.12.8.2 skrll
463 1.12.8.2 skrll #define arc_push(_s, _r) arc_write((_s), ARC_REG_POST_QUEUE, (_r))
464 1.12.8.2 skrll #define arc_pop(_s) arc_read((_s), ARC_REG_REPLY_QUEUE)
465 1.12.8.2 skrll
466 1.12.8.2 skrll /*
467 1.12.8.2 skrll * wrap up the bus_dma api.
468 1.12.8.2 skrll */
469 1.12.8.2 skrll struct arc_dmamem {
470 1.12.8.2 skrll bus_dmamap_t adm_map;
471 1.12.8.2 skrll bus_dma_segment_t adm_seg;
472 1.12.8.2 skrll size_t adm_size;
473 1.12.8.2 skrll caddr_t adm_kva;
474 1.12.8.2 skrll };
475 1.12.8.2 skrll #define ARC_DMA_MAP(_adm) ((_adm)->adm_map)
476 1.12.8.2 skrll #define ARC_DMA_DVA(_adm) ((_adm)->adm_map->dm_segs[0].ds_addr)
477 1.12.8.2 skrll #define ARC_DMA_KVA(_adm) ((void *)(_adm)->adm_kva)
478 1.12.8.2 skrll
479 1.12.8.2 skrll struct arc_dmamem *arc_dmamem_alloc(struct arc_softc *, size_t);
480 1.12.8.2 skrll void arc_dmamem_free(struct arc_softc *,
481 1.12.8.2 skrll struct arc_dmamem *);
482 1.12.8.2 skrll
483 1.12.8.2 skrll /*
484 1.12.8.2 skrll * stuff to manage a scsi command.
485 1.12.8.2 skrll */
486 1.12.8.2 skrll struct arc_ccb {
487 1.12.8.2 skrll struct arc_softc *ccb_sc;
488 1.12.8.2 skrll int ccb_id;
489 1.12.8.2 skrll
490 1.12.8.2 skrll struct scsipi_xfer *ccb_xs;
491 1.12.8.2 skrll
492 1.12.8.2 skrll bus_dmamap_t ccb_dmamap;
493 1.12.8.2 skrll bus_addr_t ccb_offset;
494 1.12.8.2 skrll struct arc_io_cmd *ccb_cmd;
495 1.12.8.2 skrll uint32_t ccb_cmd_post;
496 1.12.8.2 skrll
497 1.12.8.2 skrll TAILQ_ENTRY(arc_ccb) ccb_link;
498 1.12.8.2 skrll };
499 1.12.8.2 skrll
500 1.12.8.2 skrll int arc_alloc_ccbs(struct arc_softc *);
501 1.12.8.2 skrll struct arc_ccb *arc_get_ccb(struct arc_softc *);
502 1.12.8.2 skrll void arc_put_ccb(struct arc_softc *, struct arc_ccb *);
503 1.12.8.2 skrll int arc_load_xs(struct arc_ccb *);
504 1.12.8.2 skrll int arc_complete(struct arc_softc *, struct arc_ccb *, int);
505 1.12.8.2 skrll void arc_scsi_cmd_done(struct arc_softc *, struct arc_ccb *,
506 1.12.8.2 skrll uint32_t);
507 1.12.8.2 skrll
508 1.12.8.2 skrll /*
509 1.12.8.2 skrll * real stuff for dealing with the hardware.
510 1.12.8.2 skrll */
511 1.12.8.2 skrll int arc_map_pci_resources(struct arc_softc *, struct pci_attach_args *);
512 1.12.8.2 skrll void arc_unmap_pci_resources(struct arc_softc *);
513 1.12.8.2 skrll int arc_query_firmware(struct arc_softc *);
514 1.12.8.2 skrll
515 1.12.8.2 skrll /*
516 1.12.8.2 skrll * stuff to do messaging via the doorbells.
517 1.12.8.2 skrll */
518 1.12.8.2 skrll void arc_lock(struct arc_softc *);
519 1.12.8.2 skrll void arc_unlock(struct arc_softc *);
520 1.12.8.2 skrll void arc_wait(struct arc_softc *);
521 1.12.8.2 skrll uint8_t arc_msg_cksum(void *, uint16_t);
522 1.12.8.2 skrll int arc_msgbuf(struct arc_softc *, void *, size_t, void *, size_t);
523 1.12.8.2 skrll
524 1.12.8.2 skrll #endif /* ! _PCI_ARCMSRVAR_H_ */
525