blob: c83ccbb24983164605c5e3f85cb745b6a1b94224 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * ipr.h -- driver for IBM Power Linux RAID adapters
3 *
4 * Written By: Brian King <brking@us.ibm.com>, IBM Corporation
5 *
6 * Copyright (C) 2003, 2004 IBM Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * Alan Cox <alan@redhat.com> - Removed several careless u32/dma_addr_t errors
23 * that broke 64bit platforms.
24 */
25
26#ifndef _IPR_H
27#define _IPR_H
28
29#include <linux/types.h>
30#include <linux/completion.h>
Brian King35a39692006-09-25 12:39:20 -050031#include <linux/libata.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/list.h>
33#include <linux/kref.h>
34#include <scsi/scsi.h>
35#include <scsi/scsi_cmnd.h>
36
37/*
38 * Literals
39 */
Brian King9cd065a2007-01-23 11:25:43 -060040#define IPR_DRIVER_VERSION "2.3.1"
41#define IPR_DRIVER_DATE "(January 23, 2007)"
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding
45 * ops per device for devices not running tagged command queuing.
46 * This can be adjusted at runtime through sysfs device attributes.
47 */
48#define IPR_MAX_CMD_PER_LUN 6
Brian Kingb5145d22006-08-02 14:57:36 -050049#define IPR_MAX_CMD_PER_ATA_LUN 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51/*
52 * IPR_NUM_BASE_CMD_BLKS: This defines the maximum number of
53 * ops the mid-layer can send to the adapter.
54 */
55#define IPR_NUM_BASE_CMD_BLKS 100
56
Brian King60e74862006-11-21 10:28:10 -060057#define PCI_DEVICE_ID_IBM_OBSIDIAN_E 0x0339
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#define IPR_SUBS_DEV_ID_2780 0x0264
60#define IPR_SUBS_DEV_ID_5702 0x0266
61#define IPR_SUBS_DEV_ID_5703 0x0278
62#define IPR_SUBS_DEV_ID_572E 0x028D
63#define IPR_SUBS_DEV_ID_573E 0x02D3
64#define IPR_SUBS_DEV_ID_573D 0x02D4
65#define IPR_SUBS_DEV_ID_571A 0x02C0
66#define IPR_SUBS_DEV_ID_571B 0x02BE
67#define IPR_SUBS_DEV_ID_571E 0x02BF
brking@us.ibm.com86f51432005-11-01 17:02:42 -060068#define IPR_SUBS_DEV_ID_571F 0x02D5
69#define IPR_SUBS_DEV_ID_572A 0x02C1
70#define IPR_SUBS_DEV_ID_572B 0x02C2
Brian King60e74862006-11-21 10:28:10 -060071#define IPR_SUBS_DEV_ID_572F 0x02C3
brking@us.ibm.com86f51432005-11-01 17:02:42 -060072#define IPR_SUBS_DEV_ID_575B 0x030D
Brian King60e74862006-11-21 10:28:10 -060073#define IPR_SUBS_DEV_ID_575C 0x0338
74#define IPR_SUBS_DEV_ID_57B7 0x0360
75#define IPR_SUBS_DEV_ID_57B8 0x02C2
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77#define IPR_NAME "ipr"
78
79/*
80 * Return codes
81 */
82#define IPR_RC_JOB_CONTINUE 1
83#define IPR_RC_JOB_RETURN 2
84
85/*
86 * IOASCs
87 */
88#define IPR_IOASC_NR_INIT_CMD_REQUIRED 0x02040200
89#define IPR_IOASC_SYNC_REQUIRED 0x023f0000
90#define IPR_IOASC_MED_DO_NOT_REALLOC 0x03110C00
91#define IPR_IOASC_HW_SEL_TIMEOUT 0x04050000
92#define IPR_IOASC_HW_DEV_BUS_STATUS 0x04448500
93#define IPR_IOASC_IOASC_MASK 0xFFFFFF00
94#define IPR_IOASC_SCSI_STATUS_MASK 0x000000FF
brking@us.ibm.comdfed8232005-11-01 17:02:55 -060095#define IPR_IOASC_IR_INVALID_REQ_TYPE_OR_PKT 0x05240000
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#define IPR_IOASC_IR_RESOURCE_HANDLE 0x05250000
brking@us.ibm.comb0df54b2005-11-01 17:01:47 -060097#define IPR_IOASC_IR_NO_CMDS_TO_2ND_IOA 0x05258100
98#define IPR_IOASA_IR_DUAL_IOA_DISABLED 0x052C8000
Linus Torvalds1da177e2005-04-16 15:20:36 -070099#define IPR_IOASC_BUS_WAS_RESET 0x06290000
100#define IPR_IOASC_BUS_WAS_RESET_BY_OTHER 0x06298000
101#define IPR_IOASC_ABORTED_CMD_TERM_BY_HOST 0x0B5A0000
102
103#define IPR_FIRST_DRIVER_IOASC 0x10000000
104#define IPR_IOASC_IOA_WAS_RESET 0x10000001
105#define IPR_IOASC_PCI_ACCESS_ERROR 0x10000002
106
Brian King5469cb52007-03-29 12:42:40 -0500107/* Driver data flags */
108#define IPR_USE_LONG_TRANSOP_TIMEOUT 0x00000001
109
Brian Kingac719ab2006-11-21 10:28:42 -0600110#define IPR_DEFAULT_MAX_ERROR_DUMP 984
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111#define IPR_NUM_LOG_HCAMS 2
112#define IPR_NUM_CFG_CHG_HCAMS 2
113#define IPR_NUM_HCAMS (IPR_NUM_LOG_HCAMS + IPR_NUM_CFG_CHG_HCAMS)
brking@us.ibm.comd71a8b02005-11-01 17:02:49 -0600114#define IPR_MAX_NUM_TARGETS_PER_BUS 256
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115#define IPR_MAX_NUM_LUNS_PER_TARGET 256
116#define IPR_MAX_NUM_VSET_LUNS_PER_TARGET 8
117#define IPR_VSET_BUS 0xff
118#define IPR_IOA_BUS 0xff
119#define IPR_IOA_TARGET 0xff
120#define IPR_IOA_LUN 0xff
Brian Kingb5145d22006-08-02 14:57:36 -0500121#define IPR_MAX_NUM_BUSES 16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122#define IPR_MAX_BUS_TO_SCAN IPR_MAX_NUM_BUSES
123
124#define IPR_NUM_RESET_RELOAD_RETRIES 3
125
126/* We need resources for HCAMS, IOA reset, IOA bringdown, and ERP */
127#define IPR_NUM_INTERNAL_CMD_BLKS (IPR_NUM_HCAMS + \
128 ((IPR_NUM_RESET_RELOAD_RETRIES + 1) * 2) + 3)
129
130#define IPR_MAX_COMMANDS IPR_NUM_BASE_CMD_BLKS
131#define IPR_NUM_CMD_BLKS (IPR_NUM_BASE_CMD_BLKS + \
132 IPR_NUM_INTERNAL_CMD_BLKS)
133
134#define IPR_MAX_PHYSICAL_DEVS 192
135
136#define IPR_MAX_SGLIST 64
137#define IPR_IOA_MAX_SECTORS 32767
138#define IPR_VSET_MAX_SECTORS 512
139#define IPR_MAX_CDB_LEN 16
140
141#define IPR_DEFAULT_BUS_WIDTH 16
142#define IPR_80MBs_SCSI_RATE ((80 * 10) / (IPR_DEFAULT_BUS_WIDTH / 8))
143#define IPR_U160_SCSI_RATE ((160 * 10) / (IPR_DEFAULT_BUS_WIDTH / 8))
144#define IPR_U320_SCSI_RATE ((320 * 10) / (IPR_DEFAULT_BUS_WIDTH / 8))
145#define IPR_MAX_SCSI_RATE(width) ((320 * 10) / ((width) / 8))
146
147#define IPR_IOA_RES_HANDLE 0xffffffff
Brian King1121b792006-03-29 09:37:16 -0600148#define IPR_INVALID_RES_HANDLE 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149#define IPR_IOA_RES_ADDR 0x00ffffff
150
151/*
152 * Adapter Commands
153 */
154#define IPR_QUERY_RSRC_STATE 0xC2
155#define IPR_RESET_DEVICE 0xC3
156#define IPR_RESET_TYPE_SELECT 0x80
157#define IPR_LUN_RESET 0x40
158#define IPR_TARGET_RESET 0x20
159#define IPR_BUS_RESET 0x10
Brian Kingb5145d22006-08-02 14:57:36 -0500160#define IPR_ATA_PHY_RESET 0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161#define IPR_ID_HOST_RR_Q 0xC4
162#define IPR_QUERY_IOA_CONFIG 0xC5
163#define IPR_CANCEL_ALL_REQUESTS 0xCE
164#define IPR_HOST_CONTROLLED_ASYNC 0xCF
165#define IPR_HCAM_CDB_OP_CODE_CONFIG_CHANGE 0x01
166#define IPR_HCAM_CDB_OP_CODE_LOG_DATA 0x02
167#define IPR_SET_SUPPORTED_DEVICES 0xFB
168#define IPR_IOA_SHUTDOWN 0xF7
169#define IPR_WR_BUF_DOWNLOAD_AND_SAVE 0x05
170
171/*
172 * Timeouts
173 */
174#define IPR_SHUTDOWN_TIMEOUT (ipr_fastfail ? 60 * HZ : 10 * 60 * HZ)
175#define IPR_VSET_RW_TIMEOUT (ipr_fastfail ? 30 * HZ : 2 * 60 * HZ)
176#define IPR_ABBREV_SHUTDOWN_TIMEOUT (10 * HZ)
177#define IPR_DEVICE_RESET_TIMEOUT (ipr_fastfail ? 10 * HZ : 30 * HZ)
178#define IPR_CANCEL_ALL_TIMEOUT (ipr_fastfail ? 10 * HZ : 30 * HZ)
179#define IPR_ABORT_TASK_TIMEOUT (ipr_fastfail ? 10 * HZ : 30 * HZ)
180#define IPR_INTERNAL_TIMEOUT (ipr_fastfail ? 10 * HZ : 30 * HZ)
181#define IPR_WRITE_BUFFER_TIMEOUT (10 * 60 * HZ)
182#define IPR_SET_SUP_DEVICE_TIMEOUT (2 * 60 * HZ)
183#define IPR_REQUEST_SENSE_TIMEOUT (10 * HZ)
184#define IPR_OPERATIONAL_TIMEOUT (5 * 60)
Brian King5469cb52007-03-29 12:42:40 -0500185#define IPR_LONG_OPERATIONAL_TIMEOUT (12 * 60)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186#define IPR_WAIT_FOR_RESET_TIMEOUT (2 * HZ)
187#define IPR_CHECK_FOR_RESET_TIMEOUT (HZ / 10)
188#define IPR_WAIT_FOR_BIST_TIMEOUT (2 * HZ)
189#define IPR_DUMP_TIMEOUT (15 * HZ)
190
191/*
192 * SCSI Literals
193 */
194#define IPR_VENDOR_ID_LEN 8
195#define IPR_PROD_ID_LEN 16
196#define IPR_SERIAL_NUM_LEN 8
197
198/*
199 * Hardware literals
200 */
201#define IPR_FMT2_MBX_ADDR_MASK 0x0fffffff
202#define IPR_FMT2_MBX_BAR_SEL_MASK 0xf0000000
203#define IPR_FMT2_MKR_BAR_SEL_SHIFT 28
204#define IPR_GET_FMT2_BAR_SEL(mbx) \
205(((mbx) & IPR_FMT2_MBX_BAR_SEL_MASK) >> IPR_FMT2_MKR_BAR_SEL_SHIFT)
206#define IPR_SDT_FMT2_BAR0_SEL 0x0
207#define IPR_SDT_FMT2_BAR1_SEL 0x1
208#define IPR_SDT_FMT2_BAR2_SEL 0x2
209#define IPR_SDT_FMT2_BAR3_SEL 0x3
210#define IPR_SDT_FMT2_BAR4_SEL 0x4
211#define IPR_SDT_FMT2_BAR5_SEL 0x5
212#define IPR_SDT_FMT2_EXP_ROM_SEL 0x8
213#define IPR_FMT2_SDT_READY_TO_USE 0xC4D4E3F2
214#define IPR_DOORBELL 0x82800000
brking@us.ibm.com3d1d0da2005-11-01 17:01:54 -0600215#define IPR_RUNTIME_RESET 0x40000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
217#define IPR_PCII_IOA_TRANS_TO_OPER (0x80000000 >> 0)
218#define IPR_PCII_IOARCB_XFER_FAILED (0x80000000 >> 3)
219#define IPR_PCII_IOA_UNIT_CHECKED (0x80000000 >> 4)
220#define IPR_PCII_NO_HOST_RRQ (0x80000000 >> 5)
221#define IPR_PCII_CRITICAL_OPERATION (0x80000000 >> 6)
222#define IPR_PCII_IO_DEBUG_ACKNOWLEDGE (0x80000000 >> 7)
223#define IPR_PCII_IOARRIN_LOST (0x80000000 >> 27)
224#define IPR_PCII_MMIO_ERROR (0x80000000 >> 28)
225#define IPR_PCII_PROC_ERR_STATE (0x80000000 >> 29)
226#define IPR_PCII_HRRQ_UPDATED (0x80000000 >> 30)
227#define IPR_PCII_CORE_ISSUED_RST_REQ (0x80000000 >> 31)
228
229#define IPR_PCII_ERROR_INTERRUPTS \
230(IPR_PCII_IOARCB_XFER_FAILED | IPR_PCII_IOA_UNIT_CHECKED | \
231IPR_PCII_NO_HOST_RRQ | IPR_PCII_IOARRIN_LOST | IPR_PCII_MMIO_ERROR)
232
233#define IPR_PCII_OPER_INTERRUPTS \
234(IPR_PCII_ERROR_INTERRUPTS | IPR_PCII_HRRQ_UPDATED | IPR_PCII_IOA_TRANS_TO_OPER)
235
236#define IPR_UPROCI_RESET_ALERT (0x80000000 >> 7)
237#define IPR_UPROCI_IO_DEBUG_ALERT (0x80000000 >> 9)
238
239#define IPR_LDUMP_MAX_LONG_ACK_DELAY_IN_USEC 200000 /* 200 ms */
240#define IPR_LDUMP_MAX_SHORT_ACK_DELAY_IN_USEC 200000 /* 200 ms */
241
242/*
243 * Dump literals
244 */
245#define IPR_MAX_IOA_DUMP_SIZE (4 * 1024 * 1024)
246#define IPR_NUM_SDT_ENTRIES 511
247#define IPR_MAX_NUM_DUMP_PAGES ((IPR_MAX_IOA_DUMP_SIZE / PAGE_SIZE) + 1)
248
249/*
250 * Misc literals
251 */
252#define IPR_NUM_IOADL_ENTRIES IPR_MAX_SGLIST
253
254/*
255 * Adapter interface types
256 */
257
258struct ipr_res_addr {
259 u8 reserved;
260 u8 bus;
261 u8 target;
262 u8 lun;
263#define IPR_GET_PHYS_LOC(res_addr) \
264 (((res_addr).bus << 16) | ((res_addr).target << 8) | (res_addr).lun)
265}__attribute__((packed, aligned (4)));
266
267struct ipr_std_inq_vpids {
268 u8 vendor_id[IPR_VENDOR_ID_LEN];
269 u8 product_id[IPR_PROD_ID_LEN];
270}__attribute__((packed));
271
brking@us.ibm.comcfc32132005-11-01 17:00:18 -0600272struct ipr_vpd {
273 struct ipr_std_inq_vpids vpids;
274 u8 sn[IPR_SERIAL_NUM_LEN];
275}__attribute__((packed));
276
brking@us.ibm.comee0f05b2005-11-01 17:02:15 -0600277struct ipr_ext_vpd {
278 struct ipr_vpd vpd;
279 __be32 wwid[2];
280}__attribute__((packed));
281
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282struct ipr_std_inq_data {
283 u8 peri_qual_dev_type;
284#define IPR_STD_INQ_PERI_QUAL(peri) ((peri) >> 5)
285#define IPR_STD_INQ_PERI_DEV_TYPE(peri) ((peri) & 0x1F)
286
287 u8 removeable_medium_rsvd;
288#define IPR_STD_INQ_REMOVEABLE_MEDIUM 0x80
289
290#define IPR_IS_DASD_DEVICE(std_inq) \
291((IPR_STD_INQ_PERI_DEV_TYPE((std_inq).peri_qual_dev_type) == TYPE_DISK) && \
292!(((std_inq).removeable_medium_rsvd) & IPR_STD_INQ_REMOVEABLE_MEDIUM))
293
294#define IPR_IS_SES_DEVICE(std_inq) \
295(IPR_STD_INQ_PERI_DEV_TYPE((std_inq).peri_qual_dev_type) == TYPE_ENCLOSURE)
296
297 u8 version;
298 u8 aen_naca_fmt;
299 u8 additional_len;
300 u8 sccs_rsvd;
301 u8 bq_enc_multi;
302 u8 sync_cmdq_flags;
303
304 struct ipr_std_inq_vpids vpids;
305
306 u8 ros_rsvd_ram_rsvd[4];
307
308 u8 serial_num[IPR_SERIAL_NUM_LEN];
309}__attribute__ ((packed));
310
311struct ipr_config_table_entry {
Brian Kingb5145d22006-08-02 14:57:36 -0500312 u8 proto;
313#define IPR_PROTO_SATA 0x02
314#define IPR_PROTO_SATA_ATAPI 0x03
315#define IPR_PROTO_SAS_STP 0x06
316#define IPR_PROTO_SAS_STP_ATAPI 0x07
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 u8 array_id;
318 u8 flags;
319#define IPR_IS_IOA_RESOURCE 0x80
320#define IPR_IS_ARRAY_MEMBER 0x20
321#define IPR_IS_HOT_SPARE 0x10
322
323 u8 rsvd_subtype;
324#define IPR_RES_SUBTYPE(res) (((res)->cfgte.rsvd_subtype) & 0x0f)
325#define IPR_SUBTYPE_AF_DASD 0
326#define IPR_SUBTYPE_GENERIC_SCSI 1
327#define IPR_SUBTYPE_VOLUME_SET 2
Brian Kingb5145d22006-08-02 14:57:36 -0500328#define IPR_SUBTYPE_GENERIC_ATA 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
brking@us.ibm.comee0a90f2005-11-01 17:02:22 -0600330#define IPR_QUEUEING_MODEL(res) ((((res)->cfgte.flags) & 0x70) >> 4)
331#define IPR_QUEUE_FROZEN_MODEL 0
332#define IPR_QUEUE_NACA_MODEL 1
333
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 struct ipr_res_addr res_addr;
335 __be32 res_handle;
336 __be32 reserved4[2];
337 struct ipr_std_inq_data std_inq_data;
338}__attribute__ ((packed, aligned (4)));
339
340struct ipr_config_table_hdr {
341 u8 num_entries;
342 u8 flags;
343#define IPR_UCODE_DOWNLOAD_REQ 0x10
344 __be16 reserved;
345}__attribute__((packed, aligned (4)));
346
347struct ipr_config_table {
348 struct ipr_config_table_hdr hdr;
349 struct ipr_config_table_entry dev[IPR_MAX_PHYSICAL_DEVS];
350}__attribute__((packed, aligned (4)));
351
352struct ipr_hostrcb_cfg_ch_not {
353 struct ipr_config_table_entry cfgte;
354 u8 reserved[936];
355}__attribute__((packed, aligned (4)));
356
357struct ipr_supported_device {
358 __be16 data_length;
359 u8 reserved;
360 u8 num_records;
361 struct ipr_std_inq_vpids vpids;
362 u8 reserved2[16];
363}__attribute__((packed, aligned (4)));
364
365/* Command packet structure */
366struct ipr_cmd_pkt {
367 __be16 reserved; /* Reserved by IOA */
368 u8 request_type;
369#define IPR_RQTYPE_SCSICDB 0x00
370#define IPR_RQTYPE_IOACMD 0x01
371#define IPR_RQTYPE_HCAM 0x02
Brian Kingb5145d22006-08-02 14:57:36 -0500372#define IPR_RQTYPE_ATA_PASSTHRU 0x04
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373
374 u8 luntar_luntrn;
375
376 u8 flags_hi;
377#define IPR_FLAGS_HI_WRITE_NOT_READ 0x80
378#define IPR_FLAGS_HI_NO_ULEN_CHK 0x20
379#define IPR_FLAGS_HI_SYNC_OVERRIDE 0x10
380#define IPR_FLAGS_HI_SYNC_COMPLETE 0x08
381#define IPR_FLAGS_HI_NO_LINK_DESC 0x04
382
383 u8 flags_lo;
384#define IPR_FLAGS_LO_ALIGNED_BFR 0x20
385#define IPR_FLAGS_LO_DELAY_AFTER_RST 0x10
386#define IPR_FLAGS_LO_UNTAGGED_TASK 0x00
387#define IPR_FLAGS_LO_SIMPLE_TASK 0x02
388#define IPR_FLAGS_LO_ORDERED_TASK 0x04
389#define IPR_FLAGS_LO_HEAD_OF_Q_TASK 0x06
390#define IPR_FLAGS_LO_ACA_TASK 0x08
391
392 u8 cdb[16];
393 __be16 timeout;
394}__attribute__ ((packed, aligned(4)));
395
Brian Kingb5145d22006-08-02 14:57:36 -0500396struct ipr_ioarcb_ata_regs {
397 u8 flags;
398#define IPR_ATA_FLAG_PACKET_CMD 0x80
399#define IPR_ATA_FLAG_XFER_TYPE_DMA 0x40
400#define IPR_ATA_FLAG_STATUS_ON_GOOD_COMPLETION 0x20
401 u8 reserved[3];
402
403 __be16 data;
404 u8 feature;
405 u8 nsect;
406 u8 lbal;
407 u8 lbam;
408 u8 lbah;
409 u8 device;
410 u8 command;
411 u8 reserved2[3];
412 u8 hob_feature;
413 u8 hob_nsect;
414 u8 hob_lbal;
415 u8 hob_lbam;
416 u8 hob_lbah;
417 u8 ctl;
418}__attribute__ ((packed, aligned(4)));
419
420struct ipr_ioarcb_add_data {
421 union {
422 struct ipr_ioarcb_ata_regs regs;
423 __be32 add_cmd_parms[10];
424 }u;
425}__attribute__ ((packed, aligned(4)));
426
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427/* IOA Request Control Block 128 bytes */
428struct ipr_ioarcb {
429 __be32 ioarcb_host_pci_addr;
430 __be32 reserved;
431 __be32 res_handle;
432 __be32 host_response_handle;
433 __be32 reserved1;
434 __be32 reserved2;
435 __be32 reserved3;
436
437 __be32 write_data_transfer_length;
438 __be32 read_data_transfer_length;
439 __be32 write_ioadl_addr;
440 __be32 write_ioadl_len;
441 __be32 read_ioadl_addr;
442 __be32 read_ioadl_len;
443
444 __be32 ioasa_host_pci_addr;
445 __be16 ioasa_len;
446 __be16 reserved4;
447
448 struct ipr_cmd_pkt cmd_pkt;
449
450 __be32 add_cmd_parms_len;
Brian Kingb5145d22006-08-02 14:57:36 -0500451 struct ipr_ioarcb_add_data add_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452}__attribute__((packed, aligned (4)));
453
454struct ipr_ioadl_desc {
455 __be32 flags_and_data_len;
456#define IPR_IOADL_FLAGS_MASK 0xff000000
457#define IPR_IOADL_GET_FLAGS(x) (be32_to_cpu(x) & IPR_IOADL_FLAGS_MASK)
458#define IPR_IOADL_DATA_LEN_MASK 0x00ffffff
459#define IPR_IOADL_GET_DATA_LEN(x) (be32_to_cpu(x) & IPR_IOADL_DATA_LEN_MASK)
460#define IPR_IOADL_FLAGS_READ 0x48000000
461#define IPR_IOADL_FLAGS_READ_LAST 0x49000000
462#define IPR_IOADL_FLAGS_WRITE 0x68000000
463#define IPR_IOADL_FLAGS_WRITE_LAST 0x69000000
464#define IPR_IOADL_FLAGS_LAST 0x01000000
465
466 __be32 address;
467}__attribute__((packed, aligned (8)));
468
469struct ipr_ioasa_vset {
470 __be32 failing_lba_hi;
471 __be32 failing_lba_lo;
brking@us.ibm.comc8f74892005-11-01 17:02:08 -0600472 __be32 reserved;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473}__attribute__((packed, aligned (4)));
474
475struct ipr_ioasa_af_dasd {
476 __be32 failing_lba;
brking@us.ibm.comc8f74892005-11-01 17:02:08 -0600477 __be32 reserved[2];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478}__attribute__((packed, aligned (4)));
479
480struct ipr_ioasa_gpdd {
481 u8 end_state;
482 u8 bus_phase;
483 __be16 reserved;
brking@us.ibm.comc8f74892005-11-01 17:02:08 -0600484 __be32 ioa_data[2];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485}__attribute__((packed, aligned (4)));
486
Brian Kingb5145d22006-08-02 14:57:36 -0500487struct ipr_ioasa_gata {
488 u8 error;
489 u8 nsect; /* Interrupt reason */
490 u8 lbal;
491 u8 lbam;
492 u8 lbah;
493 u8 device;
494 u8 status;
495 u8 alt_status; /* ATA CTL */
496 u8 hob_nsect;
497 u8 hob_lbal;
498 u8 hob_lbam;
499 u8 hob_lbah;
500}__attribute__((packed, aligned (4)));
501
brking@us.ibm.comc8f74892005-11-01 17:02:08 -0600502struct ipr_auto_sense {
503 __be16 auto_sense_len;
504 __be16 ioa_data_len;
505 __be32 data[SCSI_SENSE_BUFFERSIZE/sizeof(__be32)];
506};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507
508struct ipr_ioasa {
509 __be32 ioasc;
510#define IPR_IOASC_SENSE_KEY(ioasc) ((ioasc) >> 24)
511#define IPR_IOASC_SENSE_CODE(ioasc) (((ioasc) & 0x00ff0000) >> 16)
512#define IPR_IOASC_SENSE_QUAL(ioasc) (((ioasc) & 0x0000ff00) >> 8)
513#define IPR_IOASC_SENSE_STATUS(ioasc) ((ioasc) & 0x000000ff)
514
515 __be16 ret_stat_len; /* Length of the returned IOASA */
516
517 __be16 avail_stat_len; /* Total Length of status available. */
518
519 __be32 residual_data_len; /* number of bytes in the host data */
520 /* buffers that were not used by the IOARCB command. */
521
522 __be32 ilid;
523#define IPR_NO_ILID 0
524#define IPR_DRIVER_ILID 0xffffffff
525
526 __be32 fd_ioasc;
527
528 __be32 fd_phys_locator;
529
530 __be32 fd_res_handle;
531
532 __be32 ioasc_specific; /* status code specific field */
brking@us.ibm.comc8f74892005-11-01 17:02:08 -0600533#define IPR_ADDITIONAL_STATUS_FMT 0x80000000
534#define IPR_AUTOSENSE_VALID 0x40000000
Brian Kingb5145d22006-08-02 14:57:36 -0500535#define IPR_ATA_DEVICE_WAS_RESET 0x20000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536#define IPR_IOASC_SPECIFIC_MASK 0x00ffffff
537#define IPR_FIELD_POINTER_VALID (0x80000000 >> 8)
538#define IPR_FIELD_POINTER_MASK 0x0000ffff
539
540 union {
541 struct ipr_ioasa_vset vset;
542 struct ipr_ioasa_af_dasd dasd;
543 struct ipr_ioasa_gpdd gpdd;
Brian Kingb5145d22006-08-02 14:57:36 -0500544 struct ipr_ioasa_gata gata;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 } u;
brking@us.ibm.comc8f74892005-11-01 17:02:08 -0600546
547 struct ipr_auto_sense auto_sense;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548}__attribute__((packed, aligned (4)));
549
550struct ipr_mode_parm_hdr {
551 u8 length;
552 u8 medium_type;
553 u8 device_spec_parms;
554 u8 block_desc_len;
555}__attribute__((packed));
556
557struct ipr_mode_pages {
558 struct ipr_mode_parm_hdr hdr;
559 u8 data[255 - sizeof(struct ipr_mode_parm_hdr)];
560}__attribute__((packed));
561
562struct ipr_mode_page_hdr {
563 u8 ps_page_code;
564#define IPR_MODE_PAGE_PS 0x80
565#define IPR_GET_MODE_PAGE_CODE(hdr) ((hdr)->ps_page_code & 0x3F)
566 u8 page_length;
567}__attribute__ ((packed));
568
569struct ipr_dev_bus_entry {
570 struct ipr_res_addr res_addr;
571 u8 flags;
572#define IPR_SCSI_ATTR_ENABLE_QAS 0x80
573#define IPR_SCSI_ATTR_DISABLE_QAS 0x40
574#define IPR_SCSI_ATTR_QAS_MASK 0xC0
575#define IPR_SCSI_ATTR_ENABLE_TM 0x20
576#define IPR_SCSI_ATTR_NO_TERM_PWR 0x10
577#define IPR_SCSI_ATTR_TM_SUPPORTED 0x08
578#define IPR_SCSI_ATTR_LVD_TO_SE_NOT_ALLOWED 0x04
579
580 u8 scsi_id;
581 u8 bus_width;
582 u8 extended_reset_delay;
583#define IPR_EXTENDED_RESET_DELAY 7
584
585 __be32 max_xfer_rate;
586
587 u8 spinup_delay;
588 u8 reserved3;
589 __be16 reserved4;
590}__attribute__((packed, aligned (4)));
591
592struct ipr_mode_page28 {
593 struct ipr_mode_page_hdr hdr;
594 u8 num_entries;
595 u8 entry_length;
596 struct ipr_dev_bus_entry bus[0];
597}__attribute__((packed));
598
599struct ipr_ioa_vpd {
600 struct ipr_std_inq_data std_inq_data;
601 u8 ascii_part_num[12];
602 u8 reserved[40];
603 u8 ascii_plant_code[4];
604}__attribute__((packed));
605
606struct ipr_inquiry_page3 {
607 u8 peri_qual_dev_type;
608 u8 page_code;
609 u8 reserved1;
610 u8 page_length;
611 u8 ascii_len;
612 u8 reserved2[3];
613 u8 load_id[4];
614 u8 major_release;
615 u8 card_type;
616 u8 minor_release[2];
617 u8 ptf_number[4];
618 u8 patch_number[4];
619}__attribute__((packed));
620
brking@us.ibm.com62275042005-11-01 17:01:14 -0600621#define IPR_INQUIRY_PAGE0_ENTRIES 20
622struct ipr_inquiry_page0 {
623 u8 peri_qual_dev_type;
624 u8 page_code;
625 u8 reserved1;
626 u8 len;
627 u8 page[IPR_INQUIRY_PAGE0_ENTRIES];
628}__attribute__((packed));
629
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630struct ipr_hostrcb_device_data_entry {
brking@us.ibm.comcfc32132005-11-01 17:00:18 -0600631 struct ipr_vpd vpd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 struct ipr_res_addr dev_res_addr;
brking@us.ibm.comcfc32132005-11-01 17:00:18 -0600633 struct ipr_vpd new_vpd;
634 struct ipr_vpd ioa_last_with_dev_vpd;
635 struct ipr_vpd cfc_last_with_dev_vpd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 __be32 ioa_data[5];
637}__attribute__((packed, aligned (4)));
638
brking@us.ibm.comee0f05b2005-11-01 17:02:15 -0600639struct ipr_hostrcb_device_data_entry_enhanced {
640 struct ipr_ext_vpd vpd;
641 u8 ccin[4];
642 struct ipr_res_addr dev_res_addr;
643 struct ipr_ext_vpd new_vpd;
644 u8 new_ccin[4];
645 struct ipr_ext_vpd ioa_last_with_dev_vpd;
646 struct ipr_ext_vpd cfc_last_with_dev_vpd;
647}__attribute__((packed, aligned (4)));
648
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649struct ipr_hostrcb_array_data_entry {
brking@us.ibm.comcfc32132005-11-01 17:00:18 -0600650 struct ipr_vpd vpd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 struct ipr_res_addr expected_dev_res_addr;
652 struct ipr_res_addr dev_res_addr;
653}__attribute__((packed, aligned (4)));
654
brking@us.ibm.comee0f05b2005-11-01 17:02:15 -0600655struct ipr_hostrcb_array_data_entry_enhanced {
656 struct ipr_ext_vpd vpd;
657 u8 ccin[4];
658 struct ipr_res_addr expected_dev_res_addr;
659 struct ipr_res_addr dev_res_addr;
660}__attribute__((packed, aligned (4)));
661
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662struct ipr_hostrcb_type_ff_error {
brking@us.ibm.comee0f05b2005-11-01 17:02:15 -0600663 __be32 ioa_data[502];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664}__attribute__((packed, aligned (4)));
665
666struct ipr_hostrcb_type_01_error {
667 __be32 seek_counter;
668 __be32 read_counter;
669 u8 sense_data[32];
670 __be32 ioa_data[236];
671}__attribute__((packed, aligned (4)));
672
673struct ipr_hostrcb_type_02_error {
brking@us.ibm.comcfc32132005-11-01 17:00:18 -0600674 struct ipr_vpd ioa_vpd;
675 struct ipr_vpd cfc_vpd;
676 struct ipr_vpd ioa_last_attached_to_cfc_vpd;
677 struct ipr_vpd cfc_last_attached_to_ioa_vpd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 __be32 ioa_data[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679}__attribute__((packed, aligned (4)));
680
brking@us.ibm.comee0f05b2005-11-01 17:02:15 -0600681struct ipr_hostrcb_type_12_error {
682 struct ipr_ext_vpd ioa_vpd;
683 struct ipr_ext_vpd cfc_vpd;
684 struct ipr_ext_vpd ioa_last_attached_to_cfc_vpd;
685 struct ipr_ext_vpd cfc_last_attached_to_ioa_vpd;
686 __be32 ioa_data[3];
687}__attribute__((packed, aligned (4)));
688
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689struct ipr_hostrcb_type_03_error {
brking@us.ibm.comcfc32132005-11-01 17:00:18 -0600690 struct ipr_vpd ioa_vpd;
691 struct ipr_vpd cfc_vpd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 __be32 errors_detected;
693 __be32 errors_logged;
694 u8 ioa_data[12];
brking@us.ibm.comcfc32132005-11-01 17:00:18 -0600695 struct ipr_hostrcb_device_data_entry dev[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696}__attribute__((packed, aligned (4)));
697
brking@us.ibm.comee0f05b2005-11-01 17:02:15 -0600698struct ipr_hostrcb_type_13_error {
699 struct ipr_ext_vpd ioa_vpd;
700 struct ipr_ext_vpd cfc_vpd;
701 __be32 errors_detected;
702 __be32 errors_logged;
703 struct ipr_hostrcb_device_data_entry_enhanced dev[3];
704}__attribute__((packed, aligned (4)));
705
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706struct ipr_hostrcb_type_04_error {
brking@us.ibm.comcfc32132005-11-01 17:00:18 -0600707 struct ipr_vpd ioa_vpd;
708 struct ipr_vpd cfc_vpd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 u8 ioa_data[12];
710 struct ipr_hostrcb_array_data_entry array_member[10];
711 __be32 exposed_mode_adn;
712 __be32 array_id;
brking@us.ibm.comcfc32132005-11-01 17:00:18 -0600713 struct ipr_vpd incomp_dev_vpd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 __be32 ioa_data2;
715 struct ipr_hostrcb_array_data_entry array_member2[8];
716 struct ipr_res_addr last_func_vset_res_addr;
717 u8 vset_serial_num[IPR_SERIAL_NUM_LEN];
718 u8 protection_level[8];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719}__attribute__((packed, aligned (4)));
720
brking@us.ibm.comee0f05b2005-11-01 17:02:15 -0600721struct ipr_hostrcb_type_14_error {
722 struct ipr_ext_vpd ioa_vpd;
723 struct ipr_ext_vpd cfc_vpd;
724 __be32 exposed_mode_adn;
725 __be32 array_id;
726 struct ipr_res_addr last_func_vset_res_addr;
727 u8 vset_serial_num[IPR_SERIAL_NUM_LEN];
728 u8 protection_level[8];
729 __be32 num_entries;
730 struct ipr_hostrcb_array_data_entry_enhanced array_member[18];
731}__attribute__((packed, aligned (4)));
732
brking@us.ibm.comb0df54b2005-11-01 17:01:47 -0600733struct ipr_hostrcb_type_07_error {
734 u8 failure_reason[64];
735 struct ipr_vpd vpd;
736 u32 data[222];
737}__attribute__((packed, aligned (4)));
738
brking@us.ibm.comee0f05b2005-11-01 17:02:15 -0600739struct ipr_hostrcb_type_17_error {
740 u8 failure_reason[64];
741 struct ipr_ext_vpd vpd;
742 u32 data[476];
743}__attribute__((packed, aligned (4)));
744
Brian King49dc6a12006-11-21 10:28:35 -0600745struct ipr_hostrcb_config_element {
746 u8 type_status;
747#define IPR_PATH_CFG_TYPE_MASK 0xF0
748#define IPR_PATH_CFG_NOT_EXIST 0x00
749#define IPR_PATH_CFG_IOA_PORT 0x10
750#define IPR_PATH_CFG_EXP_PORT 0x20
751#define IPR_PATH_CFG_DEVICE_PORT 0x30
752#define IPR_PATH_CFG_DEVICE_LUN 0x40
753
754#define IPR_PATH_CFG_STATUS_MASK 0x0F
755#define IPR_PATH_CFG_NO_PROB 0x00
756#define IPR_PATH_CFG_DEGRADED 0x01
757#define IPR_PATH_CFG_FAILED 0x02
758#define IPR_PATH_CFG_SUSPECT 0x03
759#define IPR_PATH_NOT_DETECTED 0x04
760#define IPR_PATH_INCORRECT_CONN 0x05
761
762 u8 cascaded_expander;
763 u8 phy;
764 u8 link_rate;
765#define IPR_PHY_LINK_RATE_MASK 0x0F
766
767 __be32 wwid[2];
768}__attribute__((packed, aligned (4)));
769
770struct ipr_hostrcb_fabric_desc {
771 __be16 length;
772 u8 ioa_port;
773 u8 cascaded_expander;
774 u8 phy;
775 u8 path_state;
776#define IPR_PATH_ACTIVE_MASK 0xC0
777#define IPR_PATH_NO_INFO 0x00
778#define IPR_PATH_ACTIVE 0x40
779#define IPR_PATH_NOT_ACTIVE 0x80
780
781#define IPR_PATH_STATE_MASK 0x0F
782#define IPR_PATH_STATE_NO_INFO 0x00
783#define IPR_PATH_HEALTHY 0x01
784#define IPR_PATH_DEGRADED 0x02
785#define IPR_PATH_FAILED 0x03
786
787 __be16 num_entries;
788 struct ipr_hostrcb_config_element elem[1];
789}__attribute__((packed, aligned (4)));
790
791#define for_each_fabric_cfg(fabric, cfg) \
792 for (cfg = (fabric)->elem; \
793 cfg < ((fabric)->elem + be16_to_cpu((fabric)->num_entries)); \
794 cfg++)
795
796struct ipr_hostrcb_type_20_error {
797 u8 failure_reason[64];
798 u8 reserved[3];
799 u8 num_entries;
800 struct ipr_hostrcb_fabric_desc desc[1];
801}__attribute__((packed, aligned (4)));
802
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803struct ipr_hostrcb_error {
804 __be32 failing_dev_ioasc;
805 struct ipr_res_addr failing_dev_res_addr;
806 __be32 failing_dev_res_handle;
807 __be32 prc;
808 union {
809 struct ipr_hostrcb_type_ff_error type_ff_error;
810 struct ipr_hostrcb_type_01_error type_01_error;
811 struct ipr_hostrcb_type_02_error type_02_error;
812 struct ipr_hostrcb_type_03_error type_03_error;
813 struct ipr_hostrcb_type_04_error type_04_error;
brking@us.ibm.comb0df54b2005-11-01 17:01:47 -0600814 struct ipr_hostrcb_type_07_error type_07_error;
brking@us.ibm.comee0f05b2005-11-01 17:02:15 -0600815 struct ipr_hostrcb_type_12_error type_12_error;
816 struct ipr_hostrcb_type_13_error type_13_error;
817 struct ipr_hostrcb_type_14_error type_14_error;
818 struct ipr_hostrcb_type_17_error type_17_error;
Brian King49dc6a12006-11-21 10:28:35 -0600819 struct ipr_hostrcb_type_20_error type_20_error;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 } u;
821}__attribute__((packed, aligned (4)));
822
823struct ipr_hostrcb_raw {
824 __be32 data[sizeof(struct ipr_hostrcb_error)/sizeof(__be32)];
825}__attribute__((packed, aligned (4)));
826
827struct ipr_hcam {
828 u8 op_code;
829#define IPR_HOST_RCB_OP_CODE_CONFIG_CHANGE 0xE1
830#define IPR_HOST_RCB_OP_CODE_LOG_DATA 0xE2
831
832 u8 notify_type;
833#define IPR_HOST_RCB_NOTIF_TYPE_EXISTING_CHANGED 0x00
834#define IPR_HOST_RCB_NOTIF_TYPE_NEW_ENTRY 0x01
835#define IPR_HOST_RCB_NOTIF_TYPE_REM_ENTRY 0x02
836#define IPR_HOST_RCB_NOTIF_TYPE_ERROR_LOG_ENTRY 0x10
837#define IPR_HOST_RCB_NOTIF_TYPE_INFORMATION_ENTRY 0x11
838
839 u8 notifications_lost;
840#define IPR_HOST_RCB_NO_NOTIFICATIONS_LOST 0
841#define IPR_HOST_RCB_NOTIFICATIONS_LOST 0x80
842
843 u8 flags;
844#define IPR_HOSTRCB_INTERNAL_OPER 0x80
845#define IPR_HOSTRCB_ERR_RESP_SENT 0x40
846
847 u8 overlay_id;
848#define IPR_HOST_RCB_OVERLAY_ID_1 0x01
849#define IPR_HOST_RCB_OVERLAY_ID_2 0x02
850#define IPR_HOST_RCB_OVERLAY_ID_3 0x03
851#define IPR_HOST_RCB_OVERLAY_ID_4 0x04
852#define IPR_HOST_RCB_OVERLAY_ID_6 0x06
brking@us.ibm.comb0df54b2005-11-01 17:01:47 -0600853#define IPR_HOST_RCB_OVERLAY_ID_7 0x07
brking@us.ibm.comee0f05b2005-11-01 17:02:15 -0600854#define IPR_HOST_RCB_OVERLAY_ID_12 0x12
855#define IPR_HOST_RCB_OVERLAY_ID_13 0x13
856#define IPR_HOST_RCB_OVERLAY_ID_14 0x14
857#define IPR_HOST_RCB_OVERLAY_ID_16 0x16
858#define IPR_HOST_RCB_OVERLAY_ID_17 0x17
Brian King49dc6a12006-11-21 10:28:35 -0600859#define IPR_HOST_RCB_OVERLAY_ID_20 0x20
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860#define IPR_HOST_RCB_OVERLAY_ID_DEFAULT 0xFF
861
862 u8 reserved1[3];
863 __be32 ilid;
864 __be32 time_since_last_ioa_reset;
865 __be32 reserved2;
866 __be32 length;
867
868 union {
869 struct ipr_hostrcb_error error;
870 struct ipr_hostrcb_cfg_ch_not ccn;
871 struct ipr_hostrcb_raw raw;
872 } u;
873}__attribute__((packed, aligned (4)));
874
875struct ipr_hostrcb {
876 struct ipr_hcam hcam;
877 dma_addr_t hostrcb_dma;
878 struct list_head queue;
Brian King49dc6a12006-11-21 10:28:35 -0600879 struct ipr_ioa_cfg *ioa_cfg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880};
881
882/* IPR smart dump table structures */
883struct ipr_sdt_entry {
884 __be32 bar_str_offset;
885 __be32 end_offset;
886 u8 entry_byte;
887 u8 reserved[3];
888
889 u8 flags;
890#define IPR_SDT_ENDIAN 0x80
891#define IPR_SDT_VALID_ENTRY 0x20
892
893 u8 resv;
894 __be16 priority;
895}__attribute__((packed, aligned (4)));
896
897struct ipr_sdt_header {
898 __be32 state;
899 __be32 num_entries;
900 __be32 num_entries_used;
901 __be32 dump_size;
902}__attribute__((packed, aligned (4)));
903
904struct ipr_sdt {
905 struct ipr_sdt_header hdr;
906 struct ipr_sdt_entry entry[IPR_NUM_SDT_ENTRIES];
907}__attribute__((packed, aligned (4)));
908
909struct ipr_uc_sdt {
910 struct ipr_sdt_header hdr;
911 struct ipr_sdt_entry entry[1];
912}__attribute__((packed, aligned (4)));
913
914/*
915 * Driver types
916 */
917struct ipr_bus_attributes {
918 u8 bus;
919 u8 qas_enabled;
920 u8 bus_width;
921 u8 reserved;
922 u32 max_xfer_rate;
923};
924
Brian King35a39692006-09-25 12:39:20 -0500925struct ipr_sata_port {
926 struct ipr_ioa_cfg *ioa_cfg;
927 struct ata_port *ap;
928 struct ipr_resource_entry *res;
929 struct ipr_ioasa_gata ioasa;
930};
931
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932struct ipr_resource_entry {
933 struct ipr_config_table_entry cfgte;
934 u8 needs_sync_complete:1;
935 u8 in_erp:1;
936 u8 add_to_ml:1;
937 u8 del_from_ml:1;
938 u8 resetting_device:1;
939
940 struct scsi_device *sdev;
Brian King35a39692006-09-25 12:39:20 -0500941 struct ipr_sata_port *sata_port;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942 struct list_head queue;
943};
944
945struct ipr_resource_hdr {
946 u16 num_entries;
947 u16 reserved;
948};
949
950struct ipr_resource_table {
951 struct ipr_resource_hdr hdr;
952 struct ipr_resource_entry dev[IPR_MAX_PHYSICAL_DEVS];
953};
954
955struct ipr_misc_cbs {
956 struct ipr_ioa_vpd ioa_vpd;
brking@us.ibm.com62275042005-11-01 17:01:14 -0600957 struct ipr_inquiry_page0 page0_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958 struct ipr_inquiry_page3 page3_data;
959 struct ipr_mode_pages mode_pages;
960 struct ipr_supported_device supp_dev;
961};
962
963struct ipr_interrupt_offsets {
964 unsigned long set_interrupt_mask_reg;
965 unsigned long clr_interrupt_mask_reg;
966 unsigned long sense_interrupt_mask_reg;
967 unsigned long clr_interrupt_reg;
968
969 unsigned long sense_interrupt_reg;
970 unsigned long ioarrin_reg;
971 unsigned long sense_uproc_interrupt_reg;
972 unsigned long set_uproc_interrupt_reg;
973 unsigned long clr_uproc_interrupt_reg;
974};
975
976struct ipr_interrupts {
977 void __iomem *set_interrupt_mask_reg;
978 void __iomem *clr_interrupt_mask_reg;
979 void __iomem *sense_interrupt_mask_reg;
980 void __iomem *clr_interrupt_reg;
981
982 void __iomem *sense_interrupt_reg;
983 void __iomem *ioarrin_reg;
984 void __iomem *sense_uproc_interrupt_reg;
985 void __iomem *set_uproc_interrupt_reg;
986 void __iomem *clr_uproc_interrupt_reg;
987};
988
989struct ipr_chip_cfg_t {
990 u32 mailbox;
991 u8 cache_line_size;
992 struct ipr_interrupt_offsets regs;
993};
994
995struct ipr_chip_t {
996 u16 vendor;
997 u16 device;
998 const struct ipr_chip_cfg_t *cfg;
999};
1000
1001enum ipr_shutdown_type {
1002 IPR_SHUTDOWN_NORMAL = 0x00,
1003 IPR_SHUTDOWN_PREPARE_FOR_NORMAL = 0x40,
1004 IPR_SHUTDOWN_ABBREV = 0x80,
1005 IPR_SHUTDOWN_NONE = 0x100
1006};
1007
1008struct ipr_trace_entry {
1009 u32 time;
1010
1011 u8 op_code;
Brian King35a39692006-09-25 12:39:20 -05001012 u8 ata_op_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013 u8 type;
1014#define IPR_TRACE_START 0x00
1015#define IPR_TRACE_FINISH 0xff
Brian King35a39692006-09-25 12:39:20 -05001016 u8 cmd_index;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017
1018 __be32 res_handle;
1019 union {
1020 u32 ioasc;
1021 u32 add_data;
1022 u32 res_addr;
1023 } u;
1024};
1025
1026struct ipr_sglist {
1027 u32 order;
1028 u32 num_sg;
brking@us.ibm.com12baa422005-11-01 17:01:27 -06001029 u32 num_dma_sg;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001030 u32 buffer_len;
1031 struct scatterlist scatterlist[1];
1032};
1033
1034enum ipr_sdt_state {
1035 INACTIVE,
1036 WAIT_FOR_DUMP,
1037 GET_DUMP,
1038 ABORT_DUMP,
1039 DUMP_OBTAINED
1040};
1041
brking@us.ibm.com62275042005-11-01 17:01:14 -06001042enum ipr_cache_state {
1043 CACHE_NONE,
1044 CACHE_DISABLED,
1045 CACHE_ENABLED,
1046 CACHE_INVALID
1047};
1048
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049/* Per-controller data */
1050struct ipr_ioa_cfg {
1051 char eye_catcher[8];
1052#define IPR_EYECATCHER "iprcfg"
1053
1054 struct list_head queue;
1055
1056 u8 allow_interrupts:1;
1057 u8 in_reset_reload:1;
1058 u8 in_ioa_bringdown:1;
1059 u8 ioa_unit_checked:1;
1060 u8 ioa_is_dead:1;
1061 u8 dump_taken:1;
1062 u8 allow_cmds:1;
1063 u8 allow_ml_add_del:1;
brking@us.ibm.comce155cc2005-11-17 09:35:12 -06001064 u8 needs_hard_reset:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065
brking@us.ibm.com62275042005-11-01 17:01:14 -06001066 enum ipr_cache_state cache_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067 u16 type; /* CCIN of the card */
1068
1069 u8 log_level;
1070#define IPR_MAX_LOG_LEVEL 4
1071#define IPR_DEFAULT_LOG_LEVEL 2
1072
1073#define IPR_NUM_TRACE_INDEX_BITS 8
1074#define IPR_NUM_TRACE_ENTRIES (1 << IPR_NUM_TRACE_INDEX_BITS)
1075#define IPR_TRACE_SIZE (sizeof(struct ipr_trace_entry) * IPR_NUM_TRACE_ENTRIES)
1076 char trace_start[8];
1077#define IPR_TRACE_START_LABEL "trace"
1078 struct ipr_trace_entry *trace;
1079 u32 trace_index:IPR_NUM_TRACE_INDEX_BITS;
1080
1081 /*
1082 * Queue for free command blocks
1083 */
1084 char ipr_free_label[8];
1085#define IPR_FREEQ_LABEL "free-q"
1086 struct list_head free_q;
1087
1088 /*
1089 * Queue for command blocks outstanding to the adapter
1090 */
1091 char ipr_pending_label[8];
1092#define IPR_PENDQ_LABEL "pend-q"
1093 struct list_head pending_q;
1094
1095 char cfg_table_start[8];
1096#define IPR_CFG_TBL_START "cfg"
1097 struct ipr_config_table *cfg_table;
1098 dma_addr_t cfg_table_dma;
1099
1100 char resource_table_label[8];
1101#define IPR_RES_TABLE_LABEL "res_tbl"
1102 struct ipr_resource_entry *res_entries;
1103 struct list_head free_res_q;
1104 struct list_head used_res_q;
1105
1106 char ipr_hcam_label[8];
1107#define IPR_HCAM_LABEL "hcams"
1108 struct ipr_hostrcb *hostrcb[IPR_NUM_HCAMS];
1109 dma_addr_t hostrcb_dma[IPR_NUM_HCAMS];
1110 struct list_head hostrcb_free_q;
1111 struct list_head hostrcb_pending_q;
1112
1113 __be32 *host_rrq;
1114 dma_addr_t host_rrq_dma;
1115#define IPR_HRRQ_REQ_RESP_HANDLE_MASK 0xfffffffc
1116#define IPR_HRRQ_RESP_BIT_SET 0x00000002
1117#define IPR_HRRQ_TOGGLE_BIT 0x00000001
1118#define IPR_HRRQ_REQ_RESP_HANDLE_SHIFT 2
1119 volatile __be32 *hrrq_start;
1120 volatile __be32 *hrrq_end;
1121 volatile __be32 *hrrq_curr;
1122 volatile u32 toggle_bit;
1123
1124 struct ipr_bus_attributes bus_attr[IPR_MAX_NUM_BUSES];
1125
Brian King5469cb52007-03-29 12:42:40 -05001126 unsigned int transop_timeout;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 const struct ipr_chip_cfg_t *chip_cfg;
1128
1129 void __iomem *hdw_dma_regs; /* iomapped PCI memory space */
1130 unsigned long hdw_dma_regs_pci; /* raw PCI memory space */
1131 void __iomem *ioa_mailbox;
1132 struct ipr_interrupts regs;
1133
1134 u16 saved_pcix_cmd_reg;
1135 u16 reset_retries;
1136
1137 u32 errors_logged;
brking@us.ibm.com3d1d0da2005-11-01 17:01:54 -06001138 u32 doorbell;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139
1140 struct Scsi_Host *host;
1141 struct pci_dev *pdev;
1142 struct ipr_sglist *ucode_sglist;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 u8 saved_mode_page_len;
1144
1145 struct work_struct work_q;
1146
1147 wait_queue_head_t reset_wait_q;
1148
1149 struct ipr_dump *dump;
1150 enum ipr_sdt_state sdt_state;
1151
1152 struct ipr_misc_cbs *vpd_cbs;
1153 dma_addr_t vpd_cbs_dma;
1154
1155 struct pci_pool *ipr_cmd_pool;
1156
1157 struct ipr_cmnd *reset_cmd;
1158
Brian King35a39692006-09-25 12:39:20 -05001159 struct ata_host ata_host;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001160 char ipr_cmd_label[8];
1161#define IPR_CMD_LABEL "ipr_cmnd"
1162 struct ipr_cmnd *ipr_cmnd_list[IPR_NUM_CMD_BLKS];
1163 u32 ipr_cmnd_list_dma[IPR_NUM_CMD_BLKS];
1164};
1165
1166struct ipr_cmnd {
1167 struct ipr_ioarcb ioarcb;
1168 struct ipr_ioasa ioasa;
1169 struct ipr_ioadl_desc ioadl[IPR_NUM_IOADL_ENTRIES];
1170 struct list_head queue;
1171 struct scsi_cmnd *scsi_cmd;
Brian King35a39692006-09-25 12:39:20 -05001172 struct ata_queued_cmd *qc;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 struct completion completion;
1174 struct timer_list timer;
1175 void (*done) (struct ipr_cmnd *);
1176 int (*job_step) (struct ipr_cmnd *);
brking@us.ibm.comdfed8232005-11-01 17:02:55 -06001177 int (*job_step_failed) (struct ipr_cmnd *);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178 u16 cmd_index;
1179 u8 sense_buffer[SCSI_SENSE_BUFFERSIZE];
1180 dma_addr_t sense_buffer_dma;
1181 unsigned short dma_use_sg;
1182 dma_addr_t dma_handle;
1183 struct ipr_cmnd *sibling;
1184 union {
1185 enum ipr_shutdown_type shutdown_type;
1186 struct ipr_hostrcb *hostrcb;
1187 unsigned long time_left;
1188 unsigned long scratch;
1189 struct ipr_resource_entry *res;
1190 struct scsi_device *sdev;
1191 } u;
1192
1193 struct ipr_ioa_cfg *ioa_cfg;
1194};
1195
1196struct ipr_ses_table_entry {
1197 char product_id[17];
1198 char compare_product_id_byte[17];
1199 u32 max_bus_speed_limit; /* MB/sec limit for this backplane */
1200};
1201
1202struct ipr_dump_header {
1203 u32 eye_catcher;
1204#define IPR_DUMP_EYE_CATCHER 0xC5D4E3F2
1205 u32 len;
1206 u32 num_entries;
1207 u32 first_entry_offset;
1208 u32 status;
1209#define IPR_DUMP_STATUS_SUCCESS 0
1210#define IPR_DUMP_STATUS_QUAL_SUCCESS 2
1211#define IPR_DUMP_STATUS_FAILED 0xffffffff
1212 u32 os;
1213#define IPR_DUMP_OS_LINUX 0x4C4E5558
1214 u32 driver_name;
1215#define IPR_DUMP_DRIVER_NAME 0x49505232
1216}__attribute__((packed, aligned (4)));
1217
1218struct ipr_dump_entry_header {
1219 u32 eye_catcher;
1220#define IPR_DUMP_EYE_CATCHER 0xC5D4E3F2
1221 u32 len;
1222 u32 num_elems;
1223 u32 offset;
1224 u32 data_type;
1225#define IPR_DUMP_DATA_TYPE_ASCII 0x41534349
1226#define IPR_DUMP_DATA_TYPE_BINARY 0x42494E41
1227 u32 id;
1228#define IPR_DUMP_IOA_DUMP_ID 0x494F4131
1229#define IPR_DUMP_LOCATION_ID 0x4C4F4341
1230#define IPR_DUMP_TRACE_ID 0x54524143
1231#define IPR_DUMP_DRIVER_VERSION_ID 0x44525652
1232#define IPR_DUMP_DRIVER_TYPE_ID 0x54595045
1233#define IPR_DUMP_IOA_CTRL_BLK 0x494F4342
1234#define IPR_DUMP_PEND_OPS 0x414F5053
1235 u32 status;
1236}__attribute__((packed, aligned (4)));
1237
1238struct ipr_dump_location_entry {
1239 struct ipr_dump_entry_header hdr;
1240 u8 location[BUS_ID_SIZE];
1241}__attribute__((packed));
1242
1243struct ipr_dump_trace_entry {
1244 struct ipr_dump_entry_header hdr;
1245 u32 trace[IPR_TRACE_SIZE / sizeof(u32)];
1246}__attribute__((packed, aligned (4)));
1247
1248struct ipr_dump_version_entry {
1249 struct ipr_dump_entry_header hdr;
1250 u8 version[sizeof(IPR_DRIVER_VERSION)];
1251};
1252
1253struct ipr_dump_ioa_type_entry {
1254 struct ipr_dump_entry_header hdr;
1255 u32 type;
1256 u32 fw_version;
1257};
1258
1259struct ipr_driver_dump {
1260 struct ipr_dump_header hdr;
1261 struct ipr_dump_version_entry version_entry;
1262 struct ipr_dump_location_entry location_entry;
1263 struct ipr_dump_ioa_type_entry ioa_type_entry;
1264 struct ipr_dump_trace_entry trace_entry;
1265}__attribute__((packed));
1266
1267struct ipr_ioa_dump {
1268 struct ipr_dump_entry_header hdr;
1269 struct ipr_sdt sdt;
1270 __be32 *ioa_data[IPR_MAX_NUM_DUMP_PAGES];
1271 u32 reserved;
1272 u32 next_page_index;
1273 u32 page_offset;
1274 u32 format;
1275#define IPR_SDT_FMT2 2
1276#define IPR_SDT_UNKNOWN 3
1277}__attribute__((packed, aligned (4)));
1278
1279struct ipr_dump {
1280 struct kref kref;
1281 struct ipr_ioa_cfg *ioa_cfg;
1282 struct ipr_driver_dump driver_dump;
1283 struct ipr_ioa_dump ioa_dump;
1284};
1285
1286struct ipr_error_table_t {
1287 u32 ioasc;
1288 int log_ioasa;
1289 int log_hcam;
1290 char *error;
1291};
1292
1293struct ipr_software_inq_lid_info {
1294 __be32 load_id;
1295 __be32 timestamp[3];
1296}__attribute__((packed, aligned (4)));
1297
1298struct ipr_ucode_image_header {
1299 __be32 header_length;
1300 __be32 lid_table_offset;
1301 u8 major_release;
1302 u8 card_type;
1303 u8 minor_release[2];
1304 u8 reserved[20];
1305 char eyecatcher[16];
1306 __be32 num_lids;
1307 struct ipr_software_inq_lid_info lid[1];
1308}__attribute__((packed, aligned (4)));
1309
1310/*
1311 * Macros
1312 */
brking@us.ibm.comd3c74872005-11-01 17:01:34 -06001313#define IPR_DBG_CMD(CMD) if (ipr_debug) { CMD; }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001314
1315#ifdef CONFIG_SCSI_IPR_TRACE
1316#define ipr_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
1317#define ipr_remove_trace_file(kobj, attr) sysfs_remove_bin_file(kobj, attr)
1318#else
1319#define ipr_create_trace_file(kobj, attr) 0
1320#define ipr_remove_trace_file(kobj, attr) do { } while(0)
1321#endif
1322
1323#ifdef CONFIG_SCSI_IPR_DUMP
1324#define ipr_create_dump_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
1325#define ipr_remove_dump_file(kobj, attr) sysfs_remove_bin_file(kobj, attr)
1326#else
1327#define ipr_create_dump_file(kobj, attr) 0
1328#define ipr_remove_dump_file(kobj, attr) do { } while(0)
1329#endif
1330
1331/*
1332 * Error logging macros
1333 */
1334#define ipr_err(...) printk(KERN_ERR IPR_NAME ": "__VA_ARGS__)
1335#define ipr_info(...) printk(KERN_INFO IPR_NAME ": "__VA_ARGS__)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001336#define ipr_dbg(...) IPR_DBG_CMD(printk(KERN_INFO IPR_NAME ": "__VA_ARGS__))
1337
Brian Kingfb3ed3c2006-03-29 09:37:37 -06001338#define ipr_ra_printk(level, ioa_cfg, ra, fmt, ...) \
1339 printk(level IPR_NAME ": %d:%d:%d:%d: " fmt, (ioa_cfg)->host->host_no, \
1340 (ra).bus, (ra).target, (ra).lun, ##__VA_ARGS__)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001341
Brian Kingfb3ed3c2006-03-29 09:37:37 -06001342#define ipr_ra_err(ioa_cfg, ra, fmt, ...) \
1343 ipr_ra_printk(KERN_ERR, ioa_cfg, ra, fmt, ##__VA_ARGS__)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001344
1345#define ipr_res_err(ioa_cfg, res, fmt, ...) \
Brian Kingfb3ed3c2006-03-29 09:37:37 -06001346 ipr_ra_err(ioa_cfg, (res)->cfgte.res_addr, fmt, ##__VA_ARGS__)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001347
brking@us.ibm.comfa15b1f2005-11-01 17:00:27 -06001348#define ipr_phys_res_err(ioa_cfg, res, fmt, ...) \
1349{ \
1350 if ((res).bus >= IPR_MAX_NUM_BUSES) { \
1351 ipr_err(fmt": unknown\n", ##__VA_ARGS__); \
1352 } else { \
1353 ipr_err(fmt": %d:%d:%d:%d\n", \
1354 ##__VA_ARGS__, (ioa_cfg)->host->host_no, \
1355 (res).bus, (res).target, (res).lun); \
1356 } \
1357}
1358
Brian King49dc6a12006-11-21 10:28:35 -06001359#define ipr_hcam_err(hostrcb, fmt, ...) \
1360{ \
1361 if (ipr_is_device(&(hostrcb)->hcam.u.error.failing_dev_res_addr)) { \
1362 ipr_ra_err((hostrcb)->ioa_cfg, \
1363 (hostrcb)->hcam.u.error.failing_dev_res_addr, \
1364 fmt, ##__VA_ARGS__); \
1365 } else { \
1366 dev_err(&(hostrcb)->ioa_cfg->pdev->dev, fmt, ##__VA_ARGS__); \
1367 } \
1368}
1369
Linus Torvalds1da177e2005-04-16 15:20:36 -07001370#define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\
1371 __FILE__, __FUNCTION__, __LINE__)
1372
brking@us.ibm.comd3c74872005-11-01 17:01:34 -06001373#define ENTER IPR_DBG_CMD(printk(KERN_INFO IPR_NAME": Entering %s\n", __FUNCTION__))
1374#define LEAVE IPR_DBG_CMD(printk(KERN_INFO IPR_NAME": Leaving %s\n", __FUNCTION__))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375
1376#define ipr_err_separator \
1377ipr_err("----------------------------------------------------------\n")
1378
1379
1380/*
1381 * Inlines
1382 */
1383
1384/**
1385 * ipr_is_ioa_resource - Determine if a resource is the IOA
1386 * @res: resource entry struct
1387 *
1388 * Return value:
1389 * 1 if IOA / 0 if not IOA
1390 **/
1391static inline int ipr_is_ioa_resource(struct ipr_resource_entry *res)
1392{
1393 return (res->cfgte.flags & IPR_IS_IOA_RESOURCE) ? 1 : 0;
1394}
1395
1396/**
1397 * ipr_is_af_dasd_device - Determine if a resource is an AF DASD
1398 * @res: resource entry struct
1399 *
1400 * Return value:
1401 * 1 if AF DASD / 0 if not AF DASD
1402 **/
1403static inline int ipr_is_af_dasd_device(struct ipr_resource_entry *res)
1404{
1405 if (IPR_IS_DASD_DEVICE(res->cfgte.std_inq_data) &&
1406 !ipr_is_ioa_resource(res) &&
1407 IPR_RES_SUBTYPE(res) == IPR_SUBTYPE_AF_DASD)
1408 return 1;
1409 else
1410 return 0;
1411}
1412
1413/**
1414 * ipr_is_vset_device - Determine if a resource is a VSET
1415 * @res: resource entry struct
1416 *
1417 * Return value:
1418 * 1 if VSET / 0 if not VSET
1419 **/
1420static inline int ipr_is_vset_device(struct ipr_resource_entry *res)
1421{
1422 if (IPR_IS_DASD_DEVICE(res->cfgte.std_inq_data) &&
1423 !ipr_is_ioa_resource(res) &&
1424 IPR_RES_SUBTYPE(res) == IPR_SUBTYPE_VOLUME_SET)
1425 return 1;
1426 else
1427 return 0;
1428}
1429
1430/**
1431 * ipr_is_gscsi - Determine if a resource is a generic scsi resource
1432 * @res: resource entry struct
1433 *
1434 * Return value:
1435 * 1 if GSCSI / 0 if not GSCSI
1436 **/
1437static inline int ipr_is_gscsi(struct ipr_resource_entry *res)
1438{
1439 if (!ipr_is_ioa_resource(res) &&
1440 IPR_RES_SUBTYPE(res) == IPR_SUBTYPE_GENERIC_SCSI)
1441 return 1;
1442 else
1443 return 0;
1444}
1445
1446/**
Brian Kinge4fbf442006-03-29 09:37:22 -06001447 * ipr_is_scsi_disk - Determine if a resource is a SCSI disk
1448 * @res: resource entry struct
1449 *
1450 * Return value:
1451 * 1 if SCSI disk / 0 if not SCSI disk
1452 **/
1453static inline int ipr_is_scsi_disk(struct ipr_resource_entry *res)
1454{
1455 if (ipr_is_af_dasd_device(res) ||
1456 (ipr_is_gscsi(res) && IPR_IS_DASD_DEVICE(res->cfgte.std_inq_data)))
1457 return 1;
1458 else
1459 return 0;
1460}
1461
1462/**
Brian Kingb5145d22006-08-02 14:57:36 -05001463 * ipr_is_gata - Determine if a resource is a generic ATA resource
1464 * @res: resource entry struct
1465 *
1466 * Return value:
1467 * 1 if GATA / 0 if not GATA
1468 **/
1469static inline int ipr_is_gata(struct ipr_resource_entry *res)
1470{
1471 if (!ipr_is_ioa_resource(res) &&
1472 IPR_RES_SUBTYPE(res) == IPR_SUBTYPE_GENERIC_ATA)
1473 return 1;
1474 else
1475 return 0;
1476}
1477
1478/**
brking@us.ibm.comee0a90f2005-11-01 17:02:22 -06001479 * ipr_is_naca_model - Determine if a resource is using NACA queueing model
1480 * @res: resource entry struct
1481 *
1482 * Return value:
1483 * 1 if NACA queueing model / 0 if not NACA queueing model
1484 **/
1485static inline int ipr_is_naca_model(struct ipr_resource_entry *res)
1486{
1487 if (ipr_is_gscsi(res) && IPR_QUEUEING_MODEL(res) == IPR_QUEUE_NACA_MODEL)
1488 return 1;
1489 return 0;
1490}
1491
1492/**
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 * ipr_is_device - Determine if resource address is that of a device
1494 * @res_addr: resource address struct
1495 *
1496 * Return value:
1497 * 1 if AF / 0 if not AF
1498 **/
1499static inline int ipr_is_device(struct ipr_res_addr *res_addr)
1500{
1501 if ((res_addr->bus < IPR_MAX_NUM_BUSES) &&
brking@us.ibm.comd71a8b02005-11-01 17:02:49 -06001502 (res_addr->target < (IPR_MAX_NUM_TARGETS_PER_BUS - 1)))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 return 1;
1504
1505 return 0;
1506}
1507
1508/**
1509 * ipr_sdt_is_fmt2 - Determine if a SDT address is in format 2
1510 * @sdt_word: SDT address
1511 *
1512 * Return value:
1513 * 1 if format 2 / 0 if not
1514 **/
1515static inline int ipr_sdt_is_fmt2(u32 sdt_word)
1516{
1517 u32 bar_sel = IPR_GET_FMT2_BAR_SEL(sdt_word);
1518
1519 switch (bar_sel) {
1520 case IPR_SDT_FMT2_BAR0_SEL:
1521 case IPR_SDT_FMT2_BAR1_SEL:
1522 case IPR_SDT_FMT2_BAR2_SEL:
1523 case IPR_SDT_FMT2_BAR3_SEL:
1524 case IPR_SDT_FMT2_BAR4_SEL:
1525 case IPR_SDT_FMT2_BAR5_SEL:
1526 case IPR_SDT_FMT2_EXP_ROM_SEL:
1527 return 1;
1528 };
1529
1530 return 0;
1531}
1532
1533#endif