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