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 |
| 55 | |
| 56 | #define CFGTBL_Trans_Simple 0x00000002l |
| 57 | |
| 58 | #define CFGTBL_BusType_Ultra2 0x00000001l |
| 59 | #define CFGTBL_BusType_Ultra3 0x00000002l |
| 60 | #define CFGTBL_BusType_Fibre1G 0x00000100l |
| 61 | #define CFGTBL_BusType_Fibre2G 0x00000200l |
| 62 | typedef struct _vals32 |
| 63 | { |
| 64 | __u32 lower; |
| 65 | __u32 upper; |
| 66 | } vals32; |
| 67 | |
| 68 | typedef union _u64bit |
| 69 | { |
| 70 | vals32 val32; |
| 71 | __u64 val; |
| 72 | } u64bit; |
| 73 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 74 | /* Type defs used in the following structs */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | #define QWORD vals32 |
| 76 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 77 | /* STRUCTURES */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | #define CISS_MAX_PHYS_LUN 1024 |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 79 | /* SCSI-3 Cmmands */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
| 81 | #pragma pack(1) |
| 82 | |
| 83 | #define CISS_INQUIRY 0x12 |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 84 | /* Date returned */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | typedef struct _InquiryData_struct |
| 86 | { |
| 87 | BYTE data_byte[36]; |
| 88 | } InquiryData_struct; |
| 89 | |
| 90 | #define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */ |
| 91 | #define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */ |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 92 | /* Data returned */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | typedef struct _ReportLUNdata_struct |
| 94 | { |
| 95 | BYTE LUNListLength[4]; |
| 96 | DWORD reserved; |
| 97 | BYTE LUN[CISS_MAX_LUN][8]; |
| 98 | } ReportLunData_struct; |
| 99 | |
| 100 | #define CCISS_READ_CAPACITY 0x25 /* Read Capacity */ |
| 101 | typedef struct _ReadCapdata_struct |
| 102 | { |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 103 | BYTE total_size[4]; /* Total size in blocks */ |
| 104 | BYTE block_size[4]; /* Size of blocks in bytes */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | } ReadCapdata_struct; |
| 106 | |
Mike Miller (OS Dev) | 00988a3 | 2006-09-30 23:27:23 -0700 | [diff] [blame] | 107 | #define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */ |
| 108 | |
| 109 | /* service action to differentiate a 16 byte read capacity from |
| 110 | other commands that use the 0x9e SCSI op code */ |
| 111 | |
| 112 | #define CCISS_READ_CAPACITY_16_SERVICE_ACT 0x10 |
| 113 | |
| 114 | typedef struct _ReadCapdata_struct_16 |
| 115 | { |
| 116 | BYTE total_size[8]; /* Total size in blocks */ |
| 117 | BYTE block_size[4]; /* Size of blocks in bytes */ |
| 118 | BYTE prot_en:1; /* protection enable bit */ |
| 119 | BYTE rto_en:1; /* reference tag own enable bit */ |
| 120 | BYTE reserved:6; /* reserved bits */ |
| 121 | BYTE reserved2[18]; /* reserved bytes per spec */ |
| 122 | } ReadCapdata_struct_16; |
| 123 | |
| 124 | /* Define the supported read/write commands for cciss based controllers */ |
| 125 | |
| 126 | #define CCISS_READ_10 0x28 /* Read(10) */ |
| 127 | #define CCISS_WRITE_10 0x2a /* Write(10) */ |
| 128 | #define CCISS_READ_16 0x88 /* Read(16) */ |
| 129 | #define CCISS_WRITE_16 0x8a /* Write(16) */ |
| 130 | |
| 131 | /* Define the CDB lengths supported by cciss based controllers */ |
| 132 | |
| 133 | #define CDB_LEN10 10 |
| 134 | #define CDB_LEN16 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 136 | /* BMIC commands */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | #define BMIC_READ 0x26 |
| 138 | #define BMIC_WRITE 0x27 |
| 139 | #define BMIC_CACHE_FLUSH 0xc2 |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 140 | #define CCISS_CACHE_FLUSH 0x01 /* C2 was already being used by CCISS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 142 | /* Command List Structure */ |
scameron@beardog.cca.cpqcorp.net | b57695f | 2009-06-08 16:02:17 -0500 | [diff] [blame] | 143 | #define CTLR_LUNID "\0\0\0\0\0\0\0\0" |
| 144 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | typedef struct _CommandListHeader_struct { |
| 146 | BYTE ReplyQueue; |
| 147 | BYTE SGList; |
| 148 | HWORD SGTotal; |
| 149 | QWORD Tag; |
| 150 | LUNAddr_struct LUN; |
| 151 | } CommandListHeader_struct; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | typedef struct _ErrDescriptor_struct { |
| 153 | QWORD Addr; |
| 154 | DWORD Len; |
| 155 | } ErrDescriptor_struct; |
| 156 | typedef struct _SGDescriptor_struct { |
| 157 | QWORD Addr; |
| 158 | DWORD Len; |
| 159 | DWORD Ext; |
| 160 | } SGDescriptor_struct; |
| 161 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | /* Command types */ |
| 163 | #define CMD_RWREQ 0x00 |
| 164 | #define CMD_IOCTL_PEND 0x01 |
| 165 | #define CMD_SCSI 0x03 |
| 166 | #define CMD_MSG_DONE 0x04 |
| 167 | #define CMD_MSG_TIMEOUT 0x05 |
Hannes Reinecke | b59e64d | 2009-07-02 22:02:06 +0200 | [diff] [blame] | 168 | #define CMD_MSG_STALE 0xff |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | |
Stephen M. Cameron | 1b7d0d2 | 2010-02-26 16:01:17 -0600 | [diff] [blame^] | 170 | /* This structure needs to be divisible by COMMANDLIST_ALIGNMENT |
| 171 | * because low bits of the address are used to to indicate that |
| 172 | * whether the tag contains an index or an address. PAD_32 and |
| 173 | * PAD_64 can be adjusted independently as needed for 32-bit |
| 174 | * and 64-bits systems. |
Mike Miller | 33079b2 | 2005-09-13 01:25:22 -0700 | [diff] [blame] | 175 | */ |
Stephen M. Cameron | 1b7d0d2 | 2010-02-26 16:01:17 -0600 | [diff] [blame^] | 176 | #define COMMANDLIST_ALIGNMENT (8) |
Stephen M. Cameron | 58daa9c | 2010-02-26 16:01:12 -0600 | [diff] [blame] | 177 | #define IS_64_BIT ((sizeof(long) - 4)/4) |
| 178 | #define IS_32_BIT (!IS_64_BIT) |
| 179 | #define PAD_32 (0) |
| 180 | #define PAD_64 (4) |
| 181 | #define PADSIZE (IS_32_BIT * PAD_32 + IS_64_BIT * PAD_64) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | typedef struct _CommandList_struct { |
| 183 | CommandListHeader_struct Header; |
| 184 | RequestBlock_struct Request; |
| 185 | ErrDescriptor_struct ErrDesc; |
| 186 | SGDescriptor_struct SG[MAXSGENTRIES]; |
| 187 | /* information associated with the command */ |
| 188 | __u32 busaddr; /* physical address of this record */ |
| 189 | ErrorInfo_struct * err_info; /* pointer to the allocated mem */ |
| 190 | int ctlr; |
| 191 | int cmd_type; |
Mike Miller | 33079b2 | 2005-09-13 01:25:22 -0700 | [diff] [blame] | 192 | long cmdindex; |
Jens Axboe | 8a3173d | 2008-11-20 09:46:09 +0100 | [diff] [blame] | 193 | struct hlist_node list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | struct request * rq; |
| 195 | struct completion *waiting; |
| 196 | int retry_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | void * scsi_cmd; |
Mike Miller | 33079b2 | 2005-09-13 01:25:22 -0700 | [diff] [blame] | 198 | char pad[PADSIZE]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | } CommandList_struct; |
| 200 | |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 201 | /* Configuration Table Structure */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | typedef struct _HostWrite_struct { |
| 203 | DWORD TransportRequest; |
| 204 | DWORD Reserved; |
| 205 | DWORD CoalIntDelay; |
| 206 | DWORD CoalIntCount; |
| 207 | } HostWrite_struct; |
| 208 | |
| 209 | typedef struct _CfgTable_struct { |
| 210 | BYTE Signature[4]; |
| 211 | DWORD SpecValence; |
| 212 | DWORD TransportSupport; |
| 213 | DWORD TransportActive; |
| 214 | HostWrite_struct HostWrite; |
| 215 | DWORD CmdsOutMax; |
| 216 | DWORD BusTypes; |
| 217 | DWORD Reserved; |
| 218 | BYTE ServerName[16]; |
| 219 | DWORD HeartBeat; |
| 220 | DWORD SCSI_Prefetch; |
Don Brace | 5c07a31 | 2009-11-12 12:50:01 -0600 | [diff] [blame] | 221 | DWORD MaxSGElements; |
| 222 | DWORD MaxLogicalUnits; |
| 223 | DWORD MaxPhysicalDrives; |
| 224 | DWORD MaxPhysicalDrivesPerLogicalUnit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | } CfgTable_struct; |
| 226 | #pragma pack() |
dann frazier | b028461 | 2010-02-17 16:53:31 -0700 | [diff] [blame] | 227 | #endif /* CCISS_CMD_H */ |