blob: 35463d2f0ee7ce71d80943105f1594eb556141d4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef CCISS_CMD_H
2#define CCISS_CMD_H
dann frazier429c42c2010-02-17 16:55:11 -07003
4#include <linux/cciss_defs.h>
5
dann frazierb0284612010-02-17 16:53:31 -07006/* DEFINES */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#define CISS_VERSION "1.00"
8
dann frazierb0284612010-02-17 16:53:31 -07009/* general boundary definitions */
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
Mike Miller0a9279c2009-04-02 12:50:55 -070014/* 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 frazierb0284612010-02-17 16:53:31 -070037/* config space register offsets */
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#define CFG_VENDORID 0x00
39#define CFG_DEVICEID 0x02
40#define CFG_I2OBAR 0x10
41#define CFG_MEM1BAR 0x14
42
dann frazierb0284612010-02-17 16:53:31 -070043/* i2o space register offsets */
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#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 Millerf92e2f52006-12-06 20:35:04 -080050#define I2O_DMA1_CFG 0x214
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
dann frazierb0284612010-02-17 16:53:31 -070052/* Configuration Table */
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#define CFGTBL_ChangeReq 0x00000001l
54#define CFGTBL_AccCmds 0x00000001l
Stephen M. Camerona6528d02010-07-19 13:46:22 -050055#define DOORBELL_CTLR_RESET 0x00000004l
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57#define CFGTBL_Trans_Simple 0x00000002l
Mike Miller5e216152010-06-02 12:58:06 -070058#define CFGTBL_Trans_Performant 0x00000004l
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60#define CFGTBL_BusType_Ultra2 0x00000001l
61#define CFGTBL_BusType_Ultra3 0x00000002l
62#define CFGTBL_BusType_Fibre1G 0x00000100l
63#define CFGTBL_BusType_Fibre2G 0x00000200l
64typedef struct _vals32
65{
66 __u32 lower;
67 __u32 upper;
68} vals32;
69
70typedef union _u64bit
71{
72 vals32 val32;
73 __u64 val;
74} u64bit;
75
dann frazierb0284612010-02-17 16:53:31 -070076/* Type defs used in the following structs */
Linus Torvalds1da177e2005-04-16 15:20:36 -070077#define QWORD vals32
78
dann frazierb0284612010-02-17 16:53:31 -070079/* STRUCTURES */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#define CISS_MAX_PHYS_LUN 1024
dann frazierb0284612010-02-17 16:53:31 -070081/* SCSI-3 Cmmands */
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83#pragma pack(1)
84
85#define CISS_INQUIRY 0x12
dann frazierb0284612010-02-17 16:53:31 -070086/* Date returned */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087typedef struct _InquiryData_struct
88{
89 BYTE data_byte[36];
90} InquiryData_struct;
91
92#define CISS_REPORT_LOG 0xc2 /* Report Logical LUNs */
93#define CISS_REPORT_PHYS 0xc3 /* Report Physical LUNs */
dann frazierb0284612010-02-17 16:53:31 -070094/* Data returned */
Linus Torvalds1da177e2005-04-16 15:20:36 -070095typedef struct _ReportLUNdata_struct
96{
97 BYTE LUNListLength[4];
98 DWORD reserved;
99 BYTE LUN[CISS_MAX_LUN][8];
100} ReportLunData_struct;
101
102#define CCISS_READ_CAPACITY 0x25 /* Read Capacity */
103typedef struct _ReadCapdata_struct
104{
dann frazierb0284612010-02-17 16:53:31 -0700105 BYTE total_size[4]; /* Total size in blocks */
106 BYTE block_size[4]; /* Size of blocks in bytes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107} ReadCapdata_struct;
108
Mike Miller (OS Dev)00988a32006-09-30 23:27:23 -0700109#define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */
110
111/* service action to differentiate a 16 byte read capacity from
112 other commands that use the 0x9e SCSI op code */
113
114#define CCISS_READ_CAPACITY_16_SERVICE_ACT 0x10
115
116typedef struct _ReadCapdata_struct_16
117{
118 BYTE total_size[8]; /* Total size in blocks */
119 BYTE block_size[4]; /* Size of blocks in bytes */
120 BYTE prot_en:1; /* protection enable bit */
121 BYTE rto_en:1; /* reference tag own enable bit */
122 BYTE reserved:6; /* reserved bits */
123 BYTE reserved2[18]; /* reserved bytes per spec */
124} ReadCapdata_struct_16;
125
126/* Define the supported read/write commands for cciss based controllers */
127
128#define CCISS_READ_10 0x28 /* Read(10) */
129#define CCISS_WRITE_10 0x2a /* Write(10) */
130#define CCISS_READ_16 0x88 /* Read(16) */
131#define CCISS_WRITE_16 0x8a /* Write(16) */
132
133/* Define the CDB lengths supported by cciss based controllers */
134
135#define CDB_LEN10 10
136#define CDB_LEN16 16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
dann frazierb0284612010-02-17 16:53:31 -0700138/* BMIC commands */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#define BMIC_READ 0x26
140#define BMIC_WRITE 0x27
141#define BMIC_CACHE_FLUSH 0xc2
dann frazierb0284612010-02-17 16:53:31 -0700142#define CCISS_CACHE_FLUSH 0x01 /* C2 was already being used by CCISS */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
dann frazierb0284612010-02-17 16:53:31 -0700144/* Command List Structure */
scameron@beardog.cca.cpqcorp.netb57695f2009-06-08 16:02:17 -0500145#define CTLR_LUNID "\0\0\0\0\0\0\0\0"
146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147typedef struct _CommandListHeader_struct {
148 BYTE ReplyQueue;
149 BYTE SGList;
150 HWORD SGTotal;
151 QWORD Tag;
152 LUNAddr_struct LUN;
153} CommandListHeader_struct;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154typedef struct _ErrDescriptor_struct {
155 QWORD Addr;
156 DWORD Len;
157} ErrDescriptor_struct;
158typedef struct _SGDescriptor_struct {
159 QWORD Addr;
160 DWORD Len;
161 DWORD Ext;
162} SGDescriptor_struct;
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164/* Command types */
165#define CMD_RWREQ 0x00
166#define CMD_IOCTL_PEND 0x01
167#define CMD_SCSI 0x03
168#define CMD_MSG_DONE 0x04
169#define CMD_MSG_TIMEOUT 0x05
Hannes Reineckeb59e64d2009-07-02 22:02:06 +0200170#define CMD_MSG_STALE 0xff
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
Stephen M. Cameron1b7d0d22010-02-26 16:01:17 -0600172/* This structure needs to be divisible by COMMANDLIST_ALIGNMENT
173 * because low bits of the address are used to to indicate that
174 * whether the tag contains an index or an address. PAD_32 and
175 * PAD_64 can be adjusted independently as needed for 32-bit
176 * and 64-bits systems.
Mike Miller33079b22005-09-13 01:25:22 -0700177 */
Mike Miller5e216152010-06-02 12:58:06 -0700178#define COMMANDLIST_ALIGNMENT (32)
Stephen M. Cameron58daa9c2010-02-26 16:01:12 -0600179#define IS_64_BIT ((sizeof(long) - 4)/4)
180#define IS_32_BIT (!IS_64_BIT)
Mike Millerf3bcb142010-06-11 13:13:36 +0200181#define PAD_32 (0)
Stephen M. Cameron58daa9c2010-02-26 16:01:12 -0600182#define PAD_64 (4)
183#define PADSIZE (IS_32_BIT * PAD_32 + IS_64_BIT * PAD_64)
Mike Miller5e216152010-06-02 12:58:06 -0700184#define DIRECT_LOOKUP_BIT 0x10
185#define DIRECT_LOOKUP_SHIFT 5
186
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187typedef struct _CommandList_struct {
188 CommandListHeader_struct Header;
189 RequestBlock_struct Request;
190 ErrDescriptor_struct ErrDesc;
191 SGDescriptor_struct SG[MAXSGENTRIES];
192 /* information associated with the command */
193 __u32 busaddr; /* physical address of this record */
194 ErrorInfo_struct * err_info; /* pointer to the allocated mem */
195 int ctlr;
196 int cmd_type;
Mike Miller33079b22005-09-13 01:25:22 -0700197 long cmdindex;
Jens Axboee6e1ee92011-01-10 21:50:33 +0100198 struct list_head list;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 struct request * rq;
200 struct completion *waiting;
201 int retry_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 void * scsi_cmd;
Mike Miller5e216152010-06-02 12:58:06 -0700203 char pad[PADSIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204} CommandList_struct;
205
dann frazierb0284612010-02-17 16:53:31 -0700206/* Configuration Table Structure */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207typedef struct _HostWrite_struct {
208 DWORD TransportRequest;
209 DWORD Reserved;
210 DWORD CoalIntDelay;
211 DWORD CoalIntCount;
212} HostWrite_struct;
213
214typedef struct _CfgTable_struct {
215 BYTE Signature[4];
216 DWORD SpecValence;
Mike Miller5e216152010-06-02 12:58:06 -0700217#define SIMPLE_MODE 0x02
218#define PERFORMANT_MODE 0x04
219#define MEMQ_MODE 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 DWORD TransportSupport;
221 DWORD TransportActive;
222 HostWrite_struct HostWrite;
223 DWORD CmdsOutMax;
224 DWORD BusTypes;
Mike Miller5e216152010-06-02 12:58:06 -0700225 DWORD TransMethodOffset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 BYTE ServerName[16];
227 DWORD HeartBeat;
228 DWORD SCSI_Prefetch;
Don Brace5c07a312009-11-12 12:50:01 -0600229 DWORD MaxSGElements;
230 DWORD MaxLogicalUnits;
231 DWORD MaxPhysicalDrives;
232 DWORD MaxPhysicalDrivesPerLogicalUnit;
Mike Miller5e216152010-06-02 12:58:06 -0700233 DWORD MaxPerformantModeCommands;
Stephen M. Camerona6528d02010-07-19 13:46:22 -0500234 u8 reserved[0x78 - 0x58];
235 u32 misc_fw_support; /* offset 0x78 */
236#define MISC_FW_DOORBELL_RESET (0x02)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237} CfgTable_struct;
Mike Miller5e216152010-06-02 12:58:06 -0700238
239struct TransTable_struct {
240 u32 BlockFetch0;
241 u32 BlockFetch1;
242 u32 BlockFetch2;
243 u32 BlockFetch3;
244 u32 BlockFetch4;
245 u32 BlockFetch5;
246 u32 BlockFetch6;
247 u32 BlockFetch7;
248 u32 RepQSize;
249 u32 RepQCount;
250 u32 RepQCtrAddrLow32;
251 u32 RepQCtrAddrHigh32;
252 u32 RepQAddr0Low32;
253 u32 RepQAddr0High32;
254};
255
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256#pragma pack()
dann frazierb0284612010-02-17 16:53:31 -0700257#endif /* CCISS_CMD_H */