Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef CCISS_CMD_H |
| 2 | #define CCISS_CMD_H |
dann frazier | 429c42c | 2010-02-17 16:55:11 -0700 | [diff] [blame] | 3 | |
| 4 | #include <linux/cciss_defs.h> |
| 5 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 6 | /* DEFINES */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #define CISS_VERSION "1.00" |
| 8 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 9 | /* general boundary definitions */ |
Don Brace | 5c07a31 | 2009-11-12 12:50:01 -0600 | [diff] [blame] | 10 | #define MAXSGENTRIES 32 |
| 11 | #define CCISS_SG_CHAIN 0x80000000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #define MAXREPLYQS 256 |
| 13 | |
Mike Miller | 0a9279c | 2009-04-02 12:50:55 -0700 | [diff] [blame] | 14 | /* Unit Attentions ASC's as defined for the MSA2012sa */ |
| 15 | #define POWER_OR_RESET 0x29 |
| 16 | #define STATE_CHANGED 0x2a |
| 17 | #define UNIT_ATTENTION_CLEARED 0x2f |
| 18 | #define LUN_FAILED 0x3e |
| 19 | #define REPORT_LUNS_CHANGED 0x3f |
| 20 | |
| 21 | /* Unit Attentions ASCQ's as defined for the MSA2012sa */ |
| 22 | |
| 23 | /* These ASCQ's defined for ASC = POWER_OR_RESET */ |
| 24 | #define POWER_ON_RESET 0x00 |
| 25 | #define POWER_ON_REBOOT 0x01 |
| 26 | #define SCSI_BUS_RESET 0x02 |
| 27 | #define MSA_TARGET_RESET 0x03 |
| 28 | #define CONTROLLER_FAILOVER 0x04 |
| 29 | #define TRANSCEIVER_SE 0x05 |
| 30 | #define TRANSCEIVER_LVD 0x06 |
| 31 | |
| 32 | /* These ASCQ's defined for ASC = STATE_CHANGED */ |
| 33 | #define RESERVATION_PREEMPTED 0x03 |
| 34 | #define ASYM_ACCESS_CHANGED 0x06 |
| 35 | #define LUN_CAPACITY_CHANGED 0x09 |
| 36 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 37 | /* config space register offsets */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #define CFG_VENDORID 0x00 |
| 39 | #define CFG_DEVICEID 0x02 |
| 40 | #define CFG_I2OBAR 0x10 |
| 41 | #define CFG_MEM1BAR 0x14 |
| 42 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 43 | /* i2o space register offsets */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #define I2O_IBDB_SET 0x20 |
| 45 | #define I2O_IBDB_CLEAR 0x70 |
| 46 | #define I2O_INT_STATUS 0x30 |
| 47 | #define I2O_INT_MASK 0x34 |
| 48 | #define I2O_IBPOST_Q 0x40 |
| 49 | #define I2O_OBPOST_Q 0x44 |
Mike Miller | f92e2f5 | 2006-12-06 20:35:04 -0800 | [diff] [blame] | 50 | #define I2O_DMA1_CFG 0x214 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 52 | /* Configuration Table */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | #define CFGTBL_ChangeReq 0x00000001l |
| 54 | #define CFGTBL_AccCmds 0x00000001l |
Stephen M. Cameron | a6528d0 | 2010-07-19 13:46:22 -0500 | [diff] [blame] | 55 | #define DOORBELL_CTLR_RESET 0x00000004l |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
| 57 | #define CFGTBL_Trans_Simple 0x00000002l |
Mike Miller | 5e21615 | 2010-06-02 12:58:06 -0700 | [diff] [blame] | 58 | #define CFGTBL_Trans_Performant 0x00000004l |
Stephen M. Cameron | 0498cc2 | 2011-03-12 10:02:16 +0100 | [diff] [blame] | 59 | #define CFGTBL_Trans_use_short_tags 0x20000000l |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
| 61 | #define CFGTBL_BusType_Ultra2 0x00000001l |
| 62 | #define CFGTBL_BusType_Ultra3 0x00000002l |
| 63 | #define CFGTBL_BusType_Fibre1G 0x00000100l |
| 64 | #define CFGTBL_BusType_Fibre2G 0x00000200l |
| 65 | typedef struct _vals32 |
| 66 | { |
| 67 | __u32 lower; |
| 68 | __u32 upper; |
| 69 | } vals32; |
| 70 | |
| 71 | typedef union _u64bit |
| 72 | { |
| 73 | vals32 val32; |
| 74 | __u64 val; |
| 75 | } u64bit; |
| 76 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 77 | /* Type defs used in the following structs */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | #define QWORD vals32 |
| 79 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 80 | /* STRUCTURES */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | #define CISS_MAX_PHYS_LUN 1024 |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 82 | /* SCSI-3 Cmmands */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
| 84 | #pragma pack(1) |
| 85 | |
| 86 | #define CISS_INQUIRY 0x12 |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 87 | /* Date returned */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | typedef struct _InquiryData_struct |
| 89 | { |
| 90 | BYTE data_byte[36]; |
| 91 | } InquiryData_struct; |
| 92 | |
| 93 | #define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */ |
| 94 | #define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */ |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 95 | /* Data returned */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | typedef struct _ReportLUNdata_struct |
| 97 | { |
| 98 | BYTE LUNListLength[4]; |
| 99 | DWORD reserved; |
| 100 | BYTE LUN[CISS_MAX_LUN][8]; |
| 101 | } ReportLunData_struct; |
| 102 | |
| 103 | #define CCISS_READ_CAPACITY 0x25 /* Read Capacity */ |
| 104 | typedef struct _ReadCapdata_struct |
| 105 | { |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 106 | BYTE total_size[4]; /* Total size in blocks */ |
| 107 | BYTE block_size[4]; /* Size of blocks in bytes */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | } ReadCapdata_struct; |
| 109 | |
Mike Miller (OS Dev) | 00988a3 | 2006-09-30 23:27:23 -0700 | [diff] [blame] | 110 | #define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */ |
| 111 | |
| 112 | /* service action to differentiate a 16 byte read capacity from |
| 113 | other commands that use the 0x9e SCSI op code */ |
| 114 | |
| 115 | #define CCISS_READ_CAPACITY_16_SERVICE_ACT 0x10 |
| 116 | |
| 117 | typedef struct _ReadCapdata_struct_16 |
| 118 | { |
| 119 | BYTE total_size[8]; /* Total size in blocks */ |
| 120 | BYTE block_size[4]; /* Size of blocks in bytes */ |
| 121 | BYTE prot_en:1; /* protection enable bit */ |
| 122 | BYTE rto_en:1; /* reference tag own enable bit */ |
| 123 | BYTE reserved:6; /* reserved bits */ |
| 124 | BYTE reserved2[18]; /* reserved bytes per spec */ |
| 125 | } ReadCapdata_struct_16; |
| 126 | |
| 127 | /* Define the supported read/write commands for cciss based controllers */ |
| 128 | |
| 129 | #define CCISS_READ_10 0x28 /* Read(10) */ |
| 130 | #define CCISS_WRITE_10 0x2a /* Write(10) */ |
| 131 | #define CCISS_READ_16 0x88 /* Read(16) */ |
| 132 | #define CCISS_WRITE_16 0x8a /* Write(16) */ |
| 133 | |
| 134 | /* Define the CDB lengths supported by cciss based controllers */ |
| 135 | |
| 136 | #define CDB_LEN10 10 |
| 137 | #define CDB_LEN16 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 139 | /* BMIC commands */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | #define BMIC_READ 0x26 |
| 141 | #define BMIC_WRITE 0x27 |
| 142 | #define BMIC_CACHE_FLUSH 0xc2 |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 143 | #define CCISS_CACHE_FLUSH 0x01 /* C2 was already being used by CCISS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | |
Stephen M. Cameron | 8f71bb8 | 2011-05-03 14:53:26 -0500 | [diff] [blame^] | 145 | #define CCISS_ABORT_MSG 0x00 |
| 146 | #define CCISS_RESET_MSG 0x01 |
| 147 | #define CCISS_RESET_TYPE_CONTROLLER 0x00 |
| 148 | #define CCISS_RESET_TYPE_BUS 0x01 |
| 149 | #define CCISS_RESET_TYPE_TARGET 0x03 |
| 150 | #define CCISS_RESET_TYPE_LUN 0x04 |
| 151 | #define CCISS_NOOP_MSG 0x03 |
| 152 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 153 | /* Command List Structure */ |
scameron@beardog.cca.cpqcorp.net | b57695f | 2009-06-08 16:02:17 -0500 | [diff] [blame] | 154 | #define CTLR_LUNID "\0\0\0\0\0\0\0\0" |
| 155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | typedef struct _CommandListHeader_struct { |
| 157 | BYTE ReplyQueue; |
| 158 | BYTE SGList; |
| 159 | HWORD SGTotal; |
| 160 | QWORD Tag; |
| 161 | LUNAddr_struct LUN; |
| 162 | } CommandListHeader_struct; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | typedef struct _ErrDescriptor_struct { |
| 164 | QWORD Addr; |
| 165 | DWORD Len; |
| 166 | } ErrDescriptor_struct; |
| 167 | typedef struct _SGDescriptor_struct { |
| 168 | QWORD Addr; |
| 169 | DWORD Len; |
| 170 | DWORD Ext; |
| 171 | } SGDescriptor_struct; |
| 172 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | /* Command types */ |
| 174 | #define CMD_RWREQ 0x00 |
| 175 | #define CMD_IOCTL_PEND 0x01 |
| 176 | #define CMD_SCSI 0x03 |
| 177 | #define CMD_MSG_DONE 0x04 |
| 178 | #define CMD_MSG_TIMEOUT 0x05 |
Hannes Reinecke | b59e64d | 2009-07-02 22:02:06 +0200 | [diff] [blame] | 179 | #define CMD_MSG_STALE 0xff |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
Stephen M. Cameron | 1b7d0d2 | 2010-02-26 16:01:17 -0600 | [diff] [blame] | 181 | /* This structure needs to be divisible by COMMANDLIST_ALIGNMENT |
| 182 | * because low bits of the address are used to to indicate that |
| 183 | * whether the tag contains an index or an address. PAD_32 and |
| 184 | * PAD_64 can be adjusted independently as needed for 32-bit |
| 185 | * and 64-bits systems. |
Mike Miller | 33079b2 | 2005-09-13 01:25:22 -0700 | [diff] [blame] | 186 | */ |
Mike Miller | 5e21615 | 2010-06-02 12:58:06 -0700 | [diff] [blame] | 187 | #define COMMANDLIST_ALIGNMENT (32) |
Stephen M. Cameron | 58daa9c | 2010-02-26 16:01:12 -0600 | [diff] [blame] | 188 | #define IS_64_BIT ((sizeof(long) - 4)/4) |
| 189 | #define IS_32_BIT (!IS_64_BIT) |
Mike Miller | f3bcb14 | 2010-06-11 13:13:36 +0200 | [diff] [blame] | 190 | #define PAD_32 (0) |
Stephen M. Cameron | 58daa9c | 2010-02-26 16:01:12 -0600 | [diff] [blame] | 191 | #define PAD_64 (4) |
| 192 | #define PADSIZE (IS_32_BIT * PAD_32 + IS_64_BIT * PAD_64) |
Mike Miller | 5e21615 | 2010-06-02 12:58:06 -0700 | [diff] [blame] | 193 | #define DIRECT_LOOKUP_BIT 0x10 |
| 194 | #define DIRECT_LOOKUP_SHIFT 5 |
| 195 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | typedef struct _CommandList_struct { |
| 197 | CommandListHeader_struct Header; |
| 198 | RequestBlock_struct Request; |
| 199 | ErrDescriptor_struct ErrDesc; |
| 200 | SGDescriptor_struct SG[MAXSGENTRIES]; |
| 201 | /* information associated with the command */ |
| 202 | __u32 busaddr; /* physical address of this record */ |
| 203 | ErrorInfo_struct * err_info; /* pointer to the allocated mem */ |
| 204 | int ctlr; |
| 205 | int cmd_type; |
Mike Miller | 33079b2 | 2005-09-13 01:25:22 -0700 | [diff] [blame] | 206 | long cmdindex; |
Jens Axboe | e6e1ee9 | 2011-01-10 21:50:33 +0100 | [diff] [blame] | 207 | struct list_head list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | struct request * rq; |
| 209 | struct completion *waiting; |
| 210 | int retry_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | void * scsi_cmd; |
Mike Miller | 5e21615 | 2010-06-02 12:58:06 -0700 | [diff] [blame] | 212 | char pad[PADSIZE]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | } CommandList_struct; |
| 214 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 215 | /* Configuration Table Structure */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | typedef struct _HostWrite_struct { |
| 217 | DWORD TransportRequest; |
| 218 | DWORD Reserved; |
| 219 | DWORD CoalIntDelay; |
| 220 | DWORD CoalIntCount; |
| 221 | } HostWrite_struct; |
| 222 | |
| 223 | typedef struct _CfgTable_struct { |
| 224 | BYTE Signature[4]; |
| 225 | DWORD SpecValence; |
Mike Miller | 5e21615 | 2010-06-02 12:58:06 -0700 | [diff] [blame] | 226 | #define SIMPLE_MODE 0x02 |
| 227 | #define PERFORMANT_MODE 0x04 |
| 228 | #define MEMQ_MODE 0x08 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | DWORD TransportSupport; |
| 230 | DWORD TransportActive; |
| 231 | HostWrite_struct HostWrite; |
| 232 | DWORD CmdsOutMax; |
| 233 | DWORD BusTypes; |
Mike Miller | 5e21615 | 2010-06-02 12:58:06 -0700 | [diff] [blame] | 234 | DWORD TransMethodOffset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | BYTE ServerName[16]; |
| 236 | DWORD HeartBeat; |
| 237 | DWORD SCSI_Prefetch; |
Don Brace | 5c07a31 | 2009-11-12 12:50:01 -0600 | [diff] [blame] | 238 | DWORD MaxSGElements; |
| 239 | DWORD MaxLogicalUnits; |
| 240 | DWORD MaxPhysicalDrives; |
| 241 | DWORD MaxPhysicalDrivesPerLogicalUnit; |
Mike Miller | 5e21615 | 2010-06-02 12:58:06 -0700 | [diff] [blame] | 242 | DWORD MaxPerformantModeCommands; |
Stephen M. Cameron | a6528d0 | 2010-07-19 13:46:22 -0500 | [diff] [blame] | 243 | u8 reserved[0x78 - 0x58]; |
| 244 | u32 misc_fw_support; /* offset 0x78 */ |
| 245 | #define MISC_FW_DOORBELL_RESET (0x02) |
Stephen M. Cameron | 62710ae | 2011-05-03 14:53:00 -0500 | [diff] [blame] | 246 | u8 driver_version[32]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | } CfgTable_struct; |
Mike Miller | 5e21615 | 2010-06-02 12:58:06 -0700 | [diff] [blame] | 248 | |
| 249 | struct TransTable_struct { |
| 250 | u32 BlockFetch0; |
| 251 | u32 BlockFetch1; |
| 252 | u32 BlockFetch2; |
| 253 | u32 BlockFetch3; |
| 254 | u32 BlockFetch4; |
| 255 | u32 BlockFetch5; |
| 256 | u32 BlockFetch6; |
| 257 | u32 BlockFetch7; |
| 258 | u32 RepQSize; |
| 259 | u32 RepQCount; |
| 260 | u32 RepQCtrAddrLow32; |
| 261 | u32 RepQCtrAddrHigh32; |
| 262 | u32 RepQAddr0Low32; |
| 263 | u32 RepQAddr0High32; |
| 264 | }; |
| 265 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | #pragma pack() |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 267 | #endif /* CCISS_CMD_H */ |