aacreg.h revision 1.8 1 /* $NetBSD: aacreg.h,v 1.8 2007/05/26 12:45:08 briggs Exp $ */
2
3 /*-
4 * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*-
40 * Copyright (c) 2000 Michael Smith
41 * Copyright (c) 2000-2001 Scott Long
42 * Copyright (c) 2000 BSDi
43 * Copyright (c) 2000 Niklas Hallqvist
44 * All rights reserved.
45 *
46 * Redistribution and use in source and binary forms, with or without
47 * modification, are permitted provided that the following conditions
48 * are met:
49 * 1. Redistributions of source code must retain the above copyright
50 * notice, this list of conditions and the following disclaimer.
51 * 2. Redistributions in binary form must reproduce the above copyright
52 * notice, this list of conditions and the following disclaimer in the
53 * documentation and/or other materials provided with the distribution.
54 *
55 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
56 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 * SUCH DAMAGE.
66 *
67 * from FreeBSD: aacreg.h,v 1.1 2000/09/13 03:20:34 msmith Exp
68 * via OpenBSD: aacreg.h,v 1.3 2001/06/12 15:40:29 niklas Exp
69 * incorporating some of: aacreg.h,v 1.23 2005/10/14 16:22:45 scottl Exp
70 */
71
72 /*
73 * Data structures defining the interface between the driver and the Adaptec
74 * 'FSA' adapters. Note that many field names and comments here are taken
75 * verbatim from the Adaptec driver source in order to make comparing the
76 * two slightly easier.
77 */
78
79 #ifndef _PCI_AACREG_H_
80 #define _PCI_AACREG_H_
81
82 /*
83 * Misc. magic numbers.
84 */
85 #define AAC_MAX_CONTAINERS 64
86 #define AAC_BLOCK_SIZE 512
87
88 /*
89 * Communications interface.
90 *
91 * Where datastructure layouts are closely parallel to the Adaptec sample code,
92 * retain their naming conventions (for now) to aid in cross-referencing.
93 */
94
95 /*
96 * We establish 4 command queues and matching response queues. Queues must
97 * be 16-byte aligned, and are sized as follows:
98 */
99 #define AAC_HOST_NORM_CMD_ENTRIES 8 /* cmd adapter->host, normal pri */
100 #define AAC_HOST_HIGH_CMD_ENTRIES 4 /* cmd adapter->host, high pri */
101 #define AAC_ADAP_NORM_CMD_ENTRIES 512 /* cmd host->adapter, normal pri */
102 #define AAC_ADAP_HIGH_CMD_ENTRIES 4 /* cmd host->adapter, high pri */
103 #define AAC_HOST_NORM_RESP_ENTRIES 512 /* resp, adapter->host, normal pri */
104 #define AAC_HOST_HIGH_RESP_ENTRIES 4 /* resp, adapter->host, high pri */
105 #define AAC_ADAP_NORM_RESP_ENTRIES 8 /* resp, host->adapter, normal pri */
106 #define AAC_ADAP_HIGH_RESP_ENTRIES 4 /* resp, host->adapter, high pri */
107
108 #define AAC_TOTALQ_LENGTH \
109 (AAC_HOST_HIGH_CMD_ENTRIES + AAC_HOST_NORM_CMD_ENTRIES + \
110 AAC_ADAP_HIGH_CMD_ENTRIES + AAC_ADAP_NORM_CMD_ENTRIES + \
111 AAC_HOST_HIGH_RESP_ENTRIES + AAC_HOST_NORM_RESP_ENTRIES + \
112 AAC_ADAP_HIGH_RESP_ENTRIES + AAC_ADAP_NORM_RESP_ENTRIES)
113
114 #define AAC_QUEUE_COUNT 8
115 #define AAC_QUEUE_ALIGN 16
116
117 struct aac_queue_entry {
118 u_int32_t aq_fib_size; /* FIB size in bytes */
119 u_int32_t aq_fib_addr; /* receiver-space address of the FIB */
120 } __attribute__ ((__packed__));
121
122 #define AAC_PRODUCER_INDEX 0
123 #define AAC_CONSUMER_INDEX 1
124
125 /*
126 * Table of queue indices and queues used to communicate with the
127 * controller. This structure must be aligned to AAC_QUEUE_ALIGN
128 */
129 struct aac_queue_table {
130 /* queue consumer/producer indexes (layout mandated by adapter) */
131 u_int32_t qt_qindex[AAC_QUEUE_COUNT][2];
132
133 /* queue entry structures (layout mandated by adapter) */
134 struct aac_queue_entry qt_HostNormCmdQueue[AAC_HOST_NORM_CMD_ENTRIES];
135 struct aac_queue_entry qt_HostHighCmdQueue[AAC_HOST_HIGH_CMD_ENTRIES];
136 struct aac_queue_entry qt_AdapNormCmdQueue[AAC_ADAP_NORM_CMD_ENTRIES];
137 struct aac_queue_entry qt_AdapHighCmdQueue[AAC_ADAP_HIGH_CMD_ENTRIES];
138 struct aac_queue_entry
139 qt_HostNormRespQueue[AAC_HOST_NORM_RESP_ENTRIES];
140 struct aac_queue_entry
141 qt_HostHighRespQueue[AAC_HOST_HIGH_RESP_ENTRIES];
142 struct aac_queue_entry
143 qt_AdapNormRespQueue[AAC_ADAP_NORM_RESP_ENTRIES];
144 struct aac_queue_entry
145 qt_AdapHighRespQueue[AAC_ADAP_HIGH_RESP_ENTRIES];
146 } __attribute__ ((__packed__));
147
148 /*
149 * Adapter Init Structure: this is passed to the adapter with the
150 * AAC_MONKER_INITSTRUCT command to point it at our control structures.
151 */
152 struct aac_adapter_init {
153 u_int32_t InitStructRevision;
154 u_int32_t MiniPortRevision;
155 u_int32_t FilesystemRevision;
156 u_int32_t CommHeaderAddress;
157 u_int32_t FastIoCommAreaAddress;
158 u_int32_t AdapterFibsPhysicalAddress;
159 u_int32_t AdapterFibsVirtualAddress;
160 u_int32_t AdapterFibsSize;
161 u_int32_t AdapterFibAlign;
162 u_int32_t PrintfBufferAddress;
163 u_int32_t PrintfBufferSize;
164 u_int32_t HostPhysMemPages;
165 u_int32_t HostElapsedSeconds;
166 /* ADAPTER_INIT_STRUCT_REVISION_4 begins here */
167 u_int32_t InitFlags; /* flags for supported features */
168 u_int32_t MaxIoCommands; /* max outstanding commands */
169 u_int32_t MaxIoSize; /* largest I/O command */
170 u_int32_t MaxFibSize; /* largest FIB to adapter */
171 } __attribute__((__packed__));
172
173 #define AAC_INIT_STRUCT_REVISION 3
174 #define AAC_INIT_STRUCT_REVISION_4 4
175 #define AAC_INIT_STRUCT_MINIPORT_REVISION 1
176 #define AAC_INITFLAGS_NEW_COMM_SUPPORTED 1
177 #define AAC_PAGE_SIZE 4096 /* Used to set HostPhysMemPages */
178
179 /*
180 * Shared data types
181 */
182
183 /*
184 * Container types
185 */
186 #define CT_NONE 0
187 #define CT_VOLUME 1
188 #define CT_MIRROR 2
189 #define CT_STRIPE 3
190 #define CT_RAID5 4
191 #define CT_SSRW 5
192 #define CT_SSRO 6
193 #define CT_MORPH 7
194 #define CT_PASSTHRU 8
195 #define CT_RAID4 9
196 #define CT_RAID10 10 /* stripe of mirror */
197 #define CT_RAID00 11 /* stripe of stripe */
198 #define CT_VOLUME_OF_MIRRORS 12 /* volume of mirror */
199 #define CT_PSEUDO_RAID3 13 /* really raid4 */
200
201 /*
202 * Host-addressable object types
203 */
204 #define FT_REG 1 /* regular file */
205 #define FT_DIR 2 /* directory */
206 #define FT_BLK 3 /* "block" device - reserved */
207 #define FT_CHR 4 /* "character special" device - reserved */
208 #define FT_LNK 5 /* symbolic link */
209 #define FT_SOCK 6 /* socket */
210 #define FT_FIFO 7 /* fifo */
211 #define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */
212 #define FT_DRIVE 9 /* phys disk - addressable in scsi by bus/target/lun */
213 #define FT_SLICE 10 /* virtual disk - raw volume - slice */
214 #define FT_PARTITION 11 /* FSA part, inside slice, container building block */
215 #define FT_VOLUME 12 /* Container - Volume Set */
216 #define FT_STRIPE 13 /* Container - Stripe Set */
217 #define FT_MIRROR 14 /* Container - Mirror Set */
218 #define FT_RAID5 15 /* Container - Raid 5 Set */
219 #define FT_DATABASE 16 /* Storage object with "foreign" content manager */
220
221 /*
222 * Host-side scatter/gather list for 32-bit commands.
223 */
224 struct aac_sg_entry {
225 u_int32_t SgAddress;
226 u_int32_t SgByteCount;
227 } __attribute__ ((__packed__));
228
229 struct aac_sg_table {
230 u_int32_t SgCount;
231 struct aac_sg_entry SgEntry[0]; /* XXX */
232 } __attribute__ ((__packed__));
233
234 /*
235 * Host-side scatter/gather list for 64-bit commands.
236 */
237 struct aac_sg_table64 {
238 u_int8_t SgCount;
239 u_int8_t SgSectorsPerPage;
240 u_int16_t SgByteOffset;
241 u_int64_t SgEntry[0];
242 } __attribute__ ((__packed__));
243
244 /*
245 * Container creation data
246 */
247 struct aac_container_creation {
248 u_int8_t ViaBuildNumber;
249 u_int8_t MicroSecond;
250 u_int8_t Via; /* 1 = FSU, 2 = API, etc. */
251 u_int8_t YearsSince1900;
252 u_int32_t Month:4; /* 1-12 */
253 u_int32_t Day:6; /* 1-32 */
254 u_int32_t Hour:6; /* 0-23 */
255 u_int32_t Minute:6; /* 0-59 */
256 u_int32_t Second:6; /* 0-59 */
257 u_int64_t ViaAdapterSerialNumber;
258 } __attribute__ ((__packed__));
259
260 struct FsaRevision {
261 union {
262 struct {
263 u_int8_t dash;
264 u_int8_t type;
265 u_int8_t minor;
266 u_int8_t major;
267 } comp;
268 u_int32_t ul;
269 } external;
270 u_int32_t buildNumber;
271 } __attribute__((__packed__));
272
273 /*
274 * Adapter Information
275 */
276
277 #define CPU_NTSIM 1
278 #define CPU_I960 2
279 #define CPU_ARM 3
280 #define CPU_SPARC 4
281 #define CPU_POWERPC 5
282 #define CPU_ALPHA 6
283 #define CPU_P7 7
284 #define CPU_I960_RX 8
285 #define CPU__last 9
286
287 #define CPUI960_JX 1
288 #define CPUI960_CX 2
289 #define CPUI960_HX 3
290 #define CPUI960_RX 4
291 #define CPUARM_SA110 5
292 #define CPUARM_xxx 6
293 #define CPUPPC_603e 7
294 #define CPUPPC_xxx 8
295 #define CPUI80303 9
296 #define CPUSUBTYPE__last 10
297
298 #define PLAT_NTSIM 1
299 #define PLAT_V3ADU 2
300 #define PLAT_CYCLONE 3
301 #define PLAT_CYCLONE_HD 4
302 #define PLAT_BATBOARD 5
303 #define PLAT_BATBOARD_HD 6
304 #define PLAT_YOLO 7
305 #define PLAT_COBRA 8
306 #define PLAT_ANAHEIM 9
307 #define PLAT_JALAPENO 10
308 #define PLAT_QUEENS 11
309 #define PLAT_JALAPENO_DELL 12
310 #define PLAT_POBLANO 13
311 #define PLAT_POBLANO_OPAL 14
312 #define PLAT_POBLANO_SL0 15
313 #define PLAT_POBLANO_SL1 16
314 #define PLAT_POBLANO_SL2 17
315 #define PLAT_POBLANO_XXX 18
316 #define PLAT_JALAPENO_P2 19
317 #define PLAT_HABANERO 20
318 #define PLAT__last 21
319
320 #define OEM_FLAVOR_ADAPTEC 1
321 #define OEM_FLAVOR_DELL 2
322 #define OEM_FLAVOR_HP 3
323 #define OEM_FLAVOR_IBM 4
324 #define OEM_FLAVOR_CPQ 5
325 #define OEM_FLAVOR_BRAND_X 6
326 #define OEM_FLAVOR_BRAND_Y 7
327 #define OEM_FLAVOR_BRAND_Z 8
328 #define OEM_FLAVOR__last 9
329
330 /*
331 * XXX the aac-2622 with no battery present reports PLATFORM_BAT_OPT_PRESENT
332 */
333 #define PLATFORM_BAT_REQ_PRESENT 1 /* BATTERY REQUIRED AND PRESENT */
334 #define PLATFORM_BAT_REQ_NOTPRESENT 2 /* BATTERY REQUIRED AND NOT PRESENT */
335 #define PLATFORM_BAT_OPT_PRESENT 3 /* BATTERY OPTIONAL AND PRESENT */
336 #define PLATFORM_BAT_OPT_NOTPRESENT 4 /* BATTERY OPTIONAL AND NOT PRESENT */
337 #define PLATFORM_BAT_NOT_SUPPORTED 5 /* BATTERY NOT SUPPORTED */
338
339 /*
340 * Structure used to respond to a RequestAdapterInfo fib.
341 */
342 struct aac_adapter_info {
343 u_int32_t PlatformBase; /* adapter type */
344 u_int32_t CpuArchitecture; /* adapter CPU type */
345 u_int32_t CpuVariant; /* adapter CPU subtype */
346 u_int32_t ClockSpeed; /* adapter CPU clockspeed */
347 u_int32_t ExecutionMem; /* adapter Execution Memory size */
348 u_int32_t BufferMem; /* adapter Data Memory */
349 u_int32_t TotalMem; /* adapter Total Memory */
350 struct FsaRevision KernelRevision; /* adapter Kernel SW Revision */
351 struct FsaRevision MonitorRevision; /* adapter Monitor/Diag SW Rev */
352 struct FsaRevision HardwareRevision; /* TDB */
353 struct FsaRevision BIOSRevision; /* adapter BIOS Revision */
354 u_int32_t ClusteringEnabled;
355 u_int32_t ClusterChannelMask;
356 u_int64_t SerialNumber;
357 u_int32_t batteryPlatform;
358 u_int32_t SupportedOptions; /* supported features of this ctrlr */
359 u_int32_t OemVariant;
360 } __attribute__((__packed__));
361
362 /*
363 * Monitor/Kernel interface.
364 */
365
366 /*
367 * Synchronous commands to the monitor/kernel.
368 */
369 #define AAC_MONKER_INITSTRUCT 0x05
370 #define AAC_MONKER_SYNCFIB 0x0c
371 #define AAC_MONKER_GETKERNVER 0x11
372 #define AAC_MONKER_GETINFO 0x19
373
374 /*
375 * Command status values
376 */
377 #define ST_OK 0
378 #define ST_PERM 1
379 #define ST_NOENT 2
380 #define ST_IO 5
381 #define ST_NXIO 6
382 #define ST_E2BIG 7
383 #define ST_ACCES 13
384 #define ST_EXIST 17
385 #define ST_XDEV 18
386 #define ST_NODEV 19
387 #define ST_NOTDIR 20
388 #define ST_ISDIR 21
389 #define ST_INVAL 22
390 #define ST_FBIG 27
391 #define ST_NOSPC 28
392 #define ST_ROFS 30
393 #define ST_MLINK 31
394 #define ST_WOULDBLOCK 35
395 #define ST_NAMETOOLONG 63
396 #define ST_NOTEMPTY 66
397 #define ST_DQUOT 69
398 #define ST_STALE 70
399 #define ST_REMOTE 71
400 #define ST_BADHANDLE 10001
401 #define ST_NOT_SYNC 10002
402 #define ST_BAD_COOKIE 10003
403 #define ST_NOTSUPP 10004
404 #define ST_TOOSMALL 10005
405 #define ST_SERVERFAULT 10006
406 #define ST_BADTYPE 10007
407 #define ST_JUKEBOX 10008
408 #define ST_NOTMOUNTED 10009
409 #define ST_MAINTMODE 10010
410 #define ST_STALEACL 10011
411
412 /*
413 * Volume manager commands
414 */
415 #define VM_Null 0
416 #define VM_NameServe 1
417 #define VM_ContainerConfig 2
418 #define VM_Ioctl 3
419 #define VM_FilesystemIoctl 4
420 #define VM_CloseAll 5
421 #define VM_CtBlockRead 6
422 #define VM_CtBlockWrite 7
423 #define VM_SliceBlockRead 8 /* raw access to configured "storage objects" */
424 #define VM_SliceBlockWrite 9
425 #define VM_DriveBlockRead 10 /* raw access to physical devices */
426 #define VM_DriveBlockWrite 11
427 #define VM_EnclosureMgt 12 /* enclosure management */
428 #define VM_Unused 13 /* used to be diskset management */
429 #define VM_CtBlockVerify 14
430 #define VM_CtPerf 15 /* performance test */
431 #define VM_CtBlockRead64 16
432 #define VM_CtBlockWrite64 17
433 #define VM_CtBlockVerify64 18
434
435 /*
436 * "Mountable object"
437 */
438 struct aac_mntobj {
439 u_int32_t ObjectId;
440 char FileSystemName[16];
441 struct aac_container_creation CreateInfo;
442 u_int32_t Capacity;
443 u_int32_t VolType;
444 u_int32_t ObjType;
445 u_int32_t ContentState;
446 #define AAC_FSCS_READONLY 0x0002 /* XXX need more information than this */
447 union {
448 u_int32_t pad[8];
449 } ObjExtension;
450 u_int32_t AlterEgoId;
451 } __attribute__ ((__packed__));
452
453 struct aac_mntinfo {
454 u_int32_t Command;
455 u_int32_t MntType;
456 u_int32_t MntCount;
457 } __attribute__ ((__packed__));
458
459 struct aac_mntinforesponse {
460 u_int32_t Status;
461 u_int32_t MntType;
462 u_int32_t MntRespCount;
463 struct aac_mntobj MntTable[1];
464 } __attribute__ ((__packed__));
465
466 /*
467 * Write 'stability' options.
468 */
469 #define CSTABLE 1
470 #define CUNSTABLE 2
471
472 /*
473 * Commit level response for a write request.
474 */
475 #define CMFILE_SYNC_NVRAM 1
476 #define CMDATA_SYNC_NVRAM 2
477 #define CMFILE_SYNC 3
478 #define CMDATA_SYNC 4
479 #define CMUNSTABLE 5
480
481 /*
482 * Block read/write operations. These structures are packed into the 'data'
483 * area in the FIB.
484 */
485 struct aac_blockread {
486 u_int32_t Command; /* not FSACommand! */
487 u_int32_t ContainerId;
488 u_int32_t BlockNumber;
489 u_int32_t ByteCount;
490 struct aac_sg_table SgMap; /* variable size */
491 } __attribute__ ((__packed__));
492
493 struct aac_blockread_response {
494 u_int32_t Status;
495 u_int32_t ByteCount;
496 } __attribute__ ((__packed__));
497
498 struct aac_blockwrite {
499 u_int32_t Command; /* not FSACommand! */
500 u_int32_t ContainerId;
501 u_int32_t BlockNumber;
502 u_int32_t ByteCount;
503 u_int32_t Stable;
504 struct aac_sg_table SgMap; /* variable size */
505 } __attribute__ ((__packed__));
506
507 struct aac_blockwrite_response {
508 u_int32_t Status;
509 u_int32_t ByteCount;
510 u_int32_t Committed;
511 } __attribute__ ((__packed__));
512
513 struct aac_close_command {
514 u_int32_t Command;
515 u_int32_t ContainerId;
516 } __attribute__ ((__packed__));
517
518 /*
519 * Register definitions for the Adaptec AAC-364 'Jalapeno I/II' adapters, based
520 * on the SA110 'StrongArm'.
521 */
522
523 #define AAC_REGSIZE 0x100
524
525 /* doorbell 0 (adapter->host) */
526 #define AAC_SA_DOORBELL0_CLEAR 0x98
527 #define AAC_SA_DOORBELL0_SET 0x9c
528 #define AAC_SA_DOORBELL0 0x9c
529 #define AAC_SA_MASK0_CLEAR 0xa0
530 #define AAC_SA_MASK0_SET 0xa4
531
532 /* doorbell 1 (host->adapter) */
533 #define AAC_SA_DOORBELL1_CLEAR 0x9a
534 #define AAC_SA_DOORBELL1_SET 0x9e
535 #define AAC_SA_MASK1_CLEAR 0xa2
536 #define AAC_SA_MASK1_SET 0xa6
537
538 /* mailbox (20 bytes) */
539 #define AAC_SA_MAILBOX 0xa8
540 #define AAC_SA_FWSTATUS 0xc4
541
542 /*
543 * Register definitions for the Adaptec 'Pablano' adapters, based on the
544 * i960Rx, and other related adapters.
545 */
546
547 #define AAC_RX_IDBR 0x20 /* inbound doorbell */
548 #define AAC_RX_IISR 0x24 /* inbound interrupt status */
549 #define AAC_RX_IIMR 0x28 /* inbound interrupt mask */
550 #define AAC_RX_ODBR 0x2c /* outbound doorbell */
551 #define AAC_RX_OISR 0x30 /* outbound interrupt status */
552 #define AAC_RX_OIMR 0x34 /* outbound interrupt mask */
553
554 #define AAC_RX_MAILBOX 0x50 /* mailbox (20 bytes) */
555 #define AAC_RX_FWSTATUS 0x6c
556
557 /*
558 * Common bit definitions for the doorbell registers.
559 */
560
561 /*
562 * Status bits in the doorbell registers.
563 */
564 #define AAC_DB_SYNC_COMMAND (1<<0) /* send/completed synchronous FIB */
565 #define AAC_DB_COMMAND_READY (1<<1) /* posted one or more commands */
566 #define AAC_DB_RESPONSE_READY (1<<2) /* one or more commands complete */
567 #define AAC_DB_COMMAND_NOT_FULL (1<<3) /* command queue not full */
568 #define AAC_DB_RESPONSE_NOT_FULL (1<<4) /* response queue not full */
569
570 /*
571 * The adapter can request the host print a message by setting the
572 * DB_PRINTF flag in DOORBELL0. The driver responds by collecting the
573 * message from the printf buffer, clearing the DB_PRINTF flag in
574 * DOORBELL0 and setting it in DOORBELL1.
575 * (ODBR and IDBR respectively for the i960Rx adapters)
576 */
577 #define AAC_DB_PRINTF (1<<5)
578
579 /*
580 * Mask containing the interrupt bits we care about. We don't anticipate
581 * (or want) interrupts not in this mask.
582 */
583 #define AAC_DB_INTERRUPTS \
584 (AAC_DB_COMMAND_READY | AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)
585
586 /*
587 * Queue names
588 *
589 * Note that we base these at 0 in order to use them as array indices. Adaptec
590 * used base 1 for some unknown reason, and sorted them in a different order.
591 */
592 #define AAC_HOST_NORM_CMD_QUEUE 0
593 #define AAC_HOST_HIGH_CMD_QUEUE 1
594 #define AAC_ADAP_NORM_CMD_QUEUE 2
595 #define AAC_ADAP_HIGH_CMD_QUEUE 3
596 #define AAC_HOST_NORM_RESP_QUEUE 4
597 #define AAC_HOST_HIGH_RESP_QUEUE 5
598 #define AAC_ADAP_NORM_RESP_QUEUE 6
599 #define AAC_ADAP_HIGH_RESP_QUEUE 7
600
601 /*
602 * List structure used to chain FIBs (used by the adapter - we hang FIBs off
603 * our private command structure and don't touch these)
604 */
605 struct aac_fib_list_entry {
606 u_int32_t Flink;
607 u_int32_t Blink;
608 } __attribute__((__packed__));
609
610 /*
611 * FIB (FSA Interface Block?); this is the datastructure passed between the
612 * host and adapter.
613 */
614 struct aac_fib_header {
615 u_int32_t XferState;
616 u_int16_t Command;
617 u_int8_t StructType;
618 u_int8_t Flags;
619 u_int16_t Size;
620 u_int16_t SenderSize;
621 u_int32_t SenderFibAddress;
622 u_int32_t ReceiverFibAddress;
623 u_int32_t SenderData;
624 union {
625 struct {
626 u_int32_t ReceiverTimeStart;
627 u_int32_t ReceiverTimeDone;
628 } _s;
629 struct aac_fib_list_entry FibLinks;
630 } _u;
631 } __attribute__((__packed__));
632
633 #define AAC_FIB_DATASIZE (512 - sizeof(struct aac_fib_header))
634
635 struct aac_fib {
636 struct aac_fib_header Header;
637 u_int8_t data[AAC_FIB_DATASIZE];
638 } __attribute__((__packed__));
639
640 /*
641 * FIB commands
642 */
643 #define TestCommandResponse 1
644 #define TestAdapterCommand 2
645
646 /* Lowlevel and comm commands */
647 #define LastTestCommand 100
648 #define ReinitHostNormCommandQueue 101
649 #define ReinitHostHighCommandQueue 102
650 #define ReinitHostHighRespQueue 103
651 #define ReinitHostNormRespQueue 104
652 #define ReinitAdapNormCommandQueue 105
653 #define ReinitAdapHighCommandQueue 107
654 #define ReinitAdapHighRespQueue 108
655 #define ReinitAdapNormRespQueue 109
656 #define InterfaceShutdown 110
657 #define DmaCommandFib 120
658 #define StartProfile 121
659 #define TermProfile 122
660 #define SpeedTest 123
661 #define TakeABreakPt 124
662 #define RequestPerfData 125
663 #define SetInterruptDefTimer 126
664 #define SetInterruptDefCount 127
665 #define GetInterruptDefStatus 128
666 #define LastCommCommand 129
667
668 /* filesystem commands */
669 #define NuFileSystem 300
670 #define UFS 301
671 #define HostFileSystem 302
672 #define LastFileSystemCommand 303
673
674 /* Container Commands */
675 #define ContainerCommand 500
676 #define ContainerCommand64 501
677
678 /* Cluster Commands */
679 #define ClusterCommand 550
680
681 /* Scsi Port commands (scsi passthrough) */
682 #define ScsiPortCommand 600
683
684 /* Misc house keeping and generic adapter initiated commands */
685 #define AifRequest 700
686 #define CheckRevision 701
687 #define FsaHostShutdown 702
688 #define RequestAdapterInfo 703
689 #define IsAdapterPaused 704
690 #define SendHostTime 705
691 #define LastMiscCommand 706
692
693 /*
694 * FIB types
695 */
696 #define AAC_FIBTYPE_TFIB 1
697 #define AAC_FIBTYPE_TQE 2
698 #define AAC_FIBTYPE_TCTPERF 3
699
700 /*
701 * FIB transfer state
702 */
703 #define AAC_FIBSTATE_HOSTOWNED (1<<0) /* owned by the host */
704 #define AAC_FIBSTATE_ADAPTEROWNED (1<<1) /* owned by the adapter */
705 #define AAC_FIBSTATE_INITIALISED (1<<2) /* initialised */
706 #define AAC_FIBSTATE_EMPTY (1<<3) /* empty */
707 #define AAC_FIBSTATE_FROMPOOL (1<<4) /* allocated from pool */
708 #define AAC_FIBSTATE_FROMHOST (1<<5) /* sent from the host */
709 #define AAC_FIBSTATE_FROMADAP (1<<6) /* sent from the adapter */
710 #define AAC_FIBSTATE_REXPECTED (1<<7) /* response is expected */
711 #define AAC_FIBSTATE_RNOTEXPECTED (1<<8) /* response is not expected */
712 #define AAC_FIBSTATE_DONEADAP (1<<9) /* processed by the adapter */
713 #define AAC_FIBSTATE_DONEHOST (1<<10) /* processed by the host */
714 #define AAC_FIBSTATE_HIGH (1<<11) /* high priority */
715 #define AAC_FIBSTATE_NORM (1<<12) /* normal priority */
716 #define AAC_FIBSTATE_ASYNC (1<<13)
717 #define AAC_FIBSTATE_ASYNCIO (1<<13) /* to be removed */
718 #define AAC_FIBSTATE_PAGEFILEIO (1<<14) /* to be removed */
719 #define AAC_FIBSTATE_SHUTDOWN (1<<15)
720 #define AAC_FIBSTATE_LAZYWRITE (1<<16) /* to be removed */
721 #define AAC_FIBSTATE_ADAPMICROFIB (1<<17)
722 #define AAC_FIBSTATE_BIOSFIB (1<<18)
723 #define AAC_FIBSTATE_FAST_RESPONSE (1<<19) /* fast response capable */
724 #define AAC_FIBSTATE_APIFIB (1<<20)
725
726 /*
727 * FIB error values
728 */
729 #define AAC_ERROR_NORMAL 0x00
730 #define AAC_ERROR_PENDING 0x01
731 #define AAC_ERROR_FATAL 0x02
732 #define AAC_ERROR_INVALID_QUEUE 0x03
733 #define AAC_ERROR_NOENTRIES 0x04
734 #define AAC_ERROR_SENDFAILED 0x05
735 #define AAC_ERROR_INVALID_QUEUE_PRIORITY 0x06
736 #define AAC_ERROR_FIB_ALLOCATION_FAILED 0x07
737 #define AAC_ERROR_FIB_DEALLOCATION_FAILED 0x08
738
739 /*
740 * Adapter Status Register
741 *
742 * Phase Staus mailbox is 32bits:
743 * <31:16> = Phase Status
744 * <15:0> = Phase
745 *
746 * The adapter reports its present state through the phase. Only
747 * a single phase should be ever be set. Each phase can have multiple
748 * phase status bits to provide more detailed information about the
749 * state of the adapter.
750 */
751 #define AAC_SELF_TEST_FAILED 0x00000004
752 #define AAC_UP_AND_RUNNING 0x00000080
753 #define AAC_KERNEL_PANIC 0x00000100
754
755 /*
756 * Data types relating to control and monitoring of the NVRAM/WriteCache
757 * subsystem.
758 */
759
760 #define AAC_NFILESYS 24 /* maximum number of filesystems */
761
762 /*
763 * NVRAM/Write Cache subsystem states
764 */
765 typedef enum {
766 NVSTATUS_DISABLED = 0, /* present, clean, not being used */
767 NVSTATUS_ENABLED, /* present, possibly dirty, ready for use */
768 NVSTATUS_ERROR, /* present, dirty, contains dirty data */
769 NVSTATUS_BATTERY, /* present, bad or low battery, may contain
770 * dirty data */
771 NVSTATUS_UNKNOWN /* for bad/missing device */
772 } AAC_NVSTATUS;
773
774 /*
775 * NVRAM/Write Cache subsystem battery component states
776 *
777 */
778 typedef enum {
779 NVBATTSTATUS_NONE = 0, /* battery has no power or is not present */
780 NVBATTSTATUS_LOW, /* battery is low on power */
781 NVBATTSTATUS_OK, /* battery is okay - normal operation possible
782 * only in this state */
783 NVBATTSTATUS_RECONDITIONING /* no battery present - reconditioning
784 * in process */
785 } AAC_NVBATTSTATUS;
786
787 /*
788 * Battery transition type
789 */
790 typedef enum {
791 NVBATT_TRANSITION_NONE = 0, /* battery now has no power or is not
792 * present */
793 NVBATT_TRANSITION_LOW, /* battery is now low on power */
794 NVBATT_TRANSITION_OK /* battery is now okay - normal
795 * operation possible only in this
796 * state */
797 } AAC_NVBATT_TRANSITION;
798
799 /*
800 * NVRAM Info structure returned for NVRAM_GetInfo call
801 */
802 struct aac_nvramdevinfo {
803 u_int32_t NV_Enabled; /* write caching enabled */
804 u_int32_t NV_Error; /* device in error state */
805 u_int32_t NV_NDirty; /* count of dirty NVRAM buffers */
806 u_int32_t NV_NActive; /* count of NVRAM buffers being
807 * written */
808 } __packed;
809
810 struct aac_nvraminfo {
811 AAC_NVSTATUS NV_Status; /* nvram subsystem status */
812 AAC_NVBATTSTATUS NV_BattStatus; /* battery status */
813 u_int32_t NV_Size; /* size of WriteCache NVRAM in
814 * bytes */
815 u_int32_t NV_BufSize; /* size of NVRAM buffers in
816 * bytes */
817 u_int32_t NV_NBufs; /* number of NVRAM buffers */
818 u_int32_t NV_NDirty; /* Num dirty NVRAM buffers */
819 u_int32_t NV_NClean; /* Num clean NVRAM buffers */
820 u_int32_t NV_NActive; /* Num NVRAM buffers being
821 * written */
822 u_int32_t NV_NBrokered; /* Num brokered NVRAM buffers */
823 struct aac_nvramdevinfo NV_DevInfo[AAC_NFILESYS]; /* per device
824 * info */
825 u_int32_t NV_BattNeedsReconditioning; /* boolean */
826 u_int32_t NV_TotalSize; /* size of all non-volatile
827 * memories in bytes */
828 } __packed;
829
830 /*
831 * Data types relating to adapter-initiated FIBs
832 *
833 * Based on types and structures in <aifstruc.h>
834 */
835
836 /*
837 * Progress Reports
838 */
839 typedef enum {
840 AifJobStsSuccess = 1,
841 AifJobStsFinished,
842 AifJobStsAborted,
843 AifJobStsFailed,
844 AifJobStsLastReportMarker = 100, /* All prior mean last report */
845 AifJobStsSuspended,
846 AifJobStsRunning
847 } AAC_AifJobStatus;
848
849 typedef enum {
850 AifJobScsiMin = 1, /* Minimum value for Scsi operation */
851 AifJobScsiZero, /* SCSI device clear operation */
852 AifJobScsiVerify, /* SCSI device Verify operation NO
853 * REPAIR */
854 AifJobScsiExercise, /* SCSI device Exercise operation */
855 AifJobScsiVerifyRepair, /* SCSI device Verify operation WITH
856 * repair */
857 AifJobScsiWritePattern, /* write pattern */
858 AifJobScsiMax = 99, /* Max Scsi value */
859 AifJobCtrMin, /* Min Ctr op value */
860 AifJobCtrZero, /* Container clear operation */
861 AifJobCtrCopy, /* Container copy operation */
862 AifJobCtrCreateMirror, /* Container Create Mirror operation */
863 AifJobCtrMergeMirror, /* Container Merge Mirror operation */
864 AifJobCtrScrubMirror, /* Container Scrub Mirror operation */
865 AifJobCtrRebuildRaid5, /* Container Rebuild Raid5 operation */
866 AifJobCtrScrubRaid5, /* Container Scrub Raid5 operation */
867 AifJobCtrMorph, /* Container morph operation */
868 AifJobCtrPartCopy, /* Container Partition copy operation */
869 AifJobCtrRebuildMirror, /* Container Rebuild Mirror operation */
870 AifJobCtrCrazyCache, /* crazy cache */
871 AifJobCtrCopyback, /* Container Copyback operation */
872 AifJobCtrCompactRaid5D, /* Container Compaction operation */
873 AifJobCtrExpandRaid5D, /* Container Expansion operation */
874 AifJobCtrRebuildRaid6, /* Container Rebuild Raid6 operation */
875 AifJobCtrScrubRaid6, /* Container Scrub Raid6 operation */
876 AifJobCtrSSBackup, /* Container snapshot backup task */
877 AifJobCtrMax = 199, /* Max Ctr type operation */
878 AifJobFsMin, /* Min Fs type operation */
879 AifJobFsCreate, /* File System Create operation */
880 AifJobFsVerify, /* File System Verify operation */
881 AifJobFsExtend, /* File System Extend operation */
882 AifJobFsMax = 299, /* Max Fs type operation */
883 AifJobApiFormatNTFS, /* Format a drive to NTFS */
884 AifJobApiFormatFAT, /* Format a drive to FAT */
885 AifJobApiUpdateSnapshot, /* update the read/write half of a
886 * snapshot */
887 AifJobApiFormatFAT32, /* Format a drive to FAT32 */
888 AifJobApiMax = 399, /* Max API type operation */
889 AifJobCtlContinuousCtrVerify, /* Adapter operation */
890 AifJobCtlMax = 499 /* Max Adapter type operation */
891 } AAC_AifJobType;
892
893 struct aac_AifContainers {
894 u_int32_t src; /* from/master */
895 u_int32_t dst; /* to/slave */
896 } __packed;
897
898 union aac_AifJobClient {
899 struct aac_AifContainers container; /* For Container and
900 * filesystem progress
901 * ops; */
902 int32_t scsi_dh; /* For SCSI progress
903 * ops */
904 };
905
906 struct aac_AifJobDesc {
907 u_int32_t jobID; /* DO NOT FILL IN! Will be
908 * filled in by AIF */
909 AAC_AifJobType type; /* Operation that is being
910 * performed */
911 union aac_AifJobClient client; /* Details */
912 } __packed;
913
914 struct aac_AifJobProgressReport {
915 struct aac_AifJobDesc jd;
916 AAC_AifJobStatus status;
917 u_int32_t finalTick;
918 u_int32_t currentTick;
919 u_int32_t jobSpecificData1;
920 u_int32_t jobSpecificData2;
921 } __packed;
922
923 /*
924 * Event Notification
925 */
926 typedef enum {
927 /* General application notifies start here */
928 AifEnGeneric = 1, /* Generic notification */
929 AifEnTaskComplete, /* Task has completed */
930 AifEnConfigChange, /* Adapter config change occurred */
931 AifEnContainerChange, /* Adapter specific container
932 * configuration change */
933 AifEnDeviceFailure, /* SCSI device failed */
934 AifEnMirrorFailover, /* Mirror failover started */
935 AifEnContainerEvent, /* Significant container event */
936 AifEnFileSystemChange, /* File system changed */
937 AifEnConfigPause, /* Container pause event */
938 AifEnConfigResume, /* Container resume event */
939 AifEnFailoverChange, /* Failover space assignment changed */
940 AifEnRAID5RebuildDone, /* RAID5 rebuild finished */
941 AifEnEnclosureManagement, /* Enclosure management event */
942 AifEnBatteryEvent, /* Significant NV battery event */
943 AifEnAddContainer, /* A new container was created. */
944 AifEnDeleteContainer, /* A container was deleted. */
945 AifEnSMARTEvent, /* SMART Event */
946 AifEnBatteryNeedsRecond, /* The battery needs reconditioning */
947 AifEnClusterEvent, /* Some cluster event */
948 AifEnDiskSetEvent, /* A disk set event occured. */
949 AifDriverNotifyStart=199, /* Notifies for host driver go here */
950 /* Host driver notifications start here */
951 AifDenMorphComplete, /* A morph operation completed */
952 AifDenVolumeExtendComplete /* Volume expand operation completed */
953 } AAC_AifEventNotifyType;
954
955 struct aac_AifEnsGeneric {
956 char text[132]; /* Generic text */
957 } __packed;
958
959 struct aac_AifEnsDeviceFailure {
960 u_int32_t deviceHandle; /* SCSI device handle */
961 } __packed;
962
963 struct aac_AifEnsMirrorFailover {
964 u_int32_t container; /* Container with failed element */
965 u_int32_t failedSlice; /* Old slice which failed */
966 u_int32_t creatingSlice; /* New slice used for auto-create */
967 } __packed;
968
969 struct aac_AifEnsContainerChange {
970 u_int32_t container[2]; /* container that changed, -1 if no
971 * container */
972 } __packed;
973
974 struct aac_AifEnsContainerEvent {
975 u_int32_t container; /* container number */
976 u_int32_t eventType; /* event type */
977 } __packed;
978
979 struct aac_AifEnsEnclosureEvent {
980 u_int32_t empID; /* enclosure management proc number */
981 u_int32_t unitID; /* unitId, fan id, power supply id,
982 * slot id, tempsensor id. */
983 u_int32_t eventType; /* event type */
984 } __packed;
985
986 struct aac_AifEnsBatteryEvent {
987 AAC_NVBATT_TRANSITION transition_type; /* eg from low to ok */
988 AAC_NVBATTSTATUS current_state; /* current batt state */
989 AAC_NVBATTSTATUS prior_state; /* prev batt state */
990 } __packed;
991
992 struct aac_AifEnsDiskSetEvent {
993 u_int32_t eventType;
994 u_int64_t DsNum;
995 u_int64_t CreatorId;
996 } __packed;
997
998 typedef enum {
999 CLUSTER_NULL_EVENT = 0,
1000 CLUSTER_PARTNER_NAME_EVENT, /* change in partner hostname or
1001 * adaptername from NULL to non-NULL */
1002 /* (partner's agent may be up) */
1003 CLUSTER_PARTNER_NULL_NAME_EVENT /* change in partner hostname or
1004 * adaptername from non-null to NULL */
1005 /* (partner has rebooted) */
1006 } AAC_ClusterAifEvent;
1007
1008 struct aac_AifEnsClusterEvent {
1009 AAC_ClusterAifEvent eventType;
1010 } __packed;
1011
1012 struct aac_AifEventNotify {
1013 AAC_AifEventNotifyType type;
1014 union {
1015 struct aac_AifEnsGeneric EG;
1016 struct aac_AifEnsDeviceFailure EDF;
1017 struct aac_AifEnsMirrorFailover EMF;
1018 struct aac_AifEnsContainerChange ECC;
1019 struct aac_AifEnsContainerEvent ECE;
1020 struct aac_AifEnsEnclosureEvent EEE;
1021 struct aac_AifEnsBatteryEvent EBE;
1022 struct aac_AifEnsDiskSetEvent EDS;
1023 /* struct aac_AifEnsSMARTEvent ES;*/
1024 struct aac_AifEnsClusterEvent ECLE;
1025 } data;
1026 } __packed;
1027
1028 /*
1029 * Adapter Initiated FIB command structures. Start with the adapter
1030 * initiated FIBs that really come from the adapter, and get responded
1031 * to by the host.
1032 */
1033 #define AAC_AIF_REPORT_MAX_SIZE 64
1034
1035 typedef enum {
1036 AifCmdEventNotify = 1, /* Notify of event */
1037 AifCmdJobProgress, /* Progress report */
1038 AifCmdAPIReport, /* Report from other user of API */
1039 AifCmdDriverNotify, /* Notify host driver of event */
1040 AifReqJobList = 100, /* Gets back complete job list */
1041 AifReqJobsForCtr, /* Gets back jobs for specific container */
1042 AifReqJobsForScsi, /* Gets back jobs for specific SCSI device */
1043 AifReqJobReport, /* Gets back a specific job report or list */
1044 AifReqTerminateJob, /* Terminates job */
1045 AifReqSuspendJob, /* Suspends a job */
1046 AifReqResumeJob, /* Resumes a job */
1047 AifReqSendAPIReport, /* API generic report requests */
1048 AifReqAPIJobStart, /* Start a job from the API */
1049 AifReqAPIJobUpdate, /* Update a job report from the API */
1050 AifReqAPIJobFinish /* Finish a job from the API */
1051 } AAC_AifCommand;
1052
1053 struct aac_aif_command {
1054 AAC_AifCommand command; /* Tell host what type of
1055 * notify this is */
1056 u_int32_t seqNumber; /* To allow ordering of
1057 * reports (if necessary) */
1058 union {
1059 struct aac_AifEventNotify EN; /* Event notify */
1060 struct aac_AifJobProgressReport PR[1]; /* Progress report */
1061 u_int8_t AR[AAC_AIF_REPORT_MAX_SIZE];
1062 u_int8_t data[AAC_FIB_DATASIZE - 8];
1063 } data;
1064 } __packed;
1065
1066 #endif /* !_PCI_AACREG_H_ */
1067