twareg.h revision 1.2.8.2 1 1.2.8.2 yamt /* $NetBSD: twareg.h,v 1.2.8.2 2006/06/21 15:05:07 yamt Exp $ */
2 1.2.8.2 yamt /* $wasabi: twareg.h,v 1.11 2006/04/27 17:12:39 wrstuden Exp $ */
3 1.2.8.2 yamt /*
4 1.2.8.2 yamt * Copyright (c) 2005-2006 Wasabi Systems, Inc.
5 1.2.8.2 yamt * All rights reserved.
6 1.2.8.2 yamt *
7 1.2.8.2 yamt * Your Wasabi Systems License Agreement specifies the terms and
8 1.2.8.2 yamt * conditions for use and redistribution.
9 1.2.8.2 yamt */
10 1.2.8.2 yamt
11 1.2.8.2 yamt
12 1.2.8.2 yamt /*-
13 1.2.8.2 yamt * Copyright (c) 2003-04 3ware, Inc.
14 1.2.8.2 yamt * All rights reserved.
15 1.2.8.2 yamt *
16 1.2.8.2 yamt * Redistribution and use in source and binary forms, with or without
17 1.2.8.2 yamt * modification, are permitted provided that the following conditions
18 1.2.8.2 yamt * are met:
19 1.2.8.2 yamt * 1. Redistributions of source code must retain the above copyright
20 1.2.8.2 yamt * notice, this list of conditions and the following disclaimer.
21 1.2.8.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
22 1.2.8.2 yamt * notice, this list of conditions and the following disclaimer in the
23 1.2.8.2 yamt * documentation and/or other materials provided with the distribution.
24 1.2.8.2 yamt *
25 1.2.8.2 yamt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
26 1.2.8.2 yamt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 1.2.8.2 yamt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 1.2.8.2 yamt * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
29 1.2.8.2 yamt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 1.2.8.2 yamt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 1.2.8.2 yamt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.2.8.2 yamt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.2.8.2 yamt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.2.8.2 yamt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.2.8.2 yamt * SUCH DAMAGE.
36 1.2.8.2 yamt *
37 1.2.8.2 yamt * $FreeBSD: src/sys/dev/twa/twa_reg.h,v 1.2 2004/08/18 16:14:44 vkashyap Exp $
38 1.2.8.2 yamt */
39 1.2.8.2 yamt
40 1.2.8.2 yamt /*
41 1.2.8.2 yamt * 3ware driver for 9000 series storage controllers.
42 1.2.8.2 yamt *
43 1.2.8.2 yamt * Author: Vinod Kashyap
44 1.2.8.2 yamt */
45 1.2.8.2 yamt
46 1.2.8.2 yamt #ifndef _PCI_TWAREG_H_
47 1.2.8.2 yamt #define _PCI_TWAREG_H_
48 1.2.8.2 yamt
49 1.2.8.2 yamt #if defined(_KERNEL)
50 1.2.8.2 yamt #include <machine/bus.h>
51 1.2.8.2 yamt
52 1.2.8.2 yamt /*
53 1.2.8.2 yamt * The following macro has no business being in twa_reg.h. It should probably
54 1.2.8.2 yamt * be defined in twa_includes.h, before the #include twa_reg.h.... But that
55 1.2.8.2 yamt * causes the API to run into build errors. Will leave it here for now...
56 1.2.8.2 yamt */
57 1.2.8.2 yamt #define TWA_64BIT_ADDRESSES ((sizeof(bus_addr_t) == 8) ? 1 : 0)
58 1.2.8.2 yamt
59 1.2.8.2 yamt /*
60 1.2.8.2 yamt * Define the following here since it relies on TWA_64BIT_ADDRESSES which
61 1.2.8.2 yamt * depends on sizeof(bus_addr_t), which is not exported to userland.
62 1.2.8.2 yamt * The userland API shouldn't care about the kernel's bus_addr_t.
63 1.2.8.2 yamt * For the userland API, use the array size that we would use for 32-bit
64 1.2.8.2 yamt * addresses since that's what we use in the sg structure definition.
65 1.2.8.2 yamt * The userland API does not actually appear to use the array, but it
66 1.2.8.2 yamt * does include the array in various command structures.
67 1.2.8.2 yamt */
68 1.2.8.2 yamt #define TWA_MAX_SG_ELEMENTS (TWA_64BIT_ADDRESSES ? 70 : 105)
69 1.2.8.2 yamt #else
70 1.2.8.2 yamt #define TWA_MAX_SG_ELEMENTS 105
71 1.2.8.2 yamt #endif
72 1.2.8.2 yamt
73 1.2.8.2 yamt #define TWAQ_FREE 0
74 1.2.8.2 yamt #define TWAQ_BUSY 1
75 1.2.8.2 yamt #define TWAQ_PENDING 2
76 1.2.8.2 yamt #define TWAQ_COMPLETE 3
77 1.2.8.2 yamt #define TWAQ_IO_PENDING 4
78 1.2.8.2 yamt #define TWAQ_COUNT 5 /* total number of queues */
79 1.2.8.2 yamt
80 1.2.8.2 yamt #define TWA_DRIVER_VERSION_STRING "1.00.00.000"
81 1.2.8.2 yamt
82 1.2.8.2 yamt #define TWA_REQUEST_TIMEOUT_PERIOD 60 /* seconds */
83 1.2.8.2 yamt
84 1.2.8.2 yamt #define TWA_MESSAGE_SOURCE_CONTROLLER_ERROR 3
85 1.2.8.2 yamt
86 1.2.8.2 yamt /* Register offsets from base address. */
87 1.2.8.2 yamt #define TWA_CONTROL_REGISTER_OFFSET 0x0
88 1.2.8.2 yamt #define TWA_STATUS_REGISTER_OFFSET 0x4
89 1.2.8.2 yamt #define TWA_COMMAND_QUEUE_OFFSET 0x8
90 1.2.8.2 yamt #define TWA_RESPONSE_QUEUE_OFFSET 0xC
91 1.2.8.2 yamt #define TWA_COMMAND_QUEUE_OFFSET_LOW 0x20
92 1.2.8.2 yamt #define TWA_COMMAND_QUEUE_OFFSET_HIGH 0x24
93 1.2.8.2 yamt
94 1.2.8.2 yamt #if defined(_KERNEL)
95 1.2.8.2 yamt #define TWA_WRITE_REGISTER(sc, offset, val) \
96 1.2.8.2 yamt bus_space_write_4(sc->twa_bus_iot, sc->twa_bus_ioh, offset, (u_int32_t)val)
97 1.2.8.2 yamt
98 1.2.8.2 yamt #define TWA_WRITE_COMMAND_QUEUE(sc, val) \
99 1.2.8.2 yamt do { \
100 1.2.8.2 yamt if (TWA_64BIT_ADDRESSES) { \
101 1.2.8.2 yamt /* First write the low 4 bytes, then the high 4. */ \
102 1.2.8.2 yamt TWA_WRITE_REGISTER(sc, TWA_COMMAND_QUEUE_OFFSET_LOW, \
103 1.2.8.2 yamt (u_int32_t)(val)); \
104 1.2.8.2 yamt TWA_WRITE_REGISTER(sc, TWA_COMMAND_QUEUE_OFFSET_HIGH,\
105 1.2.8.2 yamt (u_int32_t)(((u_int64_t)val)>>32)); \
106 1.2.8.2 yamt } else \
107 1.2.8.2 yamt TWA_WRITE_REGISTER(sc, TWA_COMMAND_QUEUE_OFFSET,\
108 1.2.8.2 yamt (u_int32_t)(val)); \
109 1.2.8.2 yamt } while (0)
110 1.2.8.2 yamt #endif
111 1.2.8.2 yamt
112 1.2.8.2 yamt /* Control register bit definitions. */
113 1.2.8.2 yamt #define TWA_CONTROL_CLEAR_SBUF_WRITE_ERROR 0x00000008
114 1.2.8.2 yamt #define TWA_CONTROL_ISSUE_HOST_INTERRUPT 0x00000020
115 1.2.8.2 yamt #define TWA_CONTROL_DISABLE_INTERRUPTS 0x00000040
116 1.2.8.2 yamt #define TWA_CONTROL_ENABLE_INTERRUPTS 0x00000080
117 1.2.8.2 yamt #define TWA_CONTROL_ISSUE_SOFT_RESET 0x00000100
118 1.2.8.2 yamt #define TWA_CONTROL_UNMASK_RESPONSE_INTERRUPT 0x00004000
119 1.2.8.2 yamt #define TWA_CONTROL_UNMASK_COMMAND_INTERRUPT 0x00008000
120 1.2.8.2 yamt #define TWA_CONTROL_MASK_RESPONSE_INTERRUPT 0x00010000
121 1.2.8.2 yamt #define TWA_CONTROL_MASK_COMMAND_INTERRUPT 0x00020000
122 1.2.8.2 yamt #define TWA_CONTROL_CLEAR_ATTENTION_INTERRUPT 0x00040000
123 1.2.8.2 yamt #define TWA_CONTROL_CLEAR_HOST_INTERRUPT 0x00080000
124 1.2.8.2 yamt #define TWA_CONTROL_CLEAR_PCI_ABORT 0x00100000
125 1.2.8.2 yamt #define TWA_CONTROL_CLEAR_QUEUE_ERROR 0x00400000
126 1.2.8.2 yamt #define TWA_CONTROL_CLEAR_PARITY_ERROR 0x00800000
127 1.2.8.2 yamt
128 1.2.8.2 yamt /* Status register bit definitions. */
129 1.2.8.2 yamt #define TWA_STATUS_ROM_BIOS_IN_SBUF 0x00000002
130 1.2.8.2 yamt #define TWA_STATUS_SBUF_WRITE_ERROR 0x00000008
131 1.2.8.2 yamt #define TWA_STATUS_COMMAND_QUEUE_EMPTY 0x00001000
132 1.2.8.2 yamt #define TWA_STATUS_MICROCONTROLLER_READY 0x00002000
133 1.2.8.2 yamt #define TWA_STATUS_RESPONSE_QUEUE_EMPTY 0x00004000
134 1.2.8.2 yamt #define TWA_STATUS_COMMAND_QUEUE_FULL 0x00008000
135 1.2.8.2 yamt #define TWA_STATUS_RESPONSE_INTERRUPT 0x00010000
136 1.2.8.2 yamt #define TWA_STATUS_COMMAND_INTERRUPT 0x00020000
137 1.2.8.2 yamt #define TWA_STATUS_ATTENTION_INTERRUPT 0x00040000
138 1.2.8.2 yamt #define TWA_STATUS_HOST_INTERRUPT 0x00080000
139 1.2.8.2 yamt #define TWA_STATUS_PCI_ABORT_INTERRUPT 0x00100000
140 1.2.8.2 yamt #define TWA_STATUS_MICROCONTROLLER_ERROR 0x00200000
141 1.2.8.2 yamt #define TWA_STATUS_QUEUE_ERROR_INTERRUPT 0x00400000
142 1.2.8.2 yamt #define TWA_STATUS_PCI_PARITY_ERROR_INTERRUPT 0x00800000
143 1.2.8.2 yamt #define TWA_STATUS_MINOR_VERSION_MASK 0x0F000000
144 1.2.8.2 yamt #define TWA_STATUS_MAJOR_VERSION_MASK 0xF0000000
145 1.2.8.2 yamt
146 1.2.8.2 yamt #define TWA_STATUS_EXPECTED_BITS 0x00002000
147 1.2.8.2 yamt #define TWA_STATUS_UNEXPECTED_BITS 0x00F00000
148 1.2.8.2 yamt
149 1.2.8.2 yamt /* For use with the %b printf format. */
150 1.2.8.2 yamt #define TWA_STATUS_BITS_DESCRIPTION \
151 1.2.8.2 yamt "\20\15CMD_Q_EMPTY\16MC_RDY\17RESP_Q_EMPTY\20CMD_Q_FULL\21RESP_INTR\22CMD_INTR\23ATTN_INTR\24HOST_INTR\25PCI_ABRT\26MC_ERR\27Q_ERR\30PCI_PERR\n"
152 1.2.8.2 yamt
153 1.2.8.2 yamt /* Detect inconsistencies in the status register. */
154 1.2.8.2 yamt #define TWA_STATUS_ERRORS(x) \
155 1.2.8.2 yamt ((x & TWA_STATUS_UNEXPECTED_BITS) && \
156 1.2.8.2 yamt (x & TWA_STATUS_MICROCONTROLLER_READY))
157 1.2.8.2 yamt
158 1.2.8.2 yamt /* PCI related defines. */
159 1.2.8.2 yamt #define TWA_IO_CONFIG_REG 0x10
160 1.2.8.2 yamt #define TWA_DEVICE_NAME "3ware 9000 series Storage Controller"
161 1.2.8.2 yamt #define TWA_VENDOR_ID 0x13C1
162 1.2.8.2 yamt #define TWA_DEVICE_ID_9K 0x1002
163 1.2.8.2 yamt
164 1.2.8.2 yamt #define TWA_PCI_CONFIG_CLEAR_PARITY_ERROR 0xc100
165 1.2.8.2 yamt #define TWA_PCI_CONFIG_CLEAR_PCI_ABORT 0x2000
166 1.2.8.2 yamt
167 1.2.8.2 yamt /* Command packet opcodes. */
168 1.2.8.2 yamt #define TWA_OP_NOP 0x00
169 1.2.8.2 yamt #define TWA_OP_INIT_CONNECTION 0x01
170 1.2.8.2 yamt #define TWA_OP_READ 0x02
171 1.2.8.2 yamt #define TWA_OP_WRITE 0x03
172 1.2.8.2 yamt #define TWA_OP_READVERIFY 0x04
173 1.2.8.2 yamt #define TWA_OP_VERIFY 0x05
174 1.2.8.2 yamt #define TWA_OP_ZEROUNIT 0x08
175 1.2.8.2 yamt #define TWA_OP_REPLACEUNIT 0x09
176 1.2.8.2 yamt #define TWA_OP_HOTSWAP 0x0A
177 1.2.8.2 yamt #define TWA_OP_SELFTESTS 0x0B
178 1.2.8.2 yamt #define TWA_OP_SYNC_PARAM 0x0C
179 1.2.8.2 yamt #define TWA_OP_REORDER_UNITS 0x0D
180 1.2.8.2 yamt #define TWA_OP_FLUSH 0x0E
181 1.2.8.2 yamt #define TWA_OP_EXECUTE_SCSI_COMMAND 0x10
182 1.2.8.2 yamt #define TWA_OP_ATA_PASSTHROUGH 0x11
183 1.2.8.2 yamt #define TWA_OP_GET_PARAM 0x12
184 1.2.8.2 yamt #define TWA_OP_SET_PARAM 0x13
185 1.2.8.2 yamt #define TWA_OP_CREATEUNIT 0x14
186 1.2.8.2 yamt #define TWA_OP_DELETEUNIT 0x15
187 1.2.8.2 yamt #define TWA_OP_DOWNLOAD_FIRMWARE 0x16
188 1.2.8.2 yamt #define TWA_OP_REBUILDUNIT 0x17
189 1.2.8.2 yamt #define TWA_OP_POWER_MANAGEMENT 0x18
190 1.2.8.2 yamt
191 1.2.8.2 yamt #define TWA_OP_REMOTE_PRINT 0x1B
192 1.2.8.2 yamt #define TWA_OP_RESET_FIRMWARE 0x1C
193 1.2.8.2 yamt #define TWA_OP_DEBUG 0x1D
194 1.2.8.2 yamt
195 1.2.8.2 yamt #define TWA_OP_DIAGNOSTICS 0x1F
196 1.2.8.2 yamt
197 1.2.8.2 yamt /* Misc defines. */
198 1.2.8.2 yamt #define TWA_ALIGNMENT 0x4
199 1.2.8.2 yamt #define TWA_MAX_UNITS 16
200 1.2.8.2 yamt #define TWA_INIT_MESSAGE_CREDITS 0x100
201 1.2.8.2 yamt #define TWA_SHUTDOWN_MESSAGE_CREDITS 0x001
202 1.2.8.2 yamt #define TWA_64BIT_SG_ADDRESSES 0x00000001
203 1.2.8.2 yamt #define TWA_EXTENDED_INIT_CONNECT 0x00000002
204 1.2.8.2 yamt #define TWA_BASE_MODE 1
205 1.2.8.2 yamt #define TWA_BASE_FW_SRL 24
206 1.2.8.2 yamt #define TWA_BASE_FW_BRANCH 0
207 1.2.8.2 yamt #define TWA_BASE_FW_BUILD 1
208 1.2.8.2 yamt #define TWA_CURRENT_FW_SRL 28
209 1.2.8.2 yamt #define TWA_CURRENT_FW_BRANCH 4
210 1.2.8.2 yamt #define TWA_CURRENT_FW_BUILD 9
211 1.2.8.2 yamt #define TWA_9000_ARCH_ID 0x5 /* 9000 series controllers */
212 1.2.8.2 yamt #define TWA_CTLR_FW_SAME_OR_NEWER 0x00000001
213 1.2.8.2 yamt #define TWA_CTLR_FW_COMPATIBLE 0x00000002
214 1.2.8.2 yamt #define TWA_BUNDLED_FW_SAFE_TO_FLASH 0x00000004
215 1.2.8.2 yamt #define TWA_CTLR_FW_RECOMMENDS_FLASH 0x00000008
216 1.2.8.2 yamt #define NUM_FW_IMAGE_CHUNKS 5
217 1.2.8.2 yamt #define TWA_MAX_IO_SIZE 0x20000 /* 128K */
218 1.2.8.2 yamt /* #define TWA_MAX_SG_ELEMENTS defined above */
219 1.2.8.2 yamt #define TWA_MAX_ATA_SG_ELEMENTS 60
220 1.2.8.2 yamt #define TWA_Q_LENGTH TWA_INIT_MESSAGE_CREDITS
221 1.2.8.2 yamt #define TWA_MAX_RESET_TRIES 3
222 1.2.8.2 yamt #define TWA_SECTOR_SIZE 0x200 /* generic I/O bufffer */
223 1.2.8.2 yamt #define TWA_SENSE_DATA_LENGTH 18
224 1.2.8.2 yamt
225 1.2.8.2 yamt #define TWA_ERROR_LOGICAL_UNIT_NOT_SUPPORTED 0x010a
226 1.2.8.2 yamt #define TWA_ERROR_UNIT_OFFLINE 0x0128
227 1.2.8.2 yamt #define TWA_ERROR_MORE_DATA 0x0231
228 1.2.8.2 yamt
229 1.2.8.2 yamt /* Scatter/Gather list entry. */
230 1.2.8.2 yamt struct twa_sg {
231 1.2.8.2 yamt #if defined(_KERNEL)
232 1.2.8.2 yamt bus_addr_t address;
233 1.2.8.2 yamt #else
234 1.2.8.2 yamt u_int32_t xx_address_xx; /* Fail if userland tries to use this */
235 1.2.8.2 yamt #endif
236 1.2.8.2 yamt u_int32_t length;
237 1.2.8.2 yamt } __attribute__ ((packed));
238 1.2.8.2 yamt
239 1.2.8.2 yamt
240 1.2.8.2 yamt /* 7000 structures. */
241 1.2.8.2 yamt struct twa_command_init_connect {
242 1.2.8.2 yamt u_int8_t opcode:5; /* TWA_OP_INITCONNECTION */
243 1.2.8.2 yamt u_int8_t res1:3;
244 1.2.8.2 yamt u_int8_t size;
245 1.2.8.2 yamt u_int8_t request_id;
246 1.2.8.2 yamt u_int8_t res2;
247 1.2.8.2 yamt u_int8_t status;
248 1.2.8.2 yamt u_int8_t flags;
249 1.2.8.2 yamt u_int16_t message_credits;
250 1.2.8.2 yamt u_int32_t features;
251 1.2.8.2 yamt u_int16_t fw_srl;
252 1.2.8.2 yamt u_int16_t fw_arch_id;
253 1.2.8.2 yamt u_int16_t fw_branch;
254 1.2.8.2 yamt u_int16_t fw_build;
255 1.2.8.2 yamt u_int32_t result;
256 1.2.8.2 yamt }__attribute__ ((packed));
257 1.2.8.2 yamt
258 1.2.8.2 yamt struct twa_command_download_firmware {
259 1.2.8.2 yamt u_int8_t opcode:5; /* TWA_DOWNLOAD_FIRMWARE */
260 1.2.8.2 yamt u_int8_t sgl_offset:3;
261 1.2.8.2 yamt u_int8_t size;
262 1.2.8.2 yamt u_int8_t request_id;
263 1.2.8.2 yamt u_int8_t unit;
264 1.2.8.2 yamt u_int8_t status;
265 1.2.8.2 yamt u_int8_t flags;
266 1.2.8.2 yamt u_int16_t param;
267 1.2.8.2 yamt struct twa_sg sgl[TWA_MAX_SG_ELEMENTS];
268 1.2.8.2 yamt } __attribute__ ((packed));
269 1.2.8.2 yamt
270 1.2.8.2 yamt
271 1.2.8.2 yamt struct twa_command_reset_firmware {
272 1.2.8.2 yamt u_int8_t opcode:5; /* TWA_OP_RESET_FIRMWARE */
273 1.2.8.2 yamt u_int8_t res1:3;
274 1.2.8.2 yamt u_int8_t size;
275 1.2.8.2 yamt u_int8_t request_id;
276 1.2.8.2 yamt u_int8_t unit;
277 1.2.8.2 yamt u_int8_t status;
278 1.2.8.2 yamt u_int8_t flags;
279 1.2.8.2 yamt u_int8_t res2;
280 1.2.8.2 yamt u_int8_t param;
281 1.2.8.2 yamt } __attribute__ ((packed));
282 1.2.8.2 yamt
283 1.2.8.2 yamt
284 1.2.8.2 yamt struct twa_command_io {
285 1.2.8.2 yamt u_int8_t opcode:5; /* TWA_OP_READ/TWA_OP_WRITE */
286 1.2.8.2 yamt u_int8_t sgl_offset:3;
287 1.2.8.2 yamt u_int8_t size;
288 1.2.8.2 yamt u_int8_t request_id;
289 1.2.8.2 yamt u_int8_t unit:4;
290 1.2.8.2 yamt u_int8_t host_id:4;
291 1.2.8.2 yamt u_int8_t status;
292 1.2.8.2 yamt u_int8_t flags;
293 1.2.8.2 yamt u_int16_t block_count;
294 1.2.8.2 yamt u_int32_t lba;
295 1.2.8.2 yamt struct twa_sg sgl[TWA_MAX_SG_ELEMENTS];
296 1.2.8.2 yamt } __attribute__ ((packed));
297 1.2.8.2 yamt
298 1.2.8.2 yamt
299 1.2.8.2 yamt struct twa_command_hotswap {
300 1.2.8.2 yamt u_int8_t opcode:5; /* TWA_OP_HOTSWAP */
301 1.2.8.2 yamt u_int8_t res1:3;
302 1.2.8.2 yamt u_int8_t size;
303 1.2.8.2 yamt u_int8_t request_id;
304 1.2.8.2 yamt u_int8_t unit:4;
305 1.2.8.2 yamt u_int8_t host_id:4;
306 1.2.8.2 yamt u_int8_t status;
307 1.2.8.2 yamt u_int8_t flags;
308 1.2.8.2 yamt u_int8_t action;
309 1.2.8.2 yamt #define TWA_OP_HOTSWAP_REMOVE 0x00 /* remove assumed-degraded unit */
310 1.2.8.2 yamt #define TWA_OP_HOTSWAP_ADD_CBOD 0x01 /* add CBOD to empty port */
311 1.2.8.2 yamt #define TWA_OP_HOTSWAP_ADD_SPARE 0x02 /* add spare to empty port */
312 1.2.8.2 yamt u_int8_t aport;
313 1.2.8.2 yamt } __attribute__ ((packed));
314 1.2.8.2 yamt
315 1.2.8.2 yamt
316 1.2.8.2 yamt struct twa_command_param {
317 1.2.8.2 yamt u_int8_t opcode:5; /* TWA_OP_GETPARAM, TWA_OP_SETPARAM */
318 1.2.8.2 yamt u_int8_t sgl_offset:3;
319 1.2.8.2 yamt u_int8_t size;
320 1.2.8.2 yamt u_int8_t request_id;
321 1.2.8.2 yamt u_int8_t unit:4;
322 1.2.8.2 yamt u_int8_t host_id:4;
323 1.2.8.2 yamt u_int8_t status;
324 1.2.8.2 yamt u_int8_t flags;
325 1.2.8.2 yamt u_int16_t param_count;
326 1.2.8.2 yamt struct twa_sg sgl[TWA_MAX_SG_ELEMENTS];
327 1.2.8.2 yamt } __attribute__ ((packed));
328 1.2.8.2 yamt
329 1.2.8.2 yamt
330 1.2.8.2 yamt struct twa_command_rebuildunit {
331 1.2.8.2 yamt u_int8_t opcode:5; /* TWA_OP_REBUILDUNIT */
332 1.2.8.2 yamt u_int8_t res1:3;
333 1.2.8.2 yamt u_int8_t size;
334 1.2.8.2 yamt u_int8_t request_id;
335 1.2.8.2 yamt u_int8_t src_unit:4;
336 1.2.8.2 yamt u_int8_t host_id:4;
337 1.2.8.2 yamt u_int8_t status;
338 1.2.8.2 yamt u_int8_t flags;
339 1.2.8.2 yamt u_int8_t action:7;
340 1.2.8.2 yamt #define TWA_OP_REBUILDUNIT_NOP 0
341 1.2.8.2 yamt #define TWA_OP_REBUILDUNIT_STOP 2 /* stop all rebuilds */
342 1.2.8.2 yamt #define TWA_OP_REBUILDUNIT_START 4 /* start rebuild with lowest unit */
343 1.2.8.2 yamt #define TWA_OP_REBUILDUNIT_STARTUNIT 5 /* rebuild src_unit (not supported) */
344 1.2.8.2 yamt u_int8_t cs:1; /* request state change on src_unit */
345 1.2.8.2 yamt u_int8_t logical_subunit; /* for RAID10 rebuild of logical subunit */
346 1.2.8.2 yamt } __attribute__ ((packed));
347 1.2.8.2 yamt
348 1.2.8.2 yamt
349 1.2.8.2 yamt struct twa_command_ata {
350 1.2.8.2 yamt u_int8_t opcode:5; /* TWA_OP_ATA_PASSTHROUGH */
351 1.2.8.2 yamt u_int8_t sgl_offset:3;
352 1.2.8.2 yamt u_int8_t size;
353 1.2.8.2 yamt u_int8_t request_id;
354 1.2.8.2 yamt u_int8_t unit:4;
355 1.2.8.2 yamt u_int8_t host_id:4;
356 1.2.8.2 yamt u_int8_t status;
357 1.2.8.2 yamt u_int8_t flags;
358 1.2.8.2 yamt u_int16_t param;
359 1.2.8.2 yamt u_int16_t features;
360 1.2.8.2 yamt u_int16_t sector_count;
361 1.2.8.2 yamt u_int16_t sector_num;
362 1.2.8.2 yamt u_int16_t cylinder_lo;
363 1.2.8.2 yamt u_int16_t cylinder_hi;
364 1.2.8.2 yamt u_int8_t drive_head;
365 1.2.8.2 yamt u_int8_t command;
366 1.2.8.2 yamt struct twa_sg sgl[TWA_MAX_ATA_SG_ELEMENTS];
367 1.2.8.2 yamt } __attribute__ ((packed));
368 1.2.8.2 yamt
369 1.2.8.2 yamt
370 1.2.8.2 yamt struct twa_command_generic {
371 1.2.8.2 yamt u_int8_t opcode:5;
372 1.2.8.2 yamt u_int8_t sgl_offset:3;
373 1.2.8.2 yamt u_int8_t size;
374 1.2.8.2 yamt u_int8_t request_id;
375 1.2.8.2 yamt u_int8_t unit:4;
376 1.2.8.2 yamt u_int8_t host_id:4;
377 1.2.8.2 yamt u_int8_t status;
378 1.2.8.2 yamt u_int8_t flags;
379 1.2.8.2 yamt #define TWA_FLAGS_SUCCESS 0x00
380 1.2.8.2 yamt #define TWA_FLAGS_INFORMATIONAL 0x01
381 1.2.8.2 yamt #define TWA_FLAGS_WARNING 0x02
382 1.2.8.2 yamt #define TWA_FLAGS_FATAL 0x03
383 1.2.8.2 yamt #define TWA_FLAGS_PERCENTAGE (1<<8) /* bits 0-6 indicate completion percentage */
384 1.2.8.2 yamt u_int16_t count; /* block count, parameter count, message credits */
385 1.2.8.2 yamt } __attribute__ ((packed));
386 1.2.8.2 yamt
387 1.2.8.2 yamt
388 1.2.8.2 yamt /* Command packet - must be TWA_ALIGNMENT aligned. */
389 1.2.8.2 yamt union twa_command_7k {
390 1.2.8.2 yamt struct twa_command_init_connect init_connect;
391 1.2.8.2 yamt struct twa_command_download_firmware download_fw;
392 1.2.8.2 yamt struct twa_command_reset_firmware reset_fw;
393 1.2.8.2 yamt struct twa_command_io io;
394 1.2.8.2 yamt struct twa_command_hotswap hotswap;
395 1.2.8.2 yamt struct twa_command_param param;
396 1.2.8.2 yamt struct twa_command_rebuildunit rebuildunit;
397 1.2.8.2 yamt struct twa_command_ata ata;
398 1.2.8.2 yamt struct twa_command_generic generic;
399 1.2.8.2 yamt } __attribute__ ((packed));
400 1.2.8.2 yamt
401 1.2.8.2 yamt
402 1.2.8.2 yamt /* 9000 structures. */
403 1.2.8.2 yamt
404 1.2.8.2 yamt /* Command Packet. */
405 1.2.8.2 yamt struct twa_command_9k {
406 1.2.8.2 yamt struct {
407 1.2.8.2 yamt u_int8_t opcode:5;
408 1.2.8.2 yamt u_int8_t reserved:3;
409 1.2.8.2 yamt } command;
410 1.2.8.2 yamt u_int8_t unit;
411 1.2.8.2 yamt u_int16_t request_id;
412 1.2.8.2 yamt u_int8_t status;
413 1.2.8.2 yamt u_int8_t sgl_offset; /* offset (in bytes) to sg_list, from the end of sgl_entries */
414 1.2.8.2 yamt u_int16_t sgl_entries;
415 1.2.8.2 yamt u_int8_t cdb[16];
416 1.2.8.2 yamt struct twa_sg sg_list[TWA_MAX_SG_ELEMENTS];
417 1.2.8.2 yamt u_int8_t padding[32];
418 1.2.8.2 yamt } __attribute__ ((packed));
419 1.2.8.2 yamt
420 1.2.8.2 yamt
421 1.2.8.2 yamt /* Command packet header. */
422 1.2.8.2 yamt struct twa_command_header {
423 1.2.8.2 yamt u_int8_t sense_data[TWA_SENSE_DATA_LENGTH];
424 1.2.8.2 yamt struct {
425 1.2.8.2 yamt int8_t reserved[4];
426 1.2.8.2 yamt u_int16_t error;
427 1.2.8.2 yamt u_int8_t padding;
428 1.2.8.2 yamt struct {
429 1.2.8.2 yamt u_int8_t severity:3;
430 1.2.8.2 yamt u_int8_t reserved:5;
431 1.2.8.2 yamt } substatus_block;
432 1.2.8.2 yamt } status_block;
433 1.2.8.2 yamt u_int8_t err_specific_desc[98];
434 1.2.8.2 yamt struct {
435 1.2.8.2 yamt u_int8_t size_header;
436 1.2.8.2 yamt u_int16_t reserved;
437 1.2.8.2 yamt u_int8_t size_sense;
438 1.2.8.2 yamt } header_desc;
439 1.2.8.2 yamt u_int8_t reserved[2];
440 1.2.8.2 yamt } __attribute__ ((packed));
441 1.2.8.2 yamt
442 1.2.8.2 yamt
443 1.2.8.2 yamt /* Full command packet. */
444 1.2.8.2 yamt struct twa_command_packet {
445 1.2.8.2 yamt struct twa_command_header cmd_hdr;
446 1.2.8.2 yamt union {
447 1.2.8.2 yamt union twa_command_7k cmd_pkt_7k;
448 1.2.8.2 yamt struct twa_command_9k cmd_pkt_9k;
449 1.2.8.2 yamt } command;
450 1.2.8.2 yamt } __attribute__ ((packed));
451 1.2.8.2 yamt
452 1.2.8.2 yamt
453 1.2.8.2 yamt /* Response queue entry. */
454 1.2.8.2 yamt union twa_response_queue {
455 1.2.8.2 yamt struct {
456 1.2.8.2 yamt u_int32_t undefined_1:4;
457 1.2.8.2 yamt u_int32_t response_id:8;
458 1.2.8.2 yamt u_int32_t undefined_2:20;
459 1.2.8.2 yamt } u;
460 1.2.8.2 yamt u_int32_t value;
461 1.2.8.2 yamt } __attribute__ ((packed));
462 1.2.8.2 yamt
463 1.2.8.2 yamt
464 1.2.8.2 yamt #define TWA_AEN_QUEUE_EMPTY 0x00
465 1.2.8.2 yamt #define TWA_AEN_SOFT_RESET 0x01
466 1.2.8.2 yamt #define TWA_AEN_SYNC_TIME_WITH_HOST 0x31
467 1.2.8.2 yamt #define TWA_AEN_SEVERITY_ERROR 0x1
468 1.2.8.2 yamt #define TWA_AEN_SEVERITY_WARNING 0x1
469 1.2.8.2 yamt #define TWA_AEN_SEVERITY_INFO 0x1
470 1.2.8.2 yamt #define TWA_AEN_SEVERITY_DEBUG 0x4
471 1.2.8.2 yamt
472 1.2.8.2 yamt #define TWA_PARAM_DRIVESUMMARY 0x0002
473 1.2.8.2 yamt #define TWA_PARAM_DRIVESTATUS 3
474 1.2.8.2 yamt
475 1.2.8.2 yamt #define TWA_DRIVE_DETECTED 0x80
476 1.2.8.2 yamt
477 1.2.8.2 yamt #define TWA_PARAM_DRIVE_TABLE 0x0200
478 1.2.8.2 yamt #define TWA_PARAM_DRIVESIZEINDEX 2
479 1.2.8.2 yamt #define TWA_PARAM_DRIVEMODELINDEX 3
480 1.2.8.2 yamt
481 1.2.8.2 yamt #define TWA_PARAM_DRIVESIZE_LENGTH 4
482 1.2.8.2 yamt #define TWA_PARAM_DRIVEMODEL_LENGTH 40
483 1.2.8.2 yamt
484 1.2.8.2 yamt
485 1.2.8.2 yamt #define TWA_PARAM_VERSION 0x0402
486 1.2.8.2 yamt #define TWA_PARAM_VERSION_Mon 2 /* monitor version [16] */
487 1.2.8.2 yamt #define TWA_PARAM_VERSION_FW 3 /* firmware version [16] */
488 1.2.8.2 yamt #define TWA_PARAM_VERSION_BIOS 4 /* BIOSs version [16] */
489 1.2.8.2 yamt #define TWA_PARAM_VERSION_PCBA 5 /* PCB version [8] */
490 1.2.8.2 yamt #define TWA_PARAM_VERSION_ATA 6 /* A-chip version [8] */
491 1.2.8.2 yamt #define TWA_PARAM_VERSION_PCI 7 /* P-chip version [8] */
492 1.2.8.2 yamt
493 1.2.8.2 yamt #define TWA_PARAM_CONTROLLER 0x0403
494 1.2.8.2 yamt #define TWA_PARAM_CONTROLLER_PortCount 3 /* number of ports [1] */
495 1.2.8.2 yamt
496 1.2.8.2 yamt #define TWA_PARAM_TIME_TABLE 0x40A
497 1.2.8.2 yamt #define TWA_PARAM_TIME_SchedulerTime 0x3
498 1.2.8.2 yamt
499 1.2.8.2 yamt #define TWA_9K_PARAM_DESCRIPTOR 0x8000
500 1.2.8.2 yamt
501 1.2.8.2 yamt
502 1.2.8.2 yamt struct twa_param_9k {
503 1.2.8.2 yamt u_int16_t table_id;
504 1.2.8.2 yamt u_int8_t parameter_id;
505 1.2.8.2 yamt u_int8_t reserved;
506 1.2.8.2 yamt u_int16_t parameter_size_bytes;
507 1.2.8.2 yamt u_int16_t parameter_actual_size_bytes;
508 1.2.8.2 yamt u_int8_t data[1];
509 1.2.8.2 yamt } __attribute__ ((packed));
510 1.2.8.2 yamt
511 1.2.8.2 yamt #endif /* !_PCI_TWAREG_H_ */
512