1 #if (!defined(dprintk)) 2 # define dprintk(x) 3 #endif 4 5 /*------------------------------------------------------------------------------ 6 * D E F I N E S 7 *----------------------------------------------------------------------------*/ 8 9 #define MAXIMUM_NUM_CONTAINERS 32 10 11 #define AAC_NUM_FIB (256 + 64) 12 #define AAC_NUM_IO_FIB 100 13 14 #define AAC_MAX_LUN (8) 15 16 #define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff) 17 18 /* 19 * These macros convert from physical channels to virtual channels 20 */ 21 #define CONTAINER_CHANNEL (0) 22 #define ID_LUN_TO_CONTAINER(id, lun) (id) 23 #define CONTAINER_TO_CHANNEL(cont) (CONTAINER_CHANNEL) 24 #define CONTAINER_TO_ID(cont) (cont) 25 #define CONTAINER_TO_LUN(cont) (0) 26 27 #define aac_phys_to_logical(x) (x+1) 28 #define aac_logical_to_phys(x) (x?x-1:0) 29 30 /* #define AAC_DETAILED_STATUS_INFO */ 31 32 struct diskparm 33 { 34 int heads; 35 int sectors; 36 int cylinders; 37 }; 38 39 40 /* 41 * DON'T CHANGE THE ORDER, this is set by the firmware 42 */ 43 44 #define CT_NONE 0 45 #define CT_VOLUME 1 46 #define CT_MIRROR 2 47 #define CT_STRIPE 3 48 #define CT_RAID5 4 49 #define CT_SSRW 5 50 #define CT_SSRO 6 51 #define CT_MORPH 7 52 #define CT_PASSTHRU 8 53 #define CT_RAID4 9 54 #define CT_RAID10 10 /* stripe of mirror */ 55 #define CT_RAID00 11 /* stripe of stripe */ 56 #define CT_VOLUME_OF_MIRRORS 12 /* volume of mirror */ 57 #define CT_PSEUDO_RAID 13 /* really raid4 */ 58 #define CT_LAST_VOLUME_TYPE 14 59 #define CT_OK 218 60 61 /* 62 * Types of objects addressable in some fashion by the client. 63 * This is a superset of those objects handled just by the filesystem 64 * and includes "raw" objects that an administrator would use to 65 * configure containers and filesystems. 66 */ 67 68 #define FT_REG 1 /* regular file */ 69 #define FT_DIR 2 /* directory */ 70 #define FT_BLK 3 /* "block" device - reserved */ 71 #define FT_CHR 4 /* "character special" device - reserved */ 72 #define FT_LNK 5 /* symbolic link */ 73 #define FT_SOCK 6 /* socket */ 74 #define FT_FIFO 7 /* fifo */ 75 #define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */ 76 #define FT_DRIVE 9 /* physical disk - addressable in scsi by bus/id/lun */ 77 #define FT_SLICE 10 /* virtual disk - raw volume - slice */ 78 #define FT_PARTITION 11 /* FSA partition - carved out of a slice - building block for containers */ 79 #define FT_VOLUME 12 /* Container - Volume Set */ 80 #define FT_STRIPE 13 /* Container - Stripe Set */ 81 #define FT_MIRROR 14 /* Container - Mirror Set */ 82 #define FT_RAID5 15 /* Container - Raid 5 Set */ 83 #define FT_DATABASE 16 /* Storage object with "foreign" content manager */ 84 85 /* 86 * Host side memory scatter gather list 87 * Used by the adapter for read, write, and readdirplus operations 88 * We have separate 32 and 64 bit version because even 89 * on 64 bit systems not all cards support the 64 bit version 90 */ 91 struct sgentry { 92 u32 addr; /* 32-bit address. */ 93 u32 count; /* Length. */ 94 }; 95 96 struct sgentry64 { 97 u32 addr[2]; /* 64-bit addr. 2 pieces for data alignment */ 98 u32 count; /* Length. */ 99 }; 100 101 /* 102 * SGMAP 103 * 104 * This is the SGMAP structure for all commands that use 105 * 32-bit addressing. 106 */ 107 108 struct sgmap { 109 u32 count; 110 struct sgentry sg[1]; 111 }; 112 113 struct sgmap64 { 114 u32 count; 115 struct sgentry64 sg[1]; 116 }; 117 118 struct creation_info 119 { 120 u8 buildnum; /* e.g., 588 */ 121 u8 usec; /* e.g., 588 */ 122 u8 via; /* e.g., 1 = FSU, 123 * 2 = API 124 */ 125 u8 year; /* e.g., 1997 = 97 */ 126 u32 date; /* 127 * unsigned Month :4; // 1 - 12 128 * unsigned Day :6; // 1 - 32 129 * unsigned Hour :6; // 0 - 23 130 * unsigned Minute :6; // 0 - 60 131 * unsigned Second :6; // 0 - 60 132 */ 133 u32 serial[2]; /* e.g., 0x1DEADB0BFAFAF001 */ 134 }; 135 136 137 /* 138 * Define all the constants needed for the communication interface 139 */ 140 141 /* 142 * Define how many queue entries each queue will have and the total 143 * number of entries for the entire communication interface. Also define 144 * how many queues we support. 145 * 146 * This has to match the controller 147 */ 148 149 #define NUMBER_OF_COMM_QUEUES 8 // 4 command; 4 response 150 #define HOST_HIGH_CMD_ENTRIES 4 151 #define HOST_NORM_CMD_ENTRIES 8 152 #define ADAP_HIGH_CMD_ENTRIES 4 153 #define ADAP_NORM_CMD_ENTRIES 512 154 #define HOST_HIGH_RESP_ENTRIES 4 155 #define HOST_NORM_RESP_ENTRIES 512 156 #define ADAP_HIGH_RESP_ENTRIES 4 157 #define ADAP_NORM_RESP_ENTRIES 8 158 159 #define TOTAL_QUEUE_ENTRIES \ 160 (HOST_NORM_CMD_ENTRIES + HOST_HIGH_CMD_ENTRIES + ADAP_NORM_CMD_ENTRIES + ADAP_HIGH_CMD_ENTRIES + \ 161 HOST_NORM_RESP_ENTRIES + HOST_HIGH_RESP_ENTRIES + ADAP_NORM_RESP_ENTRIES + ADAP_HIGH_RESP_ENTRIES) 162 163 164 /* 165 * Set the queues on a 16 byte alignment 166 */ 167 168 #define QUEUE_ALIGNMENT 16 169 170 /* 171 * The queue headers define the Communication Region queues. These 172 * are physically contiguous and accessible by both the adapter and the 173 * host. Even though all queue headers are in the same contiguous block 174 * they will be represented as individual units in the data structures. 175 */ 176 177 struct aac_entry { 178 u32 size; /* Size in bytes of Fib which this QE points to */ 179 u32 addr; /* Receiver address of the FIB */ 180 }; 181 182 /* 183 * The adapter assumes the ProducerIndex and ConsumerIndex are grouped 184 * adjacently and in that order. 185 */ 186 187 struct aac_qhdr { 188 u64 header_addr; /* Address to hand the adapter to access to this queue head */ 189 u32 *producer; /* The producer index for this queue (host address) */ 190 u32 *consumer; /* The consumer index for this queue (host address) */ 191 }; 192 193 /* 194 * Define all the events which the adapter would like to notify 195 * the host of. 196 */ 197 198 #define HostNormCmdQue 1 /* Change in host normal priority command queue */ 199 #define HostHighCmdQue 2 /* Change in host high priority command queue */ 200 #define HostNormRespQue 3 /* Change in host normal priority response queue */ 201 #define HostHighRespQue 4 /* Change in host high priority response queue */ 202 #define AdapNormRespNotFull 5 203 #define AdapHighRespNotFull 6 204 #define AdapNormCmdNotFull 7 205 #define AdapHighCmdNotFull 8 206 #define SynchCommandComplete 9 207 #define AdapInternalError 0xfe /* The adapter detected an internal error shutting down */ 208 209 /* 210 * Define all the events the host wishes to notify the 211 * adapter of. The first four values much match the Qid the 212 * corresponding queue. 213 */ 214 215 #define AdapNormCmdQue 2 216 #define AdapHighCmdQue 3 217 #define AdapNormRespQue 6 218 #define AdapHighRespQue 7 219 #define HostShutdown 8 220 #define HostPowerFail 9 221 #define FatalCommError 10 222 #define HostNormRespNotFull 11 223 #define HostHighRespNotFull 12 224 #define HostNormCmdNotFull 13 225 #define HostHighCmdNotFull 14 226 #define FastIo 15 227 #define AdapPrintfDone 16 228 229 /* 230 * Define all the queues that the adapter and host use to communicate 231 * Number them to match the physical queue layout. 232 */ 233 234 enum aac_queue_types { 235 HostNormCmdQueue = 0, /* Adapter to host normal priority command traffic */ 236 HostHighCmdQueue, /* Adapter to host high priority command traffic */ 237 AdapNormCmdQueue, /* Host to adapter normal priority command traffic */ 238 AdapHighCmdQueue, /* Host to adapter high priority command traffic */ 239 HostNormRespQueue, /* Adapter to host normal priority response traffic */ 240 HostHighRespQueue, /* Adapter to host high priority response traffic */ 241 AdapNormRespQueue, /* Host to adapter normal priority response traffic */ 242 AdapHighRespQueue /* Host to adapter high priority response traffic */ 243 }; 244 245 /* 246 * Assign type values to the FSA communication data structures 247 */ 248 249 #define FIB_MAGIC 0x0001 250 251 /* 252 * Define the priority levels the FSA communication routines support. 253 */ 254 255 #define FsaNormal 1 256 #define FsaHigh 2 257 258 /* 259 * Define the FIB. The FIB is the where all the requested data and 260 * command information are put to the application on the FSA adapter. 261 */ 262 263 struct aac_fibhdr { 264 u32 XferState; // Current transfer state for this CCB 265 u16 Command; // Routing information for the destination 266 u8 StructType; // Type FIB 267 u8 Flags; // Flags for FIB 268 u16 Size; // Size of this FIB in bytes 269 u16 SenderSize; // Size of the FIB in the sender (for response sizing) 270 u32 SenderFibAddress; // Host defined data in the FIB 271 u32 ReceiverFibAddress; // Logical address of this FIB for the adapter 272 u32 SenderData; // Place holder for the sender to store data 273 union { 274 struct { 275 u32 _ReceiverTimeStart; // Timestamp for receipt of fib 276 u32 _ReceiverTimeDone; // Timestamp for completion of fib 277 } _s; 278 } _u; 279 }; 280 281 #define FIB_DATA_SIZE_IN_BYTES (512 - sizeof(struct aac_fibhdr)) 282 283 284 struct hw_fib { 285 struct aac_fibhdr header; 286 u8 data[FIB_DATA_SIZE_IN_BYTES]; // Command specific data 287 }; 288 289 /* 290 * FIB commands 291 */ 292 293 #define TestCommandResponse 1 294 #define TestAdapterCommand 2 295 /* 296 * Lowlevel and comm commands 297 */ 298 #define LastTestCommand 100 299 #define ReinitHostNormCommandQueue 101 300 #define ReinitHostHighCommandQueue 102 301 #define ReinitHostHighRespQueue 103 302 #define ReinitHostNormRespQueue 104 303 #define ReinitAdapNormCommandQueue 105 304 #define ReinitAdapHighCommandQueue 107 305 #define ReinitAdapHighRespQueue 108 306 #define ReinitAdapNormRespQueue 109 307 #define InterfaceShutdown 110 308 #define DmaCommandFib 120 309 #define StartProfile 121 310 #define TermProfile 122 311 #define SpeedTest 123 312 #define TakeABreakPt 124 313 #define RequestPerfData 125 314 #define SetInterruptDefTimer 126 315 #define SetInterruptDefCount 127 316 #define GetInterruptDefStatus 128 317 #define LastCommCommand 129 318 /* 319 * Filesystem commands 320 */ 321 #define NuFileSystem 300 322 #define UFS 301 323 #define HostFileSystem 302 324 #define LastFileSystemCommand 303 325 /* 326 * Container Commands 327 */ 328 #define ContainerCommand 500 329 #define ContainerCommand64 501 330 /* 331 * Cluster Commands 332 */ 333 #define ClusterCommand 550 334 /* 335 * Scsi Port commands (scsi passthrough) 336 */ 337 #define ScsiPortCommand 600 338 #define ScsiPortCommand64 601 339 /* 340 * Misc house keeping and generic adapter initiated commands 341 */ 342 #define AifRequest 700 343 #define CheckRevision 701 344 #define FsaHostShutdown 702 345 #define RequestAdapterInfo 703 346 #define IsAdapterPaused 704 347 #define SendHostTime 705 348 #define LastMiscCommand 706 349 350 // 351 // Commands that will target the failover level on the FSA adapter 352 // 353 354 enum fib_xfer_state { 355 HostOwned = (1<<0), 356 AdapterOwned = (1<<1), 357 FibInitialized = (1<<2), 358 FibEmpty = (1<<3), 359 AllocatedFromPool = (1<<4), 360 SentFromHost = (1<<5), 361 SentFromAdapter = (1<<6), 362 ResponseExpected = (1<<7), 363 NoResponseExpected = (1<<8), 364 AdapterProcessed = (1<<9), 365 HostProcessed = (1<<10), 366 HighPriority = (1<<11), 367 NormalPriority = (1<<12), 368 Async = (1<<13), 369 AsyncIo = (1<<13), // rpbfix: remove with new regime 370 PageFileIo = (1<<14), // rpbfix: remove with new regime 371 ShutdownRequest = (1<<15), 372 LazyWrite = (1<<16), // rpbfix: remove with new regime 373 AdapterMicroFib = (1<<17), 374 BIOSFibPath = (1<<18), 375 FastResponseCapable = (1<<19), 376 ApiFib = (1<<20) // Its an API Fib. 377 }; 378 379 /* 380 * The following defines needs to be updated any time there is an 381 * incompatible change made to the aac_init structure. 382 */ 383 384 #define ADAPTER_INIT_STRUCT_REVISION 3 385 386 struct aac_init 387 { 388 u32 InitStructRevision; 389 u32 MiniPortRevision; 390 u32 fsrev; 391 u32 CommHeaderAddress; 392 u32 FastIoCommAreaAddress; 393 u32 AdapterFibsPhysicalAddress; 394 u32 AdapterFibsVirtualAddress; 395 u32 AdapterFibsSize; 396 u32 AdapterFibAlign; 397 u32 printfbuf; 398 u32 printfbufsiz; 399 u32 HostPhysMemPages; // number of 4k pages of host physical memory 400 u32 HostElapsedSeconds; // number of seconds since 1970. 401 }; 402 403 enum aac_log_level { 404 LOG_AAC_INIT = 10, 405 LOG_AAC_INFORMATIONAL = 20, 406 LOG_AAC_WARNING = 30, 407 LOG_AAC_LOW_ERROR = 40, 408 LOG_AAC_MEDIUM_ERROR = 50, 409 LOG_AAC_HIGH_ERROR = 60, 410 LOG_AAC_PANIC = 70, 411 LOG_AAC_DEBUG = 80, 412 LOG_AAC_WINDBG_PRINT = 90 413 }; 414 415 #define FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT 0x030b 416 #define FSAFS_NTC_FIB_CONTEXT 0x030c 417 418 struct aac_dev; 419 420 struct adapter_ops 421 { 422 void (*adapter_interrupt)(struct aac_dev *dev); 423 void (*adapter_notify)(struct aac_dev *dev, u32 event); 424 int (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 *status); 425 int (*adapter_check_health)(struct aac_dev *dev); 426 }; 427 428 /* 429 * Define which interrupt handler needs to be installed 430 */ 431 432 struct aac_driver_ident 433 { 434 int (*init)(struct aac_dev *dev); 435 char * name; 436 char * vname; 437 char * model; 438 u16 channels; 439 int quirks; 440 }; 441 /* 442 * Some adapter firmware needs communication memory 443 * below 2gig. This tells the init function to set the 444 * dma mask such that fib memory will be allocated where the 445 * adapter firmware can get to it. 446 */ 447 #define AAC_QUIRK_31BIT 0x0001 448 449 /* 450 * Some adapter firmware, when the raid card's cache is turned off, can not 451 * split up scatter gathers in order to deal with the limits of the 452 * underlying CHIM. This limit is 34 scatter gather elements. 453 */ 454 #define AAC_QUIRK_34SG 0x0002 455 456 /* 457 * This adapter is a slave (no Firmware) 458 */ 459 #define AAC_QUIRK_SLAVE 0x0004 460 461 /* 462 * This adapter is a master. 463 */ 464 #define AAC_QUIRK_MASTER 0x0008 465 466 /* 467 * The adapter interface specs all queues to be located in the same 468 * physically contigous block. The host structure that defines the 469 * commuication queues will assume they are each a separate physically 470 * contigous memory region that will support them all being one big 471 * contigous block. 472 * There is a command and response queue for each level and direction of 473 * commuication. These regions are accessed by both the host and adapter. 474 */ 475 476 struct aac_queue { 477 u64 logical; /*address we give the adapter */ 478 struct aac_entry *base; /*system virtual address */ 479 struct aac_qhdr headers; /*producer,consumer q headers*/ 480 u32 entries; /*Number of queue entries */ 481 wait_queue_head_t qfull; /*Event to wait on if q full */ 482 wait_queue_head_t cmdready; /*Cmd ready from the adapter */ 483 /* This is only valid for adapter to host command queues. */ 484 spinlock_t *lock; /* Spinlock for this queue must take this lock before accessing the lock */ 485 spinlock_t lockdata; /* Actual lock (used only on one side of the lock) */ 486 unsigned long SavedIrql; /* Previous IRQL when the spin lock is taken */ 487 u32 padding; /* Padding - FIXME - can remove I believe */ 488 struct list_head cmdq; /* A queue of FIBs which need to be prcessed by the FS thread. This is */ 489 /* only valid for command queues which receive entries from the adapter. */ 490 struct list_head pendingq; /* A queue of outstanding fib's to the adapter. */ 491 u32 numpending; /* Number of entries on outstanding queue. */ 492 struct aac_dev * dev; /* Back pointer to adapter structure */ 493 }; 494 495 /* 496 * Message queues. The order here is important, see also the 497 * queue type ordering 498 */ 499 500 struct aac_queue_block 501 { 502 struct aac_queue queue[8]; 503 }; 504 505 /* 506 * SaP1 Message Unit Registers 507 */ 508 509 struct sa_drawbridge_CSR { 510 /* Offset | Name */ 511 __le32 reserved[10]; /* 00h-27h | Reserved */ 512 u8 LUT_Offset; /* 28h | Lookup Table Offset */ 513 u8 reserved1[3]; /* 29h-2bh | Reserved */ 514 __le32 LUT_Data; /* 2ch | Looup Table Data */ 515 __le32 reserved2[26]; /* 30h-97h | Reserved */ 516 __le16 PRICLEARIRQ; /* 98h | Primary Clear Irq */ 517 __le16 SECCLEARIRQ; /* 9ah | Secondary Clear Irq */ 518 __le16 PRISETIRQ; /* 9ch | Primary Set Irq */ 519 __le16 SECSETIRQ; /* 9eh | Secondary Set Irq */ 520 __le16 PRICLEARIRQMASK;/* a0h | Primary Clear Irq Mask */ 521 __le16 SECCLEARIRQMASK;/* a2h | Secondary Clear Irq Mask */ 522 __le16 PRISETIRQMASK; /* a4h | Primary Set Irq Mask */ 523 __le16 SECSETIRQMASK; /* a6h | Secondary Set Irq Mask */ 524 __le32 MAILBOX0; /* a8h | Scratchpad 0 */ 525 __le32 MAILBOX1; /* ach | Scratchpad 1 */ 526 __le32 MAILBOX2; /* b0h | Scratchpad 2 */ 527 __le32 MAILBOX3; /* b4h | Scratchpad 3 */ 528 __le32 MAILBOX4; /* b8h | Scratchpad 4 */ 529 __le32 MAILBOX5; /* bch | Scratchpad 5 */ 530 __le32 MAILBOX6; /* c0h | Scratchpad 6 */ 531 __le32 MAILBOX7; /* c4h | Scratchpad 7 */ 532 __le32 ROM_Setup_Data; /* c8h | Rom Setup and Data */ 533 __le32 ROM_Control_Addr;/* cch | Rom Control and Address */ 534 __le32 reserved3[12]; /* d0h-ffh | reserved */ 535 __le32 LUT[64]; /* 100h-1ffh | Lookup Table Entries */ 536 }; 537 538 #define Mailbox0 SaDbCSR.MAILBOX0 539 #define Mailbox1 SaDbCSR.MAILBOX1 540 #define Mailbox2 SaDbCSR.MAILBOX2 541 #define Mailbox3 SaDbCSR.MAILBOX3 542 #define Mailbox4 SaDbCSR.MAILBOX4 543 #define Mailbox5 SaDbCSR.MAILBOX5 544 #define Mailbox7 SaDbCSR.MAILBOX7 545 546 #define DoorbellReg_p SaDbCSR.PRISETIRQ 547 #define DoorbellReg_s SaDbCSR.SECSETIRQ 548 #define DoorbellClrReg_p SaDbCSR.PRICLEARIRQ 549 550 551 #define DOORBELL_0 0x0001 552 #define DOORBELL_1 0x0002 553 #define DOORBELL_2 0x0004 554 #define DOORBELL_3 0x0008 555 #define DOORBELL_4 0x0010 556 #define DOORBELL_5 0x0020 557 #define DOORBELL_6 0x0040 558 559 560 #define PrintfReady DOORBELL_5 561 #define PrintfDone DOORBELL_5 562 563 struct sa_registers { 564 struct sa_drawbridge_CSR SaDbCSR; /* 98h - c4h */ 565 }; 566 567 568 #define Sa_MINIPORT_REVISION 1 569 570 #define sa_readw(AEP, CSR) readl(&((AEP)->regs.sa->CSR)) 571 #define sa_readl(AEP, CSR) readl(&((AEP)->regs.sa->CSR)) 572 #define sa_writew(AEP, CSR, value) writew(value, &((AEP)->regs.sa->CSR)) 573 #define sa_writel(AEP, CSR, value) writel(value, &((AEP)->regs.sa->CSR)) 574 575 /* 576 * Rx Message Unit Registers 577 */ 578 579 struct rx_mu_registers { 580 /* Local | PCI*| Name */ 581 __le32 ARSR; /* 1300h | 00h | APIC Register Select Register */ 582 __le32 reserved0; /* 1304h | 04h | Reserved */ 583 __le32 AWR; /* 1308h | 08h | APIC Window Register */ 584 __le32 reserved1; /* 130Ch | 0Ch | Reserved */ 585 __le32 IMRx[2]; /* 1310h | 10h | Inbound Message Registers */ 586 __le32 OMRx[2]; /* 1318h | 18h | Outbound Message Registers */ 587 __le32 IDR; /* 1320h | 20h | Inbound Doorbell Register */ 588 __le32 IISR; /* 1324h | 24h | Inbound Interrupt 589 Status Register */ 590 __le32 IIMR; /* 1328h | 28h | Inbound Interrupt 591 Mask Register */ 592 __le32 ODR; /* 132Ch | 2Ch | Outbound Doorbell Register */ 593 __le32 OISR; /* 1330h | 30h | Outbound Interrupt 594 Status Register */ 595 __le32 OIMR; /* 1334h | 34h | Outbound Interrupt 596 Mask Register */ 597 /* * Must access through ATU Inbound 598 Translation Window */ 599 }; 600 601 struct rx_inbound { 602 __le32 Mailbox[8]; 603 }; 604 605 #define InboundMailbox0 IndexRegs.Mailbox[0] 606 #define InboundMailbox1 IndexRegs.Mailbox[1] 607 #define InboundMailbox2 IndexRegs.Mailbox[2] 608 #define InboundMailbox3 IndexRegs.Mailbox[3] 609 #define InboundMailbox4 IndexRegs.Mailbox[4] 610 #define InboundMailbox5 IndexRegs.Mailbox[5] 611 #define InboundMailbox6 IndexRegs.Mailbox[6] 612 613 #define INBOUNDDOORBELL_0 0x00000001 614 #define INBOUNDDOORBELL_1 0x00000002 615 #define INBOUNDDOORBELL_2 0x00000004 616 #define INBOUNDDOORBELL_3 0x00000008 617 #define INBOUNDDOORBELL_4 0x00000010 618 #define INBOUNDDOORBELL_5 0x00000020 619 #define INBOUNDDOORBELL_6 0x00000040 620 621 #define OUTBOUNDDOORBELL_0 0x00000001 622 #define OUTBOUNDDOORBELL_1 0x00000002 623 #define OUTBOUNDDOORBELL_2 0x00000004 624 #define OUTBOUNDDOORBELL_3 0x00000008 625 #define OUTBOUNDDOORBELL_4 0x00000010 626 627 #define InboundDoorbellReg MUnit.IDR 628 #define OutboundDoorbellReg MUnit.ODR 629 630 struct rx_registers { 631 struct rx_mu_registers MUnit; /* 1300h - 1334h */ 632 __le32 reserved1[6]; /* 1338h - 134ch */ 633 struct rx_inbound IndexRegs; 634 }; 635 636 #define rx_readb(AEP, CSR) readb(&((AEP)->regs.rx->CSR)) 637 #define rx_readl(AEP, CSR) readl(&((AEP)->regs.rx->CSR)) 638 #define rx_writeb(AEP, CSR, value) writeb(value, &((AEP)->regs.rx->CSR)) 639 #define rx_writel(AEP, CSR, value) writel(value, &((AEP)->regs.rx->CSR)) 640 641 /* 642 * Rkt Message Unit Registers (same as Rx, except a larger reserve region) 643 */ 644 645 #define rkt_mu_registers rx_mu_registers 646 #define rkt_inbound rx_inbound 647 648 struct rkt_registers { 649 struct rkt_mu_registers MUnit; /* 1300h - 1334h */ 650 __le32 reserved1[1010]; /* 1338h - 22fch */ 651 struct rkt_inbound IndexRegs; /* 2300h - */ 652 }; 653 654 #define rkt_readb(AEP, CSR) readb(&((AEP)->regs.rkt->CSR)) 655 #define rkt_readl(AEP, CSR) readl(&((AEP)->regs.rkt->CSR)) 656 #define rkt_writeb(AEP, CSR, value) writeb(value, &((AEP)->regs.rkt->CSR)) 657 #define rkt_writel(AEP, CSR, value) writel(value, &((AEP)->regs.rkt->CSR)) 658 659 struct fib; 660 661 typedef void (*fib_callback)(void *ctxt, struct fib *fibctx); 662 663 struct aac_fib_context { 664 s16 type; // used for verification of structure 665 s16 size; 666 u32 unique; // unique value representing this context 667 ulong jiffies; // used for cleanup - dmb changed to ulong 668 struct list_head next; // used to link context's into a linked list 669 struct semaphore wait_sem; // this is used to wait for the next fib to arrive. 670 int wait; // Set to true when thread is in WaitForSingleObject 671 unsigned long count; // total number of FIBs on FibList 672 struct list_head fib_list; // this holds fibs and their attachd hw_fibs 673 }; 674 675 struct sense_data { 676 u8 error_code; /* 70h (current errors), 71h(deferred errors) */ 677 u8 valid:1; /* A valid bit of one indicates that the information */ 678 /* field contains valid information as defined in the 679 * SCSI-2 Standard. 680 */ 681 u8 segment_number; /* Only used for COPY, COMPARE, or COPY AND VERIFY Commands */ 682 u8 sense_key:4; /* Sense Key */ 683 u8 reserved:1; 684 u8 ILI:1; /* Incorrect Length Indicator */ 685 u8 EOM:1; /* End Of Medium - reserved for random access devices */ 686 u8 filemark:1; /* Filemark - reserved for random access devices */ 687 688 u8 information[4]; /* for direct-access devices, contains the unsigned 689 * logical block address or residue associated with 690 * the sense key 691 */ 692 u8 add_sense_len; /* number of additional sense bytes to follow this field */ 693 u8 cmnd_info[4]; /* not used */ 694 u8 ASC; /* Additional Sense Code */ 695 u8 ASCQ; /* Additional Sense Code Qualifier */ 696 u8 FRUC; /* Field Replaceable Unit Code - not used */ 697 u8 bit_ptr:3; /* indicates which byte of the CDB or parameter data 698 * was in error 699 */ 700 u8 BPV:1; /* bit pointer valid (BPV): 1- indicates that 701 * the bit_ptr field has valid value 702 */ 703 u8 reserved2:2; 704 u8 CD:1; /* command data bit: 1- illegal parameter in CDB. 705 * 0- illegal parameter in data. 706 */ 707 u8 SKSV:1; 708 u8 field_ptr[2]; /* byte of the CDB or parameter data in error */ 709 }; 710 711 struct fsa_dev_info { 712 u64 last; 713 u64 size; 714 u32 type; 715 u16 queue_depth; 716 u8 valid; 717 u8 ro; 718 u8 locked; 719 u8 deleted; 720 char devname[8]; 721 struct sense_data sense_data; 722 }; 723 724 struct fib { 725 void *next; /* this is used by the allocator */ 726 s16 type; 727 s16 size; 728 /* 729 * The Adapter that this I/O is destined for. 730 */ 731 struct aac_dev *dev; 732 /* 733 * This is the event the sendfib routine will wait on if the 734 * caller did not pass one and this is synch io. 735 */ 736 struct semaphore event_wait; 737 spinlock_t event_lock; 738 739 u32 done; /* gets set to 1 when fib is complete */ 740 fib_callback callback; 741 void *callback_data; 742 u32 flags; // u32 dmb was ulong 743 /* 744 * The following is used to put this fib context onto the 745 * Outstanding I/O queue. 746 */ 747 struct list_head queue; 748 /* 749 * And for the internal issue/reply queues (we may be able 750 * to merge these two) 751 */ 752 struct list_head fiblink; 753 void *data; 754 struct hw_fib *hw_fib; /* Actual shared object */ 755 dma_addr_t hw_fib_pa; /* physical address of hw_fib*/ 756 }; 757 758 /* 759 * Adapter Information Block 760 * 761 * This is returned by the RequestAdapterInfo block 762 */ 763 764 struct aac_adapter_info 765 { 766 u32 platform; 767 u32 cpu; 768 u32 subcpu; 769 u32 clock; 770 u32 execmem; 771 u32 buffermem; 772 u32 totalmem; 773 u32 kernelrev; 774 u32 kernelbuild; 775 u32 monitorrev; 776 u32 monitorbuild; 777 u32 hwrev; 778 u32 hwbuild; 779 u32 biosrev; 780 u32 biosbuild; 781 u32 cluster; 782 u32 clusterchannelmask; 783 u32 serial[2]; 784 u32 battery; 785 u32 options; 786 u32 OEM; 787 }; 788 789 /* 790 * Battery platforms 791 */ 792 #define AAC_BAT_REQ_PRESENT (1) 793 #define AAC_BAT_REQ_NOTPRESENT (2) 794 #define AAC_BAT_OPT_PRESENT (3) 795 #define AAC_BAT_OPT_NOTPRESENT (4) 796 #define AAC_BAT_NOT_SUPPORTED (5) 797 /* 798 * cpu types 799 */ 800 #define AAC_CPU_SIMULATOR (1) 801 #define AAC_CPU_I960 (2) 802 #define AAC_CPU_STRONGARM (3) 803 804 /* 805 * Supported Options 806 */ 807 #define AAC_OPT_SNAPSHOT cpu_to_le32(1) 808 #define AAC_OPT_CLUSTERS cpu_to_le32(1<<1) 809 #define AAC_OPT_WRITE_CACHE cpu_to_le32(1<<2) 810 #define AAC_OPT_64BIT_DATA cpu_to_le32(1<<3) 811 #define AAC_OPT_HOST_TIME_FIB cpu_to_le32(1<<4) 812 #define AAC_OPT_RAID50 cpu_to_le32(1<<5) 813 #define AAC_OPT_4GB_WINDOW cpu_to_le32(1<<6) 814 #define AAC_OPT_SCSI_UPGRADEABLE cpu_to_le32(1<<7) 815 #define AAC_OPT_SOFT_ERR_REPORT cpu_to_le32(1<<8) 816 #define AAC_OPT_SUPPORTED_RECONDITION cpu_to_le32(1<<9) 817 #define AAC_OPT_SGMAP_HOST64 cpu_to_le32(1<<10) 818 #define AAC_OPT_ALARM cpu_to_le32(1<<11) 819 #define AAC_OPT_NONDASD cpu_to_le32(1<<12) 820 #define AAC_OPT_SCSI_MANAGED cpu_to_le32(1<<13) 821 #define AAC_OPT_RAID_SCSI_MODE cpu_to_le32(1<<14) 822 #define AAC_OPT_SUPPLEMENT_ADAPTER_INFO cpu_to_le32(1<<16) 823 #define AAC_OPT_NEW_COMM cpu_to_le32(1<<17) 824 #define AAC_OPT_NEW_COMM_64 cpu_to_le32(1<<18) 825 826 struct aac_dev 827 { 828 struct list_head entry; 829 const char *name; 830 int id; 831 832 u16 irq_mask; 833 /* 834 * Map for 128 fib objects (64k) 835 */ 836 dma_addr_t hw_fib_pa; 837 struct hw_fib *hw_fib_va; 838 struct hw_fib *aif_base_va; 839 /* 840 * Fib Headers 841 */ 842 struct fib *fibs; 843 844 struct fib *free_fib; 845 struct fib *timeout_fib; 846 spinlock_t fib_lock; 847 848 struct aac_queue_block *queues; 849 /* 850 * The user API will use an IOCTL to register itself to receive 851 * FIBs from the adapter. The following list is used to keep 852 * track of all the threads that have requested these FIBs. The 853 * mutex is used to synchronize access to all data associated 854 * with the adapter fibs. 855 */ 856 struct list_head fib_list; 857 858 struct adapter_ops a_ops; 859 unsigned long fsrev; /* Main driver's revision number */ 860 861 struct aac_init *init; /* Holds initialization info to communicate with adapter */ 862 dma_addr_t init_pa; /* Holds physical address of the init struct */ 863 864 struct pci_dev *pdev; /* Our PCI interface */ 865 void * printfbuf; /* pointer to buffer used for printf's from the adapter */ 866 void * comm_addr; /* Base address of Comm area */ 867 dma_addr_t comm_phys; /* Physical Address of Comm area */ 868 size_t comm_size; 869 870 struct Scsi_Host *scsi_host_ptr; 871 int maximum_num_containers; 872 struct fsa_dev_info *fsa_dev; 873 pid_t thread_pid; 874 int cardtype; 875 876 /* 877 * The following is the device specific extension. 878 */ 879 union 880 { 881 struct sa_registers __iomem *sa; 882 struct rx_registers __iomem *rx; 883 struct rkt_registers __iomem *rkt; 884 } regs; 885 u32 OIMR; /* Mask Register Cache */ 886 /* 887 * AIF thread states 888 */ 889 u32 aif_thread; 890 struct completion aif_completion; 891 struct aac_adapter_info adapter_info; 892 /* These are in adapter info but they are in the io flow so 893 * lets break them out so we don't have to do an AND to check them 894 */ 895 u8 nondasd_support; 896 u8 dac_support; 897 u8 raid_scsi_mode; 898 }; 899 900 #define aac_adapter_interrupt(dev) \ 901 (dev)->a_ops.adapter_interrupt(dev) 902 903 #define aac_adapter_notify(dev, event) \ 904 (dev)->a_ops.adapter_notify(dev, event) 905 906 907 #define aac_adapter_check_health(dev) \ 908 (dev)->a_ops.adapter_check_health(dev) 909 910 911 #define FIB_CONTEXT_FLAG_TIMED_OUT (0x00000001) 912 913 /* 914 * Define the command values 915 */ 916 917 #define Null 0 918 #define GetAttributes 1 919 #define SetAttributes 2 920 #define Lookup 3 921 #define ReadLink 4 922 #define Read 5 923 #define Write 6 924 #define Create 7 925 #define MakeDirectory 8 926 #define SymbolicLink 9 927 #define MakeNode 10 928 #define Removex 11 929 #define RemoveDirectoryx 12 930 #define Rename 13 931 #define Link 14 932 #define ReadDirectory 15 933 #define ReadDirectoryPlus 16 934 #define FileSystemStatus 17 935 #define FileSystemInfo 18 936 #define PathConfigure 19 937 #define Commit 20 938 #define Mount 21 939 #define UnMount 22 940 #define Newfs 23 941 #define FsCheck 24 942 #define FsSync 25 943 #define SimReadWrite 26 944 #define SetFileSystemStatus 27 945 #define BlockRead 28 946 #define BlockWrite 29 947 #define NvramIoctl 30 948 #define FsSyncWait 31 949 #define ClearArchiveBit 32 950 #define SetAcl 33 951 #define GetAcl 34 952 #define AssignAcl 35 953 #define FaultInsertion 36 /* Fault Insertion Command */ 954 #define CrazyCache 37 /* Crazycache */ 955 956 #define MAX_FSACOMMAND_NUM 38 957 958 959 /* 960 * Define the status returns. These are very unixlike although 961 * most are not in fact used 962 */ 963 964 #define ST_OK 0 965 #define ST_PERM 1 966 #define ST_NOENT 2 967 #define ST_IO 5 968 #define ST_NXIO 6 969 #define ST_E2BIG 7 970 #define ST_ACCES 13 971 #define ST_EXIST 17 972 #define ST_XDEV 18 973 #define ST_NODEV 19 974 #define ST_NOTDIR 20 975 #define ST_ISDIR 21 976 #define ST_INVAL 22 977 #define ST_FBIG 27 978 #define ST_NOSPC 28 979 #define ST_ROFS 30 980 #define ST_MLINK 31 981 #define ST_WOULDBLOCK 35 982 #define ST_NAMETOOLONG 63 983 #define ST_NOTEMPTY 66 984 #define ST_DQUOT 69 985 #define ST_STALE 70 986 #define ST_REMOTE 71 987 #define ST_BADHANDLE 10001 988 #define ST_NOT_SYNC 10002 989 #define ST_BAD_COOKIE 10003 990 #define ST_NOTSUPP 10004 991 #define ST_TOOSMALL 10005 992 #define ST_SERVERFAULT 10006 993 #define ST_BADTYPE 10007 994 #define ST_JUKEBOX 10008 995 #define ST_NOTMOUNTED 10009 996 #define ST_MAINTMODE 10010 997 #define ST_STALEACL 10011 998 999 /* 1000 * On writes how does the client want the data written. 1001 */ 1002 1003 #define CACHE_CSTABLE 1 1004 #define CACHE_UNSTABLE 2 1005 1006 /* 1007 * Lets the client know at which level the data was commited on 1008 * a write request 1009 */ 1010 1011 #define CMFILE_SYNCH_NVRAM 1 1012 #define CMDATA_SYNCH_NVRAM 2 1013 #define CMFILE_SYNCH 3 1014 #define CMDATA_SYNCH 4 1015 #define CMUNSTABLE 5 1016 1017 struct aac_read 1018 { 1019 u32 command; 1020 u32 cid; 1021 u32 block; 1022 u32 count; 1023 struct sgmap sg; // Must be last in struct because it is variable 1024 }; 1025 1026 struct aac_read64 1027 { 1028 u32 command; 1029 u16 cid; 1030 u16 sector_count; 1031 u32 block; 1032 u16 pad; 1033 u16 flags; 1034 struct sgmap64 sg; // Must be last in struct because it is variable 1035 }; 1036 1037 struct aac_read_reply 1038 { 1039 u32 status; 1040 u32 count; 1041 }; 1042 1043 struct aac_write 1044 { 1045 u32 command; 1046 u32 cid; 1047 u32 block; 1048 u32 count; 1049 u32 stable; // Not used 1050 struct sgmap sg; // Must be last in struct because it is variable 1051 }; 1052 1053 struct aac_write64 1054 { 1055 u32 command; 1056 u16 cid; 1057 u16 sector_count; 1058 u32 block; 1059 u16 pad; 1060 u16 flags; 1061 struct sgmap64 sg; // Must be last in struct because it is variable 1062 }; 1063 struct aac_write_reply 1064 { 1065 u32 status; 1066 u32 count; 1067 u32 committed; 1068 }; 1069 1070 #define CT_FLUSH_CACHE 129 1071 struct aac_synchronize { 1072 u32 command; /* VM_ContainerConfig */ 1073 u32 type; /* CT_FLUSH_CACHE */ 1074 u32 cid; 1075 u32 parm1; 1076 u32 parm2; 1077 u32 parm3; 1078 u32 parm4; 1079 u32 count; /* sizeof(((struct aac_synchronize_reply *)NULL)->data) */ 1080 }; 1081 1082 struct aac_synchronize_reply { 1083 u32 dummy0; 1084 u32 dummy1; 1085 u32 status; /* CT_OK */ 1086 u32 parm1; 1087 u32 parm2; 1088 u32 parm3; 1089 u32 parm4; 1090 u32 parm5; 1091 u8 data[16]; 1092 }; 1093 1094 struct aac_srb 1095 { 1096 u32 function; 1097 u32 channel; 1098 u32 id; 1099 u32 lun; 1100 u32 timeout; 1101 u32 flags; 1102 u32 count; // Data xfer size 1103 u32 retry_limit; 1104 u32 cdb_size; 1105 u8 cdb[16]; 1106 struct sgmap sg; 1107 }; 1108 1109 1110 1111 #define AAC_SENSE_BUFFERSIZE 30 1112 1113 struct aac_srb_reply 1114 { 1115 u32 status; 1116 u32 srb_status; 1117 u32 scsi_status; 1118 u32 data_xfer_length; 1119 u32 sense_data_size; 1120 u8 sense_data[AAC_SENSE_BUFFERSIZE]; // Can this be SCSI_SENSE_BUFFERSIZE 1121 }; 1122 /* 1123 * SRB Flags 1124 */ 1125 #define SRB_NoDataXfer 0x0000 1126 #define SRB_DisableDisconnect 0x0004 1127 #define SRB_DisableSynchTransfer 0x0008 1128 #define SRB_BypassFrozenQueue 0x0010 1129 #define SRB_DisableAutosense 0x0020 1130 #define SRB_DataIn 0x0040 1131 #define SRB_DataOut 0x0080 1132 1133 /* 1134 * SRB Functions - set in aac_srb->function 1135 */ 1136 #define SRBF_ExecuteScsi 0x0000 1137 #define SRBF_ClaimDevice 0x0001 1138 #define SRBF_IO_Control 0x0002 1139 #define SRBF_ReceiveEvent 0x0003 1140 #define SRBF_ReleaseQueue 0x0004 1141 #define SRBF_AttachDevice 0x0005 1142 #define SRBF_ReleaseDevice 0x0006 1143 #define SRBF_Shutdown 0x0007 1144 #define SRBF_Flush 0x0008 1145 #define SRBF_AbortCommand 0x0010 1146 #define SRBF_ReleaseRecovery 0x0011 1147 #define SRBF_ResetBus 0x0012 1148 #define SRBF_ResetDevice 0x0013 1149 #define SRBF_TerminateIO 0x0014 1150 #define SRBF_FlushQueue 0x0015 1151 #define SRBF_RemoveDevice 0x0016 1152 #define SRBF_DomainValidation 0x0017 1153 1154 /* 1155 * SRB SCSI Status - set in aac_srb->scsi_status 1156 */ 1157 #define SRB_STATUS_PENDING 0x00 1158 #define SRB_STATUS_SUCCESS 0x01 1159 #define SRB_STATUS_ABORTED 0x02 1160 #define SRB_STATUS_ABORT_FAILED 0x03 1161 #define SRB_STATUS_ERROR 0x04 1162 #define SRB_STATUS_BUSY 0x05 1163 #define SRB_STATUS_INVALID_REQUEST 0x06 1164 #define SRB_STATUS_INVALID_PATH_ID 0x07 1165 #define SRB_STATUS_NO_DEVICE 0x08 1166 #define SRB_STATUS_TIMEOUT 0x09 1167 #define SRB_STATUS_SELECTION_TIMEOUT 0x0A 1168 #define SRB_STATUS_COMMAND_TIMEOUT 0x0B 1169 #define SRB_STATUS_MESSAGE_REJECTED 0x0D 1170 #define SRB_STATUS_BUS_RESET 0x0E 1171 #define SRB_STATUS_PARITY_ERROR 0x0F 1172 #define SRB_STATUS_REQUEST_SENSE_FAILED 0x10 1173 #define SRB_STATUS_NO_HBA 0x11 1174 #define SRB_STATUS_DATA_OVERRUN 0x12 1175 #define SRB_STATUS_UNEXPECTED_BUS_FREE 0x13 1176 #define SRB_STATUS_PHASE_SEQUENCE_FAILURE 0x14 1177 #define SRB_STATUS_BAD_SRB_BLOCK_LENGTH 0x15 1178 #define SRB_STATUS_REQUEST_FLUSHED 0x16 1179 #define SRB_STATUS_DELAYED_RETRY 0x17 1180 #define SRB_STATUS_INVALID_LUN 0x20 1181 #define SRB_STATUS_INVALID_TARGET_ID 0x21 1182 #define SRB_STATUS_BAD_FUNCTION 0x22 1183 #define SRB_STATUS_ERROR_RECOVERY 0x23 1184 #define SRB_STATUS_NOT_STARTED 0x24 1185 #define SRB_STATUS_NOT_IN_USE 0x30 1186 #define SRB_STATUS_FORCE_ABORT 0x31 1187 #define SRB_STATUS_DOMAIN_VALIDATION_FAIL 0x32 1188 1189 /* 1190 * Object-Server / Volume-Manager Dispatch Classes 1191 */ 1192 1193 #define VM_Null 0 1194 #define VM_NameServe 1 1195 #define VM_ContainerConfig 2 1196 #define VM_Ioctl 3 1197 #define VM_FilesystemIoctl 4 1198 #define VM_CloseAll 5 1199 #define VM_CtBlockRead 6 1200 #define VM_CtBlockWrite 7 1201 #define VM_SliceBlockRead 8 /* raw access to configured "storage objects" */ 1202 #define VM_SliceBlockWrite 9 1203 #define VM_DriveBlockRead 10 /* raw access to physical devices */ 1204 #define VM_DriveBlockWrite 11 1205 #define VM_EnclosureMgt 12 /* enclosure management */ 1206 #define VM_Unused 13 /* used to be diskset management */ 1207 #define VM_CtBlockVerify 14 1208 #define VM_CtPerf 15 /* performance test */ 1209 #define VM_CtBlockRead64 16 1210 #define VM_CtBlockWrite64 17 1211 #define VM_CtBlockVerify64 18 1212 #define VM_CtHostRead64 19 1213 #define VM_CtHostWrite64 20 1214 1215 #define MAX_VMCOMMAND_NUM 21 /* used for sizing stats array - leave last */ 1216 1217 /* 1218 * Descriptive information (eg, vital stats) 1219 * that a content manager might report. The 1220 * FileArray filesystem component is one example 1221 * of a content manager. Raw mode might be 1222 * another. 1223 */ 1224 1225 struct aac_fsinfo { 1226 u32 fsTotalSize; /* Consumed by fs, incl. metadata */ 1227 u32 fsBlockSize; 1228 u32 fsFragSize; 1229 u32 fsMaxExtendSize; 1230 u32 fsSpaceUnits; 1231 u32 fsMaxNumFiles; 1232 u32 fsNumFreeFiles; 1233 u32 fsInodeDensity; 1234 }; /* valid iff ObjType == FT_FILESYS && !(ContentState & FSCS_NOTCLEAN) */ 1235 1236 union aac_contentinfo { 1237 struct aac_fsinfo filesys; /* valid iff ObjType == FT_FILESYS && !(ContentState & FSCS_NOTCLEAN) */ 1238 }; 1239 1240 /* 1241 * Query for Container Configuration Status 1242 */ 1243 1244 #define CT_GET_CONFIG_STATUS 147 1245 struct aac_get_config_status { 1246 u32 command; /* VM_ContainerConfig */ 1247 u32 type; /* CT_GET_CONFIG_STATUS */ 1248 u32 parm1; 1249 u32 parm2; 1250 u32 parm3; 1251 u32 parm4; 1252 u32 parm5; 1253 u32 count; /* sizeof(((struct aac_get_config_status_resp *)NULL)->data) */ 1254 }; 1255 1256 #define CFACT_CONTINUE 0 1257 #define CFACT_PAUSE 1 1258 #define CFACT_ABORT 2 1259 struct aac_get_config_status_resp { 1260 u32 response; /* ST_OK */ 1261 u32 dummy0; 1262 u32 status; /* CT_OK */ 1263 u32 parm1; 1264 u32 parm2; 1265 u32 parm3; 1266 u32 parm4; 1267 u32 parm5; 1268 struct { 1269 u32 action; /* CFACT_CONTINUE, CFACT_PAUSE or CFACT_ABORT */ 1270 u16 flags; 1271 s16 count; 1272 } data; 1273 }; 1274 1275 /* 1276 * Accept the configuration as-is 1277 */ 1278 1279 #define CT_COMMIT_CONFIG 152 1280 1281 struct aac_commit_config { 1282 u32 command; /* VM_ContainerConfig */ 1283 u32 type; /* CT_COMMIT_CONFIG */ 1284 }; 1285 1286 /* 1287 * Query for Container Configuration Count 1288 */ 1289 1290 #define CT_GET_CONTAINER_COUNT 4 1291 struct aac_get_container_count { 1292 u32 command; /* VM_ContainerConfig */ 1293 u32 type; /* CT_GET_CONTAINER_COUNT */ 1294 }; 1295 1296 struct aac_get_container_count_resp { 1297 u32 response; /* ST_OK */ 1298 u32 dummy0; 1299 u32 MaxContainers; 1300 u32 ContainerSwitchEntries; 1301 u32 MaxPartitions; 1302 }; 1303 1304 1305 /* 1306 * Query for "mountable" objects, ie, objects that are typically 1307 * associated with a drive letter on the client (host) side. 1308 */ 1309 1310 struct aac_mntent { 1311 u32 oid; 1312 u8 name[16]; // if applicable 1313 struct creation_info create_info; // if applicable 1314 u32 capacity; 1315 u32 vol; // substrate structure 1316 u32 obj; // FT_FILESYS, FT_DATABASE, etc. 1317 u32 state; // unready for mounting, readonly, etc. 1318 union aac_contentinfo fileinfo; // Info specific to content manager (eg, filesystem) 1319 u32 altoid; // != oid <==> snapshot or broken mirror exists 1320 }; 1321 1322 #define FSCS_NOTCLEAN 0x0001 /* fsck is neccessary before mounting */ 1323 #define FSCS_READONLY 0x0002 /* possible result of broken mirror */ 1324 #define FSCS_HIDDEN 0x0004 /* should be ignored - set during a clear */ 1325 1326 struct aac_query_mount { 1327 u32 command; 1328 u32 type; 1329 u32 count; 1330 }; 1331 1332 struct aac_mount { 1333 u32 status; 1334 u32 type; /* should be same as that requested */ 1335 u32 count; 1336 struct aac_mntent mnt[1]; 1337 }; 1338 1339 #define CT_READ_NAME 130 1340 struct aac_get_name { 1341 u32 command; /* VM_ContainerConfig */ 1342 u32 type; /* CT_READ_NAME */ 1343 u32 cid; 1344 u32 parm1; 1345 u32 parm2; 1346 u32 parm3; 1347 u32 parm4; 1348 u32 count; /* sizeof(((struct aac_get_name_resp *)NULL)->data) */ 1349 }; 1350 1351 #define CT_OK 218 1352 struct aac_get_name_resp { 1353 u32 dummy0; 1354 u32 dummy1; 1355 u32 status; /* CT_OK */ 1356 u32 parm1; 1357 u32 parm2; 1358 u32 parm3; 1359 u32 parm4; 1360 u32 parm5; 1361 u8 data[16]; 1362 }; 1363 1364 /* 1365 * The following command is sent to shut down each container. 1366 */ 1367 1368 struct aac_close { 1369 u32 command; 1370 u32 cid; 1371 }; 1372 1373 struct aac_query_disk 1374 { 1375 s32 cnum; 1376 s32 bus; 1377 s32 id; 1378 s32 lun; 1379 u32 valid; 1380 u32 locked; 1381 u32 deleted; 1382 s32 instance; 1383 s8 name[10]; 1384 u32 unmapped; 1385 }; 1386 1387 struct aac_delete_disk { 1388 u32 disknum; 1389 u32 cnum; 1390 }; 1391 1392 struct fib_ioctl 1393 { 1394 u32 fibctx; 1395 s32 wait; 1396 char __user *fib; 1397 }; 1398 1399 struct revision 1400 { 1401 u32 compat; 1402 u32 version; 1403 u32 build; 1404 }; 1405 1406 /* 1407 * Ugly - non Linux like ioctl coding for back compat. 1408 */ 1409 1410 #define CTL_CODE(function, method) ( \ 1411 (4<< 16) | ((function) << 2) | (method) \ 1412 ) 1413 1414 /* 1415 * Define the method codes for how buffers are passed for I/O and FS 1416 * controls 1417 */ 1418 1419 #define METHOD_BUFFERED 0 1420 #define METHOD_NEITHER 3 1421 1422 /* 1423 * Filesystem ioctls 1424 */ 1425 1426 #define FSACTL_SENDFIB CTL_CODE(2050, METHOD_BUFFERED) 1427 #define FSACTL_SEND_RAW_SRB CTL_CODE(2067, METHOD_BUFFERED) 1428 #define FSACTL_DELETE_DISK 0x163 1429 #define FSACTL_QUERY_DISK 0x173 1430 #define FSACTL_OPEN_GET_ADAPTER_FIB CTL_CODE(2100, METHOD_BUFFERED) 1431 #define FSACTL_GET_NEXT_ADAPTER_FIB CTL_CODE(2101, METHOD_BUFFERED) 1432 #define FSACTL_CLOSE_GET_ADAPTER_FIB CTL_CODE(2102, METHOD_BUFFERED) 1433 #define FSACTL_MINIPORT_REV_CHECK CTL_CODE(2107, METHOD_BUFFERED) 1434 #define FSACTL_GET_PCI_INFO CTL_CODE(2119, METHOD_BUFFERED) 1435 #define FSACTL_FORCE_DELETE_DISK CTL_CODE(2120, METHOD_NEITHER) 1436 #define FSACTL_GET_CONTAINERS 2131 1437 1438 1439 struct aac_common 1440 { 1441 /* 1442 * If this value is set to 1 then interrupt moderation will occur 1443 * in the base commuication support. 1444 */ 1445 u32 irq_mod; 1446 u32 peak_fibs; 1447 u32 zero_fibs; 1448 u32 fib_timeouts; 1449 /* 1450 * Statistical counters in debug mode 1451 */ 1452 #ifdef DBG 1453 u32 FibsSent; 1454 u32 FibRecved; 1455 u32 NoResponseSent; 1456 u32 NoResponseRecved; 1457 u32 AsyncSent; 1458 u32 AsyncRecved; 1459 u32 NormalSent; 1460 u32 NormalRecved; 1461 #endif 1462 }; 1463 1464 extern struct aac_common aac_config; 1465 1466 1467 /* 1468 * The following macro is used when sending and receiving FIBs. It is 1469 * only used for debugging. 1470 */ 1471 1472 #ifdef DBG 1473 #define FIB_COUNTER_INCREMENT(counter) (counter)++ 1474 #else 1475 #define FIB_COUNTER_INCREMENT(counter) 1476 #endif 1477 1478 /* 1479 * Adapter direct commands 1480 * Monitor/Kernel API 1481 */ 1482 1483 #define BREAKPOINT_REQUEST 0x00000004 1484 #define INIT_STRUCT_BASE_ADDRESS 0x00000005 1485 #define READ_PERMANENT_PARAMETERS 0x0000000a 1486 #define WRITE_PERMANENT_PARAMETERS 0x0000000b 1487 #define HOST_CRASHING 0x0000000d 1488 #define SEND_SYNCHRONOUS_FIB 0x0000000c 1489 #define COMMAND_POST_RESULTS 0x00000014 1490 #define GET_ADAPTER_PROPERTIES 0x00000019 1491 #define GET_DRIVER_BUFFER_PROPERTIES 0x00000023 1492 #define RCV_TEMP_READINGS 0x00000025 1493 #define GET_COMM_PREFERRED_SETTINGS 0x00000026 1494 #define IOP_RESET 0x00001000 1495 #define RE_INIT_ADAPTER 0x000000ee 1496 1497 /* 1498 * Adapter Status Register 1499 * 1500 * Phase Staus mailbox is 32bits: 1501 * <31:16> = Phase Status 1502 * <15:0> = Phase 1503 * 1504 * The adapter reports is present state through the phase. Only 1505 * a single phase should be ever be set. Each phase can have multiple 1506 * phase status bits to provide more detailed information about the 1507 * state of the board. Care should be taken to ensure that any phase 1508 * status bits that are set when changing the phase are also valid 1509 * for the new phase or be cleared out. Adapter software (monitor, 1510 * iflash, kernel) is responsible for properly maintining the phase 1511 * status mailbox when it is running. 1512 * 1513 * MONKER_API Phases 1514 * 1515 * Phases are bit oriented. It is NOT valid to have multiple bits set 1516 */ 1517 1518 #define SELF_TEST_FAILED 0x00000004 1519 #define MONITOR_PANIC 0x00000020 1520 #define KERNEL_UP_AND_RUNNING 0x00000080 1521 #define KERNEL_PANIC 0x00000100 1522 1523 /* 1524 * Doorbell bit defines 1525 */ 1526 1527 #define DoorBellSyncCmdAvailable (1<<0) /* Host -> Adapter */ 1528 #define DoorBellPrintfDone (1<<5) /* Host -> Adapter */ 1529 #define DoorBellAdapterNormCmdReady (1<<1) /* Adapter -> Host */ 1530 #define DoorBellAdapterNormRespReady (1<<2) /* Adapter -> Host */ 1531 #define DoorBellAdapterNormCmdNotFull (1<<3) /* Adapter -> Host */ 1532 #define DoorBellAdapterNormRespNotFull (1<<4) /* Adapter -> Host */ 1533 #define DoorBellPrintfReady (1<<5) /* Adapter -> Host */ 1534 1535 /* 1536 * For FIB communication, we need all of the following things 1537 * to send back to the user. 1538 */ 1539 1540 #define AifCmdEventNotify 1 /* Notify of event */ 1541 #define AifEnConfigChange 3 /* Adapter configuration change */ 1542 #define AifEnContainerChange 4 /* Container configuration change */ 1543 #define AifEnDeviceFailure 5 /* SCSI device failed */ 1544 #define AifEnAddContainer 15 /* A new array was created */ 1545 #define AifEnDeleteContainer 16 /* A container was deleted */ 1546 #define AifEnExpEvent 23 /* Firmware Event Log */ 1547 #define AifExeFirmwarePanic 3 /* Firmware Event Panic */ 1548 #define AifHighPriority 3 /* Highest Priority Event */ 1549 1550 #define AifCmdJobProgress 2 /* Progress report */ 1551 #define AifJobCtrZero 101 /* Array Zero progress */ 1552 #define AifJobStsSuccess 1 /* Job completes */ 1553 #define AifCmdAPIReport 3 /* Report from other user of API */ 1554 #define AifCmdDriverNotify 4 /* Notify host driver of event */ 1555 #define AifDenMorphComplete 200 /* A morph operation completed */ 1556 #define AifDenVolumeExtendComplete 201 /* A volume extend completed */ 1557 #define AifReqJobList 100 /* Gets back complete job list */ 1558 #define AifReqJobsForCtr 101 /* Gets back jobs for specific container */ 1559 #define AifReqJobsForScsi 102 /* Gets back jobs for specific SCSI device */ 1560 #define AifReqJobReport 103 /* Gets back a specific job report or list of them */ 1561 #define AifReqTerminateJob 104 /* Terminates job */ 1562 #define AifReqSuspendJob 105 /* Suspends a job */ 1563 #define AifReqResumeJob 106 /* Resumes a job */ 1564 #define AifReqSendAPIReport 107 /* API generic report requests */ 1565 #define AifReqAPIJobStart 108 /* Start a job from the API */ 1566 #define AifReqAPIJobUpdate 109 /* Update a job report from the API */ 1567 #define AifReqAPIJobFinish 110 /* Finish a job from the API */ 1568 1569 /* 1570 * Adapter Initiated FIB command structures. Start with the adapter 1571 * initiated FIBs that really come from the adapter, and get responded 1572 * to by the host. 1573 */ 1574 1575 struct aac_aifcmd { 1576 u32 command; /* Tell host what type of notify this is */ 1577 u32 seqnum; /* To allow ordering of reports (if necessary) */ 1578 u8 data[1]; /* Undefined length (from kernel viewpoint) */ 1579 }; 1580 1581 /** 1582 * Convert capacity to cylinders 1583 * accounting for the fact capacity could be a 64 bit value 1584 * 1585 */ 1586 static inline u32 cap_to_cyls(sector_t capacity, u32 divisor) 1587 { 1588 sector_div(capacity, divisor); 1589 return (u32)capacity; 1590 } 1591 1592 struct scsi_cmnd; 1593 1594 const char *aac_driverinfo(struct Scsi_Host *); 1595 struct fib *fib_alloc(struct aac_dev *dev); 1596 int fib_setup(struct aac_dev *dev); 1597 void fib_map_free(struct aac_dev *dev); 1598 void fib_free(struct fib * context); 1599 void fib_init(struct fib * context); 1600 void fib_dealloc(struct fib * context); 1601 void aac_printf(struct aac_dev *dev, u32 val); 1602 int fib_send(u16 command, struct fib * context, unsigned long size, int priority, int wait, int reply, fib_callback callback, void *ctxt); 1603 int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry); 1604 void aac_consumer_free(struct aac_dev * dev, struct aac_queue * q, u32 qnum); 1605 int fib_complete(struct fib * context); 1606 #define fib_data(fibctx) ((void *)(fibctx)->hw_fib->data) 1607 struct aac_dev *aac_init_adapter(struct aac_dev *dev); 1608 int aac_get_config_status(struct aac_dev *dev); 1609 int aac_get_containers(struct aac_dev *dev); 1610 int aac_scsi_cmd(struct scsi_cmnd *cmd); 1611 int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg); 1612 int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg); 1613 int aac_rx_init(struct aac_dev *dev); 1614 int aac_rkt_init(struct aac_dev *dev); 1615 int aac_sa_init(struct aac_dev *dev); 1616 unsigned int aac_response_normal(struct aac_queue * q); 1617 unsigned int aac_command_normal(struct aac_queue * q); 1618 int aac_command_thread(struct aac_dev * dev); 1619 int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context *fibctx); 1620 int fib_adapter_complete(struct fib * fibptr, unsigned short size); 1621 struct aac_driver_ident* aac_get_driver_ident(int devtype); 1622 int aac_get_adapter_info(struct aac_dev* dev); 1623 int aac_send_shutdown(struct aac_dev *dev); 1624