[SCSI] hpsa: mark last scatter gather element as the last
[deliverable/linux.git] / drivers / scsi / hpsa_cmd.h
CommitLineData
edd16368
SC
1/*
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 */
d66ae08b 26#define SG_ENTRIES_IN_CMD 32 /* Max SG entries excluding chain blocks */
33a2ffce 27#define HPSA_SG_CHAIN 0x80000000
e1d9cbfa 28#define HPSA_SG_LAST 0x40000000
edd16368
SC
29#define MAXREPLYQS 256
30
31/* Command Status value */
32#define CMD_SUCCESS 0x0000
33#define CMD_TARGET_STATUS 0x0001
34#define CMD_DATA_UNDERRUN 0x0002
35#define CMD_DATA_OVERRUN 0x0003
36#define CMD_INVALID 0x0004
37#define CMD_PROTOCOL_ERR 0x0005
38#define CMD_HARDWARE_ERR 0x0006
39#define CMD_CONNECTION_LOST 0x0007
40#define CMD_ABORTED 0x0008
41#define CMD_ABORT_FAILED 0x0009
42#define CMD_UNSOLICITED_ABORT 0x000A
43#define CMD_TIMEOUT 0x000B
44#define CMD_UNABORTABLE 0x000C
45
46/* Unit Attentions ASC's as defined for the MSA2012sa */
47#define POWER_OR_RESET 0x29
48#define STATE_CHANGED 0x2a
49#define UNIT_ATTENTION_CLEARED 0x2f
50#define LUN_FAILED 0x3e
51#define REPORT_LUNS_CHANGED 0x3f
52
53/* Unit Attentions ASCQ's as defined for the MSA2012sa */
54
55 /* These ASCQ's defined for ASC = POWER_OR_RESET */
56#define POWER_ON_RESET 0x00
57#define POWER_ON_REBOOT 0x01
58#define SCSI_BUS_RESET 0x02
59#define MSA_TARGET_RESET 0x03
60#define CONTROLLER_FAILOVER 0x04
61#define TRANSCEIVER_SE 0x05
62#define TRANSCEIVER_LVD 0x06
63
64 /* These ASCQ's defined for ASC = STATE_CHANGED */
65#define RESERVATION_PREEMPTED 0x03
66#define ASYM_ACCESS_CHANGED 0x06
67#define LUN_CAPACITY_CHANGED 0x09
68
69/* transfer direction */
70#define XFER_NONE 0x00
71#define XFER_WRITE 0x01
72#define XFER_READ 0x02
73#define XFER_RSVD 0x03
74
75/* task attribute */
76#define ATTR_UNTAGGED 0x00
77#define ATTR_SIMPLE 0x04
78#define ATTR_HEADOFQUEUE 0x05
79#define ATTR_ORDERED 0x06
80#define ATTR_ACA 0x07
81
82/* cdb type */
83#define TYPE_CMD 0x00
84#define TYPE_MSG 0x01
85
75167d2c
SC
86/* Message Types */
87#define HPSA_TASK_MANAGEMENT 0x00
88#define HPSA_RESET 0x01
89#define HPSA_SCAN 0x02
90#define HPSA_NOOP 0x03
91
92#define HPSA_CTLR_RESET_TYPE 0x00
93#define HPSA_BUS_RESET_TYPE 0x01
94#define HPSA_TARGET_RESET_TYPE 0x03
95#define HPSA_LUN_RESET_TYPE 0x04
96#define HPSA_NEXUS_RESET_TYPE 0x05
97
98/* Task Management Functions */
99#define HPSA_TMF_ABORT_TASK 0x00
100#define HPSA_TMF_ABORT_TASK_SET 0x01
101#define HPSA_TMF_CLEAR_ACA 0x02
102#define HPSA_TMF_CLEAR_TASK_SET 0x03
103#define HPSA_TMF_QUERY_TASK 0x04
104#define HPSA_TMF_QUERY_TASK_SET 0x05
105#define HPSA_TMF_QUERY_ASYNCEVENT 0x06
106
107
108
edd16368
SC
109/* config space register offsets */
110#define CFG_VENDORID 0x00
111#define CFG_DEVICEID 0x02
112#define CFG_I2OBAR 0x10
113#define CFG_MEM1BAR 0x14
114
115/* i2o space register offsets */
116#define I2O_IBDB_SET 0x20
117#define I2O_IBDB_CLEAR 0x70
118#define I2O_INT_STATUS 0x30
119#define I2O_INT_MASK 0x34
120#define I2O_IBPOST_Q 0x40
121#define I2O_OBPOST_Q 0x44
122#define I2O_DMA1_CFG 0x214
123
124/* Configuration Table */
125#define CFGTBL_ChangeReq 0x00000001l
126#define CFGTBL_AccCmds 0x00000001l
1df8552a 127#define DOORBELL_CTLR_RESET 0x00000004l
cf0b08d0 128#define DOORBELL_CTLR_RESET2 0x00000020l
edd16368
SC
129
130#define CFGTBL_Trans_Simple 0x00000002l
303932fd 131#define CFGTBL_Trans_Performant 0x00000004l
960a30e7 132#define CFGTBL_Trans_use_short_tags 0x20000000l
254f796b 133#define CFGTBL_Trans_enable_directed_msix (1 << 30)
edd16368
SC
134
135#define CFGTBL_BusType_Ultra2 0x00000001l
136#define CFGTBL_BusType_Ultra3 0x00000002l
137#define CFGTBL_BusType_Fibre1G 0x00000100l
138#define CFGTBL_BusType_Fibre2G 0x00000200l
139struct vals32 {
01a02ffc
SC
140 u32 lower;
141 u32 upper;
edd16368
SC
142};
143
144union u64bit {
145 struct vals32 val32;
01a02ffc 146 u64 val;
edd16368
SC
147};
148
149/* FIXME this is a per controller value (barf!) */
b7ec021f 150#define HPSA_MAX_LUN 1024
edd16368 151#define HPSA_MAX_PHYS_LUN 1024
aca4a520 152#define MAX_EXT_TARGETS 32
b7ec021f 153#define HPSA_MAX_DEVICES (HPSA_MAX_PHYS_LUN + HPSA_MAX_LUN + \
aca4a520 154 MAX_EXT_TARGETS + 1) /* + 1 is for the controller itself */
edd16368
SC
155
156/* SCSI-3 Commands */
157#pragma pack(1)
158
159#define HPSA_INQUIRY 0x12
160struct InquiryData {
01a02ffc 161 u8 data_byte[36];
edd16368
SC
162};
163
164#define HPSA_REPORT_LOG 0xc2 /* Report Logical LUNs */
165#define HPSA_REPORT_PHYS 0xc3 /* Report Physical LUNs */
a93aa1fe 166#define HPSA_REPORT_PHYS_EXTENDED 0x02
edd16368 167struct ReportLUNdata {
01a02ffc
SC
168 u8 LUNListLength[4];
169 u32 reserved;
170 u8 LUN[HPSA_MAX_LUN][8];
edd16368
SC
171};
172
173struct ReportExtendedLUNdata {
01a02ffc
SC
174 u8 LUNListLength[4];
175 u8 extended_response_flag;
176 u8 reserved[3];
177 u8 LUN[HPSA_MAX_LUN][24];
edd16368
SC
178};
179
180struct SenseSubsystem_info {
01a02ffc
SC
181 u8 reserved[36];
182 u8 portname[8];
183 u8 reserved1[1108];
edd16368
SC
184};
185
edd16368
SC
186/* BMIC commands */
187#define BMIC_READ 0x26
188#define BMIC_WRITE 0x27
189#define BMIC_CACHE_FLUSH 0xc2
190#define HPSA_CACHE_FLUSH 0x01 /* C2 was already being used by HPSA */
e85c5974 191#define BMIC_FLASH_FIRMWARE 0xF7
edd16368
SC
192
193/* Command List Structure */
194union SCSI3Addr {
195 struct {
01a02ffc
SC
196 u8 Dev;
197 u8 Bus:6;
198 u8 Mode:2; /* b00 */
edd16368
SC
199 } PeripDev;
200 struct {
01a02ffc
SC
201 u8 DevLSB;
202 u8 DevMSB:6;
203 u8 Mode:2; /* b01 */
edd16368
SC
204 } LogDev;
205 struct {
01a02ffc
SC
206 u8 Dev:5;
207 u8 Bus:3;
208 u8 Targ:6;
209 u8 Mode:2; /* b10 */
edd16368
SC
210 } LogUnit;
211};
212
213struct PhysDevAddr {
01a02ffc
SC
214 u32 TargetId:24;
215 u32 Bus:6;
216 u32 Mode:2;
edd16368
SC
217 /* 2 level target device addr */
218 union SCSI3Addr Target[2];
219};
220
221struct LogDevAddr {
01a02ffc
SC
222 u32 VolId:30;
223 u32 Mode:2;
224 u8 reserved[4];
edd16368
SC
225};
226
227union LUNAddr {
01a02ffc 228 u8 LunAddrBytes[8];
edd16368
SC
229 union SCSI3Addr SCSI3Lun[4];
230 struct PhysDevAddr PhysDev;
231 struct LogDevAddr LogDev;
232};
233
234struct CommandListHeader {
01a02ffc
SC
235 u8 ReplyQueue;
236 u8 SGList;
237 u16 SGTotal;
edd16368
SC
238 struct vals32 Tag;
239 union LUNAddr LUN;
240};
241
242struct RequestBlock {
01a02ffc 243 u8 CDBLen;
edd16368 244 struct {
01a02ffc
SC
245 u8 Type:3;
246 u8 Attribute:3;
247 u8 Direction:2;
edd16368 248 } Type;
01a02ffc
SC
249 u16 Timeout;
250 u8 CDB[16];
edd16368
SC
251};
252
253struct ErrDescriptor {
254 struct vals32 Addr;
01a02ffc 255 u32 Len;
edd16368
SC
256};
257
258struct SGDescriptor {
259 struct vals32 Addr;
01a02ffc
SC
260 u32 Len;
261 u32 Ext;
edd16368
SC
262};
263
264union MoreErrInfo {
265 struct {
01a02ffc
SC
266 u8 Reserved[3];
267 u8 Type;
268 u32 ErrorInfo;
edd16368
SC
269 } Common_Info;
270 struct {
01a02ffc
SC
271 u8 Reserved[2];
272 u8 offense_size; /* size of offending entry */
273 u8 offense_num; /* byte # of offense 0-base */
274 u32 offense_value;
edd16368
SC
275 } Invalid_Cmd;
276};
277struct ErrorInfo {
01a02ffc
SC
278 u8 ScsiStatus;
279 u8 SenseLen;
280 u16 CommandStatus;
281 u32 ResidualCnt;
edd16368 282 union MoreErrInfo MoreErrInfo;
01a02ffc 283 u8 SenseInfo[SENSEINFOBYTES];
edd16368
SC
284};
285/* Command types */
286#define CMD_IOCTL_PEND 0x01
287#define CMD_SCSI 0x03
288
303932fd
DB
289#define DIRECT_LOOKUP_SHIFT 5
290#define DIRECT_LOOKUP_BIT 0x10
d896f3f3 291#define DIRECT_LOOKUP_MASK (~((1 << DIRECT_LOOKUP_SHIFT) - 1))
303932fd
DB
292
293#define HPSA_ERROR_BIT 0x02
edd16368 294struct ctlr_info; /* defined in hpsa.h */
303932fd
DB
295/* The size of this structure needs to be divisible by 32
296 * on all architectures because low 5 bits of the addresses
297 * are used as follows:
298 *
299 * bit 0: to device, used to indicate "performant mode" command
300 * from device, indidcates error status.
301 * bit 1-3: to device, indicates block fetch table entry for
302 * reducing DMA in fetching commands from host memory.
303 * bit 4: used to indicate whether tag is "direct lookup" (index),
304 * or a bus address.
edd16368 305 */
303932fd 306
edd16368
SC
307struct CommandList {
308 struct CommandListHeader Header;
309 struct RequestBlock Request;
310 struct ErrDescriptor ErrDesc;
d66ae08b 311 struct SGDescriptor SG[SG_ENTRIES_IN_CMD];
edd16368 312 /* information associated with the command */
01a02ffc 313 u32 busaddr; /* physical addr of this record */
edd16368
SC
314 struct ErrorInfo *err_info; /* pointer to the allocated mem */
315 struct ctlr_info *h;
316 int cmd_type;
317 long cmdindex;
9e0fc764 318 struct list_head list;
edd16368
SC
319 struct request *rq;
320 struct completion *waiting;
edd16368 321 void *scsi_cmd;
303932fd
DB
322
323/* on 64 bit architectures, to get this to be 32-byte-aligned
db61bfcf
SC
324 * it so happens we need PAD_64 bytes of padding, on 32 bit systems,
325 * we need PAD_32 bytes of padding (see below). This does that.
326 * If it happens that 64 bit and 32 bit systems need different
327 * padding, PAD_32 and PAD_64 can be set independently, and.
328 * the code below will do the right thing.
303932fd 329 */
db61bfcf
SC
330#define IS_32_BIT ((8 - sizeof(long))/4)
331#define IS_64_BIT (!IS_32_BIT)
43aebfa1
SC
332#define PAD_32 (4)
333#define PAD_64 (4)
db61bfcf 334#define COMMANDLIST_PAD (IS_32_BIT * PAD_32 + IS_64_BIT * PAD_64)
303932fd 335 u8 pad[COMMANDLIST_PAD];
edd16368
SC
336};
337
338/* Configuration Table Structure */
339struct HostWrite {
01a02ffc
SC
340 u32 TransportRequest;
341 u32 Reserved;
342 u32 CoalIntDelay;
343 u32 CoalIntCount;
edd16368
SC
344};
345
303932fd
DB
346#define SIMPLE_MODE 0x02
347#define PERFORMANT_MODE 0x04
348#define MEMQ_MODE 0x08
349
edd16368 350struct CfgTable {
303932fd
DB
351 u8 Signature[4];
352 u32 SpecValence;
353 u32 TransportSupport;
354 u32 TransportActive;
355 struct HostWrite HostWrite;
356 u32 CmdsOutMax;
357 u32 BusTypes;
358 u32 TransMethodOffset;
359 u8 ServerName[16];
360 u32 HeartBeat;
97a5e98c
SC
361 u32 driver_support;
362#define ENABLE_SCSI_PREFETCH 0x100
28e13446 363#define ENABLE_UNIT_ATTN 0x01
303932fd
DB
364 u32 MaxScatterGatherElements;
365 u32 MaxLogicalUnits;
366 u32 MaxPhysicalDevices;
367 u32 MaxPhysicalDrivesPerLogicalUnit;
368 u32 MaxPerformantModeCommands;
75167d2c
SC
369 u32 MaxBlockFetch;
370 u32 PowerConservationSupport;
371 u32 PowerConservationEnable;
372 u32 TMFSupportFlags;
373 u8 TMFTagMask[8];
374 u8 reserved[0x78 - 0x70];
1df8552a
SC
375 u32 misc_fw_support; /* offset 0x78 */
376#define MISC_FW_DOORBELL_RESET (0x02)
cf0b08d0 377#define MISC_FW_DOORBELL_RESET2 (0x010)
580ada3c 378 u8 driver_version[32];
75167d2c 379
303932fd
DB
380};
381
382#define NUM_BLOCKFETCH_ENTRIES 8
383struct TransTable_struct {
384 u32 BlockFetch[NUM_BLOCKFETCH_ENTRIES];
385 u32 RepQSize;
386 u32 RepQCount;
387 u32 RepQCtrAddrLow32;
388 u32 RepQCtrAddrHigh32;
254f796b
MG
389#define MAX_REPLY_QUEUES 8
390 struct vals32 RepQAddr[MAX_REPLY_QUEUES];
edd16368
SC
391};
392
393struct hpsa_pci_info {
394 unsigned char bus;
395 unsigned char dev_fn;
396 unsigned short domain;
01a02ffc 397 u32 board_id;
edd16368
SC
398};
399
400#pragma pack()
401#endif /* HPSA_CMD_H */
This page took 0.284914 seconds and 5 git commands to generate.