Linux 2.6.33-rc6
[cris-mirror.git] / drivers / block / cciss_cmd.h
blob6afa700890fffc5d01cf81c83151e487b5c92e1f
1 #ifndef CCISS_CMD_H
2 #define CCISS_CMD_H
3 //###########################################################################
4 //DEFINES
5 //###########################################################################
6 #define CISS_VERSION "1.00"
8 //general boundary definitions
9 #define SENSEINFOBYTES 32//note that this value may vary between host implementations
10 #define MAXSGENTRIES 32
11 #define CCISS_SG_CHAIN 0x80000000
12 #define MAXREPLYQS 256
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
29 /* 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
36 /* Unit Attentions ASCQ's as defined for the MSA2012sa */
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
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
52 //transfer direction
53 #define XFER_NONE 0x00
54 #define XFER_WRITE 0x01
55 #define XFER_READ 0x02
56 #define XFER_RSVD 0x03
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
65 //cdb type
66 #define TYPE_CMD 0x00
67 #define TYPE_MSG 0x01
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
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
82 #define I2O_DMA1_CFG 0x214
84 //Configuration Table
85 #define CFGTBL_ChangeReq 0x00000001l
86 #define CFGTBL_AccCmds 0x00000001l
88 #define CFGTBL_Trans_Simple 0x00000002l
90 #define CFGTBL_BusType_Ultra2 0x00000001l
91 #define CFGTBL_BusType_Ultra3 0x00000002l
92 #define CFGTBL_BusType_Fibre1G 0x00000100l
93 #define CFGTBL_BusType_Fibre2G 0x00000200l
94 typedef struct _vals32
96 __u32 lower;
97 __u32 upper;
98 } vals32;
100 typedef union _u64bit
102 vals32 val32;
103 __u64 val;
104 } u64bit;
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
113 //###########################################################################
114 //STRUCTURES
115 //###########################################################################
116 #define CISS_MAX_LUN 1024
117 #define CISS_MAX_PHYS_LUN 1024
118 // SCSI-3 Cmmands
120 #pragma pack(1)
122 #define CISS_INQUIRY 0x12
123 //Date returned
124 typedef struct _InquiryData_struct
126 BYTE data_byte[36];
127 } InquiryData_struct;
129 #define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */
130 #define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */
131 // Data returned
132 typedef struct _ReportLUNdata_struct
134 BYTE LUNListLength[4];
135 DWORD reserved;
136 BYTE LUN[CISS_MAX_LUN][8];
137 } ReportLunData_struct;
139 #define CCISS_READ_CAPACITY 0x25 /* Read Capacity */
140 typedef struct _ReadCapdata_struct
142 BYTE total_size[4]; // Total size in blocks
143 BYTE block_size[4]; // Size of blocks in bytes
144 } ReadCapdata_struct;
146 #define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */
148 /* service action to differentiate a 16 byte read capacity from
149 other commands that use the 0x9e SCSI op code */
151 #define CCISS_READ_CAPACITY_16_SERVICE_ACT 0x10
153 typedef struct _ReadCapdata_struct_16
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;
163 /* Define the supported read/write commands for cciss based controllers */
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) */
170 /* Define the CDB lengths supported by cciss based controllers */
172 #define CDB_LEN10 10
173 #define CDB_LEN16 16
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
181 //Command List Structure
182 typedef 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;
201 typedef 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;
208 typedef struct _LogDevAddr_struct {
209 DWORD VolId:30;
210 DWORD Mode:2;
211 BYTE reserved[4];
212 } LogDevAddr_struct;
214 typedef union _LUNAddr_struct {
215 BYTE LunAddrBytes[8];
216 SCSI3Addr_struct SCSI3Lun[4];
217 PhysDevAddr_struct PhysDev;
218 LogDevAddr_struct LogDev;
219 } LUNAddr_struct;
221 #define CTLR_LUNID "\0\0\0\0\0\0\0\0"
223 typedef struct _CommandListHeader_struct {
224 BYTE ReplyQueue;
225 BYTE SGList;
226 HWORD SGTotal;
227 QWORD Tag;
228 LUNAddr_struct LUN;
229 } CommandListHeader_struct;
230 typedef 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;
240 typedef struct _ErrDescriptor_struct {
241 QWORD Addr;
242 DWORD Len;
243 } ErrDescriptor_struct;
244 typedef struct _SGDescriptor_struct {
245 QWORD Addr;
246 DWORD Len;
247 DWORD Ext;
248 } SGDescriptor_struct;
250 typedef 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;
263 typedef 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;
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
278 #define CMD_MSG_STALE 0xff
280 /* This structure needs to be divisible by 8 for new
281 * indexing method.
283 #define PADSIZE (sizeof(long) - 4)
284 typedef 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;
294 long cmdindex;
295 struct hlist_node list;
296 struct request * rq;
297 struct completion *waiting;
298 int retry_count;
299 void * scsi_cmd;
300 char pad[PADSIZE];
301 } CommandList_struct;
303 //Configuration Table Structure
304 typedef struct _HostWrite_struct {
305 DWORD TransportRequest;
306 DWORD Reserved;
307 DWORD CoalIntDelay;
308 DWORD CoalIntCount;
309 } HostWrite_struct;
311 typedef 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;
323 DWORD MaxSGElements;
324 DWORD MaxLogicalUnits;
325 DWORD MaxPhysicalDrives;
326 DWORD MaxPhysicalDrivesPerLogicalUnit;
327 } CfgTable_struct;
328 #pragma pack()
329 #endif // CCISS_CMD_H