Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef CCISS_CMD_H |
| 2 | #define CCISS_CMD_H |
| 3 | //########################################################################### |
| 4 | //DEFINES |
| 5 | //########################################################################### |
| 6 | #define CISS_VERSION "1.00" |
| 7 | |
| 8 | //general boundary defintions |
| 9 | #define SENSEINFOBYTES 32//note that this value may vary between host implementations |
| 10 | #define MAXSGENTRIES 31 |
| 11 | #define MAXREPLYQS 256 |
| 12 | |
| 13 | //Command Status value |
| 14 | #define CMD_SUCCESS 0x0000 |
| 15 | #define CMD_TARGET_STATUS 0x0001 |
| 16 | #define CMD_DATA_UNDERRUN 0x0002 |
| 17 | #define CMD_DATA_OVERRUN 0x0003 |
| 18 | #define CMD_INVALID 0x0004 |
| 19 | #define CMD_PROTOCOL_ERR 0x0005 |
| 20 | #define CMD_HARDWARE_ERR 0x0006 |
| 21 | #define CMD_CONNECTION_LOST 0x0007 |
| 22 | #define CMD_ABORTED 0x0008 |
| 23 | #define CMD_ABORT_FAILED 0x0009 |
| 24 | #define CMD_UNSOLICITED_ABORT 0x000A |
| 25 | #define CMD_TIMEOUT 0x000B |
| 26 | #define CMD_UNABORTABLE 0x000C |
| 27 | |
Mike Miller | 0a9279c | 2009-04-02 12:50:55 -0700 | [diff] [blame] | 28 | /* Unit Attentions ASC's as defined for the MSA2012sa */ |
| 29 | #define POWER_OR_RESET 0x29 |
| 30 | #define STATE_CHANGED 0x2a |
| 31 | #define UNIT_ATTENTION_CLEARED 0x2f |
| 32 | #define LUN_FAILED 0x3e |
| 33 | #define REPORT_LUNS_CHANGED 0x3f |
| 34 | |
| 35 | /* Unit Attentions ASCQ's as defined for the MSA2012sa */ |
| 36 | |
| 37 | /* These ASCQ's defined for ASC = POWER_OR_RESET */ |
| 38 | #define POWER_ON_RESET 0x00 |
| 39 | #define POWER_ON_REBOOT 0x01 |
| 40 | #define SCSI_BUS_RESET 0x02 |
| 41 | #define MSA_TARGET_RESET 0x03 |
| 42 | #define CONTROLLER_FAILOVER 0x04 |
| 43 | #define TRANSCEIVER_SE 0x05 |
| 44 | #define TRANSCEIVER_LVD 0x06 |
| 45 | |
| 46 | /* These ASCQ's defined for ASC = STATE_CHANGED */ |
| 47 | #define RESERVATION_PREEMPTED 0x03 |
| 48 | #define ASYM_ACCESS_CHANGED 0x06 |
| 49 | #define LUN_CAPACITY_CHANGED 0x09 |
| 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | //transfer direction |
| 52 | #define XFER_NONE 0x00 |
| 53 | #define XFER_WRITE 0x01 |
| 54 | #define XFER_READ 0x02 |
| 55 | #define XFER_RSVD 0x03 |
| 56 | |
| 57 | //task attribute |
| 58 | #define ATTR_UNTAGGED 0x00 |
| 59 | #define ATTR_SIMPLE 0x04 |
| 60 | #define ATTR_HEADOFQUEUE 0x05 |
| 61 | #define ATTR_ORDERED 0x06 |
| 62 | #define ATTR_ACA 0x07 |
| 63 | |
| 64 | //cdb type |
| 65 | #define TYPE_CMD 0x00 |
| 66 | #define TYPE_MSG 0x01 |
| 67 | |
| 68 | //config space register offsets |
| 69 | #define CFG_VENDORID 0x00 |
| 70 | #define CFG_DEVICEID 0x02 |
| 71 | #define CFG_I2OBAR 0x10 |
| 72 | #define CFG_MEM1BAR 0x14 |
| 73 | |
| 74 | //i2o space register offsets |
| 75 | #define I2O_IBDB_SET 0x20 |
| 76 | #define I2O_IBDB_CLEAR 0x70 |
| 77 | #define I2O_INT_STATUS 0x30 |
| 78 | #define I2O_INT_MASK 0x34 |
| 79 | #define I2O_IBPOST_Q 0x40 |
| 80 | #define I2O_OBPOST_Q 0x44 |
Mike Miller | f92e2f5 | 2006-12-06 20:35:04 -0800 | [diff] [blame] | 81 | #define I2O_DMA1_CFG 0x214 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
| 83 | //Configuration Table |
| 84 | #define CFGTBL_ChangeReq 0x00000001l |
| 85 | #define CFGTBL_AccCmds 0x00000001l |
| 86 | |
| 87 | #define CFGTBL_Trans_Simple 0x00000002l |
| 88 | |
| 89 | #define CFGTBL_BusType_Ultra2 0x00000001l |
| 90 | #define CFGTBL_BusType_Ultra3 0x00000002l |
| 91 | #define CFGTBL_BusType_Fibre1G 0x00000100l |
| 92 | #define CFGTBL_BusType_Fibre2G 0x00000200l |
| 93 | typedef struct _vals32 |
| 94 | { |
| 95 | __u32 lower; |
| 96 | __u32 upper; |
| 97 | } vals32; |
| 98 | |
| 99 | typedef union _u64bit |
| 100 | { |
| 101 | vals32 val32; |
| 102 | __u64 val; |
| 103 | } u64bit; |
| 104 | |
| 105 | // Type defs used in the following structs |
| 106 | #define BYTE __u8 |
| 107 | #define WORD __u16 |
| 108 | #define HWORD __u16 |
| 109 | #define DWORD __u32 |
| 110 | #define QWORD vals32 |
| 111 | |
| 112 | //########################################################################### |
| 113 | //STRUCTURES |
| 114 | //########################################################################### |
Mike Miller | 799202c | 2006-12-06 20:35:12 -0800 | [diff] [blame] | 115 | #define CISS_MAX_LUN 1024 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | #define CISS_MAX_PHYS_LUN 1024 |
| 117 | // SCSI-3 Cmmands |
| 118 | |
| 119 | #pragma pack(1) |
| 120 | |
| 121 | #define CISS_INQUIRY 0x12 |
| 122 | //Date returned |
| 123 | typedef struct _InquiryData_struct |
| 124 | { |
| 125 | BYTE data_byte[36]; |
| 126 | } InquiryData_struct; |
| 127 | |
| 128 | #define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */ |
| 129 | #define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */ |
| 130 | // Data returned |
| 131 | typedef struct _ReportLUNdata_struct |
| 132 | { |
| 133 | BYTE LUNListLength[4]; |
| 134 | DWORD reserved; |
| 135 | BYTE LUN[CISS_MAX_LUN][8]; |
| 136 | } ReportLunData_struct; |
| 137 | |
| 138 | #define CCISS_READ_CAPACITY 0x25 /* Read Capacity */ |
| 139 | typedef struct _ReadCapdata_struct |
| 140 | { |
| 141 | BYTE total_size[4]; // Total size in blocks |
| 142 | BYTE block_size[4]; // Size of blocks in bytes |
| 143 | } ReadCapdata_struct; |
| 144 | |
Mike Miller (OS Dev) | 00988a3 | 2006-09-30 23:27:23 -0700 | [diff] [blame] | 145 | #define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */ |
| 146 | |
| 147 | /* service action to differentiate a 16 byte read capacity from |
| 148 | other commands that use the 0x9e SCSI op code */ |
| 149 | |
| 150 | #define CCISS_READ_CAPACITY_16_SERVICE_ACT 0x10 |
| 151 | |
| 152 | typedef struct _ReadCapdata_struct_16 |
| 153 | { |
| 154 | BYTE total_size[8]; /* Total size in blocks */ |
| 155 | BYTE block_size[4]; /* Size of blocks in bytes */ |
| 156 | BYTE prot_en:1; /* protection enable bit */ |
| 157 | BYTE rto_en:1; /* reference tag own enable bit */ |
| 158 | BYTE reserved:6; /* reserved bits */ |
| 159 | BYTE reserved2[18]; /* reserved bytes per spec */ |
| 160 | } ReadCapdata_struct_16; |
| 161 | |
| 162 | /* Define the supported read/write commands for cciss based controllers */ |
| 163 | |
| 164 | #define CCISS_READ_10 0x28 /* Read(10) */ |
| 165 | #define CCISS_WRITE_10 0x2a /* Write(10) */ |
| 166 | #define CCISS_READ_16 0x88 /* Read(16) */ |
| 167 | #define CCISS_WRITE_16 0x8a /* Write(16) */ |
| 168 | |
| 169 | /* Define the CDB lengths supported by cciss based controllers */ |
| 170 | |
| 171 | #define CDB_LEN10 10 |
| 172 | #define CDB_LEN16 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
| 174 | // BMIC commands |
| 175 | #define BMIC_READ 0x26 |
| 176 | #define BMIC_WRITE 0x27 |
| 177 | #define BMIC_CACHE_FLUSH 0xc2 |
| 178 | #define CCISS_CACHE_FLUSH 0x01 //C2 was already being used by CCISS |
| 179 | |
| 180 | //Command List Structure |
| 181 | typedef union _SCSI3Addr_struct { |
| 182 | struct { |
| 183 | BYTE Dev; |
| 184 | BYTE Bus:6; |
| 185 | BYTE Mode:2; // b00 |
| 186 | } PeripDev; |
| 187 | struct { |
| 188 | BYTE DevLSB; |
| 189 | BYTE DevMSB:6; |
| 190 | BYTE Mode:2; // b01 |
| 191 | } LogDev; |
| 192 | struct { |
| 193 | BYTE Dev:5; |
| 194 | BYTE Bus:3; |
| 195 | BYTE Targ:6; |
| 196 | BYTE Mode:2; // b10 |
| 197 | } LogUnit; |
| 198 | } SCSI3Addr_struct; |
| 199 | |
| 200 | typedef struct _PhysDevAddr_struct { |
| 201 | DWORD TargetId:24; |
| 202 | DWORD Bus:6; |
| 203 | DWORD Mode:2; |
| 204 | SCSI3Addr_struct Target[2]; //2 level target device addr |
| 205 | } PhysDevAddr_struct; |
| 206 | |
| 207 | typedef struct _LogDevAddr_struct { |
| 208 | DWORD VolId:30; |
| 209 | DWORD Mode:2; |
| 210 | BYTE reserved[4]; |
| 211 | } LogDevAddr_struct; |
| 212 | |
| 213 | typedef union _LUNAddr_struct { |
| 214 | BYTE LunAddrBytes[8]; |
| 215 | SCSI3Addr_struct SCSI3Lun[4]; |
| 216 | PhysDevAddr_struct PhysDev; |
| 217 | LogDevAddr_struct LogDev; |
| 218 | } LUNAddr_struct; |
| 219 | |
scameron@beardog.cca.cpqcorp.net | b57695f | 2009-06-08 16:02:17 -0500 | [diff] [blame] | 220 | #define CTLR_LUNID "\0\0\0\0\0\0\0\0" |
| 221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | typedef struct _CommandListHeader_struct { |
| 223 | BYTE ReplyQueue; |
| 224 | BYTE SGList; |
| 225 | HWORD SGTotal; |
| 226 | QWORD Tag; |
| 227 | LUNAddr_struct LUN; |
| 228 | } CommandListHeader_struct; |
| 229 | typedef struct _RequestBlock_struct { |
| 230 | BYTE CDBLen; |
| 231 | struct { |
| 232 | BYTE Type:3; |
| 233 | BYTE Attribute:3; |
| 234 | BYTE Direction:2; |
| 235 | } Type; |
| 236 | HWORD Timeout; |
| 237 | BYTE CDB[16]; |
| 238 | } RequestBlock_struct; |
| 239 | typedef struct _ErrDescriptor_struct { |
| 240 | QWORD Addr; |
| 241 | DWORD Len; |
| 242 | } ErrDescriptor_struct; |
| 243 | typedef struct _SGDescriptor_struct { |
| 244 | QWORD Addr; |
| 245 | DWORD Len; |
| 246 | DWORD Ext; |
| 247 | } SGDescriptor_struct; |
| 248 | |
| 249 | typedef union _MoreErrInfo_struct{ |
| 250 | struct { |
| 251 | BYTE Reserved[3]; |
| 252 | BYTE Type; |
| 253 | DWORD ErrorInfo; |
| 254 | }Common_Info; |
| 255 | struct{ |
| 256 | BYTE Reserved[2]; |
| 257 | BYTE offense_size;//size of offending entry |
| 258 | BYTE offense_num; //byte # of offense 0-base |
| 259 | DWORD offense_value; |
| 260 | }Invalid_Cmd; |
| 261 | }MoreErrInfo_struct; |
| 262 | typedef struct _ErrorInfo_struct { |
| 263 | BYTE ScsiStatus; |
| 264 | BYTE SenseLen; |
| 265 | HWORD CommandStatus; |
| 266 | DWORD ResidualCnt; |
| 267 | MoreErrInfo_struct MoreErrInfo; |
| 268 | BYTE SenseInfo[SENSEINFOBYTES]; |
| 269 | } ErrorInfo_struct; |
| 270 | |
| 271 | /* Command types */ |
| 272 | #define CMD_RWREQ 0x00 |
| 273 | #define CMD_IOCTL_PEND 0x01 |
| 274 | #define CMD_SCSI 0x03 |
| 275 | #define CMD_MSG_DONE 0x04 |
| 276 | #define CMD_MSG_TIMEOUT 0x05 |
| 277 | |
Mike Miller | 33079b2 | 2005-09-13 01:25:22 -0700 | [diff] [blame] | 278 | /* This structure needs to be divisible by 8 for new |
| 279 | * indexing method. |
| 280 | */ |
| 281 | #define PADSIZE (sizeof(long) - 4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | typedef struct _CommandList_struct { |
| 283 | CommandListHeader_struct Header; |
| 284 | RequestBlock_struct Request; |
| 285 | ErrDescriptor_struct ErrDesc; |
| 286 | SGDescriptor_struct SG[MAXSGENTRIES]; |
| 287 | /* information associated with the command */ |
| 288 | __u32 busaddr; /* physical address of this record */ |
| 289 | ErrorInfo_struct * err_info; /* pointer to the allocated mem */ |
| 290 | int ctlr; |
| 291 | int cmd_type; |
Mike Miller | 33079b2 | 2005-09-13 01:25:22 -0700 | [diff] [blame] | 292 | long cmdindex; |
Jens Axboe | 8a3173d | 2008-11-20 09:46:09 +0100 | [diff] [blame] | 293 | struct hlist_node list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | struct request * rq; |
| 295 | struct completion *waiting; |
| 296 | int retry_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | void * scsi_cmd; |
Mike Miller | 33079b2 | 2005-09-13 01:25:22 -0700 | [diff] [blame] | 298 | char pad[PADSIZE]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | } CommandList_struct; |
| 300 | |
| 301 | //Configuration Table Structure |
| 302 | typedef struct _HostWrite_struct { |
| 303 | DWORD TransportRequest; |
| 304 | DWORD Reserved; |
| 305 | DWORD CoalIntDelay; |
| 306 | DWORD CoalIntCount; |
| 307 | } HostWrite_struct; |
| 308 | |
| 309 | typedef struct _CfgTable_struct { |
| 310 | BYTE Signature[4]; |
| 311 | DWORD SpecValence; |
| 312 | DWORD TransportSupport; |
| 313 | DWORD TransportActive; |
| 314 | HostWrite_struct HostWrite; |
| 315 | DWORD CmdsOutMax; |
| 316 | DWORD BusTypes; |
| 317 | DWORD Reserved; |
| 318 | BYTE ServerName[16]; |
| 319 | DWORD HeartBeat; |
| 320 | DWORD SCSI_Prefetch; |
| 321 | } CfgTable_struct; |
| 322 | #pragma pack() |
| 323 | #endif // CCISS_CMD_H |