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