blob: 277422b7e060e457657d20896ae31e63d17433a0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef CCISS_CMD_H
2#define CCISS_CMD_H
dann frazierb0284612010-02-17 16:53:31 -07003/* DEFINES */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#define CISS_VERSION "1.00"
5
dann frazierb0284612010-02-17 16:53:31 -07006/* general boundary definitions */
7#define SENSEINFOBYTES 32 /* note that this value may vary
8 between host implementations */
Don Brace5c07a312009-11-12 12:50:01 -06009#define MAXSGENTRIES 32
10#define CCISS_SG_CHAIN 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#define MAXREPLYQS 256
12
dann frazierb0284612010-02-17 16:53:31 -070013/* Command Status value */
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#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 Miller0a9279c2009-04-02 12:50:55 -070028/* 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
dann frazierb0284612010-02-17 16:53:31 -070051/* transfer direction */
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#define XFER_NONE 0x00
53#define XFER_WRITE 0x01
54#define XFER_READ 0x02
55#define XFER_RSVD 0x03
56
dann frazierb0284612010-02-17 16:53:31 -070057/* task attribute */
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#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
dann frazierb0284612010-02-17 16:53:31 -070064/* cdb type */
Linus Torvalds1da177e2005-04-16 15:20:36 -070065#define TYPE_CMD 0x00
66#define TYPE_MSG 0x01
67
dann frazierb0284612010-02-17 16:53:31 -070068/* config space register offsets */
Linus Torvalds1da177e2005-04-16 15:20:36 -070069#define CFG_VENDORID 0x00
70#define CFG_DEVICEID 0x02
71#define CFG_I2OBAR 0x10
72#define CFG_MEM1BAR 0x14
73
dann frazierb0284612010-02-17 16:53:31 -070074/* i2o space register offsets */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#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 Millerf92e2f52006-12-06 20:35:04 -080081#define I2O_DMA1_CFG 0x214
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
dann frazierb0284612010-02-17 16:53:31 -070083/* Configuration Table */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084#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
93typedef struct _vals32
94{
95 __u32 lower;
96 __u32 upper;
97} vals32;
98
99typedef union _u64bit
100{
101 vals32 val32;
102 __u64 val;
103} u64bit;
104
dann frazierb0284612010-02-17 16:53:31 -0700105/* Type defs used in the following structs */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106#define BYTE __u8
107#define WORD __u16
108#define HWORD __u16
109#define DWORD __u32
110#define QWORD vals32
111
dann frazierb0284612010-02-17 16:53:31 -0700112/* STRUCTURES */
Mike Miller799202c2006-12-06 20:35:12 -0800113#define CISS_MAX_LUN 1024
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114#define CISS_MAX_PHYS_LUN 1024
dann frazierb0284612010-02-17 16:53:31 -0700115/* SCSI-3 Cmmands */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
117#pragma pack(1)
118
119#define CISS_INQUIRY 0x12
dann frazierb0284612010-02-17 16:53:31 -0700120/* Date returned */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121typedef struct _InquiryData_struct
122{
123 BYTE data_byte[36];
124} InquiryData_struct;
125
126#define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */
127#define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */
dann frazierb0284612010-02-17 16:53:31 -0700128/* Data returned */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129typedef struct _ReportLUNdata_struct
130{
131 BYTE LUNListLength[4];
132 DWORD reserved;
133 BYTE LUN[CISS_MAX_LUN][8];
134} ReportLunData_struct;
135
136#define CCISS_READ_CAPACITY 0x25 /* Read Capacity */
137typedef struct _ReadCapdata_struct
138{
dann frazierb0284612010-02-17 16:53:31 -0700139 BYTE total_size[4]; /* Total size in blocks */
140 BYTE block_size[4]; /* Size of blocks in bytes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141} ReadCapdata_struct;
142
Mike Miller (OS Dev)00988a32006-09-30 23:27:23 -0700143#define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */
144
145/* service action to differentiate a 16 byte read capacity from
146 other commands that use the 0x9e SCSI op code */
147
148#define CCISS_READ_CAPACITY_16_SERVICE_ACT 0x10
149
150typedef struct _ReadCapdata_struct_16
151{
152 BYTE total_size[8]; /* Total size in blocks */
153 BYTE block_size[4]; /* Size of blocks in bytes */
154 BYTE prot_en:1; /* protection enable bit */
155 BYTE rto_en:1; /* reference tag own enable bit */
156 BYTE reserved:6; /* reserved bits */
157 BYTE reserved2[18]; /* reserved bytes per spec */
158} ReadCapdata_struct_16;
159
160/* Define the supported read/write commands for cciss based controllers */
161
162#define CCISS_READ_10 0x28 /* Read(10) */
163#define CCISS_WRITE_10 0x2a /* Write(10) */
164#define CCISS_READ_16 0x88 /* Read(16) */
165#define CCISS_WRITE_16 0x8a /* Write(16) */
166
167/* Define the CDB lengths supported by cciss based controllers */
168
169#define CDB_LEN10 10
170#define CDB_LEN16 16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
dann frazierb0284612010-02-17 16:53:31 -0700172/* BMIC commands */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173#define BMIC_READ 0x26
174#define BMIC_WRITE 0x27
175#define BMIC_CACHE_FLUSH 0xc2
dann frazierb0284612010-02-17 16:53:31 -0700176#define CCISS_CACHE_FLUSH 0x01 /* C2 was already being used by CCISS */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
dann frazierb0284612010-02-17 16:53:31 -0700178/* Command List Structure */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179typedef union _SCSI3Addr_struct {
180 struct {
181 BYTE Dev;
182 BYTE Bus:6;
dann frazierb0284612010-02-17 16:53:31 -0700183 BYTE Mode:2; /* b00 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 } PeripDev;
185 struct {
186 BYTE DevLSB;
187 BYTE DevMSB:6;
dann frazierb0284612010-02-17 16:53:31 -0700188 BYTE Mode:2; /* b01 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 } LogDev;
190 struct {
191 BYTE Dev:5;
192 BYTE Bus:3;
193 BYTE Targ:6;
dann frazierb0284612010-02-17 16:53:31 -0700194 BYTE Mode:2; /* b10 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 } LogUnit;
196} SCSI3Addr_struct;
197
198typedef struct _PhysDevAddr_struct {
199 DWORD TargetId:24;
200 DWORD Bus:6;
201 DWORD Mode:2;
dann frazierb0284612010-02-17 16:53:31 -0700202 SCSI3Addr_struct Target[2]; /* 2 level target device addr */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203} PhysDevAddr_struct;
204
205typedef struct _LogDevAddr_struct {
206 DWORD VolId:30;
207 DWORD Mode:2;
208 BYTE reserved[4];
209} LogDevAddr_struct;
210
211typedef union _LUNAddr_struct {
212 BYTE LunAddrBytes[8];
213 SCSI3Addr_struct SCSI3Lun[4];
214 PhysDevAddr_struct PhysDev;
215 LogDevAddr_struct LogDev;
216} LUNAddr_struct;
217
scameron@beardog.cca.cpqcorp.netb57695f2009-06-08 16:02:17 -0500218#define CTLR_LUNID "\0\0\0\0\0\0\0\0"
219
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220typedef struct _CommandListHeader_struct {
221 BYTE ReplyQueue;
222 BYTE SGList;
223 HWORD SGTotal;
224 QWORD Tag;
225 LUNAddr_struct LUN;
226} CommandListHeader_struct;
227typedef struct _RequestBlock_struct {
228 BYTE CDBLen;
229 struct {
230 BYTE Type:3;
231 BYTE Attribute:3;
232 BYTE Direction:2;
233 } Type;
234 HWORD Timeout;
235 BYTE CDB[16];
236} RequestBlock_struct;
237typedef struct _ErrDescriptor_struct {
238 QWORD Addr;
239 DWORD Len;
240} ErrDescriptor_struct;
241typedef struct _SGDescriptor_struct {
242 QWORD Addr;
243 DWORD Len;
244 DWORD Ext;
245} SGDescriptor_struct;
246
247typedef union _MoreErrInfo_struct{
248 struct {
249 BYTE Reserved[3];
250 BYTE Type;
251 DWORD ErrorInfo;
252 }Common_Info;
253 struct{
254 BYTE Reserved[2];
dann frazierb0284612010-02-17 16:53:31 -0700255 BYTE offense_size; /* size of offending entry */
256 BYTE offense_num; /* byte # of offense 0-base */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 DWORD offense_value;
258 }Invalid_Cmd;
259}MoreErrInfo_struct;
260typedef struct _ErrorInfo_struct {
261 BYTE ScsiStatus;
262 BYTE SenseLen;
263 HWORD CommandStatus;
264 DWORD ResidualCnt;
265 MoreErrInfo_struct MoreErrInfo;
266 BYTE SenseInfo[SENSEINFOBYTES];
267} ErrorInfo_struct;
268
269/* Command types */
270#define CMD_RWREQ 0x00
271#define CMD_IOCTL_PEND 0x01
272#define CMD_SCSI 0x03
273#define CMD_MSG_DONE 0x04
274#define CMD_MSG_TIMEOUT 0x05
Hannes Reineckeb59e64d2009-07-02 22:02:06 +0200275#define CMD_MSG_STALE 0xff
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
Mike Miller33079b22005-09-13 01:25:22 -0700277/* This structure needs to be divisible by 8 for new
278 * indexing method.
279 */
280#define PADSIZE (sizeof(long) - 4)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281typedef struct _CommandList_struct {
282 CommandListHeader_struct Header;
283 RequestBlock_struct Request;
284 ErrDescriptor_struct ErrDesc;
285 SGDescriptor_struct SG[MAXSGENTRIES];
286 /* information associated with the command */
287 __u32 busaddr; /* physical address of this record */
288 ErrorInfo_struct * err_info; /* pointer to the allocated mem */
289 int ctlr;
290 int cmd_type;
Mike Miller33079b22005-09-13 01:25:22 -0700291 long cmdindex;
Jens Axboe8a3173d2008-11-20 09:46:09 +0100292 struct hlist_node list;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 struct request * rq;
294 struct completion *waiting;
295 int retry_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 void * scsi_cmd;
Mike Miller33079b22005-09-13 01:25:22 -0700297 char pad[PADSIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298} CommandList_struct;
299
dann frazierb0284612010-02-17 16:53:31 -0700300/* Configuration Table Structure */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301typedef struct _HostWrite_struct {
302 DWORD TransportRequest;
303 DWORD Reserved;
304 DWORD CoalIntDelay;
305 DWORD CoalIntCount;
306} HostWrite_struct;
307
308typedef struct _CfgTable_struct {
309 BYTE Signature[4];
310 DWORD SpecValence;
311 DWORD TransportSupport;
312 DWORD TransportActive;
313 HostWrite_struct HostWrite;
314 DWORD CmdsOutMax;
315 DWORD BusTypes;
316 DWORD Reserved;
317 BYTE ServerName[16];
318 DWORD HeartBeat;
319 DWORD SCSI_Prefetch;
Don Brace5c07a312009-11-12 12:50:01 -0600320 DWORD MaxSGElements;
321 DWORD MaxLogicalUnits;
322 DWORD MaxPhysicalDrives;
323 DWORD MaxPhysicalDrivesPerLogicalUnit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324} CfgTable_struct;
325#pragma pack()
dann frazierb0284612010-02-17 16:53:31 -0700326#endif /* CCISS_CMD_H */