1 /*- 2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2000-2001 Scott Long 4 * Copyright (c) 2000 BSDi 5 * Copyright (c) 2001 Adaptec, Inc. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $FreeBSD$ 30 */ 31 32 /* 33 * Data structures defining the interface between the driver and the Adaptec 34 * 'FSA' adapters. Note that many field names and comments here are taken 35 * verbatim from the Adaptec driver source in order to make comparing the 36 * two slightly easier. 37 */ 38 39 /* 40 * Misc. magic numbers. 41 */ 42 #define AAC_MAX_CONTAINERS 64 43 #define AAC_BLOCK_SIZE 512 44 45 /* 46 * Communications interface. 47 * 48 * Where datastructure layouts are closely parallel to the Adaptec sample code, 49 * retain their naming conventions (for now) to aid in cross-referencing. 50 */ 51 52 /* 53 * We establish 4 command queues and matching response queues. Queues must 54 * be 16-byte aligned, and are sized as follows: 55 */ 56 #define AAC_HOST_NORM_CMD_ENTRIES 8 /* command adapter->host, 57 * normal priority */ 58 #define AAC_HOST_HIGH_CMD_ENTRIES 4 /* command adapter->host, 59 * high priority */ 60 #define AAC_ADAP_NORM_CMD_ENTRIES 512 /* command host->adapter, 61 * normal priority */ 62 #define AAC_ADAP_HIGH_CMD_ENTRIES 4 /* command host->adapter, 63 * high priority */ 64 #define AAC_HOST_NORM_RESP_ENTRIES 512 /* response, adapter->host, 65 * normal priority */ 66 #define AAC_HOST_HIGH_RESP_ENTRIES 4 /* response, adapter->host, 67 * high priority */ 68 #define AAC_ADAP_NORM_RESP_ENTRIES 8 /* response, host->adapter, 69 * normal priority */ 70 #define AAC_ADAP_HIGH_RESP_ENTRIES 4 /* response, host->adapter, 71 * high priority */ 72 73 #define AAC_TOTALQ_LENGTH (AAC_HOST_HIGH_CMD_ENTRIES + \ 74 AAC_HOST_NORM_CMD_ENTRIES + \ 75 AAC_ADAP_HIGH_CMD_ENTRIES + \ 76 AAC_ADAP_NORM_CMD_ENTRIES + \ 77 AAC_HOST_HIGH_RESP_ENTRIES + \ 78 AAC_HOST_NORM_RESP_ENTRIES + \ 79 AAC_ADAP_HIGH_RESP_ENTRIES + \ 80 AAC_ADAP_NORM_RESP_ENTRIES) 81 #define AAC_QUEUE_COUNT 8 82 #define AAC_QUEUE_ALIGN 16 83 84 struct aac_queue_entry { 85 u_int32_t aq_fib_size; /* FIB size in bytes */ 86 u_int32_t aq_fib_addr; /* receiver-space address of the FIB */ 87 } __packed; 88 89 #define AAC_PRODUCER_INDEX 0 90 #define AAC_CONSUMER_INDEX 1 91 92 /* 93 * Table of queue indices and queues used to communicate with the 94 * controller. This structure must be aligned to AAC_QUEUE_ALIGN 95 */ 96 struct aac_queue_table { 97 /* queue consumer/producer indexes (layout mandated by adapter) */ 98 u_int32_t qt_qindex[AAC_QUEUE_COUNT][2]; 99 100 /* queue entry structures (layout mandated by adapter) */ 101 struct aac_queue_entry qt_HostNormCmdQueue [AAC_HOST_NORM_CMD_ENTRIES]; 102 struct aac_queue_entry qt_HostHighCmdQueue [AAC_HOST_HIGH_CMD_ENTRIES]; 103 struct aac_queue_entry qt_AdapNormCmdQueue [AAC_ADAP_NORM_CMD_ENTRIES]; 104 struct aac_queue_entry qt_AdapHighCmdQueue [AAC_ADAP_HIGH_CMD_ENTRIES]; 105 struct aac_queue_entry qt_HostNormRespQueue[AAC_HOST_NORM_RESP_ENTRIES]; 106 struct aac_queue_entry qt_HostHighRespQueue[AAC_HOST_HIGH_RESP_ENTRIES]; 107 struct aac_queue_entry qt_AdapNormRespQueue[AAC_ADAP_NORM_RESP_ENTRIES]; 108 struct aac_queue_entry qt_AdapHighRespQueue[AAC_ADAP_HIGH_RESP_ENTRIES]; 109 } __packed; 110 111 /* 112 * Queue names 113 * 114 * Note that we base these at 0 in order to use them as array indices. Adaptec 115 * used base 1 for some unknown reason, and sorted them in a different order. 116 */ 117 #define AAC_HOST_NORM_CMD_QUEUE 0 118 #define AAC_HOST_HIGH_CMD_QUEUE 1 119 #define AAC_ADAP_NORM_CMD_QUEUE 2 120 #define AAC_ADAP_HIGH_CMD_QUEUE 3 121 #define AAC_HOST_NORM_RESP_QUEUE 4 122 #define AAC_HOST_HIGH_RESP_QUEUE 5 123 #define AAC_ADAP_NORM_RESP_QUEUE 6 124 #define AAC_ADAP_HIGH_RESP_QUEUE 7 125 126 /* 127 * List structure used to chain FIBs (used by the adapter - we hang FIBs off 128 * our private command structure and don't touch these) 129 */ 130 struct aac_fib_list_entry { 131 u_int32_t Flink; 132 u_int32_t Blink; 133 } __packed; 134 135 /* 136 * FIB (FSA Interface Block?); this is the datastructure passed between the host 137 * and adapter. 138 */ 139 struct aac_fib_header { 140 u_int32_t XferState; 141 u_int16_t Command; 142 u_int8_t StructType; 143 u_int8_t Flags; 144 u_int16_t Size; 145 u_int16_t SenderSize; 146 u_int32_t SenderFibAddress; 147 u_int32_t ReceiverFibAddress; 148 u_int32_t SenderData; 149 union { 150 struct { 151 u_int32_t ReceiverTimeStart; 152 u_int32_t ReceiverTimeDone; 153 } _s; 154 struct aac_fib_list_entry FibLinks; 155 } _u; 156 } __packed; 157 158 #define AAC_FIB_DATASIZE (512 - sizeof(struct aac_fib_header)) 159 160 struct aac_fib { 161 struct aac_fib_header Header; 162 u_int8_t data[AAC_FIB_DATASIZE]; 163 } __packed; 164 165 /* 166 * FIB commands 167 */ 168 typedef enum { 169 TestCommandResponse = 1, 170 TestAdapterCommand = 2, 171 172 /* lowlevel and comm commands */ 173 LastTestCommand = 100, 174 ReinitHostNormCommandQueue = 101, 175 ReinitHostHighCommandQueue = 102, 176 ReinitHostHighRespQueue = 103, 177 ReinitHostNormRespQueue = 104, 178 ReinitAdapNormCommandQueue = 105, 179 ReinitAdapHighCommandQueue = 107, 180 ReinitAdapHighRespQueue = 108, 181 ReinitAdapNormRespQueue = 109, 182 InterfaceShutdown = 110, 183 DmaCommandFib = 120, 184 StartProfile = 121, 185 TermProfile = 122, 186 SpeedTest = 123, 187 TakeABreakPt = 124, 188 RequestPerfData = 125, 189 SetInterruptDefTimer= 126, 190 SetInterruptDefCount= 127, 191 GetInterruptDefStatus= 128, 192 LastCommCommand = 129, 193 194 /* filesystem commands */ 195 NuFileSystem = 300, 196 UFS = 301, 197 HostFileSystem = 302, 198 LastFileSystemCommand = 303, 199 200 /* Container Commands */ 201 ContainerCommand = 500, 202 ContainerCommand64 = 501, 203 204 /* Cluster Commands */ 205 ClusterCommand = 550, 206 207 /* Scsi Port commands (scsi passthrough) */ 208 ScsiPortCommand = 600, 209 210 /* misc house keeping and generic adapter initiated commands */ 211 AifRequest = 700, 212 CheckRevision = 701, 213 FsaHostShutdown = 702, 214 RequestAdapterInfo = 703, 215 IsAdapterPaused = 704, 216 SendHostTime = 705, 217 LastMiscCommand = 706 218 } AAC_FibCommands; 219 220 /* 221 * FIB types 222 */ 223 #define AAC_FIBTYPE_TFIB 1 224 #define AAC_FIBTYPE_TQE 2 225 #define AAC_FIBTYPE_TCTPERF 3 226 227 /* 228 * FIB transfer state 229 */ 230 #define AAC_FIBSTATE_HOSTOWNED (1<<0) /* owned by the host */ 231 #define AAC_FIBSTATE_ADAPTEROWNED (1<<1) /* owned by the adapter */ 232 #define AAC_FIBSTATE_INITIALISED (1<<2) /* initialised */ 233 #define AAC_FIBSTATE_EMPTY (1<<3) /* empty */ 234 #define AAC_FIBSTATE_FROMPOOL (1<<4) /* allocated from pool */ 235 #define AAC_FIBSTATE_FROMHOST (1<<5) /* sent from the host */ 236 #define AAC_FIBSTATE_FROMADAP (1<<6) /* sent from the adapter */ 237 #define AAC_FIBSTATE_REXPECTED (1<<7) /* response is expected */ 238 #define AAC_FIBSTATE_RNOTEXPECTED (1<<8) /* response is not expected */ 239 #define AAC_FIBSTATE_DONEADAP (1<<9) /* processed by the adapter */ 240 #define AAC_FIBSTATE_DONEHOST (1<<10) /* processed by the host */ 241 #define AAC_FIBSTATE_HIGH (1<<11) /* high priority */ 242 #define AAC_FIBSTATE_NORM (1<<12) /* normal priority */ 243 #define AAC_FIBSTATE_ASYNC (1<<13) 244 #define AAC_FIBSTATE_ASYNCIO (1<<13) /* to be removed */ 245 #define AAC_FIBSTATE_PAGEFILEIO (1<<14) /* to be removed */ 246 #define AAC_FIBSTATE_SHUTDOWN (1<<15) 247 #define AAC_FIBSTATE_LAZYWRITE (1<<16) /* to be removed */ 248 #define AAC_FIBSTATE_ADAPMICROFIB (1<<17) 249 #define AAC_FIBSTATE_BIOSFIB (1<<18) 250 #define AAC_FIBSTATE_FAST_RESPONSE (1<<19) /* fast response capable */ 251 #define AAC_FIBSTATE_APIFIB (1<<20) 252 253 /* 254 * FIB error values 255 */ 256 #define AAC_ERROR_NORMAL 0x00 257 #define AAC_ERROR_PENDING 0x01 258 #define AAC_ERROR_FATAL 0x02 259 #define AAC_ERROR_INVALID_QUEUE 0x03 260 #define AAC_ERROR_NOENTRIES 0x04 261 #define AAC_ERROR_SENDFAILED 0x05 262 #define AAC_ERROR_INVALID_QUEUE_PRIORITY 0x06 263 #define AAC_ERROR_FIB_ALLOCATION_FAILED 0x07 264 #define AAC_ERROR_FIB_DEALLOCATION_FAILED 0x08 265 266 /* 267 * Adapter Init Structure: this is passed to the adapter with the 268 * AAC_MONKER_INITSTRUCT command to point it at our control structures. 269 */ 270 struct aac_adapter_init { 271 u_int32_t InitStructRevision; 272 #define AAC_INIT_STRUCT_REVISION 3 273 u_int32_t MiniPortRevision; 274 #define AAC_INIT_STRUCT_MINIPORT_REVISION 1 275 u_int32_t FilesystemRevision; 276 u_int32_t CommHeaderAddress; 277 u_int32_t FastIoCommAreaAddress; 278 u_int32_t AdapterFibsPhysicalAddress; 279 u_int32_t AdapterFibsVirtualAddress; 280 u_int32_t AdapterFibsSize; 281 u_int32_t AdapterFibAlign; 282 u_int32_t PrintfBufferAddress; 283 u_int32_t PrintfBufferSize; 284 #define AAC_PAGE_SIZE 4096 285 u_int32_t HostPhysMemPages; 286 u_int32_t HostElapsedSeconds; 287 } __packed; 288 289 /* 290 * Shared data types 291 */ 292 /* 293 * Container types 294 */ 295 typedef enum { 296 CT_NONE = 0, 297 CT_VOLUME, 298 CT_MIRROR, 299 CT_STRIPE, 300 CT_RAID5, 301 CT_SSRW, 302 CT_SSRO, 303 CT_MORPH, 304 CT_PASSTHRU, 305 CT_RAID4, 306 CT_RAID10, /* stripe of mirror */ 307 CT_RAID00, /* stripe of stripe */ 308 CT_VOLUME_OF_MIRRORS, /* volume of mirror */ 309 CT_PSEUDO_RAID3, /* really raid4 */ 310 CT_RAID50, /* stripe of raid5 */ 311 } AAC_FSAVolType; 312 313 /* 314 * Host-addressable object types 315 */ 316 typedef enum { 317 FT_REG = 1, /* regular file */ 318 FT_DIR, /* directory */ 319 FT_BLK, /* "block" device - reserved */ 320 FT_CHR, /* "character special" device - reserved */ 321 FT_LNK, /* symbolic link */ 322 FT_SOCK, /* socket */ 323 FT_FIFO, /* fifo */ 324 FT_FILESYS, /* ADAPTEC's "FSA"(tm) filesystem */ 325 FT_DRIVE, /* physical disk - addressable in scsi by b/t/l */ 326 FT_SLICE, /* virtual disk - raw volume - slice */ 327 FT_PARTITION, /* FSA partition - carved out of a slice - building 328 * block for containers */ 329 FT_VOLUME, /* Container - Volume Set */ 330 FT_STRIPE, /* Container - Stripe Set */ 331 FT_MIRROR, /* Container - Mirror Set */ 332 FT_RAID5, /* Container - Raid 5 Set */ 333 FT_DATABASE /* Storage object with "foreign" content manager */ 334 } AAC_FType; 335 336 /* 337 * Host-side scatter/gather list for 32-bit commands. 338 */ 339 struct aac_sg_entry { 340 u_int32_t SgAddress; 341 u_int32_t SgByteCount; 342 } __packed; 343 344 struct aac_sg_entry64 { 345 u_int64_t SgAddress; 346 u_int32_t SgByteCount; 347 } __packed; 348 349 struct aac_sg_table { 350 u_int32_t SgCount; 351 struct aac_sg_entry SgEntry[0]; 352 } __packed; 353 354 /* 355 * Host-side scatter/gather list for 64-bit commands. 356 */ 357 struct aac_sg_table64 { 358 u_int32_t SgCount; 359 struct aac_sg_entry64 SgEntry64[0]; 360 } __packed; 361 362 /* 363 * Container creation data 364 */ 365 struct aac_container_creation { 366 u_int8_t ViaBuildNumber; 367 u_int8_t MicroSecond; 368 u_int8_t Via; /* 1 = FSU, 2 = API, etc. */ 369 u_int8_t YearsSince1900; 370 u_int32_t Month:4; /* 1-12 */ 371 u_int32_t Day:6; /* 1-32 */ 372 u_int32_t Hour:6; /* 0-23 */ 373 u_int32_t Minute:6; /* 0-59 */ 374 u_int32_t Second:6; /* 0-59 */ 375 u_int64_t ViaAdapterSerialNumber; 376 } __packed; 377 378 /* 379 * Revision number handling 380 */ 381 382 typedef enum { 383 RevApplication = 1, 384 RevDkiCli, 385 RevNetService, 386 RevApi, 387 RevFileSysDriver, 388 RevMiniportDriver, 389 RevAdapterSW, 390 RevMonitor, 391 RevRemoteApi 392 } RevComponent; 393 394 struct FsaRevision { 395 union { 396 struct { 397 u_int8_t dash; 398 u_int8_t type; 399 u_int8_t minor; 400 u_int8_t major; 401 } comp; 402 u_int32_t ul; 403 } external; 404 u_int32_t buildNumber; 405 } __packed; 406 407 /* 408 * Adapter Information 409 */ 410 411 typedef enum { 412 CPU_NTSIM = 1, 413 CPU_I960, 414 CPU_ARM, 415 CPU_SPARC, 416 CPU_POWERPC, 417 CPU_ALPHA, 418 CPU_P7, 419 CPU_I960_RX, 420 CPU__last 421 } AAC_CpuType; 422 423 typedef enum { 424 CPUI960_JX = 1, 425 CPUI960_CX, 426 CPUI960_HX, 427 CPUI960_RX, 428 CPUARM_SA110, 429 CPUARM_xxx, 430 CPUMPC_824x, 431 CPUPPC_xxx, 432 CPUSUBTYPE__last 433 } AAC_CpuSubType; 434 435 typedef enum { 436 PLAT_NTSIM = 1, 437 PLAT_V3ADU, 438 PLAT_CYCLONE, 439 PLAT_CYCLONE_HD, 440 PLAT_BATBOARD, 441 PLAT_BATBOARD_HD, 442 PLAT_YOLO, 443 PLAT_COBRA, 444 PLAT_ANAHEIM, 445 PLAT_JALAPENO, 446 PLAT_QUEENS, 447 PLAT_JALAPENO_DELL, 448 PLAT_POBLANO, 449 PLAT_POBLANO_OPAL, 450 PLAT_POBLANO_SL0, 451 PLAT_POBLANO_SL1, 452 PLAT_POBLANO_SL2, 453 PLAT_POBLANO_XXX, 454 PLAT_JALAPENO_P2, 455 PLAT_HABANERO, 456 PLAT__last 457 } AAC_Platform; 458 459 typedef enum { 460 OEM_FLAVOR_ADAPTEC = 1, 461 OEM_FLAVOR_DELL, 462 OEM_FLAVOR_HP, 463 OEM_FLAVOR_IBM, 464 OEM_FLAVOR_CPQ, 465 OEM_FLAVOR_BRAND_X, 466 OEM_FLAVOR_BRAND_Y, 467 OEM_FLAVOR_BRAND_Z, 468 OEM_FLAVOR__last 469 } AAC_OemFlavor; 470 471 /* 472 * XXX the aac-2622 with no battery present reports PLATFORM_BAT_OPT_PRESENT 473 */ 474 typedef enum 475 { 476 PLATFORM_BAT_REQ_PRESENT = 1, /* BATTERY REQUIRED AND PRESENT */ 477 PLATFORM_BAT_REQ_NOTPRESENT, /* BATTERY REQUIRED AND NOT PRESENT */ 478 PLATFORM_BAT_OPT_PRESENT, /* BATTERY OPTIONAL AND PRESENT */ 479 PLATFORM_BAT_OPT_NOTPRESENT, /* BATTERY OPTIONAL AND NOT PRESENT */ 480 PLATFORM_BAT_NOT_SUPPORTED /* BATTERY NOT SUPPORTED */ 481 } AAC_BatteryPlatform; 482 483 /* 484 * options supported by this board 485 * there has to be a one to one mapping of these defines and the ones in 486 * fsaapi.h, search for FSA_SUPPORT_SNAPSHOT 487 */ 488 #define AAC_SUPPORTED_SNAPSHOT 0x01 489 #define AAC_SUPPORTED_CLUSTERS 0x02 490 #define AAC_SUPPORTED_WRITE_CACHE 0x04 491 #define AAC_SUPPORTED_64BIT_DATA 0x08 492 #define AAC_SUPPORTED_HOST_TIME_FIB 0x10 493 #define AAC_SUPPORTED_RAID50 0x20 494 #define AAC_SUPPORTED_4GB_WINDOW 0x40 495 #define AAC_SUPPORTED_SCSI_UPGRADEABLE 0x80 496 #define AAC_SUPPORTED_SOFT_ERR_REPORT 0x100 497 #define AAC_SUPPORTED_NOT_RECONDITION 0x200 498 #define AAC_SUPPORTED_SGMAP_HOST64 0x400 499 #define AAC_SUPPORTED_ALARM 0x800 500 #define AAC_SUPPORTED_NONDASD 0x1000 501 502 /* 503 * Structure used to respond to a RequestAdapterInfo fib. 504 */ 505 struct aac_adapter_info { 506 AAC_Platform PlatformBase; /* adapter type */ 507 AAC_CpuType CpuArchitecture; /* adapter CPU type */ 508 AAC_CpuSubType CpuVariant; /* adapter CPU subtype */ 509 u_int32_t ClockSpeed; /* adapter CPU clockspeed */ 510 u_int32_t ExecutionMem; /* adapter Execution Memory 511 * size */ 512 u_int32_t BufferMem; /* adapter Data Memory */ 513 u_int32_t TotalMem; /* adapter Total Memory */ 514 struct FsaRevision KernelRevision; /* adapter Kernel Software 515 * Revision */ 516 struct FsaRevision MonitorRevision; /* adapter Monitor/Diagnostic 517 * Software Revision */ 518 struct FsaRevision HardwareRevision;/* TBD */ 519 struct FsaRevision BIOSRevision; /* adapter BIOS Revision */ 520 u_int32_t ClusteringEnabled; 521 u_int32_t ClusterChannelMask; 522 u_int64_t SerialNumber; 523 AAC_BatteryPlatform batteryPlatform; 524 u_int32_t SupportedOptions; /* supported features of this 525 * controller */ 526 AAC_OemFlavor OemVariant; 527 } __packed; 528 529 /* 530 * Monitor/Kernel interface. 531 */ 532 533 /* 534 * Synchronous commands to the monitor/kernel. 535 */ 536 #define AAC_MONKER_INITSTRUCT 0x05 537 #define AAC_MONKER_SYNCFIB 0x0c 538 #define AAC_MONKER_GETKERNVER 0x11 539 #define AAC_MONKER_GETINFO 0x19 540 541 /* 542 * Adapter Status Register 543 * 544 * Phase Staus mailbox is 32bits: 545 * <31:16> = Phase Status 546 * <15:0> = Phase 547 * 548 * The adapter reports its present state through the phase. Only 549 * a single phase should be ever be set. Each phase can have multiple 550 * phase status bits to provide more detailed information about the 551 * state of the adapter. 552 */ 553 #define AAC_SELF_TEST_FAILED 0x00000004 554 #define AAC_UP_AND_RUNNING 0x00000080 555 #define AAC_KERNEL_PANIC 0x00000100 556 557 /* 558 * Data types relating to control and monitoring of the NVRAM/WriteCache 559 * subsystem. 560 */ 561 562 #define AAC_NFILESYS 24 /* maximum number of filesystems */ 563 564 /* 565 * NVRAM/Write Cache subsystem states 566 */ 567 typedef enum { 568 NVSTATUS_DISABLED = 0, /* present, clean, not being used */ 569 NVSTATUS_ENABLED, /* present, possibly dirty, ready for use */ 570 NVSTATUS_ERROR, /* present, dirty, contains dirty data */ 571 NVSTATUS_BATTERY, /* present, bad or low battery, may contain 572 * dirty data */ 573 NVSTATUS_UNKNOWN /* for bad/missing device */ 574 } AAC_NVSTATUS; 575 576 /* 577 * NVRAM/Write Cache subsystem battery component states 578 * 579 */ 580 typedef enum { 581 NVBATTSTATUS_NONE = 0, /* battery has no power or is not present */ 582 NVBATTSTATUS_LOW, /* battery is low on power */ 583 NVBATTSTATUS_OK, /* battery is okay - normal operation possible 584 * only in this state */ 585 NVBATTSTATUS_RECONDITIONING /* no battery present - reconditioning 586 * in process */ 587 } AAC_NVBATTSTATUS; 588 589 /* 590 * Battery transition type 591 */ 592 typedef enum { 593 NVBATT_TRANSITION_NONE = 0, /* battery now has no power or is not 594 * present */ 595 NVBATT_TRANSITION_LOW, /* battery is now low on power */ 596 NVBATT_TRANSITION_OK /* battery is now okay - normal 597 * operation possible only in this 598 * state */ 599 } AAC_NVBATT_TRANSITION; 600 601 /* 602 * NVRAM Info structure returned for NVRAM_GetInfo call 603 */ 604 struct aac_nvramdevinfo { 605 u_int32_t NV_Enabled; /* write caching enabled */ 606 u_int32_t NV_Error; /* device in error state */ 607 u_int32_t NV_NDirty; /* count of dirty NVRAM buffers */ 608 u_int32_t NV_NActive; /* count of NVRAM buffers being 609 * written */ 610 } __packed; 611 612 struct aac_nvraminfo { 613 AAC_NVSTATUS NV_Status; /* nvram subsystem status */ 614 AAC_NVBATTSTATUS NV_BattStatus; /* battery status */ 615 u_int32_t NV_Size; /* size of WriteCache NVRAM in 616 * bytes */ 617 u_int32_t NV_BufSize; /* size of NVRAM buffers in 618 * bytes */ 619 u_int32_t NV_NBufs; /* number of NVRAM buffers */ 620 u_int32_t NV_NDirty; /* Num dirty NVRAM buffers */ 621 u_int32_t NV_NClean; /* Num clean NVRAM buffers */ 622 u_int32_t NV_NActive; /* Num NVRAM buffers being 623 * written */ 624 u_int32_t NV_NBrokered; /* Num brokered NVRAM buffers */ 625 struct aac_nvramdevinfo NV_DevInfo[AAC_NFILESYS]; /* per device 626 * info */ 627 u_int32_t NV_BattNeedsReconditioning; /* boolean */ 628 u_int32_t NV_TotalSize; /* size of all non-volatile 629 * memories in bytes */ 630 } __packed; 631 632 /* 633 * Data types relating to adapter-initiated FIBs 634 * 635 * Based on types and structures in <aifstruc.h> 636 */ 637 638 /* 639 * Progress Reports 640 */ 641 typedef enum { 642 AifJobStsSuccess = 1, 643 AifJobStsFinished, 644 AifJobStsAborted, 645 AifJobStsFailed, 646 AifJobStsLastReportMarker = 100, /* All prior mean last report */ 647 AifJobStsSuspended, 648 AifJobStsRunning 649 } AAC_AifJobStatus; 650 651 typedef enum { 652 AifJobScsiMin = 1, /* Minimum value for Scsi operation */ 653 AifJobScsiZero, /* SCSI device clear operation */ 654 AifJobScsiVerify, /* SCSI device Verify operation NO 655 * REPAIR */ 656 AifJobScsiExercise, /* SCSI device Exercise operation */ 657 AifJobScsiVerifyRepair, /* SCSI device Verify operation WITH 658 * repair */ 659 AifJobScsiMax = 99, /* Max Scsi value */ 660 AifJobCtrMin, /* Min Ctr op value */ 661 AifJobCtrZero, /* Container clear operation */ 662 AifJobCtrCopy, /* Container copy operation */ 663 AifJobCtrCreateMirror, /* Container Create Mirror operation */ 664 AifJobCtrMergeMirror, /* Container Merge Mirror operation */ 665 AifJobCtrScrubMirror, /* Container Scrub Mirror operation */ 666 AifJobCtrRebuildRaid5, /* Container Rebuild Raid5 operation */ 667 AifJobCtrScrubRaid5, /* Container Scrub Raid5 operation */ 668 AifJobCtrMorph, /* Container morph operation */ 669 AifJobCtrPartCopy, /* Container Partition copy operation */ 670 AifJobCtrRebuildMirror, /* Container Rebuild Mirror operation */ 671 AifJobCtrCrazyCache, /* crazy cache */ 672 AifJobCtrMax = 199, /* Max Ctr type operation */ 673 AifJobFsMin, /* Min Fs type operation */ 674 AifJobFsCreate, /* File System Create operation */ 675 AifJobFsVerify, /* File System Verify operation */ 676 AifJobFsExtend, /* File System Extend operation */ 677 AifJobFsMax = 299, /* Max Fs type operation */ 678 AifJobApiFormatNTFS, /* Format a drive to NTFS */ 679 AifJobApiFormatFAT, /* Format a drive to FAT */ 680 AifJobApiUpdateSnapshot, /* update the read/write half of a 681 * snapshot */ 682 AifJobApiFormatFAT32, /* Format a drive to FAT32 */ 683 AifJobApiMax = 399, /* Max API type operation */ 684 AifJobCtlContinuousCtrVerify, /* Adapter operation */ 685 AifJobCtlMax = 499 /* Max Adapter type operation */ 686 } AAC_AifJobType; 687 688 struct aac_AifContainers { 689 u_int32_t src; /* from/master */ 690 u_int32_t dst; /* to/slave */ 691 } __packed; 692 693 union aac_AifJobClient { 694 struct aac_AifContainers container; /* For Container and 695 * filesystem progress 696 * ops; */ 697 int32_t scsi_dh; /* For SCSI progress 698 * ops */ 699 }; 700 701 struct aac_AifJobDesc { 702 u_int32_t jobID; /* DO NOT FILL IN! Will be 703 * filled in by AIF */ 704 AAC_AifJobType type; /* Operation that is being 705 * performed */ 706 union aac_AifJobClient client; /* Details */ 707 } __packed; 708 709 struct aac_AifJobProgressReport { 710 struct aac_AifJobDesc jd; 711 AAC_AifJobStatus status; 712 u_int32_t finalTick; 713 u_int32_t currentTick; 714 u_int32_t jobSpecificData1; 715 u_int32_t jobSpecificData2; 716 } __packed; 717 718 /* 719 * Event Notification 720 */ 721 typedef enum { 722 /* General application notifies start here */ 723 AifEnGeneric = 1, /* Generic notification */ 724 AifEnTaskComplete, /* Task has completed */ 725 AifEnConfigChange, /* Adapter config change occurred */ 726 AifEnContainerChange, /* Adapter specific container 727 * configuration change */ 728 AifEnDeviceFailure, /* SCSI device failed */ 729 AifEnMirrorFailover, /* Mirror failover started */ 730 AifEnContainerEvent, /* Significant container event */ 731 AifEnFileSystemChange, /* File system changed */ 732 AifEnConfigPause, /* Container pause event */ 733 AifEnConfigResume, /* Container resume event */ 734 AifEnFailoverChange, /* Failover space assignment changed */ 735 AifEnRAID5RebuildDone, /* RAID5 rebuild finished */ 736 AifEnEnclosureManagement, /* Enclosure management event */ 737 AifEnBatteryEvent, /* Significant NV battery event */ 738 AifEnAddContainer, /* A new container was created. */ 739 AifEnDeleteContainer, /* A container was deleted. */ 740 AifEnSMARTEvent, /* SMART Event */ 741 AifEnBatteryNeedsRecond, /* The battery needs reconditioning */ 742 AifEnClusterEvent, /* Some cluster event */ 743 AifEnDiskSetEvent, /* A disk set event occured. */ 744 AifDriverNotifyStart=199, /* Notifies for host driver go here */ 745 /* Host driver notifications start here */ 746 AifDenMorphComplete, /* A morph operation completed */ 747 AifDenVolumeExtendComplete /* Volume expand operation completed */ 748 } AAC_AifEventNotifyType; 749 750 struct aac_AifEnsGeneric { 751 char text[132]; /* Generic text */ 752 } __packed; 753 754 struct aac_AifEnsDeviceFailure { 755 u_int32_t deviceHandle; /* SCSI device handle */ 756 } __packed; 757 758 struct aac_AifEnsMirrorFailover { 759 u_int32_t container; /* Container with failed element */ 760 u_int32_t failedSlice; /* Old slice which failed */ 761 u_int32_t creatingSlice; /* New slice used for auto-create */ 762 } __packed; 763 764 struct aac_AifEnsContainerChange { 765 u_int32_t container[2]; /* container that changed, -1 if no 766 * container */ 767 } __packed; 768 769 struct aac_AifEnsContainerEvent { 770 u_int32_t container; /* container number */ 771 u_int32_t eventType; /* event type */ 772 } __packed; 773 774 struct aac_AifEnsEnclosureEvent { 775 u_int32_t empID; /* enclosure management proc number */ 776 u_int32_t unitID; /* unitId, fan id, power supply id, 777 * slot id, tempsensor id. */ 778 u_int32_t eventType; /* event type */ 779 } __packed; 780 781 struct aac_AifEnsBatteryEvent { 782 AAC_NVBATT_TRANSITION transition_type; /* eg from low to ok */ 783 AAC_NVBATTSTATUS current_state; /* current batt state */ 784 AAC_NVBATTSTATUS prior_state; /* prev batt state */ 785 } __packed; 786 787 struct aac_AifEnsDiskSetEvent { 788 u_int32_t eventType; 789 u_int64_t DsNum; 790 u_int64_t CreatorId; 791 } __packed; 792 793 typedef enum { 794 CLUSTER_NULL_EVENT = 0, 795 CLUSTER_PARTNER_NAME_EVENT, /* change in partner hostname or 796 * adaptername from NULL to non-NULL */ 797 /* (partner's agent may be up) */ 798 CLUSTER_PARTNER_NULL_NAME_EVENT /* change in partner hostname or 799 * adaptername from non-null to NULL */ 800 /* (partner has rebooted) */ 801 } AAC_ClusterAifEvent; 802 803 struct aac_AifEnsClusterEvent { 804 AAC_ClusterAifEvent eventType; 805 } __packed; 806 807 struct aac_AifEventNotify { 808 AAC_AifEventNotifyType type; 809 union { 810 struct aac_AifEnsGeneric EG; 811 struct aac_AifEnsDeviceFailure EDF; 812 struct aac_AifEnsMirrorFailover EMF; 813 struct aac_AifEnsContainerChange ECC; 814 struct aac_AifEnsContainerEvent ECE; 815 struct aac_AifEnsEnclosureEvent EEE; 816 struct aac_AifEnsBatteryEvent EBE; 817 struct aac_AifEnsDiskSetEvent EDS; 818 /* struct aac_AifEnsSMARTEvent ES;*/ 819 struct aac_AifEnsClusterEvent ECLE; 820 } data; 821 } __packed; 822 823 /* 824 * Adapter Initiated FIB command structures. Start with the adapter 825 * initiated FIBs that really come from the adapter, and get responded 826 * to by the host. 827 */ 828 #define AAC_AIF_REPORT_MAX_SIZE 64 829 830 typedef enum { 831 AifCmdEventNotify = 1, /* Notify of event */ 832 AifCmdJobProgress, /* Progress report */ 833 AifCmdAPIReport, /* Report from other user of API */ 834 AifCmdDriverNotify, /* Notify host driver of event */ 835 AifReqJobList = 100, /* Gets back complete job list */ 836 AifReqJobsForCtr, /* Gets back jobs for specific container */ 837 AifReqJobsForScsi, /* Gets back jobs for specific SCSI device */ 838 AifReqJobReport, /* Gets back a specific job report or list */ 839 AifReqTerminateJob, /* Terminates job */ 840 AifReqSuspendJob, /* Suspends a job */ 841 AifReqResumeJob, /* Resumes a job */ 842 AifReqSendAPIReport, /* API generic report requests */ 843 AifReqAPIJobStart, /* Start a job from the API */ 844 AifReqAPIJobUpdate, /* Update a job report from the API */ 845 AifReqAPIJobFinish /* Finish a job from the API */ 846 } AAC_AifCommand; 847 848 struct aac_aif_command { 849 AAC_AifCommand command; /* Tell host what type of 850 * notify this is */ 851 u_int32_t seqNumber; /* To allow ordering of 852 * reports (if necessary) */ 853 union { 854 struct aac_AifEventNotify EN; /* Event notify */ 855 struct aac_AifJobProgressReport PR[1]; /* Progress report */ 856 u_int8_t AR[AAC_AIF_REPORT_MAX_SIZE]; 857 u_int8_t data[AAC_FIB_DATASIZE - 8]; 858 } data; 859 } __packed; 860 861 /* 862 * Filesystem commands/data 863 * 864 * The adapter has a very complex filesystem interface, most of which we ignore. 865 * (And which seems not to be implemented, anyway.) 866 */ 867 868 /* 869 * FSA commands 870 * (not used?) 871 */ 872 typedef enum { 873 Null = 0, 874 GetAttributes, 875 SetAttributes, 876 Lookup, 877 ReadLink, 878 Read, 879 Write, 880 Create, 881 MakeDirectory, 882 SymbolicLink, 883 MakeNode, 884 Removex, 885 RemoveDirectory, 886 Rename, 887 Link, 888 ReadDirectory, 889 ReadDirectoryPlus, 890 FileSystemStatus, 891 FileSystemInfo, 892 PathConfigure, 893 Commit, 894 Mount, 895 UnMount, 896 Newfs, 897 FsCheck, 898 FsSync, 899 SimReadWrite, 900 SetFileSystemStatus, 901 BlockRead, 902 BlockWrite, 903 NvramIoctl, 904 FsSyncWait, 905 ClearArchiveBit, 906 SetAcl, 907 GetAcl, 908 AssignAcl, 909 FaultInsertion, 910 CrazyCache 911 } AAC_FSACommand; 912 913 /* 914 * Command status values 915 */ 916 typedef enum { 917 ST_OK = 0, 918 ST_PERM = 1, 919 ST_NOENT = 2, 920 ST_IO = 5, 921 ST_NXIO = 6, 922 ST_E2BIG = 7, 923 ST_ACCES = 13, 924 ST_EXIST = 17, 925 ST_XDEV = 18, 926 ST_NODEV = 19, 927 ST_NOTDIR = 20, 928 ST_ISDIR = 21, 929 ST_INVAL = 22, 930 ST_FBIG = 27, 931 ST_NOSPC = 28, 932 ST_ROFS = 30, 933 ST_MLINK = 31, 934 ST_WOULDBLOCK = 35, 935 ST_NAMETOOLONG = 63, 936 ST_NOTEMPTY = 66, 937 ST_DQUOT = 69, 938 ST_STALE = 70, 939 ST_REMOTE = 71, 940 ST_BADHANDLE = 10001, 941 ST_NOT_SYNC = 10002, 942 ST_BAD_COOKIE = 10003, 943 ST_NOTSUPP = 10004, 944 ST_TOOSMALL = 10005, 945 ST_SERVERFAULT = 10006, 946 ST_BADTYPE = 10007, 947 ST_JUKEBOX = 10008, 948 ST_NOTMOUNTED = 10009, 949 ST_MAINTMODE = 10010, 950 ST_STALEACL = 10011 951 } AAC_FSAStatus; 952 953 /* 954 * Volume manager commands 955 */ 956 typedef enum _VM_COMMANDS { 957 VM_Null = 0, 958 VM_NameServe, 959 VM_ContainerConfig, 960 VM_Ioctl, 961 VM_FilesystemIoctl, 962 VM_CloseAll, 963 VM_CtBlockRead, 964 VM_CtBlockWrite, 965 VM_SliceBlockRead, /* raw access to configured storage objects */ 966 VM_SliceBlockWrite, 967 VM_DriveBlockRead, /* raw access to physical devices */ 968 VM_DriveBlockWrite, 969 VM_EnclosureMgt, /* enclosure management */ 970 VM_Unused, /* used to be diskset management */ 971 VM_CtBlockVerify, 972 VM_CtPerf, /* performance test */ 973 VM_CtBlockRead64, 974 VM_CtBlockWrite64, 975 VM_CtBlockVerify64, 976 VM_CtHostRead64, 977 VM_CtHostWrite64, 978 } AAC_VMCommand; 979 980 /* 981 * "mountable object" 982 */ 983 struct aac_mntobj { 984 u_int32_t ObjectId; 985 char FileSystemName[16]; 986 struct aac_container_creation CreateInfo; 987 u_int32_t Capacity; 988 u_int32_t VolType; 989 u_int32_t ObjType; 990 u_int32_t ContentState; 991 #define FSCS_READONLY 0x0002 /* XXX need more information 992 * than this */ 993 union { 994 u_int32_t pad[8]; 995 } ObjExtension; 996 u_int32_t AlterEgoId; 997 } __packed; 998 999 struct aac_mntinfo { 1000 u_int32_t Command; 1001 u_int32_t MntType; 1002 u_int32_t MntCount; 1003 } __packed; 1004 1005 struct aac_mntinforesp { 1006 u_int32_t Status; 1007 u_int32_t MntType; 1008 u_int32_t MntRespCount; 1009 struct aac_mntobj MntTable[1]; 1010 } __packed; 1011 1012 /* 1013 * Container shutdown command. 1014 */ 1015 struct aac_closecommand { 1016 u_int32_t Command; 1017 u_int32_t ContainerId; 1018 } __packed; 1019 1020 /* 1021 * Container Config Command 1022 */ 1023 #define CT_GET_SCSI_METHOD 64 1024 struct aac_ctcfg { 1025 u_int32_t Command; 1026 u_int32_t cmd; 1027 u_int32_t param; 1028 } __packed; 1029 1030 struct aac_ctcfg_resp { 1031 u_int32_t Status; 1032 u_int32_t resp; 1033 u_int32_t param; 1034 } __packed; 1035 1036 /* 1037 * 'Ioctl' commads 1038 */ 1039 #define AAC_SCSI_MAX_PORTS 10 1040 #define AAC_BUS_NO_EXIST 0 1041 #define AAC_BUS_VALID 1 1042 #define AAC_BUS_FAULTED 2 1043 #define AAC_BUS_DISABLED 3 1044 #define GetBusInfo 0x9 1045 1046 struct aac_getbusinf { 1047 u_int32_t ProbeComplete; 1048 u_int32_t BusCount; 1049 u_int32_t TargetsPerBus; 1050 u_int8_t InitiatorBusId[AAC_SCSI_MAX_PORTS]; 1051 u_int8_t BusValid[AAC_SCSI_MAX_PORTS]; 1052 } __packed; 1053 1054 struct aac_vmioctl { 1055 u_int32_t Command; 1056 u_int32_t ObjType; 1057 u_int32_t MethId; 1058 u_int32_t ObjId; 1059 u_int32_t IoctlCmd; 1060 u_int32_t IoctlBuf[1]; /* Placeholder? */ 1061 } __packed; 1062 1063 struct aac_vmi_businf_resp { 1064 u_int32_t Status; 1065 u_int32_t ObjType; 1066 u_int32_t MethId; 1067 u_int32_t ObjId; 1068 u_int32_t IoctlCmd; 1069 struct aac_getbusinf BusInf; 1070 } __packed; 1071 1072 #define AAC_BTL_TO_HANDLE(b, t, l) \ 1073 (((b & 0x3f) << 7) | ((l & 0x7) << 4) | (t & 0xf)) 1074 #define GetDeviceProbeInfo 0x5 1075 1076 struct aac_vmi_devinfo_resp { 1077 u_int32_t Status; 1078 u_int32_t ObjType; 1079 u_int32_t MethId; 1080 u_int32_t ObjId; 1081 u_int32_t IoctlCmd; 1082 u_int8_t VendorId[8]; 1083 u_int8_t ProductId[16]; 1084 u_int8_t ProductRev[4]; 1085 u_int32_t Inquiry7; 1086 u_int32_t align1; 1087 u_int32_t Inquiry0; 1088 u_int32_t align2; 1089 u_int32_t Inquiry1; 1090 u_int32_t align3; 1091 u_int32_t reserved[2]; 1092 u_int8_t VendorSpecific[20]; 1093 u_int32_t Smart:1; 1094 u_int32_t AAC_Managed:1; 1095 u_int32_t align4; 1096 u_int32_t reserved2:6; 1097 u_int32_t Bus; 1098 u_int32_t Target; 1099 u_int32_t Lun; 1100 u_int32_t ultraEnable:1, 1101 disconnectEnable:1, 1102 fast20EnabledW:1, 1103 scamDevice:1, 1104 scamTolerant:1, 1105 setForSync:1, 1106 setForWide:1, 1107 syncDevice:1, 1108 wideDevice:1, 1109 reserved1:7, 1110 ScsiRate:8, 1111 ScsiOffset:8; 1112 }; /* Do not pack */ 1113 1114 #define ResetBus 0x16 1115 struct aac_resetbus { 1116 u_int32_t BusNumber; 1117 }; 1118 1119 /* 1120 * Write 'stability' options. 1121 */ 1122 typedef enum { 1123 CSTABLE = 1, 1124 CUNSTABLE 1125 } AAC_CacheLevel; 1126 1127 /* 1128 * Commit level response for a write request. 1129 */ 1130 typedef enum { 1131 CMFILE_SYNC_NVRAM = 1, 1132 CMDATA_SYNC_NVRAM, 1133 CMFILE_SYNC, 1134 CMDATA_SYNC, 1135 CMUNSTABLE 1136 } AAC_CommitLevel; 1137 1138 /* 1139 * Block read/write operations. 1140 * These structures are packed into the 'data' area in the FIB. 1141 */ 1142 1143 struct aac_blockread { 1144 u_int32_t Command; /* not FSACommand! */ 1145 u_int32_t ContainerId; 1146 u_int32_t BlockNumber; 1147 u_int32_t ByteCount; 1148 struct aac_sg_table SgMap; /* variable size */ 1149 } __packed; 1150 1151 struct aac_blockread64 { 1152 u_int32_t Command; 1153 u_int16_t ContainerId; 1154 u_int16_t SectorCount; 1155 u_int32_t BlockNumber; 1156 u_int16_t Pad; 1157 u_int16_t Flags; 1158 struct aac_sg_table64 SgMap64; 1159 } __packed; 1160 1161 struct aac_blockread_response { 1162 u_int32_t Status; 1163 u_int32_t ByteCount; 1164 } __packed; 1165 1166 struct aac_blockwrite { 1167 u_int32_t Command; /* not FSACommand! */ 1168 u_int32_t ContainerId; 1169 u_int32_t BlockNumber; 1170 u_int32_t ByteCount; 1171 u_int32_t Stable; 1172 struct aac_sg_table SgMap; /* variable size */ 1173 } __packed; 1174 1175 struct aac_blockwrite64 { 1176 u_int32_t Command; /* not FSACommand! */ 1177 u_int16_t ContainerId; 1178 u_int16_t SectorCount; 1179 u_int32_t BlockNumber; 1180 u_int16_t Pad; 1181 u_int16_t Flags; 1182 struct aac_sg_table64 SgMap64; /* variable size */ 1183 } __packed; 1184 1185 struct aac_blockwrite_response { 1186 u_int32_t Status; 1187 u_int32_t ByteCount; 1188 u_int32_t Committed; 1189 } __packed; 1190 1191 /* 1192 * Container shutdown command. 1193 */ 1194 struct aac_close_command { 1195 u_int32_t Command; 1196 u_int32_t ContainerId; 1197 }; 1198 1199 /* 1200 * SCSI Passthrough structures 1201 */ 1202 struct aac_srb32 { 1203 u_int32_t function; 1204 u_int32_t bus; 1205 u_int32_t target; 1206 u_int32_t lun; 1207 u_int32_t timeout; 1208 u_int32_t flags; 1209 u_int32_t data_len; 1210 u_int32_t retry_limit; 1211 u_int32_t cdb_len; 1212 u_int8_t cdb[16]; 1213 struct aac_sg_table sg_map32; 1214 }; 1215 1216 enum { 1217 AAC_SRB_FUNC_EXECUTE_SCSI = 0x00, 1218 AAC_SRB_FUNC_CLAIM_DEVICE, 1219 AAC_SRB_FUNC_IO_CONTROL, 1220 AAC_SRB_FUNC_RECEIVE_EVENT, 1221 AAC_SRB_FUNC_RELEASE_QUEUE, 1222 AAC_SRB_FUNC_ATTACH_DEVICE, 1223 AAC_SRB_FUNC_RELEASE_DEVICE, 1224 AAC_SRB_FUNC_SHUTDOWN, 1225 AAC_SRB_FUNC_FLUSH, 1226 AAC_SRB_FUNC_ABORT_COMMAND = 0x10, 1227 AAC_SRB_FUNC_RELEASE_RECOVERY, 1228 AAC_SRB_FUNC_RESET_BUS, 1229 AAC_SRB_FUNC_RESET_DEVICE, 1230 AAC_SRB_FUNC_TERMINATE_IO, 1231 AAC_SRB_FUNC_FLUSH_QUEUE, 1232 AAC_SRB_FUNC_REMOVE_DEVICE, 1233 AAC_SRB_FUNC_DOMAIN_VALIDATION 1234 }; 1235 1236 #define AAC_SRB_FLAGS_NO_DATA_XFER 0x0000 1237 #define AAC_SRB_FLAGS_DISABLE_DISCONNECT 0x0004 1238 #define AAC_SRB_FLAGS_DISABLE_SYNC_TRANSFER 0x0008 1239 #define AAC_SRB_FLAGS_BYPASS_FROZEN_QUEUE 0x0010 1240 #define AAC_SRB_FLAGS_DISABLE_AUTOSENSE 0x0020 1241 #define AAC_SRB_FLAGS_DATA_IN 0x0040 1242 #define AAC_SRB_FLAGS_DATA_OUT 0x0080 1243 #define AAC_SRB_FLAGS_UNSPECIFIED_DIRECTION \ 1244 (AAC_SRB_FLAGS_DATA_IN | AAC_SRB_FLAGS_DATA_OUT) 1245 1246 #define AAC_HOST_SENSE_DATA_MAX 30 1247 1248 struct aac_srb_response { 1249 u_int32_t fib_status; 1250 u_int32_t srb_status; 1251 u_int32_t scsi_status; 1252 u_int32_t data_len; 1253 u_int32_t sense_len; 1254 u_int8_t sense[AAC_HOST_SENSE_DATA_MAX]; 1255 }; 1256 1257 enum { 1258 AAC_SRB_STS_PENDING = 0x00, 1259 AAC_SRB_STS_SUCCESS, 1260 AAC_SRB_STS_ABORTED, 1261 AAC_SRB_STS_ABORT_FAILED, 1262 AAC_SRB_STS_ERROR, 1263 AAC_SRB_STS_BUSY, 1264 AAC_SRB_STS_INVALID_REQUEST, 1265 AAC_SRB_STS_INVALID_PATH_ID, 1266 AAC_SRB_STS_NO_DEVICE, 1267 AAC_SRB_STS_TIMEOUT, 1268 AAC_SRB_STS_SELECTION_TIMEOUT, 1269 AAC_SRB_STS_COMMAND_TIMEOUT, 1270 AAC_SRB_STS_MESSAGE_REJECTED = 0x0D, 1271 AAC_SRB_STS_BUS_RESET, 1272 AAC_SRB_STS_PARITY_ERROR, 1273 AAC_SRB_STS_REQUEST_SENSE_FAILED, 1274 AAC_SRB_STS_NO_HBA, 1275 AAC_SRB_STS_DATA_OVERRUN, 1276 AAC_SRB_STS_UNEXPECTED_BUS_FREE, 1277 AAC_SRB_STS_PHASE_SEQUENCE_FAILURE, 1278 AAC_SRB_STS_BAD_SRB_BLOCK_LENGTH, 1279 AAC_SRB_STS_REQUEST_FLUSHED, 1280 AAC_SRB_STS_INVALID_LUN = 0x20, 1281 AAC_SRB_STS_INVALID_TARGET_ID, 1282 AAC_SRB_STS_BAD_FUNCTION, 1283 AAC_SRB_STS_ERROR_RECOVERY 1284 }; 1285 1286 /* 1287 * Register set for adapters based on the Falcon bridge and PPC core 1288 */ 1289 1290 #define AAC_FA_DOORBELL0_CLEAR 0x00 1291 #define AAC_FA_DOORBELL1_CLEAR 0x02 1292 #define AAC_FA_DOORBELL0 0x04 1293 #define AAC_FA_DOORBELL1 0x06 1294 #define AAC_FA_MASK0_CLEAR 0x08 1295 #define AAC_FA_MASK1_CLEAR 0x0a 1296 #define AAC_FA_MASK0 0x0c 1297 #define AAC_FA_MASK1 0x0e 1298 #define AAC_FA_MAILBOX 0x10 1299 #define AAC_FA_FWSTATUS 0x2c /* Mailbox 7 */ 1300 #define AAC_FA_INTSRC 0x900 1301 1302 #define AAC_FA_HACK(sc) (void)AAC_GETREG4(sc, AAC_FA_INTSRC) 1303 1304 /* 1305 * Register definitions for the Adaptec AAC-364 'Jalapeno I/II' adapters, based 1306 * on the SA110 'StrongArm'. 1307 */ 1308 1309 #define AAC_SA_DOORBELL0_CLEAR 0x98 /* doorbell 0 (adapter->host) */ 1310 #define AAC_SA_DOORBELL0_SET 0x9c 1311 #define AAC_SA_DOORBELL0 0x9c 1312 #define AAC_SA_MASK0_CLEAR 0xa0 1313 #define AAC_SA_MASK0_SET 0xa4 1314 1315 #define AAC_SA_DOORBELL1_CLEAR 0x9a /* doorbell 1 (host->adapter) */ 1316 #define AAC_SA_DOORBELL1_SET 0x9e 1317 #define AAC_SA_DOORBELL1 0x9e 1318 #define AAC_SA_MASK1_CLEAR 0xa2 1319 #define AAC_SA_MASK1_SET 0xa6 1320 1321 #define AAC_SA_MAILBOX 0xa8 /* mailbox (20 bytes) */ 1322 #define AAC_SA_FWSTATUS 0xc4 1323 1324 /* 1325 * Register definitions for the Adaptec 'Pablano' adapters, based on the i960Rx, 1326 * and other related adapters. 1327 */ 1328 1329 #define AAC_RX_IDBR 0x20 /* inbound doorbell register */ 1330 #define AAC_RX_IISR 0x24 /* inbound interrupt status register */ 1331 #define AAC_RX_IIMR 0x28 /* inbound interrupt mask register */ 1332 #define AAC_RX_ODBR 0x2c /* outbound doorbell register */ 1333 #define AAC_RX_OISR 0x30 /* outbound interrupt status register */ 1334 #define AAC_RX_OIMR 0x34 /* outbound interrupt mask register */ 1335 1336 #define AAC_RX_MAILBOX 0x50 /* mailbox (20 bytes) */ 1337 #define AAC_RX_FWSTATUS 0x6c 1338 1339 /* 1340 * Common bit definitions for the doorbell registers. 1341 */ 1342 1343 /* 1344 * Status bits in the doorbell registers. 1345 */ 1346 #define AAC_DB_SYNC_COMMAND (1<<0) /* send/completed synchronous FIB */ 1347 #define AAC_DB_COMMAND_READY (1<<1) /* posted one or more commands */ 1348 #define AAC_DB_RESPONSE_READY (1<<2) /* one or more commands complete */ 1349 #define AAC_DB_COMMAND_NOT_FULL (1<<3) /* command queue not full */ 1350 #define AAC_DB_RESPONSE_NOT_FULL (1<<4) /* response queue not full */ 1351 1352 /* 1353 * The adapter can request the host print a message by setting the 1354 * DB_PRINTF flag in DOORBELL0. The driver responds by collecting the 1355 * message from the printf buffer, clearing the DB_PRINTF flag in 1356 * DOORBELL0 and setting it in DOORBELL1. 1357 * (ODBR and IDBR respectively for the i960Rx adapters) 1358 */ 1359 #define AAC_DB_PRINTF (1<<5) /* adapter requests host printf */ 1360 #define AAC_PRINTF_DONE (1<<5) /* Host completed printf processing */ 1361 1362 /* 1363 * Mask containing the interrupt bits we care about. We don't anticipate (or 1364 * want) interrupts not in this mask. 1365 */ 1366 #define AAC_DB_INTERRUPTS (AAC_DB_COMMAND_READY | \ 1367 AAC_DB_RESPONSE_READY | \ 1368 AAC_DB_PRINTF) 1369