48 #ifndef MPTBASE_H_INCLUDED
49 #define MPTBASE_H_INCLUDED
52 #include <linux/kernel.h>
53 #include <linux/pci.h>
72 #define MODULEAUTHOR "LSI Corporation"
76 #define COPYRIGHT "Copyright (c) 1999-2008 " MODULEAUTHOR
79 #define MPT_LINUX_VERSION_COMMON "3.04.20"
80 #define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.04.20"
81 #define WHAT_MAGIC_STRING "@" "(" "#" ")"
83 #define show_mptmod_ver(s,ver) \
84 printk(KERN_INFO "%s %s\n", s, ver);
90 #define MPT_MAX_ADAPTERS 18
91 #define MPT_MAX_PROTOCOL_DRIVERS 16
92 #define MPT_MAX_CALLBACKNAME_LEN 49
94 #define MPT_MAX_FC_DEVICES 255
95 #define MPT_MAX_SCSI_DEVICES 16
96 #define MPT_LAST_LUN 255
97 #define MPT_SENSE_BUFFER_ALLOC 64
99 #if MPT_SENSE_BUFFER_ALLOC >= 256
100 # undef MPT_SENSE_BUFFER_ALLOC
101 # define MPT_SENSE_BUFFER_ALLOC 256
102 # define MPT_SENSE_BUFFER_SIZE 255
104 # define MPT_SENSE_BUFFER_SIZE MPT_SENSE_BUFFER_ALLOC
107 #define MPT_NAME_LENGTH 32
108 #define MPT_KOBJ_NAME_LEN 20
110 #define MPT_PROCFS_MPTBASEDIR "mpt"
112 #define MPT_PROCFS_SUMMARY_ALL_NODE MPT_PROCFS_MPTBASEDIR "/summary"
113 #define MPT_PROCFS_SUMMARY_ALL_PATHNAME "/proc/" MPT_PROCFS_SUMMARY_ALL_NODE
114 #define MPT_FW_REV_MAGIC_ID_STRING "FwRev="
116 #define MPT_MAX_REQ_DEPTH 1023
117 #define MPT_DEFAULT_REQ_DEPTH 256
118 #define MPT_MIN_REQ_DEPTH 128
120 #define MPT_MAX_REPLY_DEPTH MPT_MAX_REQ_DEPTH
121 #define MPT_DEFAULT_REPLY_DEPTH 128
122 #define MPT_MIN_REPLY_DEPTH 8
123 #define MPT_MAX_REPLIES_PER_ISR 32
125 #define MPT_MAX_FRAME_SIZE 128
126 #define MPT_DEFAULT_FRAME_SIZE 128
128 #define MPT_REPLY_FRAME_SIZE 0x50
130 #define MPT_SG_REQ_128_SCALE 1
131 #define MPT_SG_REQ_96_SCALE 2
132 #define MPT_SG_REQ_64_SCALE 4
137 #define MPT_COALESCING_TIMEOUT 0x10
143 #define MPT_ULTRA320 0x08
144 #define MPT_ULTRA160 0x09
145 #define MPT_ULTRA2 0x0A
146 #define MPT_ULTRA 0x0C
147 #define MPT_FAST 0x19
148 #define MPT_SCSI 0x32
149 #define MPT_ASYNC 0xFF
161 #define MPT_FC_CAN_QUEUE 1024
162 #define MPT_SCSI_CAN_QUEUE 127
163 #define MPT_SAS_CAN_QUEUE 127
168 #ifdef CONFIG_FUSION_MAX_SGE
169 #if CONFIG_FUSION_MAX_SGE < 16
170 #define MPT_SCSI_SG_DEPTH 16
171 #elif CONFIG_FUSION_MAX_SGE > 128
172 #define MPT_SCSI_SG_DEPTH 128
174 #define MPT_SCSI_SG_DEPTH CONFIG_FUSION_MAX_SGE
177 #define MPT_SCSI_SG_DEPTH 40
180 #ifdef CONFIG_FUSION_MAX_FC_SGE
181 #if CONFIG_FUSION_MAX_FC_SGE < 16
182 #define MPT_SCSI_FC_SG_DEPTH 16
183 #elif CONFIG_FUSION_MAX_FC_SGE > 256
184 #define MPT_SCSI_FC_SG_DEPTH 256
186 #define MPT_SCSI_FC_SG_DEPTH CONFIG_FUSION_MAX_FC_SGE
189 #define MPT_SCSI_FC_SG_DEPTH 40
193 # define EVENT_DESCR_STR_SZ 100
195 #define MPT_POLLING_INTERVAL 1000
208 #define MYIOC_s_FMT MYNAM ": %s: "
209 #define MYIOC_s_DEBUG_FMT KERN_DEBUG MYNAM ": %s: "
210 #define MYIOC_s_INFO_FMT KERN_INFO MYNAM ": %s: "
211 #define MYIOC_s_NOTE_FMT KERN_NOTICE MYNAM ": %s: "
212 #define MYIOC_s_WARN_FMT KERN_WARNING MYNAM ": %s: WARNING - "
213 #define MYIOC_s_ERR_FMT KERN_ERR MYNAM ": %s: ERROR - "
219 #define ATTOFLAG_DISC 0x0001
220 #define ATTOFLAG_TAGGED 0x0002
221 #define ATTOFLAG_WIDE_ENB 0x0008
222 #define ATTOFLAG_ID_ENB 0x0010
223 #define ATTOFLAG_LUN_ENB 0x0060
225 typedef struct _ATTO_DEVICE_INFO
230 } ATTO_DEVICE_INFO,
MPI_POINTER PTR_ATTO_DEVICE_INFO,
233 typedef struct _ATTO_CONFIG_PAGE_SCSI_PORT_2
239 ATTO_DEVICE_INFO DeviceSettings[16];
240 } fATTO_CONFIG_PAGE_SCSI_PORT_2,
MPI_POINTER PTR_ATTO_CONFIG_PAGE_SCSI_PORT_2,
241 ATTO_SCSIPortPage2_t,
MPI_POINTER pATTO_SCSIPortPage2_t;
259 struct mpt_pci_driver{
268 typedef union _MPT_FRAME_TRACKER {
320 typedef struct _MPT_FRAME_HDR {
327 MPT_FRAME_TRACKER
frame;
331 #define MPT_REQ_MSGFLAGS_DROPME 0x80
333 typedef struct _MPT_SGL_HDR {
337 typedef struct _MPT_SGL64_HDR {
345 typedef struct _SYSIF_REGS
359 u32 RequestHiPriFifo;
379 #define MPT_TARGET_NO_NEGO_WIDE 0x01
380 #define MPT_TARGET_NO_NEGO_SYNC 0x02
381 #define MPT_TARGET_NO_NEGO_QAS 0x04
382 #define MPT_TAPE_NEGO_IDP 0x08
387 typedef struct _VirtTarget {
405 typedef struct _VirtDevice {
414 #define MPT_TARGET_DEFAULT_DV_STATUS 0x00
415 #define MPT_TARGET_FLAGS_VALID_NEGO 0x01
416 #define MPT_TARGET_FLAGS_VALID_INQUIRY 0x02
417 #define MPT_TARGET_FLAGS_Q_YES 0x08
418 #define MPT_TARGET_FLAGS_VALID_56 0x10
419 #define MPT_TARGET_FLAGS_SAF_TE_ISSUED 0x20
420 #define MPT_TARGET_FLAGS_RAID_COMPONENT 0x40
421 #define MPT_TARGET_FLAGS_LED_ON 0x80
427 #define MPTCTL_RESET_OK 0x01
429 #define MPT_MGMT_STATUS_RF_VALID 0x01
430 #define MPT_MGMT_STATUS_COMMAND_GOOD 0x02
431 #define MPT_MGMT_STATUS_PENDING 0x04
432 #define MPT_MGMT_STATUS_DID_IOCRESET 0x08
434 #define MPT_MGMT_STATUS_SENSE_VALID 0x10
435 #define MPT_MGMT_STATUS_TIMER_ACTIVE 0x20
436 #define MPT_MGMT_STATUS_FREE_MF 0x40
439 #define INITIALIZE_MGMT_STATUS(status) \
440 status = MPT_MGMT_STATUS_PENDING;
441 #define CLEAR_MGMT_STATUS(status) \
443 #define CLEAR_MGMT_PENDING_STATUS(status) \
444 status &= ~MPT_MGMT_STATUS_PENDING;
445 #define SET_MGMT_MSG_CONTEXT(msg_context, value) \
448 typedef struct _MPT_MGMT {
461 #define MPTCTL_EVENT_LOG_SIZE (0x000000032)
462 typedef struct _mpt_ioctl_events {
471 #define MPT_CONFIG_GOOD MPI_IOCSTATUS_SUCCESS
472 #define MPT_CONFIG_ERROR 0x002F
478 #define MPT_SCSICFG_USE_NVRAM 0x01
479 #define MPT_SCSICFG_ALL_IDS 0x02
482 typedef struct _SpiCfgData {
506 typedef struct _SasCfgData {
518 struct inactive_raid_component_info {
525 typedef struct _RaidCfgData {
528 struct mutex inactive_list_mutex;
534 typedef struct _FcCfgData {
543 #define MPT_RPORT_INFO_FLAGS_REGISTERED 0x01
544 #define MPT_RPORT_INFO_FLAGS_MISSING 0x02
549 struct mptfc_rport_info
565 #define MPT_HOST_BUS_UNKNOWN (0xFF)
566 #define MPT_HOST_TOO_MANY_TM (0x05)
567 #define MPT_HOST_NVRAM_INVALID (0xFFFFFFFF)
568 #define MPT_HOST_NO_CHAIN (0xFFFFFFFF)
569 #define MPT_NVRAM_MASK_TIMEOUT (0x000000FF)
570 #define MPT_NVRAM_SYNC_MASK (0x0000FF00)
571 #define MPT_NVRAM_SYNC_SHIFT (8)
572 #define MPT_NVRAM_DISCONNECT_ENABLE (0x00010000)
573 #define MPT_NVRAM_ID_SCAN_ENABLE (0x00020000)
574 #define MPT_NVRAM_LUN_SCAN_ENABLE (0x00040000)
575 #define MPT_NVRAM_TAG_QUEUE_ENABLE (0x00080000)
576 #define MPT_NVRAM_WIDE_DISABLE (0x00100000)
577 #define MPT_NVRAM_BOOT_CHOICE (0x00200000)
585 typedef struct _MPT_SCSI_HOST {
586 struct _MPT_ADAPTER *
ioc;
589 long last_queue_full;
597 typedef void (*MPT_SCHEDULE_TARGET_RESET)(
void *
ioc);
598 typedef void (*MPT_FLUSH_RUNNING_CMDS)(MPT_SCSI_HOST *hd);
603 typedef struct _MPT_ADAPTER
609 #ifdef CONFIG_FUSION_LOGGING
614 char board_assembly[16];
615 char board_tracer[16];
616 u16 nvdata_version_persistent;
617 u16 nvdata_version_default;
620 u16 device_missing_delay;
635 MPT_FRAME_HDR *reply_frames;
636 u32 reply_frames_low_dma;
642 MPT_ADD_CHAIN add_chain;
658 MPT_FRAME_HDR *req_frames;
659 u32 req_frames_low_dma;
670 u32 sense_buf_low_dma;
672 u32 HostPageBuffer_sz;
685 struct _MPT_ADAPTER *alt_ioc;
690 struct _mpt_ioctl_events *
events;
699 u32 NB_for_64_byte_frame;
715 int errata_flag_1064;
716 int aen_event_read_flag;
727 struct mutex sas_topology_mutex;
735 struct mutex sas_discovery_mutex;
736 u8 sas_discovery_runtime;
737 u8 sas_discovery_ignore_events;
741 u64 hba_port_sas_addr;
742 u16 hba_port_num_phy;
744 struct mutex sas_device_info_mutex;
745 u8 old_sas_discovery_protocal;
746 u8 sas_discovery_quiesce_io;
749 MPT_MGMT mptbase_cmds;
750 MPT_MGMT internal_cmds;
751 MPT_MGMT taskmgmt_cmds;
754 int taskmgmt_in_progress;
755 u8 taskmgmt_quiesce_io;
756 u8 ioc_reset_in_progress;
758 u8 wait_on_reset_completion;
759 MPT_SCHEDULE_TARGET_RESET schedule_target_reset;
760 MPT_FLUSH_RUNNING_CMDS schedule_dead_ioc_flush_running_cmds;
773 unsigned long hard_resets;
775 unsigned long soft_resets;
777 unsigned long timeouts;
782 u32 broadcast_aen_busy;
800 typedef int (*MPT_RESETHANDLER)(MPT_ADAPTER *
ioc,
int reset_phase);
802 #define MPT_IOC_PRE_RESET 0
803 #define MPT_IOC_POST_RESET 1
804 #define MPT_IOC_SETUP_RESET 2
810 typedef struct _MPT_HOST_EVENT {
816 #define MPT_HOSTEVENT_IOC_BRINGUP 0x91
817 #define MPT_HOSTEVENT_IOC_RECOVER 0x92
822 typedef struct _mpt_sge {
828 #define mpt_msg_flags(ioc) \
829 (ioc->sg_addr_size == sizeof(u64)) ? \
830 MPI_SCSIIO_MSGFLGS_SENSE_WIDTH_64 : \
831 MPI_SCSIIO_MSGFLGS_SENSE_WIDTH_32
833 #define MPT_SGE_FLAGS_64_BIT_ADDRESSING \
834 (MPI_SGE_FLAGS_64_BIT_ADDRESSING << MPI_SGE_FLAGS_SHIFT)
842 #define MPT_INDEX_2_MFPTR(ioc,idx) \
843 (MPT_FRAME_HDR*)( (u8*)(ioc)->req_frames + (ioc)->req_sz * (idx) )
845 #define MFPTR_2_MPT_INDEX(ioc,mf) \
846 (int)( ((u8*)mf - (u8*)(ioc)->req_frames) / (ioc)->req_sz )
848 #define MPT_INDEX_2_RFPTR(ioc,idx) \
849 (MPT_FRAME_HDR*)( (u8*)(ioc)->reply_frames + (ioc)->req_sz * (idx) )
853 #define SCSI_STD_SENSE_BYTES 18
854 #define SCSI_STD_INQUIRY_BYTES 36
855 #define SCSI_MAX_INQUIRY_BYTES 96
865 typedef struct _MPT_LOCAL_REPLY {
868 u8 sense[SCSI_STD_SENSE_BYTES];
878 #define TM_STATE_NONE (0)
879 #define TM_STATE_IN_PROGRESS (1)
880 #define TM_STATE_ERROR (2)
894 typedef struct _x_config_parms {
915 extern int mpt_resume(
struct pci_dev *pdev);
962 #define CAST_U32_TO_PTR(x) ((void *)(u64)x)
963 #define CAST_PTR_TO_U32(x) ((u32)(u64)x)
965 #define CAST_U32_TO_PTR(x) ((void *)x)
966 #define CAST_PTR_TO_U32(x) ((u32)x)
969 #define MPT_PROTOCOL_FLAGS_c_c_c_c(pflags) \
970 ((pflags) & MPI_PORTFACTS_PROTOCOL_INITIATOR) ? 'I' : 'i', \
971 ((pflags) & MPI_PORTFACTS_PROTOCOL_TARGET) ? 'T' : 't', \
972 ((pflags) & MPI_PORTFACTS_PROTOCOL_LAN) ? 'L' : 'l', \
973 ((pflags) & MPI_PORTFACTS_PROTOCOL_LOGBUSADDR) ? 'B' : 'b'
980 #define MPT_TRANSFER_IOC_TO_HOST (0x00000000)
981 #define MPT_TRANSFER_HOST_TO_IOC (0x04000000)
982 #define MPT_SGE_FLAGS_LAST_ELEMENT (0x80000000)
983 #define MPT_SGE_FLAGS_END_OF_BUFFER (0x40000000)
984 #define MPT_SGE_FLAGS_LOCAL_ADDRESS (0x08000000)
985 #define MPT_SGE_FLAGS_DIRECTION (0x04000000)
986 #define MPT_SGE_FLAGS_END_OF_LIST (0x01000000)
988 #define MPT_SGE_FLAGS_TRANSACTION_ELEMENT (0x00000000)
989 #define MPT_SGE_FLAGS_SIMPLE_ELEMENT (0x10000000)
990 #define MPT_SGE_FLAGS_CHAIN_ELEMENT (0x30000000)
991 #define MPT_SGE_FLAGS_ELEMENT_MASK (0x30000000)
993 #define MPT_SGE_FLAGS_SSIMPLE_READ \
994 (MPT_SGE_FLAGS_LAST_ELEMENT | \
995 MPT_SGE_FLAGS_END_OF_BUFFER | \
996 MPT_SGE_FLAGS_END_OF_LIST | \
997 MPT_SGE_FLAGS_SIMPLE_ELEMENT | \
998 MPT_TRANSFER_IOC_TO_HOST)
999 #define MPT_SGE_FLAGS_SSIMPLE_WRITE \
1000 (MPT_SGE_FLAGS_LAST_ELEMENT | \
1001 MPT_SGE_FLAGS_END_OF_BUFFER | \
1002 MPT_SGE_FLAGS_END_OF_LIST | \
1003 MPT_SGE_FLAGS_SIMPLE_ELEMENT | \
1004 MPT_TRANSFER_HOST_TO_IOC)