blob: 8049815d8c1ef97d810a95c80c156ce9c4621194 [file] [log] [blame]
Stephen M. Cameronedd16362009-12-08 14:09:11 -08001/*
2 * Disk Array driver for HP Smart Array SAS controllers
3 * Copyright 2000, 2009 Hewlett-Packard Development Company, L.P.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12 * NON INFRINGEMENT. See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 * Questions/Comments/Bugfixes to iss_storagedev@hp.com
19 *
20 */
21#ifndef HPSA_CMD_H
22#define HPSA_CMD_H
23
24/* general boundary defintions */
25#define SENSEINFOBYTES 32 /* may vary between hbas */
Stephen M. Camerond66ae082012-01-19 14:00:48 -060026#define SG_ENTRIES_IN_CMD 32 /* Max SG entries excluding chain blocks */
Stephen M. Cameron33a2ffc2010-02-25 14:03:27 -060027#define HPSA_SG_CHAIN 0x80000000
Stephen M. Cameronedd16362009-12-08 14:09:11 -080028#define MAXREPLYQS 256
29
30/* Command Status value */
31#define CMD_SUCCESS 0x0000
32#define CMD_TARGET_STATUS 0x0001
33#define CMD_DATA_UNDERRUN 0x0002
34#define CMD_DATA_OVERRUN 0x0003
35#define CMD_INVALID 0x0004
36#define CMD_PROTOCOL_ERR 0x0005
37#define CMD_HARDWARE_ERR 0x0006
38#define CMD_CONNECTION_LOST 0x0007
39#define CMD_ABORTED 0x0008
40#define CMD_ABORT_FAILED 0x0009
41#define CMD_UNSOLICITED_ABORT 0x000A
42#define CMD_TIMEOUT 0x000B
43#define CMD_UNABORTABLE 0x000C
44
45/* Unit Attentions ASC's as defined for the MSA2012sa */
46#define POWER_OR_RESET 0x29
47#define STATE_CHANGED 0x2a
48#define UNIT_ATTENTION_CLEARED 0x2f
49#define LUN_FAILED 0x3e
50#define REPORT_LUNS_CHANGED 0x3f
51
52/* Unit Attentions ASCQ's as defined for the MSA2012sa */
53
54 /* These ASCQ's defined for ASC = POWER_OR_RESET */
55#define POWER_ON_RESET 0x00
56#define POWER_ON_REBOOT 0x01
57#define SCSI_BUS_RESET 0x02
58#define MSA_TARGET_RESET 0x03
59#define CONTROLLER_FAILOVER 0x04
60#define TRANSCEIVER_SE 0x05
61#define TRANSCEIVER_LVD 0x06
62
63 /* These ASCQ's defined for ASC = STATE_CHANGED */
64#define RESERVATION_PREEMPTED 0x03
65#define ASYM_ACCESS_CHANGED 0x06
66#define LUN_CAPACITY_CHANGED 0x09
67
68/* transfer direction */
69#define XFER_NONE 0x00
70#define XFER_WRITE 0x01
71#define XFER_READ 0x02
72#define XFER_RSVD 0x03
73
74/* task attribute */
75#define ATTR_UNTAGGED 0x00
76#define ATTR_SIMPLE 0x04
77#define ATTR_HEADOFQUEUE 0x05
78#define ATTR_ORDERED 0x06
79#define ATTR_ACA 0x07
80
81/* cdb type */
82#define TYPE_CMD 0x00
83#define TYPE_MSG 0x01
84
85/* config space register offsets */
86#define CFG_VENDORID 0x00
87#define CFG_DEVICEID 0x02
88#define CFG_I2OBAR 0x10
89#define CFG_MEM1BAR 0x14
90
91/* i2o space register offsets */
92#define I2O_IBDB_SET 0x20
93#define I2O_IBDB_CLEAR 0x70
94#define I2O_INT_STATUS 0x30
95#define I2O_INT_MASK 0x34
96#define I2O_IBPOST_Q 0x40
97#define I2O_OBPOST_Q 0x44
98#define I2O_DMA1_CFG 0x214
99
100/* Configuration Table */
101#define CFGTBL_ChangeReq 0x00000001l
102#define CFGTBL_AccCmds 0x00000001l
Stephen M. Cameron1df85522010-06-16 13:51:40 -0500103#define DOORBELL_CTLR_RESET 0x00000004l
Stephen M. Cameroncf0b08d2011-05-03 14:59:46 -0500104#define DOORBELL_CTLR_RESET2 0x00000020l
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800105
106#define CFGTBL_Trans_Simple 0x00000002l
Don Brace303932f2010-02-04 08:42:40 -0600107#define CFGTBL_Trans_Performant 0x00000004l
Stephen M. Cameron960a30e2011-02-15 15:33:03 -0600108#define CFGTBL_Trans_use_short_tags 0x20000000l
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800109
110#define CFGTBL_BusType_Ultra2 0x00000001l
111#define CFGTBL_BusType_Ultra3 0x00000002l
112#define CFGTBL_BusType_Fibre1G 0x00000100l
113#define CFGTBL_BusType_Fibre2G 0x00000200l
114struct vals32 {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600115 u32 lower;
116 u32 upper;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800117};
118
119union u64bit {
120 struct vals32 val32;
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600121 u64 val;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800122};
123
124/* FIXME this is a per controller value (barf!) */
Scott Teelb7ec0212011-10-26 16:21:12 -0500125#define HPSA_MAX_LUN 1024
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800126#define HPSA_MAX_PHYS_LUN 1024
Scott Teelaca4a522012-01-19 14:01:19 -0600127#define MAX_EXT_TARGETS 32
Scott Teelb7ec0212011-10-26 16:21:12 -0500128#define HPSA_MAX_DEVICES (HPSA_MAX_PHYS_LUN + HPSA_MAX_LUN + \
Scott Teelaca4a522012-01-19 14:01:19 -0600129 MAX_EXT_TARGETS + 1) /* + 1 is for the controller itself */
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800130
131/* SCSI-3 Commands */
132#pragma pack(1)
133
134#define HPSA_INQUIRY 0x12
135struct InquiryData {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600136 u8 data_byte[36];
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800137};
138
139#define HPSA_REPORT_LOG 0xc2 /* Report Logical LUNs */
140#define HPSA_REPORT_PHYS 0xc3 /* Report Physical LUNs */
141struct ReportLUNdata {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600142 u8 LUNListLength[4];
143 u32 reserved;
144 u8 LUN[HPSA_MAX_LUN][8];
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800145};
146
147struct ReportExtendedLUNdata {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600148 u8 LUNListLength[4];
149 u8 extended_response_flag;
150 u8 reserved[3];
151 u8 LUN[HPSA_MAX_LUN][24];
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800152};
153
154struct SenseSubsystem_info {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600155 u8 reserved[36];
156 u8 portname[8];
157 u8 reserved1[1108];
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800158};
159
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800160/* BMIC commands */
161#define BMIC_READ 0x26
162#define BMIC_WRITE 0x27
163#define BMIC_CACHE_FLUSH 0xc2
164#define HPSA_CACHE_FLUSH 0x01 /* C2 was already being used by HPSA */
165
166/* Command List Structure */
167union SCSI3Addr {
168 struct {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600169 u8 Dev;
170 u8 Bus:6;
171 u8 Mode:2; /* b00 */
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800172 } PeripDev;
173 struct {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600174 u8 DevLSB;
175 u8 DevMSB:6;
176 u8 Mode:2; /* b01 */
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800177 } LogDev;
178 struct {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600179 u8 Dev:5;
180 u8 Bus:3;
181 u8 Targ:6;
182 u8 Mode:2; /* b10 */
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800183 } LogUnit;
184};
185
186struct PhysDevAddr {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600187 u32 TargetId:24;
188 u32 Bus:6;
189 u32 Mode:2;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800190 /* 2 level target device addr */
191 union SCSI3Addr Target[2];
192};
193
194struct LogDevAddr {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600195 u32 VolId:30;
196 u32 Mode:2;
197 u8 reserved[4];
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800198};
199
200union LUNAddr {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600201 u8 LunAddrBytes[8];
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800202 union SCSI3Addr SCSI3Lun[4];
203 struct PhysDevAddr PhysDev;
204 struct LogDevAddr LogDev;
205};
206
207struct CommandListHeader {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600208 u8 ReplyQueue;
209 u8 SGList;
210 u16 SGTotal;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800211 struct vals32 Tag;
212 union LUNAddr LUN;
213};
214
215struct RequestBlock {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600216 u8 CDBLen;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800217 struct {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600218 u8 Type:3;
219 u8 Attribute:3;
220 u8 Direction:2;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800221 } Type;
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600222 u16 Timeout;
223 u8 CDB[16];
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800224};
225
226struct ErrDescriptor {
227 struct vals32 Addr;
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600228 u32 Len;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800229};
230
231struct SGDescriptor {
232 struct vals32 Addr;
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600233 u32 Len;
234 u32 Ext;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800235};
236
237union MoreErrInfo {
238 struct {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600239 u8 Reserved[3];
240 u8 Type;
241 u32 ErrorInfo;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800242 } Common_Info;
243 struct {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600244 u8 Reserved[2];
245 u8 offense_size; /* size of offending entry */
246 u8 offense_num; /* byte # of offense 0-base */
247 u32 offense_value;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800248 } Invalid_Cmd;
249};
250struct ErrorInfo {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600251 u8 ScsiStatus;
252 u8 SenseLen;
253 u16 CommandStatus;
254 u32 ResidualCnt;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800255 union MoreErrInfo MoreErrInfo;
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600256 u8 SenseInfo[SENSEINFOBYTES];
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800257};
258/* Command types */
259#define CMD_IOCTL_PEND 0x01
260#define CMD_SCSI 0x03
261
Don Brace303932f2010-02-04 08:42:40 -0600262#define DIRECT_LOOKUP_SHIFT 5
263#define DIRECT_LOOKUP_BIT 0x10
Stephen M. Camerond896f3f2011-01-06 14:47:53 -0600264#define DIRECT_LOOKUP_MASK (~((1 << DIRECT_LOOKUP_SHIFT) - 1))
Don Brace303932f2010-02-04 08:42:40 -0600265
266#define HPSA_ERROR_BIT 0x02
267struct ctlr_info; /* defined in hpsa.h */
268/* The size of this structure needs to be divisible by 32
269 * on all architectures because low 5 bits of the addresses
270 * are used as follows:
271 *
272 * bit 0: to device, used to indicate "performant mode" command
273 * from device, indidcates error status.
274 * bit 1-3: to device, indicates block fetch table entry for
275 * reducing DMA in fetching commands from host memory.
276 * bit 4: used to indicate whether tag is "direct lookup" (index),
277 * or a bus address.
278 */
279
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800280struct CommandList {
281 struct CommandListHeader Header;
282 struct RequestBlock Request;
283 struct ErrDescriptor ErrDesc;
Stephen M. Camerond66ae082012-01-19 14:00:48 -0600284 struct SGDescriptor SG[SG_ENTRIES_IN_CMD];
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800285 /* information associated with the command */
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600286 u32 busaddr; /* physical addr of this record */
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800287 struct ErrorInfo *err_info; /* pointer to the allocated mem */
288 struct ctlr_info *h;
289 int cmd_type;
290 long cmdindex;
Stephen M. Cameron9e0fc762011-02-15 15:32:48 -0600291 struct list_head list;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800292 struct request *rq;
293 struct completion *waiting;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800294 void *scsi_cmd;
Don Brace303932f2010-02-04 08:42:40 -0600295
296/* on 64 bit architectures, to get this to be 32-byte-aligned
Stephen M. Camerondb61bfc2010-02-25 14:03:22 -0600297 * it so happens we need PAD_64 bytes of padding, on 32 bit systems,
298 * we need PAD_32 bytes of padding (see below). This does that.
299 * If it happens that 64 bit and 32 bit systems need different
300 * padding, PAD_32 and PAD_64 can be set independently, and.
301 * the code below will do the right thing.
Don Brace303932f2010-02-04 08:42:40 -0600302 */
Stephen M. Camerondb61bfc2010-02-25 14:03:22 -0600303#define IS_32_BIT ((8 - sizeof(long))/4)
304#define IS_64_BIT (!IS_32_BIT)
Stephen M. Cameron43aebfa2010-02-25 14:03:32 -0600305#define PAD_32 (4)
306#define PAD_64 (4)
Stephen M. Camerondb61bfc2010-02-25 14:03:22 -0600307#define COMMANDLIST_PAD (IS_32_BIT * PAD_32 + IS_64_BIT * PAD_64)
Don Brace303932f2010-02-04 08:42:40 -0600308 u8 pad[COMMANDLIST_PAD];
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800309};
310
311/* Configuration Table Structure */
312struct HostWrite {
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600313 u32 TransportRequest;
314 u32 Reserved;
315 u32 CoalIntDelay;
316 u32 CoalIntCount;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800317};
318
Don Brace303932f2010-02-04 08:42:40 -0600319#define SIMPLE_MODE 0x02
320#define PERFORMANT_MODE 0x04
321#define MEMQ_MODE 0x08
322
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800323struct CfgTable {
Don Brace303932f2010-02-04 08:42:40 -0600324 u8 Signature[4];
325 u32 SpecValence;
326 u32 TransportSupport;
327 u32 TransportActive;
328 struct HostWrite HostWrite;
329 u32 CmdsOutMax;
330 u32 BusTypes;
331 u32 TransMethodOffset;
332 u8 ServerName[16];
333 u32 HeartBeat;
334 u32 SCSI_Prefetch;
335 u32 MaxScatterGatherElements;
336 u32 MaxLogicalUnits;
337 u32 MaxPhysicalDevices;
338 u32 MaxPhysicalDrivesPerLogicalUnit;
339 u32 MaxPerformantModeCommands;
Stephen M. Cameron1df85522010-06-16 13:51:40 -0500340 u8 reserved[0x78 - 0x58];
341 u32 misc_fw_support; /* offset 0x78 */
342#define MISC_FW_DOORBELL_RESET (0x02)
Stephen M. Cameroncf0b08d2011-05-03 14:59:46 -0500343#define MISC_FW_DOORBELL_RESET2 (0x010)
Stephen M. Cameron580ada32011-05-03 14:59:10 -0500344 u8 driver_version[32];
Don Brace303932f2010-02-04 08:42:40 -0600345};
346
347#define NUM_BLOCKFETCH_ENTRIES 8
348struct TransTable_struct {
349 u32 BlockFetch[NUM_BLOCKFETCH_ENTRIES];
350 u32 RepQSize;
351 u32 RepQCount;
352 u32 RepQCtrAddrLow32;
353 u32 RepQCtrAddrHigh32;
354 u32 RepQAddr0Low32;
355 u32 RepQAddr0High32;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800356};
357
358struct hpsa_pci_info {
359 unsigned char bus;
360 unsigned char dev_fn;
361 unsigned short domain;
Stephen M. Cameron01a02ff2010-02-04 08:41:33 -0600362 u32 board_id;
Stephen M. Cameronedd16362009-12-08 14:09:11 -0800363};
364
365#pragma pack()
366#endif /* HPSA_CMD_H */