1 /* 2 * linux/drivers/message/fusion/mptbase.h 3 * High performance SCSI + LAN / Fibre Channel device drivers. 4 * For use with PCI chip/adapter(s): 5 * LSIFC9xx/LSI409xx Fibre Channel 6 * running LSI Logic Fusion MPT (Message Passing Technology) firmware. 7 * 8 * Credits: 9 * (see mptbase.c) 10 * 11 * Copyright (c) 1999-2004 LSI Logic Corporation 12 * Originally By: Steven J. Ralston 13 * (mailto:sjralston1@netscape.net) 14 * (mailto:mpt_linux_developer@lsil.com) 15 * 16 * $Id: mptbase.h,v 1.149 2003/05/07 14:08:31 pdelaney Exp $ 17 */ 18 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 19 /* 20 This program is free software; you can redistribute it and/or modify 21 it under the terms of the GNU General Public License as published by 22 the Free Software Foundation; version 2 of the License. 23 24 This program is distributed in the hope that it will be useful, 25 but WITHOUT ANY WARRANTY; without even the implied warranty of 26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 GNU General Public License for more details. 28 29 NO WARRANTY 30 THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR 31 CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT 32 LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 33 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is 34 solely responsible for determining the appropriateness of using and 35 distributing the Program and assumes all risks associated with its 36 exercise of rights under this Agreement, including but not limited to 37 the risks and costs of program errors, damage to or loss of data, 38 programs or equipment, and unavailability or interruption of operations. 39 40 DISCLAIMER OF LIABILITY 41 NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY 42 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND 44 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 45 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 46 USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 47 HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 48 49 You should have received a copy of the GNU General Public License 50 along with this program; if not, write to the Free Software 51 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 52 */ 53 54 #ifndef MPTBASE_H_INCLUDED 55 #define MPTBASE_H_INCLUDED 56 /*{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 57 58 #include "linux_compat.h" /* linux-2.2.x (vs. -2.4.x) tweaks */ 59 #include "scsi3.h" /* SCSI defines */ 60 61 #include "lsi/mpi_type.h" 62 #include "lsi/mpi.h" /* Fusion MPI(nterface) basic defs */ 63 #include "lsi/mpi_ioc.h" /* Fusion MPT IOC(ontroller) defs */ 64 #include "lsi/mpi_cnfg.h" /* IOC configuration support */ 65 #include "lsi/mpi_init.h" /* SCSI Host (initiator) protocol support */ 66 #include "lsi/mpi_lan.h" /* LAN over FC protocol support */ 67 #include "lsi/mpi_raid.h" /* Integrated Mirroring support */ 68 69 #include "lsi/mpi_fc.h" /* Fibre Channel (lowlevel) support */ 70 #include "lsi/mpi_targ.h" /* SCSI/FCP Target protcol support */ 71 #include "lsi/mpi_tool.h" /* Tools support */ 72 #include "lsi/fc_log.h" 73 74 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 75 76 #ifndef MODULEAUTHOR 77 #define MODULEAUTHOR "LSI Logic Corporation" 78 #endif 79 80 #ifndef COPYRIGHT 81 #define COPYRIGHT "Copyright (c) 1999-2004 " MODULEAUTHOR 82 #endif 83 84 #define MPT_LINUX_VERSION_COMMON "2.05.16" 85 #define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-2.05.16" 86 #define WHAT_MAGIC_STRING "@" "(" "#" ")" 87 88 #define show_mptmod_ver(s,ver) \ 89 printk(KERN_INFO "%s %s\n", s, ver); 90 91 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 92 /* 93 * Fusion MPT(linux) driver configurable stuff... 94 */ 95 #define MPT_MAX_ADAPTERS 18 96 #define MPT_MAX_PROTOCOL_DRIVERS 16 97 #define MPT_MAX_BUS 1 /* Do not change */ 98 #define MPT_MAX_FC_DEVICES 255 99 #define MPT_MAX_SCSI_DEVICES 16 100 #define MPT_LAST_LUN 255 101 #define MPT_SENSE_BUFFER_ALLOC 64 102 /* allow for 256 max sense alloc, but only 255 max request */ 103 #if MPT_SENSE_BUFFER_ALLOC >= 256 104 # undef MPT_SENSE_BUFFER_ALLOC 105 # define MPT_SENSE_BUFFER_ALLOC 256 106 # define MPT_SENSE_BUFFER_SIZE 255 107 #else 108 # define MPT_SENSE_BUFFER_SIZE MPT_SENSE_BUFFER_ALLOC 109 #endif 110 111 #define MPT_NAME_LENGTH 32 112 113 #define MPT_PROCFS_MPTBASEDIR "mpt" 114 /* chg it to "driver/fusion" ? */ 115 #define MPT_PROCFS_SUMMARY_ALL_NODE MPT_PROCFS_MPTBASEDIR "/summary" 116 #define MPT_PROCFS_SUMMARY_ALL_PATHNAME "/proc/" MPT_PROCFS_SUMMARY_ALL_NODE 117 #define MPT_FW_REV_MAGIC_ID_STRING "FwRev=" 118 119 #define MPT_MAX_REQ_DEPTH 1023 120 #define MPT_DEFAULT_REQ_DEPTH 256 121 #define MPT_MIN_REQ_DEPTH 128 122 123 #define MPT_MAX_REPLY_DEPTH MPT_MAX_REQ_DEPTH 124 #define MPT_DEFAULT_REPLY_DEPTH 128 125 #define MPT_MIN_REPLY_DEPTH 8 126 #define MPT_MAX_REPLIES_PER_ISR 32 127 128 #define MPT_MAX_FRAME_SIZE 128 129 #define MPT_DEFAULT_FRAME_SIZE 128 130 131 #define MPT_REPLY_FRAME_SIZE 0x40 /* Must be a multiple of 8 */ 132 133 #define MPT_SG_REQ_128_SCALE 1 134 #define MPT_SG_REQ_96_SCALE 2 135 #define MPT_SG_REQ_64_SCALE 4 136 137 #define CAN_SLEEP 1 138 #define NO_SLEEP 0 139 140 #define MPT_COALESCING_TIMEOUT 0x10 141 142 /* 143 * SCSI transfer rate defines. 144 */ 145 #define MPT_ULTRA320 0x08 146 #define MPT_ULTRA160 0x09 147 #define MPT_ULTRA2 0x0A 148 #define MPT_ULTRA 0x0C 149 #define MPT_FAST 0x19 150 #define MPT_SCSI 0x32 151 #define MPT_ASYNC 0xFF 152 153 #define MPT_NARROW 0 154 #define MPT_WIDE 1 155 156 #define C0_1030 0x08 157 #define XL_929 0x01 158 159 #ifdef __KERNEL__ /* { */ 160 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 161 162 #include <linux/proc_fs.h> 163 164 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 165 /* 166 * Attempt semi-consistent error & warning msgs across 167 * MPT drivers. NOTE: Users of these macro defs must 168 * themselves define their own MYNAM. 169 */ 170 #define MYIOC_s_INFO_FMT KERN_INFO MYNAM ": %s: " 171 #define MYIOC_s_NOTE_FMT KERN_NOTICE MYNAM ": %s: " 172 #define MYIOC_s_WARN_FMT KERN_WARNING MYNAM ": %s: WARNING - " 173 #define MYIOC_s_ERR_FMT KERN_ERR MYNAM ": %s: ERROR - " 174 175 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 176 /* 177 * MPT protocol driver defs... 178 */ 179 typedef enum { 180 MPTBASE_DRIVER, /* MPT base class */ 181 MPTCTL_DRIVER, /* MPT ioctl class */ 182 MPTSCSIH_DRIVER, /* MPT SCSI host (initiator) class */ 183 MPTLAN_DRIVER, /* MPT LAN class */ 184 MPTSTM_DRIVER, /* MPT SCSI target mode class */ 185 MPTDMP_DRIVER, /* MPT Dynamic Multi-pathing class */ 186 MPTUNKNOWN_DRIVER 187 } MPT_DRIVER_CLASS; 188 189 /* 190 * MPT adapter / port / bus / device info structures... 191 */ 192 193 typedef union _MPT_FRAME_TRACKER { 194 struct { 195 struct _MPT_FRAME_HDR *forw; 196 struct _MPT_FRAME_HDR *back; 197 u32 arg1; 198 u32 pad; 199 void *argp1; 200 #ifndef MPT_SCSI_USE_NEW_EH 201 void *argp2; 202 #endif 203 } linkage; 204 /* 205 * NOTE: When request frames are free, on the linkage structure 206 * contets are valid. All other values are invalid. 207 * In particular, do NOT reply on offset [2] 208 * (in words) being the * message context. 209 * The message context must be reset (computed via base address 210 * + an offset) prior to issuing any command. 211 * 212 * NOTE2: On non-32-bit systems, where pointers are LARGE, 213 * using the linkage pointers destroys our sacred MsgContext 214 * field contents. But we don't care anymore because these 215 * are now reset in mpt_put_msg_frame() just prior to sending 216 * a request off to the IOC. 217 */ 218 struct { 219 u32 __hdr[2]; 220 /* 221 * The following _MUST_ match the location of the 222 * MsgContext field in the MPT message headers. 223 */ 224 union { 225 u32 MsgContext; 226 struct { 227 u16 req_idx; /* Request index */ 228 u8 cb_idx; /* callback function index */ 229 u8 rsvd; 230 } fld; 231 } msgctxu; 232 } hwhdr; 233 /* 234 * Remark: 32 bit identifier: 235 * 31-24: reserved 236 * 23-16: call back index 237 * 15-0 : request index 238 */ 239 } MPT_FRAME_TRACKER; 240 241 /* 242 * We might want to view/access a frame as: 243 * 1) generic request header 244 * 2) SCSIIORequest 245 * 3) SCSIIOReply 246 * 4) MPIDefaultReply 247 * 5) frame tracker 248 */ 249 typedef struct _MPT_FRAME_HDR { 250 union { 251 MPIHeader_t hdr; 252 SCSIIORequest_t scsireq; 253 SCSIIOReply_t sreply; 254 ConfigReply_t configreply; 255 MPIDefaultReply_t reply; 256 MPT_FRAME_TRACKER frame; 257 } u; 258 } MPT_FRAME_HDR; 259 260 #define MPT_REQ_MSGFLAGS_DROPME 0x80 261 262 /* Used for tracking the free request frames 263 * and free reply frames. 264 */ 265 typedef struct _MPT_Q_TRACKER { 266 MPT_FRAME_HDR *head; 267 MPT_FRAME_HDR *tail; 268 } MPT_Q_TRACKER; 269 270 271 typedef struct _MPT_SGL_HDR { 272 SGESimple32_t sge[1]; 273 } MPT_SGL_HDR; 274 275 typedef struct _MPT_SGL64_HDR { 276 SGESimple64_t sge[1]; 277 } MPT_SGL64_HDR; 278 279 280 typedef struct _Q_ITEM { 281 struct _Q_ITEM *forw; 282 struct _Q_ITEM *back; 283 } Q_ITEM; 284 285 typedef struct _Q_TRACKER { 286 struct _Q_ITEM *head; 287 struct _Q_ITEM *tail; 288 } Q_TRACKER; 289 290 typedef struct _MPT_DONE_Q { 291 struct _MPT_DONE_Q *forw; 292 struct _MPT_DONE_Q *back; 293 void *argp; 294 } MPT_DONE_Q; 295 296 typedef struct _DONE_Q_TRACKER { 297 MPT_DONE_Q *head; 298 MPT_DONE_Q *tail; 299 } DONE_Q_TRACKER; 300 301 /* 302 * Chip-specific stuff... FC929 delineates break between 303 * FC and Parallel SCSI parts. Do NOT re-order. 304 */ 305 306 typedef enum { 307 FC919X = 0x0819, 308 FC929X = 0x0829, 309 FC909 = 0x0909, 310 FC919 = 0x0919, 311 FC929 = 0x0929, 312 C1030 = 0x1030, 313 C1035 = 0x1035, 314 FCUNK = 0xFBAD 315 } CHIP_TYPE; 316 317 /* 318 * System interface register set 319 */ 320 321 typedef struct _SYSIF_REGS 322 { 323 u32 Doorbell; /* 00 System<->IOC Doorbell reg */ 324 u32 WriteSequence; /* 04 Write Sequence register */ 325 u32 Diagnostic; /* 08 Diagnostic register */ 326 u32 TestBase; /* 0C Test Base Address */ 327 u32 DiagRwData; /* 10 Read Write Data (fw download) */ 328 u32 DiagRwAddress; /* 14 Read Write Address (fw download)*/ 329 u32 Reserved1[6]; /* 18-2F reserved for future use */ 330 u32 IntStatus; /* 30 Interrupt Status */ 331 u32 IntMask; /* 34 Interrupt Mask */ 332 u32 Reserved2[2]; /* 38-3F reserved for future use */ 333 u32 RequestFifo; /* 40 Request Post/Free FIFO */ 334 u32 ReplyFifo; /* 44 Reply Post/Free FIFO */ 335 u32 Reserved3[2]; /* 48-4F reserved for future use */ 336 u32 HostIndex; /* 50 Host Index register */ 337 u32 Reserved4[15]; /* 54-8F */ 338 u32 Fubar; /* 90 For Fubar usage */ 339 u32 Reserved5[27]; /* 94-FF */ 340 } SYSIF_REGS; 341 342 /* 343 * NOTE: Use MPI_{DOORBELL,WRITESEQ,DIAG}_xxx defs in lsi/mpi.h 344 * in conjunction with SYSIF_REGS accesses! 345 */ 346 347 348 /* 349 * Dynamic Multi-Pathing specific stuff... 350 */ 351 #define DMP_MAX_PATHS 8 352 353 typedef struct _PathInfo { 354 u8 ioc; 355 u8 target; 356 u8 pad; 357 u8 pflags; 358 } PathInfo; 359 360 #define PATHINFO_FLAGS_OWNED 0x01 361 #define PATHINFO_FLAGS_EXISTS 0x02 362 #define PATHINFO_FLAGS_AVAILABLE 0x04 363 #define PATHINFO_FLAGS_SECONDARY 0x08 364 365 #define PFLAGS_EXISTS_AND_AVAIL (PATHINFO_FLAGS_EXISTS|PATHINFO_FLAGS_AVAILABLE) 366 #define PFLAGS_AVAIL_AND_OWNED (PATHINFO_FLAGS_AVAILABLE|PATHINFO_FLAGS_OWNED) 367 368 typedef struct _ScsiCmndTracker { 369 void *head; 370 void *tail; 371 } ScsiCmndTracker; 372 373 374 /* 375 * VirtDevice - FC LUN device or SCSI target device 376 * (used to be FCSCSI_TARGET) 377 */ 378 typedef struct _VirtDevice { 379 struct _VirtDevice *forw; 380 struct _VirtDevice *back; 381 struct scsi_device *device; 382 rwlock_t VdevLock; 383 int ref_cnt; 384 u8 tflags; 385 u8 ioc_id; 386 u8 target_id; 387 u8 bus_id; 388 u8 minSyncFactor; /* 0xFF is async */ 389 u8 maxOffset; /* 0 if async */ 390 u8 maxWidth; /* 0 if narrow, 1 if wide*/ 391 u8 negoFlags; /* bit field, 0 if WDTR/SDTR/QAS allowed */ 392 u8 raidVolume; /* set, if RAID Volume */ 393 u8 type; /* byte 0 of Inquiry data */ 394 u8 cflags; /* controller flags */ 395 u8 rsvd1raid; 396 int npaths; 397 u16 fc_phys_lun; 398 u16 fc_xlat_lun; 399 int stall_detected; 400 PathInfo path[DMP_MAX_PATHS]; 401 struct timer_list stall_timer; 402 struct timer_list retry_timer; 403 struct timer_list gone_timer; 404 ScsiCmndTracker WaitQ; 405 ScsiCmndTracker SentQ; 406 ScsiCmndTracker DoneQ; 407 u32 num_luns; 408 u32 luns[8]; /* Max LUNs is 256 */ 409 u8 pad[4]; 410 u8 inq_data[8]; 411 /* IEEE Registered Extended Identifier 412 obtained via INQUIRY VPD page 0x83 */ 413 /* NOTE: Do not separate uniq_prepad and uniq_data 414 as they are treateed as a single entity in the code */ 415 u8 uniq_prepad[8]; 416 u8 uniq_data[20]; 417 u8 pad2[4]; 418 } VirtDevice; 419 420 /* 421 * Fibre Channel (SCSI) target device and associated defines... 422 */ 423 #define MPT_TARGET_DEFAULT_DV_STATUS 0 424 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,55) 425 #define MPT_TARGET_FLAGS_CONFIGURED 0x02 426 #define MPT_TARGET_FLAGS_Q_YES 0x08 427 #else 428 #define MPT_TARGET_FLAGS_VALID_NEGO 0x01 429 #define MPT_TARGET_FLAGS_VALID_INQUIRY 0x02 430 #define MPT_TARGET_FLAGS_Q_YES 0x08 431 #define MPT_TARGET_FLAGS_VALID_56 0x10 432 #define MPT_TARGET_FLAGS_SAF_TE_ISSUED 0x20 433 #endif 434 435 #define MPT_TARGET_NO_NEGO_WIDE 0x01 436 #define MPT_TARGET_NO_NEGO_SYNC 0x02 437 #define MPT_TARGET_NO_NEGO_QAS 0x04 438 439 typedef struct _VirtDevTracker { 440 struct _VirtDevice *head; 441 struct _VirtDevice *tail; 442 rwlock_t VlistLock; 443 int pad; 444 } VirtDevTracker; 445 446 447 /* 448 * /proc/mpt interface 449 */ 450 typedef struct { 451 const char *name; 452 mode_t mode; 453 int pad; 454 read_proc_t *read_proc; 455 write_proc_t *write_proc; 456 } mpt_proc_entry_t; 457 458 #define MPT_PROC_READ_RETURN(buf,start,offset,request,eof,len) \ 459 do { \ 460 len -= offset; \ 461 if (len < request) { \ 462 *eof = 1; \ 463 if (len <= 0) \ 464 return 0; \ 465 } else \ 466 len = request; \ 467 *start = buf + offset; \ 468 return len; \ 469 } while (0) 470 471 472 /* 473 * IOCTL structure and associated defines 474 */ 475 476 #define MPT_IOCTL_STATUS_DID_IOCRESET 0x01 /* IOC Reset occurred on the current*/ 477 #define MPT_IOCTL_STATUS_RF_VALID 0x02 /* The Reply Frame is VALID */ 478 #define MPT_IOCTL_STATUS_TIMER_ACTIVE 0x04 /* The timer is running */ 479 #define MPT_IOCTL_STATUS_SENSE_VALID 0x08 /* Sense data is valid */ 480 #define MPT_IOCTL_STATUS_COMMAND_GOOD 0x10 /* Command Status GOOD */ 481 #define MPT_IOCTL_STATUS_TMTIMER_ACTIVE 0x20 /* The TM timer is running */ 482 #define MPT_IOCTL_STATUS_TM_FAILED 0x40 /* User TM request failed */ 483 484 #define MPTCTL_RESET_OK 0x01 /* Issue Bus Reset */ 485 486 typedef struct _MPT_IOCTL { 487 struct _MPT_ADAPTER *ioc; 488 struct timer_list timer; /* timer function for this adapter */ 489 u8 ReplyFrame[MPT_DEFAULT_FRAME_SIZE]; /* reply frame data */ 490 u8 sense[MPT_SENSE_BUFFER_ALLOC]; 491 int wait_done; /* wake-up value for this ioc */ 492 u8 rsvd; 493 u8 status; /* current command status */ 494 u8 reset; /* 1 if bus reset allowed */ 495 u8 target; /* target for reset */ 496 void *tmPtr; 497 struct timer_list TMtimer; /* timer function for this adapter */ 498 } MPT_IOCTL; 499 500 /* 501 * Event Structure and define 502 */ 503 #define MPTCTL_EVENT_LOG_SIZE (0x0000000A) 504 typedef struct _mpt_ioctl_events { 505 u32 event; /* Specified by define above */ 506 u32 eventContext; /* Index or counter */ 507 int data[2]; /* First 8 bytes of Event Data */ 508 } MPT_IOCTL_EVENTS; 509 510 /* 511 * CONFIGPARM status defines 512 */ 513 #define MPT_CONFIG_GOOD MPI_IOCSTATUS_SUCCESS 514 #define MPT_CONFIG_ERROR 0x002F 515 516 /* 517 * Substructure to store SCSI specific configuration page data 518 */ 519 /* dvStatus defines: */ 520 #define MPT_SCSICFG_NEGOTIATE 0x01 /* Negotiate on next IO */ 521 #define MPT_SCSICFG_NEED_DV 0x02 /* Schedule DV */ 522 #define MPT_SCSICFG_DV_PENDING 0x04 /* DV on this physical id pending */ 523 #define MPT_SCSICFG_DV_NOT_DONE 0x08 /* DV has not been performed */ 524 #define MPT_SCSICFG_BLK_NEGO 0x10 /* WriteSDP1 with WDTR and SDTR disabled */ 525 #define MPT_SCSICFG_RELOAD_IOC_PG3 0x20 /* IOC Pg 3 data is obsolete */ 526 /* Args passed to writeSDP1: */ 527 #define MPT_SCSICFG_USE_NVRAM 0x01 /* WriteSDP1 using NVRAM */ 528 #define MPT_SCSICFG_ALL_IDS 0x02 /* WriteSDP1 to all IDS */ 529 /* #define MPT_SCSICFG_BLK_NEGO 0x10 WriteSDP1 with WDTR and SDTR disabled */ 530 531 typedef struct _ScsiCfgData { 532 u32 PortFlags; 533 int *nvram; /* table of device NVRAM values */ 534 IOCPage2_t *pIocPg2; /* table of Raid Volumes */ 535 IOCPage3_t *pIocPg3; /* table of physical disks */ 536 IOCPage4_t *pIocPg4; /* SEP devices addressing */ 537 dma_addr_t IocPg4_dma; /* Phys Addr of IOCPage4 data */ 538 int IocPg4Sz; /* IOCPage4 size */ 539 u8 dvStatus[MPT_MAX_SCSI_DEVICES]; 540 int isRaid; /* bit field, 1 if RAID */ 541 u8 minSyncFactor; /* 0xFF if async */ 542 u8 maxSyncOffset; /* 0 if async */ 543 u8 maxBusWidth; /* 0 if narrow, 1 if wide */ 544 u8 busType; /* SE, LVD, HD */ 545 u8 sdp1version; /* SDP1 version */ 546 u8 sdp1length; /* SDP1 length */ 547 u8 sdp0version; /* SDP0 version */ 548 u8 sdp0length; /* SDP0 length */ 549 u8 dvScheduled; /* 1 if scheduled */ 550 u8 forceDv; /* 1 to force DV scheduling */ 551 u8 noQas; /* Disable QAS for this adapter */ 552 u8 Saf_Te; /* 1 to force all Processors as SAF-TE if Inquiry data length is too short to check for SAF-TE */ 553 u8 rsvd[1]; 554 } ScsiCfgData; 555 556 /* 557 * Adapter Structure - pci_dev specific. Maximum: MPT_MAX_ADAPTERS 558 */ 559 typedef struct _MPT_ADAPTER 560 { 561 struct _MPT_ADAPTER *forw; 562 struct _MPT_ADAPTER *back; 563 int id; /* Unique adapter id N {0,1,2,...} */ 564 int pci_irq; /* This irq */ 565 char name[MPT_NAME_LENGTH]; /* "iocN" */ 566 char *prod_name; /* "LSIFC9x9" */ 567 volatile SYSIF_REGS *chip; /* == c8817000 (mmap) */ 568 volatile SYSIF_REGS *pio_chip; /* Programmed IO (downloadboot) */ 569 u32 mem_phys; /* == f4020000 (mmap) */ 570 u32 pio_mem_phys; /* Programmed IO (downloadboot) */ 571 int mem_size; /* mmap memory size */ 572 int alloc_total; 573 u32 last_state; 574 int active; 575 u8 *reply_alloc; /* Reply frames alloc ptr */ 576 dma_addr_t reply_alloc_dma; 577 MPT_FRAME_HDR *reply_frames; /* Reply msg frames - rounded up! */ 578 dma_addr_t reply_frames_dma; 579 u32 reply_frames_low_dma; 580 int reply_depth; /* Num Allocated reply frames */ 581 int reply_sz; /* Reply frame size */ 582 CHIP_TYPE chip_type; 583 /* We (host driver) get to manage our own RequestQueue! */ 584 u8 *req_alloc; /* Request frames alloc ptr */ 585 dma_addr_t req_alloc_dma; 586 MPT_FRAME_HDR *req_frames; /* Request msg frames - rounded up! */ 587 dma_addr_t req_frames_dma; 588 u32 req_frames_low_dma; 589 int req_depth; /* Number of request frames */ 590 int req_sz; /* Request frame size (bytes) */ 591 spinlock_t FreeQlock; 592 MPT_Q_TRACKER FreeQ; 593 /* Pool of SCSI sense buffers for commands coming from 594 * the SCSI mid-layer. We have one 256 byte sense buffer 595 * for each REQ entry. 596 */ 597 u8 *sense_buf_pool; 598 dma_addr_t sense_buf_pool_dma; 599 u32 sense_buf_low_dma; 600 int mtrr_reg; 601 struct pci_dev *pcidev; /* struct pci_dev pointer */ 602 u8 *memmap; /* mmap address */ 603 struct Scsi_Host *sh; /* Scsi Host pointer */ 604 ScsiCfgData spi_data; /* Scsi config. data */ 605 MPT_IOCTL *ioctl; /* ioctl data pointer */ 606 struct proc_dir_entry *ioc_dentry; 607 struct _MPT_ADAPTER *alt_ioc; /* ptr to 929 bound adapter port */ 608 spinlock_t diagLock; /* diagnostic reset lock */ 609 int diagPending; 610 u32 biosVersion; /* BIOS version from IO Unit Page 2 */ 611 int eventTypes; /* Event logging parameters */ 612 int eventContext; /* Next event context */ 613 int eventLogSize; /* Max number of cached events */ 614 #ifdef MPTSCSIH_DBG_TIMEOUT 615 int timeout_hard; 616 int timeout_delta; 617 int timeout_cnt; 618 int timeout_maxcnt; 619 #endif 620 struct _mpt_ioctl_events *events; /* pointer to event log */ 621 u8 *cached_fw; /* Pointer to FW */ 622 dma_addr_t cached_fw_dma; 623 Q_TRACKER configQ; /* linked list of config. requests */ 624 int hs_reply_idx; 625 #ifndef MFCNT 626 u32 pad0; 627 #else 628 u32 mfcnt; 629 #endif 630 u32 hs_req[MPT_MAX_FRAME_SIZE/sizeof(u32)]; 631 u16 hs_reply[MPT_MAX_FRAME_SIZE/sizeof(u16)]; 632 IOCFactsReply_t facts; 633 PortFactsReply_t pfacts[2]; 634 FCPortPage0_t fc_port_page0[2]; 635 LANPage0_t lan_cnfg_page0; 636 LANPage1_t lan_cnfg_page1; 637 u8 FirstWhoInit; 638 u8 upload_fw; /* If set, do a fw upload */ 639 u8 reload_fw; /* Force a FW Reload on next reset */ 640 u8 pad1[5]; 641 } MPT_ADAPTER; 642 643 644 typedef struct _MPT_ADAPTER_TRACKER { 645 MPT_ADAPTER *head; 646 MPT_ADAPTER *tail; 647 } MPT_ADAPTER_TRACKER; 648 649 /* 650 * New return value convention: 651 * 1 = Ok to free associated request frame 652 * 0 = not Ok ... 653 */ 654 typedef int (*MPT_CALLBACK)(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply); 655 typedef int (*MPT_EVHANDLER)(MPT_ADAPTER *ioc, EventNotificationReply_t *evReply); 656 typedef int (*MPT_RESETHANDLER)(MPT_ADAPTER *ioc, int reset_phase); 657 /* reset_phase defs */ 658 #define MPT_IOC_PRE_RESET 0 659 #define MPT_IOC_POST_RESET 1 660 #define MPT_IOC_SETUP_RESET 2 661 662 /* 663 * Invent MPT host event (super-set of MPI Events) 664 * Fitted to 1030's 64-byte [max] request frame size 665 */ 666 typedef struct _MPT_HOST_EVENT { 667 EventNotificationReply_t MpiEvent; /* 8 32-bit words! */ 668 u32 pad[6]; 669 void *next; 670 } MPT_HOST_EVENT; 671 672 #define MPT_HOSTEVENT_IOC_BRINGUP 0x91 673 #define MPT_HOSTEVENT_IOC_RECOVER 0x92 674 675 /* Define the generic types based on the size 676 * of the dma_addr_t type. 677 */ 678 typedef struct _mpt_sge { 679 u32 FlagsLength; 680 dma_addr_t Address; 681 } MptSge_t; 682 683 #define mpt_addr_size() \ 684 ((sizeof(dma_addr_t) == sizeof(u64)) ? MPI_SGE_FLAGS_64_BIT_ADDRESSING : \ 685 MPI_SGE_FLAGS_32_BIT_ADDRESSING) 686 687 #define mpt_msg_flags() \ 688 ((sizeof(dma_addr_t) == sizeof(u64)) ? MPI_SCSIIO_MSGFLGS_SENSE_WIDTH_64 : \ 689 MPI_SCSIIO_MSGFLGS_SENSE_WIDTH_32) 690 691 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 692 /* 693 * Funky (private) macros... 694 */ 695 #ifdef MPT_DEBUG 696 #define dprintk(x) printk x 697 #else 698 #define dprintk(x) 699 #endif 700 701 #ifdef MPT_DEBUG_INIT 702 #define dinitprintk(x) printk x 703 #define DBG_DUMP_FW_REQUEST_FRAME(mfp) \ 704 { int i, n = 10; \ 705 u32 *m = (u32 *)(mfp); \ 706 printk(KERN_INFO " "); \ 707 for (i=0; i<n; i++) \ 708 printk(" %08x", le32_to_cpu(m[i])); \ 709 printk("\n"); \ 710 } 711 #else 712 #define dinitprintk(x) 713 #define DBG_DUMP_FW_REQUEST_FRAME(mfp) 714 #endif 715 716 #ifdef MPT_DEBUG_EXIT 717 #define dexitprintk(x) printk x 718 #else 719 #define dexitprintk(x) 720 #endif 721 722 #ifdef MPT_DEBUG_RESET 723 #define drsprintk(x) printk x 724 #else 725 #define drsprintk(x) 726 #endif 727 728 #ifdef MPT_DEBUG_HANDSHAKE 729 #define dhsprintk(x) printk x 730 #else 731 #define dhsprintk(x) 732 #endif 733 734 //#if defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME) 735 #if defined(MPT_DEBUG_MSG_FRAME) 736 #define dmfprintk(x) printk x 737 #else 738 #define dmfprintk(x) 739 #endif 740 741 #ifdef MPT_DEBUG_IRQ 742 #define dirqprintk(x) printk x 743 #else 744 #define dirqprintk(x) 745 #endif 746 747 #ifdef MPT_DEBUG_SG 748 #define dsgprintk(x) printk x 749 #else 750 #define dsgprintk(x) 751 #endif 752 753 #if defined(MPT_DEBUG_DL) || defined(MPT_DEBUG) 754 #define ddlprintk(x) printk x 755 #else 756 #define ddlprintk(x) 757 #endif 758 759 760 #ifdef MPT_DEBUG_DV 761 #define ddvprintk(x) printk x 762 #else 763 #define ddvprintk(x) 764 #endif 765 766 #if defined(MPT_DEBUG_DV) || defined(MPT_DEBUG_DV_TINY) 767 #define ddvtprintk(x) printk x 768 #else 769 #define ddvtprintk(x) 770 #endif 771 772 #ifdef MPT_DEBUG_IOCTL 773 #define dctlprintk(x) printk x 774 #else 775 #define dctlprintk(x) 776 #endif 777 778 #ifdef MPT_DEBUG_RESET 779 #define dtmprintk(x) printk x 780 #else 781 #define dtmprintk(x) 782 #endif 783 784 #ifdef MPT_DEBUG_NEH 785 #define nehprintk(x) printk x 786 #else 787 #define nehprintk(x) 788 #endif 789 790 #if defined(MPT_DEBUG_CONFIG) || defined(MPT_DEBUG) 791 #define dcprintk(x) printk x 792 #else 793 #define dcprintk(x) 794 #endif 795 796 #if defined(MPT_DEBUG_SCSI) || defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME) 797 #define dsprintk(x) printk x 798 #else 799 #define dsprintk(x) 800 #endif 801 802 803 #define MPT_INDEX_2_MFPTR(ioc,idx) \ 804 (MPT_FRAME_HDR*)( (u8*)(ioc)->req_frames + (ioc)->req_sz * (idx) ) 805 806 #define MFPTR_2_MPT_INDEX(ioc,mf) \ 807 (int)( ((u8*)mf - (u8*)(ioc)->req_frames) / (ioc)->req_sz ) 808 809 #define MPT_INDEX_2_RFPTR(ioc,idx) \ 810 (MPT_FRAME_HDR*)( (u8*)(ioc)->reply_frames + (ioc)->req_sz * (idx) ) 811 812 #define Q_INIT(q,type) (q)->head = (q)->tail = (type*)(q) 813 #define Q_IS_EMPTY(q) ((Q_ITEM*)(q)->head == (Q_ITEM*)(q)) 814 815 #define Q_ADD_TAIL(qt,i,type) { \ 816 Q_TRACKER *_qt = (Q_TRACKER*)(qt); \ 817 Q_ITEM *oldTail = _qt->tail; \ 818 (i)->forw = (type*)_qt; \ 819 (i)->back = (type*)oldTail; \ 820 oldTail->forw = (Q_ITEM*)(i); \ 821 _qt->tail = (Q_ITEM*)(i); \ 822 } 823 824 #define Q_ADD_HEAD(qt,i,type) { \ 825 Q_TRACKER *_qt = (Q_TRACKER*)(qt); \ 826 Q_ITEM *oldHead = _qt->head; \ 827 (i)->forw = (type*)oldHead; \ 828 (i)->back = (type*)_qt; \ 829 oldHead->back = (Q_ITEM*)(i); \ 830 _qt->head = (Q_ITEM*)(i); \ 831 } 832 833 #define Q_DEL_ITEM(i) { \ 834 Q_ITEM *_forw = (Q_ITEM*)(i)->forw; \ 835 Q_ITEM *_back = (Q_ITEM*)(i)->back; \ 836 _back->forw = _forw; \ 837 _forw->back = _back; \ 838 } 839 840 #define SWAB4(value) \ 841 (u32)( (((value) & 0x000000ff) << 24) \ 842 | (((value) & 0x0000ff00) << 8) \ 843 | (((value) & 0x00ff0000) >> 8) \ 844 | (((value) & 0xff000000) >> 24) ) 845 846 847 #if defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME) 848 #define DBG_DUMP_REPLY_FRAME(mfp) \ 849 { u32 *m = (u32 *)(mfp); \ 850 int i, n = (le32_to_cpu(m[0]) & 0x00FF0000) >> 16; \ 851 printk(KERN_INFO " "); \ 852 for (i=0; i<n; i++) \ 853 printk(" %08x", le32_to_cpu(m[i])); \ 854 printk("\n"); \ 855 } 856 #define DBG_DUMP_REQUEST_FRAME_HDR(mfp) \ 857 { int i, n = 3; \ 858 u32 *m = (u32 *)(mfp); \ 859 printk(KERN_INFO " "); \ 860 for (i=0; i<n; i++) \ 861 printk(" %08x", le32_to_cpu(m[i])); \ 862 printk("\n"); \ 863 } 864 #else 865 #define DBG_DUMP_REPLY_FRAME(mfp) 866 #define DBG_DUMP_REQUEST_FRAME_HDR(mfp) 867 #endif 868 869 870 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 871 872 /* 873 * MPT_SCSI_HOST defines - Used by the IOCTL and the SCSI drivers 874 * Private to the driver. 875 */ 876 /* LOCAL structure and fields used when processing 877 * internally generated commands. These include: 878 * bus scan, dv and config requests. 879 */ 880 typedef struct _MPT_LOCAL_REPLY { 881 ConfigPageHeader_t header; 882 int completion; 883 u8 sense[SCSI_STD_SENSE_BYTES]; 884 u8 scsiStatus; 885 u8 skip; 886 u32 pad; 887 } MPT_LOCAL_REPLY; 888 889 #define MPT_HOST_BUS_UNKNOWN (0xFF) 890 #define MPT_HOST_TOO_MANY_TM (0x05) 891 #define MPT_HOST_NVRAM_INVALID (0xFFFFFFFF) 892 #define MPT_HOST_NO_CHAIN (0xFFFFFFFF) 893 #define MPT_NVRAM_MASK_TIMEOUT (0x000000FF) 894 #define MPT_NVRAM_SYNC_MASK (0x0000FF00) 895 #define MPT_NVRAM_SYNC_SHIFT (8) 896 #define MPT_NVRAM_DISCONNECT_ENABLE (0x00010000) 897 #define MPT_NVRAM_ID_SCAN_ENABLE (0x00020000) 898 #define MPT_NVRAM_LUN_SCAN_ENABLE (0x00040000) 899 #define MPT_NVRAM_TAG_QUEUE_ENABLE (0x00080000) 900 #define MPT_NVRAM_WIDE_DISABLE (0x00100000) 901 #define MPT_NVRAM_BOOT_CHOICE (0x00200000) 902 903 #ifdef MPT_SCSI_USE_NEW_EH 904 /* The TM_STATE variable is used to provide strict single threading of TM 905 * requests as well as communicate TM error conditions. 906 */ 907 #define TM_STATE_NONE (0) 908 #define TM_STATE_IN_PROGRESS (1) 909 #define TM_STATE_ERROR (2) 910 #endif 911 912 typedef struct _MPT_SCSI_HOST { 913 MPT_ADAPTER *ioc; 914 int port; 915 u32 pad0; 916 struct scsi_cmnd **ScsiLookup; 917 /* Pool of buffers for chaining. ReqToChain 918 * and ChainToChain track index of chain buffers. 919 * ChainBuffer (DMA) virt/phys addresses. 920 * FreeChainQ (lock) locking mechanisms. 921 */ 922 int *ReqToChain; 923 int *ChainToChain; 924 u8 *ChainBuffer; 925 dma_addr_t ChainBufferDMA; 926 MPT_Q_TRACKER FreeChainQ; 927 spinlock_t FreeChainQlock; 928 u32 qtag_tick; 929 VirtDevice **Targets; 930 MPT_LOCAL_REPLY *pLocal; /* used for internal commands */ 931 struct timer_list timer; 932 struct timer_list TMtimer; /* Timer for TM commands ONLY */ 933 /* Pool of memory for holding SCpnts before doing 934 * OS callbacks. freeQ is the free pool. 935 */ 936 u8 *memQ; 937 DONE_Q_TRACKER freeQ; 938 DONE_Q_TRACKER doneQ; /* Holds Linux formmatted requests */ 939 DONE_Q_TRACKER pendingQ; /* Holds MPI formmatted requests */ 940 MPT_Q_TRACKER taskQ; /* TM request Q */ 941 spinlock_t freedoneQlock; 942 int taskQcnt; 943 int num_chain; /* Number of chain buffers */ 944 int max_sge; /* Max No of SGE*/ 945 u8 numTMrequests; 946 u8 tmPending; 947 u8 resetPending; 948 u8 is_spi; /* Parallel SCSI i/f */ 949 u8 negoNvram; /* DV disabled, nego NVRAM */ 950 u8 is_multipath; /* Multi-path compatible */ 951 #ifdef MPT_SCSI_USE_NEW_EH 952 u8 tmState; 953 u8 rsvd[1]; 954 #else 955 u8 rsvd[2]; 956 #endif 957 MPT_FRAME_HDR *tmPtr; /* Ptr to TM request*/ 958 MPT_FRAME_HDR *cmdPtr; /* Ptr to nonOS request */ 959 struct scsi_cmnd *abortSCpnt; 960 MPT_LOCAL_REPLY localReply; /* internal cmd reply struct */ 961 unsigned long hard_resets; /* driver forced bus resets count */ 962 unsigned long soft_resets; /* fw/external bus resets count */ 963 unsigned long timeouts; /* cmd timeouts */ 964 ushort sel_timeout[MPT_MAX_FC_DEVICES]; 965 } MPT_SCSI_HOST; 966 967 /* 968 * Structure for overlaying onto scsi_cmnd->SCp area 969 * NOTE: SCp area is 36 bytes min, 44 bytes max? 970 */ 971 typedef struct _scPrivate { 972 struct scsi_cmnd *forw; 973 struct scsi_cmnd *back; 974 void *p1; 975 void *p2; 976 u8 io_path_id; /* DMP */ 977 u8 pad[7]; 978 } scPrivate; 979 980 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 981 /* 982 * More Dynamic Multi-Pathing stuff... 983 */ 984 985 /* Forward decl, a strange C thing, to prevent gcc compiler warnings */ 986 struct scsi_cmnd; 987 988 /* 989 * DMP service layer structure / API interface 990 */ 991 typedef struct _DmpServices { 992 VirtDevTracker VdevList; 993 struct semaphore *Daemon; 994 int (*ScsiPathSelect) 995 (struct scsi_cmnd *, MPT_SCSI_HOST **hd, int *target, int *lun); 996 int (*DmpIoDoneChk) 997 (MPT_SCSI_HOST *, struct scsi_cmnd *, 998 SCSIIORequest_t *, 999 SCSIIOReply_t *); 1000 void (*mptscsih_scanVlist) 1001 (MPT_SCSI_HOST *, int portnum); 1002 int (*ScsiAbort) 1003 (struct scsi_cmnd *); 1004 int (*ScsiBusReset) 1005 (struct scsi_cmnd *); 1006 } DmpServices_t; 1007 1008 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1009 /* 1010 * Generic structure passed to the base mpt_config function. 1011 */ 1012 typedef struct _x_config_parms { 1013 Q_ITEM linkage; /* linked list */ 1014 struct timer_list timer; /* timer function for this request */ 1015 ConfigPageHeader_t *hdr; 1016 dma_addr_t physAddr; 1017 int wait_done; /* wait for this request */ 1018 u32 pageAddr; /* properly formatted */ 1019 u8 action; 1020 u8 dir; 1021 u8 timeout; /* seconds */ 1022 u8 pad1; 1023 u16 status; 1024 u16 pad2; 1025 } CONFIGPARMS; 1026 1027 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1028 /* 1029 * Public entry points... 1030 */ 1031 extern int mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass); 1032 extern void mpt_deregister(int cb_idx); 1033 extern int mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc); 1034 extern void mpt_event_deregister(int cb_idx); 1035 extern int mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func); 1036 extern void mpt_reset_deregister(int cb_idx); 1037 extern int mpt_register_ascqops_strings(void *ascqTable, int ascqtbl_sz, const char **opsTable); 1038 extern void mpt_deregister_ascqops_strings(void); 1039 extern MPT_FRAME_HDR *mpt_get_msg_frame(int handle, int iocid); 1040 extern void mpt_free_msg_frame(int handle, int iocid, MPT_FRAME_HDR *mf); 1041 extern void mpt_put_msg_frame(int handle, int iocid, MPT_FRAME_HDR *mf); 1042 extern void mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr); 1043 extern void mpt_add_chain(char *pAddr, u8 next, u16 length, dma_addr_t dma_addr); 1044 1045 extern int mpt_send_handshake_request(int handle, int iocid, int reqBytes, u32 *req, int sleepFlag); 1046 extern int mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req, int replyBytes, u16 *u16reply, int maxwait, int sleepFlag); 1047 extern int mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp); 1048 extern MPT_ADAPTER *mpt_adapter_find_first(void); 1049 extern MPT_ADAPTER *mpt_adapter_find_next(MPT_ADAPTER *prev); 1050 extern u32 mpt_GetIocState(MPT_ADAPTER *ioc, int cooked); 1051 extern void mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buf, int *size, int len, int showlan); 1052 extern int mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag); 1053 extern int mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *cfg); 1054 extern int mpt_toolbox(MPT_ADAPTER *ioc, CONFIGPARMS *cfg); 1055 extern void mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size); 1056 extern void mpt_free_fw_memory(MPT_ADAPTER *ioc); 1057 extern int mpt_findImVolumes(MPT_ADAPTER *ioc); 1058 extern int mpt_read_ioc_pg_3(MPT_ADAPTER *ioc); 1059 1060 /* 1061 * Public data decl's... 1062 */ 1063 extern MPT_ADAPTER *mpt_adapters[MPT_MAX_ADAPTERS]; 1064 extern struct proc_dir_entry *mpt_proc_root_dir; 1065 extern DmpServices_t *DmpService; 1066 1067 extern int mpt_lan_index; /* needed by mptlan.c */ 1068 extern int mpt_stm_index; /* needed by mptstm.c */ 1069 1070 extern void *mpt_v_ASCQ_TablePtr; 1071 extern const char **mpt_ScsiOpcodesPtr; 1072 extern int mpt_ASCQ_TableSz; 1073 1074 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1075 #endif /* } __KERNEL__ */ 1076 1077 /* 1078 * More (public) macros... 1079 */ 1080 #ifndef MIN 1081 #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 1082 #endif 1083 #ifndef MAX 1084 #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 1085 #endif 1086 1087 #ifndef offsetof 1088 #define offsetof(t, m) ((size_t) (&((t *)0)->m)) 1089 #endif 1090 1091 #if defined(__alpha__) || defined(__sparc_v9__) || defined(__ia64__) || defined(__x86_64__) 1092 #define CAST_U32_TO_PTR(x) ((void *)(u64)x) 1093 #define CAST_PTR_TO_U32(x) ((u32)(u64)x) 1094 #else 1095 #define CAST_U32_TO_PTR(x) ((void *)x) 1096 #define CAST_PTR_TO_U32(x) ((u32)x) 1097 #endif 1098 1099 #define MPT_PROTOCOL_FLAGS_c_c_c_c(pflags) \ 1100 ((pflags) & MPI_PORTFACTS_PROTOCOL_INITIATOR) ? 'I' : 'i', \ 1101 ((pflags) & MPI_PORTFACTS_PROTOCOL_TARGET) ? 'T' : 't', \ 1102 ((pflags) & MPI_PORTFACTS_PROTOCOL_LAN) ? 'L' : 'l', \ 1103 ((pflags) & MPI_PORTFACTS_PROTOCOL_LOGBUSADDR) ? 'B' : 'b' 1104 1105 /* 1106 * Shifted SGE Defines - Use in SGE with FlagsLength member. 1107 * Otherwise, use MPI_xxx defines (refer to "lsi/mpi.h" header). 1108 * Defaults: 32 bit SGE, SYSTEM_ADDRESS if direction bit is 0, read 1109 */ 1110 #define MPT_TRANSFER_IOC_TO_HOST (0x00000000) 1111 #define MPT_TRANSFER_HOST_TO_IOC (0x04000000) 1112 #define MPT_SGE_FLAGS_LAST_ELEMENT (0x80000000) 1113 #define MPT_SGE_FLAGS_END_OF_BUFFER (0x40000000) 1114 #define MPT_SGE_FLAGS_LOCAL_ADDRESS (0x08000000) 1115 #define MPT_SGE_FLAGS_DIRECTION (0x04000000) 1116 #define MPT_SGE_FLAGS_ADDRESSING (mpt_addr_size() << MPI_SGE_FLAGS_SHIFT) 1117 #define MPT_SGE_FLAGS_END_OF_LIST (0x01000000) 1118 1119 #define MPT_SGE_FLAGS_TRANSACTION_ELEMENT (0x00000000) 1120 #define MPT_SGE_FLAGS_SIMPLE_ELEMENT (0x10000000) 1121 #define MPT_SGE_FLAGS_CHAIN_ELEMENT (0x30000000) 1122 #define MPT_SGE_FLAGS_ELEMENT_MASK (0x30000000) 1123 1124 #define MPT_SGE_FLAGS_SSIMPLE_READ \ 1125 (MPT_SGE_FLAGS_LAST_ELEMENT | \ 1126 MPT_SGE_FLAGS_END_OF_BUFFER | \ 1127 MPT_SGE_FLAGS_END_OF_LIST | \ 1128 MPT_SGE_FLAGS_SIMPLE_ELEMENT | \ 1129 MPT_SGE_FLAGS_ADDRESSING | \ 1130 MPT_TRANSFER_IOC_TO_HOST) 1131 #define MPT_SGE_FLAGS_SSIMPLE_WRITE \ 1132 (MPT_SGE_FLAGS_LAST_ELEMENT | \ 1133 MPT_SGE_FLAGS_END_OF_BUFFER | \ 1134 MPT_SGE_FLAGS_END_OF_LIST | \ 1135 MPT_SGE_FLAGS_SIMPLE_ELEMENT | \ 1136 MPT_SGE_FLAGS_ADDRESSING | \ 1137 MPT_TRANSFER_HOST_TO_IOC) 1138 1139 /*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1140 #endif 1141 1142