blob: 43bf5593b59bf6ed1da79abbbba46a0fea499d44 [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
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
28//transfer direction
29#define XFER_NONE 0x00
30#define XFER_WRITE 0x01
31#define XFER_READ 0x02
32#define XFER_RSVD 0x03
33
34//task attribute
35#define ATTR_UNTAGGED 0x00
36#define ATTR_SIMPLE 0x04
37#define ATTR_HEADOFQUEUE 0x05
38#define ATTR_ORDERED 0x06
39#define ATTR_ACA 0x07
40
41//cdb type
42#define TYPE_CMD 0x00
43#define TYPE_MSG 0x01
44
45//config space register offsets
46#define CFG_VENDORID 0x00
47#define CFG_DEVICEID 0x02
48#define CFG_I2OBAR 0x10
49#define CFG_MEM1BAR 0x14
50
51//i2o space register offsets
52#define I2O_IBDB_SET 0x20
53#define I2O_IBDB_CLEAR 0x70
54#define I2O_INT_STATUS 0x30
55#define I2O_INT_MASK 0x34
56#define I2O_IBPOST_Q 0x40
57#define I2O_OBPOST_Q 0x44
Mike Millerf92e2f52006-12-06 20:35:04 -080058#define I2O_DMA1_CFG 0x214
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60//Configuration Table
61#define CFGTBL_ChangeReq 0x00000001l
62#define CFGTBL_AccCmds 0x00000001l
63
64#define CFGTBL_Trans_Simple 0x00000002l
65
66#define CFGTBL_BusType_Ultra2 0x00000001l
67#define CFGTBL_BusType_Ultra3 0x00000002l
68#define CFGTBL_BusType_Fibre1G 0x00000100l
69#define CFGTBL_BusType_Fibre2G 0x00000200l
70typedef struct _vals32
71{
72 __u32 lower;
73 __u32 upper;
74} vals32;
75
76typedef union _u64bit
77{
78 vals32 val32;
79 __u64 val;
80} u64bit;
81
82// Type defs used in the following structs
83#define BYTE __u8
84#define WORD __u16
85#define HWORD __u16
86#define DWORD __u32
87#define QWORD vals32
88
89//###########################################################################
90//STRUCTURES
91//###########################################################################
Mike Miller799202c2006-12-06 20:35:12 -080092#define CISS_MAX_LUN 1024
Linus Torvalds1da177e2005-04-16 15:20:36 -070093#define CISS_MAX_PHYS_LUN 1024
94// SCSI-3 Cmmands
95
96#pragma pack(1)
97
98#define CISS_INQUIRY 0x12
99//Date returned
100typedef struct _InquiryData_struct
101{
102 BYTE data_byte[36];
103} InquiryData_struct;
104
105#define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */
106#define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */
107// Data returned
108typedef struct _ReportLUNdata_struct
109{
110 BYTE LUNListLength[4];
111 DWORD reserved;
112 BYTE LUN[CISS_MAX_LUN][8];
113} ReportLunData_struct;
114
115#define CCISS_READ_CAPACITY 0x25 /* Read Capacity */
116typedef struct _ReadCapdata_struct
117{
118 BYTE total_size[4]; // Total size in blocks
119 BYTE block_size[4]; // Size of blocks in bytes
120} ReadCapdata_struct;
121
Mike Miller (OS Dev)00988a32006-09-30 23:27:23 -0700122#define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */
123
124/* service action to differentiate a 16 byte read capacity from
125 other commands that use the 0x9e SCSI op code */
126
127#define CCISS_READ_CAPACITY_16_SERVICE_ACT 0x10
128
129typedef struct _ReadCapdata_struct_16
130{
131 BYTE total_size[8]; /* Total size in blocks */
132 BYTE block_size[4]; /* Size of blocks in bytes */
133 BYTE prot_en:1; /* protection enable bit */
134 BYTE rto_en:1; /* reference tag own enable bit */
135 BYTE reserved:6; /* reserved bits */
136 BYTE reserved2[18]; /* reserved bytes per spec */
137} ReadCapdata_struct_16;
138
139/* Define the supported read/write commands for cciss based controllers */
140
141#define CCISS_READ_10 0x28 /* Read(10) */
142#define CCISS_WRITE_10 0x2a /* Write(10) */
143#define CCISS_READ_16 0x88 /* Read(16) */
144#define CCISS_WRITE_16 0x8a /* Write(16) */
145
146/* Define the CDB lengths supported by cciss based controllers */
147
148#define CDB_LEN10 10
149#define CDB_LEN16 16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
151// BMIC commands
152#define BMIC_READ 0x26
153#define BMIC_WRITE 0x27
154#define BMIC_CACHE_FLUSH 0xc2
155#define CCISS_CACHE_FLUSH 0x01 //C2 was already being used by CCISS
156
157//Command List Structure
158typedef union _SCSI3Addr_struct {
159 struct {
160 BYTE Dev;
161 BYTE Bus:6;
162 BYTE Mode:2; // b00
163 } PeripDev;
164 struct {
165 BYTE DevLSB;
166 BYTE DevMSB:6;
167 BYTE Mode:2; // b01
168 } LogDev;
169 struct {
170 BYTE Dev:5;
171 BYTE Bus:3;
172 BYTE Targ:6;
173 BYTE Mode:2; // b10
174 } LogUnit;
175} SCSI3Addr_struct;
176
177typedef struct _PhysDevAddr_struct {
178 DWORD TargetId:24;
179 DWORD Bus:6;
180 DWORD Mode:2;
181 SCSI3Addr_struct Target[2]; //2 level target device addr
182} PhysDevAddr_struct;
183
184typedef struct _LogDevAddr_struct {
185 DWORD VolId:30;
186 DWORD Mode:2;
187 BYTE reserved[4];
188} LogDevAddr_struct;
189
190typedef union _LUNAddr_struct {
191 BYTE LunAddrBytes[8];
192 SCSI3Addr_struct SCSI3Lun[4];
193 PhysDevAddr_struct PhysDev;
194 LogDevAddr_struct LogDev;
195} LUNAddr_struct;
196
197typedef struct _CommandListHeader_struct {
198 BYTE ReplyQueue;
199 BYTE SGList;
200 HWORD SGTotal;
201 QWORD Tag;
202 LUNAddr_struct LUN;
203} CommandListHeader_struct;
204typedef struct _RequestBlock_struct {
205 BYTE CDBLen;
206 struct {
207 BYTE Type:3;
208 BYTE Attribute:3;
209 BYTE Direction:2;
210 } Type;
211 HWORD Timeout;
212 BYTE CDB[16];
213} RequestBlock_struct;
214typedef struct _ErrDescriptor_struct {
215 QWORD Addr;
216 DWORD Len;
217} ErrDescriptor_struct;
218typedef struct _SGDescriptor_struct {
219 QWORD Addr;
220 DWORD Len;
221 DWORD Ext;
222} SGDescriptor_struct;
223
224typedef union _MoreErrInfo_struct{
225 struct {
226 BYTE Reserved[3];
227 BYTE Type;
228 DWORD ErrorInfo;
229 }Common_Info;
230 struct{
231 BYTE Reserved[2];
232 BYTE offense_size;//size of offending entry
233 BYTE offense_num; //byte # of offense 0-base
234 DWORD offense_value;
235 }Invalid_Cmd;
236}MoreErrInfo_struct;
237typedef struct _ErrorInfo_struct {
238 BYTE ScsiStatus;
239 BYTE SenseLen;
240 HWORD CommandStatus;
241 DWORD ResidualCnt;
242 MoreErrInfo_struct MoreErrInfo;
243 BYTE SenseInfo[SENSEINFOBYTES];
244} ErrorInfo_struct;
245
246/* Command types */
247#define CMD_RWREQ 0x00
248#define CMD_IOCTL_PEND 0x01
249#define CMD_SCSI 0x03
250#define CMD_MSG_DONE 0x04
251#define CMD_MSG_TIMEOUT 0x05
252
Mike Miller33079b22005-09-13 01:25:22 -0700253/* This structure needs to be divisible by 8 for new
254 * indexing method.
255 */
256#define PADSIZE (sizeof(long) - 4)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257typedef struct _CommandList_struct {
258 CommandListHeader_struct Header;
259 RequestBlock_struct Request;
260 ErrDescriptor_struct ErrDesc;
261 SGDescriptor_struct SG[MAXSGENTRIES];
262 /* information associated with the command */
263 __u32 busaddr; /* physical address of this record */
264 ErrorInfo_struct * err_info; /* pointer to the allocated mem */
265 int ctlr;
266 int cmd_type;
Mike Miller33079b22005-09-13 01:25:22 -0700267 long cmdindex;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 struct _CommandList_struct *prev;
269 struct _CommandList_struct *next;
270 struct request * rq;
271 struct completion *waiting;
272 int retry_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 void * scsi_cmd;
Mike Miller33079b22005-09-13 01:25:22 -0700274 char pad[PADSIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275} CommandList_struct;
276
277//Configuration Table Structure
278typedef struct _HostWrite_struct {
279 DWORD TransportRequest;
280 DWORD Reserved;
281 DWORD CoalIntDelay;
282 DWORD CoalIntCount;
283} HostWrite_struct;
284
285typedef struct _CfgTable_struct {
286 BYTE Signature[4];
287 DWORD SpecValence;
288 DWORD TransportSupport;
289 DWORD TransportActive;
290 HostWrite_struct HostWrite;
291 DWORD CmdsOutMax;
292 DWORD BusTypes;
293 DWORD Reserved;
294 BYTE ServerName[16];
295 DWORD HeartBeat;
296 DWORD SCSI_Prefetch;
297} CfgTable_struct;
298#pragma pack()
299#endif // CCISS_CMD_H