2 * Disk Array driver for HP Smart Array SAS controllers
3 * Copyright 2000, 2009 Hewlett-Packard Development Company, L.P.
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.
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.
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.
18 * Questions/Comments/Bugfixes to iss_storagedev@hp.com
24 /* general boundary defintions */
25 #define SENSEINFOBYTES 32 /* may vary between hbas */
26 #define MAXSGENTRIES 32
27 #define HPSA_SG_CHAIN 0x80000000
28 #define MAXREPLYQS 256
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
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
52 /* Unit Attentions ASCQ's as defined for the MSA2012sa */
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
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
68 /* transfer direction */
69 #define XFER_NONE 0x00
70 #define XFER_WRITE 0x01
71 #define XFER_READ 0x02
72 #define XFER_RSVD 0x03
75 #define ATTR_UNTAGGED 0x00
76 #define ATTR_SIMPLE 0x04
77 #define ATTR_HEADOFQUEUE 0x05
78 #define ATTR_ORDERED 0x06
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
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
100 /* Configuration Table */
101 #define CFGTBL_ChangeReq 0x00000001l
102 #define CFGTBL_AccCmds 0x00000001l
103 #define DOORBELL_CTLR_RESET 0x00000004l
104 #define DOORBELL_CTLR_RESET2 0x00000020l
106 #define CFGTBL_Trans_Simple 0x00000002l
107 #define CFGTBL_Trans_Performant 0x00000004l
108 #define CFGTBL_Trans_use_short_tags 0x20000000l
110 #define CFGTBL_BusType_Ultra2 0x00000001l
111 #define CFGTBL_BusType_Ultra3 0x00000002l
112 #define CFGTBL_BusType_Fibre1G 0x00000100l
113 #define CFGTBL_BusType_Fibre2G 0x00000200l
124 /* FIXME this is a per controller value (barf!) */
125 #define HPSA_MAX_TARGETS_PER_CTLR 16
126 #define HPSA_MAX_LUN 1024
127 #define HPSA_MAX_PHYS_LUN 1024
128 #define MAX_MSA2XXX_ENCLOSURES 32
129 #define HPSA_MAX_DEVICES (HPSA_MAX_PHYS_LUN + HPSA_MAX_LUN + \
130 MAX_MSA2XXX_ENCLOSURES + 1) /* + 1 is for the controller itself */
132 /* SCSI-3 Commands */
135 #define HPSA_INQUIRY 0x12
140 #define HPSA_REPORT_LOG 0xc2 /* Report Logical LUNs */
141 #define HPSA_REPORT_PHYS 0xc3 /* Report Physical LUNs */
142 struct ReportLUNdata
{
145 u8 LUN
[HPSA_MAX_LUN
][8];
148 struct ReportExtendedLUNdata
{
150 u8 extended_response_flag
;
152 u8 LUN
[HPSA_MAX_LUN
][24];
155 struct SenseSubsystem_info
{
162 #define BMIC_READ 0x26
163 #define BMIC_WRITE 0x27
164 #define BMIC_CACHE_FLUSH 0xc2
165 #define HPSA_CACHE_FLUSH 0x01 /* C2 was already being used by HPSA */
167 /* Command List Structure */
191 /* 2 level target device addr */
192 union SCSI3Addr Target
[2];
203 union SCSI3Addr SCSI3Lun
[4];
204 struct PhysDevAddr PhysDev
;
205 struct LogDevAddr LogDev
;
208 struct CommandListHeader
{
216 struct RequestBlock
{
227 struct ErrDescriptor
{
232 struct SGDescriptor
{
246 u8 offense_size
; /* size of offending entry */
247 u8 offense_num
; /* byte # of offense 0-base */
256 union MoreErrInfo MoreErrInfo
;
257 u8 SenseInfo
[SENSEINFOBYTES
];
260 #define CMD_IOCTL_PEND 0x01
261 #define CMD_SCSI 0x03
263 #define DIRECT_LOOKUP_SHIFT 5
264 #define DIRECT_LOOKUP_BIT 0x10
265 #define DIRECT_LOOKUP_MASK (~((1 << DIRECT_LOOKUP_SHIFT) - 1))
267 #define HPSA_ERROR_BIT 0x02
268 struct ctlr_info
; /* defined in hpsa.h */
269 /* The size of this structure needs to be divisible by 32
270 * on all architectures because low 5 bits of the addresses
271 * are used as follows:
273 * bit 0: to device, used to indicate "performant mode" command
274 * from device, indidcates error status.
275 * bit 1-3: to device, indicates block fetch table entry for
276 * reducing DMA in fetching commands from host memory.
277 * bit 4: used to indicate whether tag is "direct lookup" (index),
282 struct CommandListHeader Header
;
283 struct RequestBlock Request
;
284 struct ErrDescriptor ErrDesc
;
285 struct SGDescriptor SG
[MAXSGENTRIES
];
286 /* information associated with the command */
287 u32 busaddr
; /* physical addr of this record */
288 struct ErrorInfo
*err_info
; /* pointer to the allocated mem */
292 struct list_head list
;
294 struct completion
*waiting
;
297 /* on 64 bit architectures, to get this to be 32-byte-aligned
298 * it so happens we need PAD_64 bytes of padding, on 32 bit systems,
299 * we need PAD_32 bytes of padding (see below). This does that.
300 * If it happens that 64 bit and 32 bit systems need different
301 * padding, PAD_32 and PAD_64 can be set independently, and.
302 * the code below will do the right thing.
304 #define IS_32_BIT ((8 - sizeof(long))/4)
305 #define IS_64_BIT (!IS_32_BIT)
308 #define COMMANDLIST_PAD (IS_32_BIT * PAD_32 + IS_64_BIT * PAD_64)
309 u8 pad
[COMMANDLIST_PAD
];
312 /* Configuration Table Structure */
314 u32 TransportRequest
;
320 #define SIMPLE_MODE 0x02
321 #define PERFORMANT_MODE 0x04
322 #define MEMQ_MODE 0x08
327 u32 TransportSupport
;
329 struct HostWrite HostWrite
;
332 u32 TransMethodOffset
;
336 u32 MaxScatterGatherElements
;
338 u32 MaxPhysicalDevices
;
339 u32 MaxPhysicalDrivesPerLogicalUnit
;
340 u32 MaxPerformantModeCommands
;
341 u8 reserved
[0x78 - 0x58];
342 u32 misc_fw_support
; /* offset 0x78 */
343 #define MISC_FW_DOORBELL_RESET (0x02)
344 #define MISC_FW_DOORBELL_RESET2 (0x010)
345 u8 driver_version
[32];
348 #define NUM_BLOCKFETCH_ENTRIES 8
349 struct TransTable_struct
{
350 u32 BlockFetch
[NUM_BLOCKFETCH_ENTRIES
];
353 u32 RepQCtrAddrLow32
;
354 u32 RepQCtrAddrHigh32
;
359 struct hpsa_pci_info
{
361 unsigned char dev_fn
;
362 unsigned short domain
;
367 #endif /* HPSA_CMD_H */