2 * Adaptec AAC series RAID controller driver
3 * (c) Copyright 2001 Red Hat Inc.
5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux.
8 * Copyright (c) 2000-2010 Adaptec, Inc.
9 * 2010 PMC-Sierra, Inc. (aacraid@pmc-sierra.com)
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; see the file COPYING. If not, write to
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <linux/kernel.h>
28 #include <linux/init.h>
29 #include <linux/types.h>
30 #include <linux/pci.h>
31 #include <linux/spinlock.h>
32 #include <linux/slab.h>
33 #include <linux/completion.h>
34 #include <linux/blkdev.h>
35 #include <linux/uaccess.h>
36 #include <linux/highmem.h> /* For flush_kernel_dcache_page */
37 #include <linux/module.h>
39 #include <scsi/scsi.h>
40 #include <scsi/scsi_cmnd.h>
41 #include <scsi/scsi_device.h>
42 #include <scsi/scsi_host.h>
46 /* values for inqd_pdt: Peripheral device type in plain English */
47 #define INQD_PDT_DA 0x00 /* Direct-access (DISK) device */
48 #define INQD_PDT_PROC 0x03 /* Processor device */
49 #define INQD_PDT_CHNGR 0x08 /* Changer (jukebox, scsi2) */
50 #define INQD_PDT_COMM 0x09 /* Communication device (scsi2) */
51 #define INQD_PDT_NOLUN2 0x1f /* Unknown Device (scsi2) */
52 #define INQD_PDT_NOLUN 0x7f /* Logical Unit Not Present */
54 #define INQD_PDT_DMASK 0x1F /* Peripheral Device Type Mask */
55 #define INQD_PDT_QMASK 0xE0 /* Peripheral Device Qualifer Mask */
61 #define SENCODE_NO_SENSE 0x00
62 #define SENCODE_END_OF_DATA 0x00
63 #define SENCODE_BECOMING_READY 0x04
64 #define SENCODE_INIT_CMD_REQUIRED 0x04
65 #define SENCODE_UNRECOVERED_READ_ERROR 0x11
66 #define SENCODE_PARAM_LIST_LENGTH_ERROR 0x1A
67 #define SENCODE_INVALID_COMMAND 0x20
68 #define SENCODE_LBA_OUT_OF_RANGE 0x21
69 #define SENCODE_INVALID_CDB_FIELD 0x24
70 #define SENCODE_LUN_NOT_SUPPORTED 0x25
71 #define SENCODE_INVALID_PARAM_FIELD 0x26
72 #define SENCODE_PARAM_NOT_SUPPORTED 0x26
73 #define SENCODE_PARAM_VALUE_INVALID 0x26
74 #define SENCODE_RESET_OCCURRED 0x29
75 #define SENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x3E
76 #define SENCODE_INQUIRY_DATA_CHANGED 0x3F
77 #define SENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x39
78 #define SENCODE_DIAGNOSTIC_FAILURE 0x40
79 #define SENCODE_INTERNAL_TARGET_FAILURE 0x44
80 #define SENCODE_INVALID_MESSAGE_ERROR 0x49
81 #define SENCODE_LUN_FAILED_SELF_CONFIG 0x4c
82 #define SENCODE_OVERLAPPED_COMMAND 0x4E
85 * Additional sense codes
88 #define ASENCODE_NO_SENSE 0x00
89 #define ASENCODE_END_OF_DATA 0x05
90 #define ASENCODE_BECOMING_READY 0x01
91 #define ASENCODE_INIT_CMD_REQUIRED 0x02
92 #define ASENCODE_PARAM_LIST_LENGTH_ERROR 0x00
93 #define ASENCODE_INVALID_COMMAND 0x00
94 #define ASENCODE_LBA_OUT_OF_RANGE 0x00
95 #define ASENCODE_INVALID_CDB_FIELD 0x00
96 #define ASENCODE_LUN_NOT_SUPPORTED 0x00
97 #define ASENCODE_INVALID_PARAM_FIELD 0x00
98 #define ASENCODE_PARAM_NOT_SUPPORTED 0x01
99 #define ASENCODE_PARAM_VALUE_INVALID 0x02
100 #define ASENCODE_RESET_OCCURRED 0x00
101 #define ASENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x00
102 #define ASENCODE_INQUIRY_DATA_CHANGED 0x03
103 #define ASENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x00
104 #define ASENCODE_DIAGNOSTIC_FAILURE 0x80
105 #define ASENCODE_INTERNAL_TARGET_FAILURE 0x00
106 #define ASENCODE_INVALID_MESSAGE_ERROR 0x00
107 #define ASENCODE_LUN_FAILED_SELF_CONFIG 0x00
108 #define ASENCODE_OVERLAPPED_COMMAND 0x00
110 #define AAC_STAT_GOOD (DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD)
112 #define BYTE0(x) (unsigned char)(x)
113 #define BYTE1(x) (unsigned char)((x) >> 8)
114 #define BYTE2(x) (unsigned char)((x) >> 16)
115 #define BYTE3(x) (unsigned char)((x) >> 24)
117 /* MODE_SENSE data format */
124 } __attribute__((packed
)) hd
;
130 } __attribute__((packed
)) bd
;
132 } __attribute__((packed
)) aac_modep_data
;
134 /* MODE_SENSE_10 data format */
142 } __attribute__((packed
)) hd
;
148 } __attribute__((packed
)) bd
;
150 } __attribute__((packed
)) aac_modep10_data
;
152 /*------------------------------------------------------------------------------
153 * S T R U C T S / T Y P E D E F S
154 *----------------------------------------------------------------------------*/
155 /* SCSI inquiry data */
156 struct inquiry_data
{
157 u8 inqd_pdt
; /* Peripheral qualifier | Peripheral Device Type */
158 u8 inqd_dtq
; /* RMB | Device Type Qualifier */
159 u8 inqd_ver
; /* ISO version | ECMA version | ANSI-approved version */
160 u8 inqd_rdf
; /* AENC | TrmIOP | Response data format */
161 u8 inqd_len
; /* Additional length (n-4) */
162 u8 inqd_pad1
[2];/* Reserved - must be zero */
163 u8 inqd_pad2
; /* RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
164 u8 inqd_vid
[8]; /* Vendor ID */
165 u8 inqd_pid
[16];/* Product ID */
166 u8 inqd_prl
[4]; /* Product Revision Level */
169 /* Added for VPD 0x83 */
171 u8 CodeSet
:4; /* VPD_CODE_SET */
173 u8 IdentifierType
:4; /* VPD_IDENTIFIER_TYPE */
179 u8 SerialNumber
[8]; /* SN in ASCII */
181 } TVPD_ID_Descriptor_Type_1
;
184 u8 CodeSet
:4; /* VPD_CODE_SET */
186 u8 IdentifierType
:4; /* VPD_IDENTIFIER_TYPE */
192 /* The serial number supposed to be 40 bits,
193 * bit we only support 32, so make the last byte zero. */
198 } TVPD_ID_Descriptor_Type_2
;
202 u8 DeviceTypeQualifier
:3;
206 TVPD_ID_Descriptor_Type_1 IdDescriptorType1
;
207 TVPD_ID_Descriptor_Type_2 IdDescriptorType2
;
212 * M O D U L E G L O B A L S
215 static long aac_build_sg(struct scsi_cmnd
*scsicmd
, struct sgmap
*sgmap
);
216 static long aac_build_sg64(struct scsi_cmnd
*scsicmd
, struct sgmap64
*psg
);
217 static long aac_build_sgraw(struct scsi_cmnd
*scsicmd
, struct sgmapraw
*psg
);
218 static long aac_build_sgraw2(struct scsi_cmnd
*scsicmd
,
219 struct aac_raw_io2
*rio2
, int sg_max
);
220 static int aac_convert_sgraw2(struct aac_raw_io2
*rio2
,
221 int pages
, int nseg
, int nseg_new
);
222 static int aac_send_srb_fib(struct scsi_cmnd
* scsicmd
);
223 #ifdef AAC_DETAILED_STATUS_INFO
224 static char *aac_get_status_string(u32 status
);
228 * Non dasd selection is handled entirely in aachba now
231 static int nondasd
= -1;
232 static int aac_cache
= 2; /* WCE=0 to avoid performance problems */
233 static int dacmode
= -1;
236 int startup_timeout
= 180;
237 int aif_timeout
= 120;
238 int aac_sync_mode
; /* Only Sync. transfer - disabled */
239 int aac_convert_sgl
= 1; /* convert non-conformable s/g list - enabled */
241 module_param(aac_sync_mode
, int, S_IRUGO
|S_IWUSR
);
242 MODULE_PARM_DESC(aac_sync_mode
, "Force sync. transfer mode"
244 module_param(aac_convert_sgl
, int, S_IRUGO
|S_IWUSR
);
245 MODULE_PARM_DESC(aac_convert_sgl
, "Convert non-conformable s/g list"
247 module_param(nondasd
, int, S_IRUGO
|S_IWUSR
);
248 MODULE_PARM_DESC(nondasd
, "Control scanning of hba for nondasd devices."
250 module_param_named(cache
, aac_cache
, int, S_IRUGO
|S_IWUSR
);
251 MODULE_PARM_DESC(cache
, "Disable Queue Flush commands:\n"
252 "\tbit 0 - Disable FUA in WRITE SCSI commands\n"
253 "\tbit 1 - Disable SYNCHRONIZE_CACHE SCSI command\n"
254 "\tbit 2 - Disable only if Battery is protecting Cache");
255 module_param(dacmode
, int, S_IRUGO
|S_IWUSR
);
256 MODULE_PARM_DESC(dacmode
, "Control whether dma addressing is using 64 bit DAC."
258 module_param_named(commit
, aac_commit
, int, S_IRUGO
|S_IWUSR
);
259 MODULE_PARM_DESC(commit
, "Control whether a COMMIT_CONFIG is issued to the"
260 " adapter for foreign arrays.\n"
261 "This is typically needed in systems that do not have a BIOS."
263 module_param_named(msi
, aac_msi
, int, S_IRUGO
|S_IWUSR
);
264 MODULE_PARM_DESC(msi
, "IRQ handling."
265 " 0=PIC(default), 1=MSI, 2=MSI-X)");
266 module_param(startup_timeout
, int, S_IRUGO
|S_IWUSR
);
267 MODULE_PARM_DESC(startup_timeout
, "The duration of time in seconds to wait for"
268 " adapter to have it's kernel up and\n"
269 "running. This is typically adjusted for large systems that do not"
271 module_param(aif_timeout
, int, S_IRUGO
|S_IWUSR
);
272 MODULE_PARM_DESC(aif_timeout
, "The duration of time in seconds to wait for"
273 " applications to pick up AIFs before\n"
274 "deregistering them. This is typically adjusted for heavily burdened"
278 module_param(numacb
, int, S_IRUGO
|S_IWUSR
);
279 MODULE_PARM_DESC(numacb
, "Request a limit to the number of adapter control"
280 " blocks (FIB) allocated. Valid values are 512 and down. Default is"
281 " to use suggestion from Firmware.");
284 module_param(acbsize
, int, S_IRUGO
|S_IWUSR
);
285 MODULE_PARM_DESC(acbsize
, "Request a specific adapter control block (FIB)"
286 " size. Valid values are 512, 2048, 4096 and 8192. Default is to use"
287 " suggestion from Firmware.");
289 int update_interval
= 30 * 60;
290 module_param(update_interval
, int, S_IRUGO
|S_IWUSR
);
291 MODULE_PARM_DESC(update_interval
, "Interval in seconds between time sync"
292 " updates issued to adapter.");
294 int check_interval
= 24 * 60 * 60;
295 module_param(check_interval
, int, S_IRUGO
|S_IWUSR
);
296 MODULE_PARM_DESC(check_interval
, "Interval in seconds between adapter health"
299 int aac_check_reset
= 1;
300 module_param_named(check_reset
, aac_check_reset
, int, S_IRUGO
|S_IWUSR
);
301 MODULE_PARM_DESC(check_reset
, "If adapter fails health check, reset the"
302 " adapter. a value of -1 forces the reset to adapters programmed to"
305 int expose_physicals
= -1;
306 module_param(expose_physicals
, int, S_IRUGO
|S_IWUSR
);
307 MODULE_PARM_DESC(expose_physicals
, "Expose physical components of the arrays."
308 " -1=protect 0=off, 1=on");
310 int aac_reset_devices
;
311 module_param_named(reset_devices
, aac_reset_devices
, int, S_IRUGO
|S_IWUSR
);
312 MODULE_PARM_DESC(reset_devices
, "Force an adapter reset at initialization.");
315 module_param_named(wwn
, aac_wwn
, int, S_IRUGO
|S_IWUSR
);
316 MODULE_PARM_DESC(wwn
, "Select a WWN type for the arrays:\n"
318 "\t1 - Array Meta Data Signature (default)\n"
319 "\t2 - Adapter Serial Number");
322 static inline int aac_valid_context(struct scsi_cmnd
*scsicmd
,
323 struct fib
*fibptr
) {
324 struct scsi_device
*device
;
326 if (unlikely(!scsicmd
|| !scsicmd
->scsi_done
)) {
327 dprintk((KERN_WARNING
"aac_valid_context: scsi command corrupt\n"));
328 aac_fib_complete(fibptr
);
331 scsicmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
332 device
= scsicmd
->device
;
333 if (unlikely(!device
)) {
334 dprintk((KERN_WARNING
"aac_valid_context: scsi device corrupt\n"));
335 aac_fib_complete(fibptr
);
342 * aac_get_config_status - check the adapter configuration
343 * @common: adapter to query
345 * Query config status, and commit the configuration if needed.
347 int aac_get_config_status(struct aac_dev
*dev
, int commit_flag
)
352 if (!(fibptr
= aac_fib_alloc(dev
)))
355 aac_fib_init(fibptr
);
357 struct aac_get_config_status
*dinfo
;
358 dinfo
= (struct aac_get_config_status
*) fib_data(fibptr
);
360 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
361 dinfo
->type
= cpu_to_le32(CT_GET_CONFIG_STATUS
);
362 dinfo
->count
= cpu_to_le32(sizeof(((struct aac_get_config_status_resp
*)NULL
)->data
));
365 status
= aac_fib_send(ContainerCommand
,
367 sizeof (struct aac_get_config_status
),
372 printk(KERN_WARNING
"aac_get_config_status: SendFIB failed.\n");
374 struct aac_get_config_status_resp
*reply
375 = (struct aac_get_config_status_resp
*) fib_data(fibptr
);
376 dprintk((KERN_WARNING
377 "aac_get_config_status: response=%d status=%d action=%d\n",
378 le32_to_cpu(reply
->response
),
379 le32_to_cpu(reply
->status
),
380 le32_to_cpu(reply
->data
.action
)));
381 if ((le32_to_cpu(reply
->response
) != ST_OK
) ||
382 (le32_to_cpu(reply
->status
) != CT_OK
) ||
383 (le32_to_cpu(reply
->data
.action
) > CFACT_PAUSE
)) {
384 printk(KERN_WARNING
"aac_get_config_status: Will not issue the Commit Configuration\n");
388 /* Do not set XferState to zero unless receives a response from F/W */
390 aac_fib_complete(fibptr
);
392 /* Send a CT_COMMIT_CONFIG to enable discovery of devices */
394 if ((aac_commit
== 1) || commit_flag
) {
395 struct aac_commit_config
* dinfo
;
396 aac_fib_init(fibptr
);
397 dinfo
= (struct aac_commit_config
*) fib_data(fibptr
);
399 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
400 dinfo
->type
= cpu_to_le32(CT_COMMIT_CONFIG
);
402 status
= aac_fib_send(ContainerCommand
,
404 sizeof (struct aac_commit_config
),
408 /* Do not set XferState to zero unless
409 * receives a response from F/W */
411 aac_fib_complete(fibptr
);
412 } else if (aac_commit
== 0) {
414 "aac_get_config_status: Foreign device configurations are being ignored\n");
417 /* FIB should be freed only after getting the response from the F/W */
418 if (status
!= -ERESTARTSYS
)
419 aac_fib_free(fibptr
);
423 static void aac_expose_phy_device(struct scsi_cmnd
*scsicmd
)
426 scsi_sg_copy_to_buffer(scsicmd
, &inq_data
, sizeof(inq_data
));
427 if ((inq_data
& 0x20) && (inq_data
& 0x1f) == TYPE_DISK
) {
429 scsi_sg_copy_from_buffer(scsicmd
, &inq_data
, sizeof(inq_data
));
434 * aac_get_containers - list containers
435 * @common: adapter to probe
437 * Make a list of all containers on this controller
439 int aac_get_containers(struct aac_dev
*dev
)
441 struct fsa_dev_info
*fsa_dev_ptr
;
445 struct aac_get_container_count
*dinfo
;
446 struct aac_get_container_count_resp
*dresp
;
447 int maximum_num_containers
= MAXIMUM_NUM_CONTAINERS
;
449 if (!(fibptr
= aac_fib_alloc(dev
)))
452 aac_fib_init(fibptr
);
453 dinfo
= (struct aac_get_container_count
*) fib_data(fibptr
);
454 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
455 dinfo
->type
= cpu_to_le32(CT_GET_CONTAINER_COUNT
);
457 status
= aac_fib_send(ContainerCommand
,
459 sizeof (struct aac_get_container_count
),
464 dresp
= (struct aac_get_container_count_resp
*)fib_data(fibptr
);
465 maximum_num_containers
= le32_to_cpu(dresp
->ContainerSwitchEntries
);
466 if (fibptr
->dev
->supplement_adapter_info
.SupportedOptions2
&
467 AAC_OPTION_SUPPORTED_240_VOLUMES
) {
468 maximum_num_containers
=
469 le32_to_cpu(dresp
->MaxSimpleVolumes
);
471 aac_fib_complete(fibptr
);
473 /* FIB should be freed only after getting the response from the F/W */
474 if (status
!= -ERESTARTSYS
)
475 aac_fib_free(fibptr
);
477 if (maximum_num_containers
< MAXIMUM_NUM_CONTAINERS
)
478 maximum_num_containers
= MAXIMUM_NUM_CONTAINERS
;
479 if (dev
->fsa_dev
== NULL
||
480 dev
->maximum_num_containers
!= maximum_num_containers
) {
482 fsa_dev_ptr
= dev
->fsa_dev
;
484 dev
->fsa_dev
= kcalloc(maximum_num_containers
,
485 sizeof(*fsa_dev_ptr
), GFP_KERNEL
);
494 dev
->maximum_num_containers
= maximum_num_containers
;
496 for (index
= 0; index
< dev
->maximum_num_containers
; index
++) {
497 dev
->fsa_dev
[index
].devname
[0] = '\0';
498 dev
->fsa_dev
[index
].valid
= 0;
500 status
= aac_probe_container(dev
, index
);
503 printk(KERN_WARNING
"aac_get_containers: SendFIB failed.\n");
510 static void get_container_name_callback(void *context
, struct fib
* fibptr
)
512 struct aac_get_name_resp
* get_name_reply
;
513 struct scsi_cmnd
* scsicmd
;
515 scsicmd
= (struct scsi_cmnd
*) context
;
517 if (!aac_valid_context(scsicmd
, fibptr
))
520 dprintk((KERN_DEBUG
"get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies
));
521 BUG_ON(fibptr
== NULL
);
523 get_name_reply
= (struct aac_get_name_resp
*) fib_data(fibptr
);
524 /* Failure is irrelevant, using default value instead */
525 if ((le32_to_cpu(get_name_reply
->status
) == CT_OK
)
526 && (get_name_reply
->data
[0] != '\0')) {
527 char *sp
= get_name_reply
->data
;
528 sp
[sizeof(((struct aac_get_name_resp
*)NULL
)->data
)] = '\0';
532 struct inquiry_data inq
;
533 char d
[sizeof(((struct inquiry_data
*)NULL
)->inqd_pid
)];
534 int count
= sizeof(d
);
537 *dp
++ = (*sp
) ? *sp
++ : ' ';
538 } while (--count
> 0);
540 scsi_sg_copy_to_buffer(scsicmd
, &inq
, sizeof(inq
));
541 memcpy(inq
.inqd_pid
, d
, sizeof(d
));
542 scsi_sg_copy_from_buffer(scsicmd
, &inq
, sizeof(inq
));
546 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
548 aac_fib_complete(fibptr
);
549 scsicmd
->scsi_done(scsicmd
);
553 * aac_get_container_name - get container name, none blocking.
555 static int aac_get_container_name(struct scsi_cmnd
* scsicmd
)
558 struct aac_get_name
*dinfo
;
559 struct fib
* cmd_fibcontext
;
560 struct aac_dev
* dev
;
562 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
564 cmd_fibcontext
= aac_fib_alloc_tag(dev
, scsicmd
);
566 aac_fib_init(cmd_fibcontext
);
567 dinfo
= (struct aac_get_name
*) fib_data(cmd_fibcontext
);
569 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
570 dinfo
->type
= cpu_to_le32(CT_READ_NAME
);
571 dinfo
->cid
= cpu_to_le32(scmd_id(scsicmd
));
572 dinfo
->count
= cpu_to_le32(sizeof(((struct aac_get_name_resp
*)NULL
)->data
));
574 status
= aac_fib_send(ContainerCommand
,
576 sizeof(struct aac_get_name_resp
),
579 (fib_callback
)get_container_name_callback
,
583 * Check that the command queued to the controller
585 if (status
== -EINPROGRESS
) {
586 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
590 printk(KERN_WARNING
"aac_get_container_name: aac_fib_send failed with status: %d.\n", status
);
591 aac_fib_complete(cmd_fibcontext
);
595 static int aac_probe_container_callback2(struct scsi_cmnd
* scsicmd
)
597 struct fsa_dev_info
*fsa_dev_ptr
= ((struct aac_dev
*)(scsicmd
->device
->host
->hostdata
))->fsa_dev
;
599 if ((fsa_dev_ptr
[scmd_id(scsicmd
)].valid
& 1))
600 return aac_scsi_cmd(scsicmd
);
602 scsicmd
->result
= DID_NO_CONNECT
<< 16;
603 scsicmd
->scsi_done(scsicmd
);
607 static void _aac_probe_container2(void * context
, struct fib
* fibptr
)
609 struct fsa_dev_info
*fsa_dev_ptr
;
610 int (*callback
)(struct scsi_cmnd
*);
611 struct scsi_cmnd
* scsicmd
= (struct scsi_cmnd
*)context
;
614 if (!aac_valid_context(scsicmd
, fibptr
))
617 scsicmd
->SCp
.Status
= 0;
618 fsa_dev_ptr
= fibptr
->dev
->fsa_dev
;
620 struct aac_mount
* dresp
= (struct aac_mount
*) fib_data(fibptr
);
621 fsa_dev_ptr
+= scmd_id(scsicmd
);
623 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
624 (le32_to_cpu(dresp
->mnt
[0].vol
) != CT_NONE
) &&
625 (le32_to_cpu(dresp
->mnt
[0].state
) != FSCS_HIDDEN
)) {
626 if (!(fibptr
->dev
->supplement_adapter_info
.SupportedOptions2
&
627 AAC_OPTION_VARIABLE_BLOCK_SIZE
)) {
628 dresp
->mnt
[0].fileinfo
.bdevinfo
.block_size
= 0x200;
629 fsa_dev_ptr
->block_size
= 0x200;
631 fsa_dev_ptr
->block_size
=
632 le32_to_cpu(dresp
->mnt
[0].fileinfo
.bdevinfo
.block_size
);
634 fsa_dev_ptr
->valid
= 1;
635 /* sense_key holds the current state of the spin-up */
636 if (dresp
->mnt
[0].state
& cpu_to_le32(FSCS_NOT_READY
))
637 fsa_dev_ptr
->sense_data
.sense_key
= NOT_READY
;
638 else if (fsa_dev_ptr
->sense_data
.sense_key
== NOT_READY
)
639 fsa_dev_ptr
->sense_data
.sense_key
= NO_SENSE
;
640 fsa_dev_ptr
->type
= le32_to_cpu(dresp
->mnt
[0].vol
);
642 = ((u64
)le32_to_cpu(dresp
->mnt
[0].capacity
)) +
643 (((u64
)le32_to_cpu(dresp
->mnt
[0].capacityhigh
)) << 32);
644 fsa_dev_ptr
->ro
= ((le32_to_cpu(dresp
->mnt
[0].state
) & FSCS_READONLY
) != 0);
646 if ((fsa_dev_ptr
->valid
& 1) == 0)
647 fsa_dev_ptr
->valid
= 0;
648 scsicmd
->SCp
.Status
= le32_to_cpu(dresp
->count
);
650 aac_fib_complete(fibptr
);
651 aac_fib_free(fibptr
);
652 callback
= (int (*)(struct scsi_cmnd
*))(scsicmd
->SCp
.ptr
);
653 scsicmd
->SCp
.ptr
= NULL
;
654 (*callback
)(scsicmd
);
658 static void _aac_probe_container1(void * context
, struct fib
* fibptr
)
660 struct scsi_cmnd
* scsicmd
;
661 struct aac_mount
* dresp
;
662 struct aac_query_mount
*dinfo
;
665 dresp
= (struct aac_mount
*) fib_data(fibptr
);
666 if (!(fibptr
->dev
->supplement_adapter_info
.SupportedOptions2
&
667 AAC_OPTION_VARIABLE_BLOCK_SIZE
))
668 dresp
->mnt
[0].capacityhigh
= 0;
669 if ((le32_to_cpu(dresp
->status
) != ST_OK
) ||
670 (le32_to_cpu(dresp
->mnt
[0].vol
) != CT_NONE
)) {
671 _aac_probe_container2(context
, fibptr
);
674 scsicmd
= (struct scsi_cmnd
*) context
;
676 if (!aac_valid_context(scsicmd
, fibptr
))
679 aac_fib_init(fibptr
);
681 dinfo
= (struct aac_query_mount
*)fib_data(fibptr
);
683 if (fibptr
->dev
->supplement_adapter_info
.SupportedOptions2
&
684 AAC_OPTION_VARIABLE_BLOCK_SIZE
)
685 dinfo
->command
= cpu_to_le32(VM_NameServeAllBlk
);
687 dinfo
->command
= cpu_to_le32(VM_NameServe64
);
689 dinfo
->count
= cpu_to_le32(scmd_id(scsicmd
));
690 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
692 status
= aac_fib_send(ContainerCommand
,
694 sizeof(struct aac_query_mount
),
697 _aac_probe_container2
,
700 * Check that the command queued to the controller
702 if (status
== -EINPROGRESS
)
703 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
704 else if (status
< 0) {
705 /* Inherit results from VM_NameServe, if any */
706 dresp
->status
= cpu_to_le32(ST_OK
);
707 _aac_probe_container2(context
, fibptr
);
711 static int _aac_probe_container(struct scsi_cmnd
* scsicmd
, int (*callback
)(struct scsi_cmnd
*))
714 int status
= -ENOMEM
;
716 if ((fibptr
= aac_fib_alloc((struct aac_dev
*)scsicmd
->device
->host
->hostdata
))) {
717 struct aac_query_mount
*dinfo
;
719 aac_fib_init(fibptr
);
721 dinfo
= (struct aac_query_mount
*)fib_data(fibptr
);
723 if (fibptr
->dev
->supplement_adapter_info
.SupportedOptions2
&
724 AAC_OPTION_VARIABLE_BLOCK_SIZE
)
725 dinfo
->command
= cpu_to_le32(VM_NameServeAllBlk
);
727 dinfo
->command
= cpu_to_le32(VM_NameServe
);
729 dinfo
->count
= cpu_to_le32(scmd_id(scsicmd
));
730 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
731 scsicmd
->SCp
.ptr
= (char *)callback
;
733 status
= aac_fib_send(ContainerCommand
,
735 sizeof(struct aac_query_mount
),
738 _aac_probe_container1
,
741 * Check that the command queued to the controller
743 if (status
== -EINPROGRESS
) {
744 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
748 scsicmd
->SCp
.ptr
= NULL
;
749 aac_fib_complete(fibptr
);
750 aac_fib_free(fibptr
);
754 struct fsa_dev_info
*fsa_dev_ptr
= ((struct aac_dev
*)(scsicmd
->device
->host
->hostdata
))->fsa_dev
;
756 fsa_dev_ptr
+= scmd_id(scsicmd
);
757 if ((fsa_dev_ptr
->valid
& 1) == 0) {
758 fsa_dev_ptr
->valid
= 0;
759 return (*callback
)(scsicmd
);
767 * aac_probe_container - query a logical volume
768 * @dev: device to query
769 * @cid: container identifier
771 * Queries the controller about the given volume. The volume information
772 * is updated in the struct fsa_dev_info structure rather than returned.
774 static int aac_probe_container_callback1(struct scsi_cmnd
* scsicmd
)
776 scsicmd
->device
= NULL
;
780 int aac_probe_container(struct aac_dev
*dev
, int cid
)
782 struct scsi_cmnd
*scsicmd
= kmalloc(sizeof(*scsicmd
), GFP_KERNEL
);
783 struct scsi_device
*scsidev
= kmalloc(sizeof(*scsidev
), GFP_KERNEL
);
786 if (!scsicmd
|| !scsidev
) {
791 scsicmd
->list
.next
= NULL
;
792 scsicmd
->scsi_done
= (void (*)(struct scsi_cmnd
*))aac_probe_container_callback1
;
794 scsicmd
->device
= scsidev
;
795 scsidev
->sdev_state
= 0;
797 scsidev
->host
= dev
->scsi_host_ptr
;
799 if (_aac_probe_container(scsicmd
, aac_probe_container_callback1
) == 0)
800 while (scsicmd
->device
== scsidev
)
803 status
= scsicmd
->SCp
.Status
;
808 /* Local Structure to set SCSI inquiry data strings */
810 char vid
[8]; /* Vendor ID */
811 char pid
[16]; /* Product ID */
812 char prl
[4]; /* Product Revision Level */
816 * InqStrCopy - string merge
817 * @a: string to copy from
818 * @b: string to copy to
820 * Copy a String from one location to another
824 static void inqstrcpy(char *a
, char *b
)
827 while (*a
!= (char)0)
831 static char *container_types
[] = {
855 char * get_container_type(unsigned tindex
)
857 if (tindex
>= ARRAY_SIZE(container_types
))
858 tindex
= ARRAY_SIZE(container_types
) - 1;
859 return container_types
[tindex
];
862 /* Function: setinqstr
864 * Arguments: [1] pointer to void [1] int
866 * Purpose: Sets SCSI inquiry data strings for vendor, product
867 * and revision level. Allows strings to be set in platform dependent
868 * files instead of in OS dependent driver source.
871 static void setinqstr(struct aac_dev
*dev
, void *data
, int tindex
)
873 struct scsi_inq
*str
;
875 str
= (struct scsi_inq
*)(data
); /* cast data to scsi inq block */
876 memset(str
, ' ', sizeof(*str
));
878 if (dev
->supplement_adapter_info
.AdapterTypeText
[0]) {
879 char * cp
= dev
->supplement_adapter_info
.AdapterTypeText
;
881 if ((cp
[0] == 'A') && (cp
[1] == 'O') && (cp
[2] == 'C'))
882 inqstrcpy("SMC", str
->vid
);
884 c
= sizeof(str
->vid
);
885 while (*cp
&& *cp
!= ' ' && --c
)
889 inqstrcpy (dev
->supplement_adapter_info
.AdapterTypeText
,
892 while (*cp
&& *cp
!= ' ')
897 /* last six chars reserved for vol type */
899 if (strlen(cp
) > sizeof(str
->pid
)) {
900 c
= cp
[sizeof(str
->pid
)];
901 cp
[sizeof(str
->pid
)] = '\0';
903 inqstrcpy (cp
, str
->pid
);
905 cp
[sizeof(str
->pid
)] = c
;
907 struct aac_driver_ident
*mp
= aac_get_driver_ident(dev
->cardtype
);
909 inqstrcpy (mp
->vname
, str
->vid
);
910 /* last six chars reserved for vol type */
911 inqstrcpy (mp
->model
, str
->pid
);
914 if (tindex
< ARRAY_SIZE(container_types
)){
915 char *findit
= str
->pid
;
917 for ( ; *findit
!= ' '; findit
++); /* walk till we find a space */
918 /* RAID is superfluous in the context of a RAID device */
919 if (memcmp(findit
-4, "RAID", 4) == 0)
920 *(findit
-= 4) = ' ';
921 if (((findit
- str
->pid
) + strlen(container_types
[tindex
]))
922 < (sizeof(str
->pid
) + sizeof(str
->prl
)))
923 inqstrcpy (container_types
[tindex
], findit
+ 1);
925 inqstrcpy ("V1.0", str
->prl
);
928 static void get_container_serial_callback(void *context
, struct fib
* fibptr
)
930 struct aac_get_serial_resp
* get_serial_reply
;
931 struct scsi_cmnd
* scsicmd
;
933 BUG_ON(fibptr
== NULL
);
935 scsicmd
= (struct scsi_cmnd
*) context
;
936 if (!aac_valid_context(scsicmd
, fibptr
))
939 get_serial_reply
= (struct aac_get_serial_resp
*) fib_data(fibptr
);
940 /* Failure is irrelevant, using default value instead */
941 if (le32_to_cpu(get_serial_reply
->status
) == CT_OK
) {
942 /*Check to see if it's for VPD 0x83 or 0x80 */
943 if (scsicmd
->cmnd
[2] == 0x83) {
944 /* vpd page 0x83 - Device Identification Page */
946 TVPD_Page83 VPDPage83Data
;
948 memset(((u8
*)&VPDPage83Data
), 0,
949 sizeof(VPDPage83Data
));
951 /* DIRECT_ACCESS_DEVIC */
952 VPDPage83Data
.DeviceType
= 0;
953 /* DEVICE_CONNECTED */
954 VPDPage83Data
.DeviceTypeQualifier
= 0;
955 /* VPD_DEVICE_IDENTIFIERS */
956 VPDPage83Data
.PageCode
= 0x83;
957 VPDPage83Data
.Reserved
= 0;
958 VPDPage83Data
.PageLength
=
959 sizeof(VPDPage83Data
.IdDescriptorType1
) +
960 sizeof(VPDPage83Data
.IdDescriptorType2
);
962 /* T10 Vendor Identifier Field Format */
963 /* VpdCodeSetAscii */
964 VPDPage83Data
.IdDescriptorType1
.CodeSet
= 2;
965 /* VpdIdentifierTypeVendorId */
966 VPDPage83Data
.IdDescriptorType1
.IdentifierType
= 1;
967 VPDPage83Data
.IdDescriptorType1
.IdentifierLength
=
968 sizeof(VPDPage83Data
.IdDescriptorType1
) - 4;
970 /* "ADAPTEC " for adaptec */
971 memcpy(VPDPage83Data
.IdDescriptorType1
.VendId
,
973 sizeof(VPDPage83Data
.IdDescriptorType1
.VendId
));
974 memcpy(VPDPage83Data
.IdDescriptorType1
.ProductId
,
977 VPDPage83Data
.IdDescriptorType1
.ProductId
));
979 /* Convert to ascii based serial number.
980 * The LSB is the the end.
982 for (i
= 0; i
< 8; i
++) {
984 (u8
)((get_serial_reply
->uid
>> ((7 - i
) * 4)) & 0xF);
986 VPDPage83Data
.IdDescriptorType1
.SerialNumber
[i
] =
989 VPDPage83Data
.IdDescriptorType1
.SerialNumber
[i
] =
994 /* VpdCodeSetBinary */
995 VPDPage83Data
.IdDescriptorType2
.CodeSet
= 1;
996 /* VpdIdentifierTypeEUI64 */
997 VPDPage83Data
.IdDescriptorType2
.IdentifierType
= 2;
998 VPDPage83Data
.IdDescriptorType2
.IdentifierLength
=
999 sizeof(VPDPage83Data
.IdDescriptorType2
) - 4;
1001 VPDPage83Data
.IdDescriptorType2
.EU64Id
.VendId
[0] = 0xD0;
1002 VPDPage83Data
.IdDescriptorType2
.EU64Id
.VendId
[1] = 0;
1003 VPDPage83Data
.IdDescriptorType2
.EU64Id
.VendId
[2] = 0;
1005 VPDPage83Data
.IdDescriptorType2
.EU64Id
.Serial
=
1006 get_serial_reply
->uid
;
1007 VPDPage83Data
.IdDescriptorType2
.EU64Id
.Reserved
= 0;
1009 /* Move the inquiry data to the response buffer. */
1010 scsi_sg_copy_from_buffer(scsicmd
, &VPDPage83Data
,
1011 sizeof(VPDPage83Data
));
1013 /* It must be for VPD 0x80 */
1016 sp
[0] = INQD_PDT_DA
;
1017 sp
[1] = scsicmd
->cmnd
[2];
1019 sp
[3] = snprintf(sp
+4, sizeof(sp
)-4, "%08X",
1020 le32_to_cpu(get_serial_reply
->uid
));
1021 scsi_sg_copy_from_buffer(scsicmd
, sp
,
1026 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1028 aac_fib_complete(fibptr
);
1029 scsicmd
->scsi_done(scsicmd
);
1033 * aac_get_container_serial - get container serial, none blocking.
1035 static int aac_get_container_serial(struct scsi_cmnd
* scsicmd
)
1038 struct aac_get_serial
*dinfo
;
1039 struct fib
* cmd_fibcontext
;
1040 struct aac_dev
* dev
;
1042 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1044 cmd_fibcontext
= aac_fib_alloc_tag(dev
, scsicmd
);
1046 aac_fib_init(cmd_fibcontext
);
1047 dinfo
= (struct aac_get_serial
*) fib_data(cmd_fibcontext
);
1049 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
1050 dinfo
->type
= cpu_to_le32(CT_CID_TO_32BITS_UID
);
1051 dinfo
->cid
= cpu_to_le32(scmd_id(scsicmd
));
1053 status
= aac_fib_send(ContainerCommand
,
1055 sizeof(struct aac_get_serial_resp
),
1058 (fib_callback
) get_container_serial_callback
,
1062 * Check that the command queued to the controller
1064 if (status
== -EINPROGRESS
) {
1065 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1069 printk(KERN_WARNING
"aac_get_container_serial: aac_fib_send failed with status: %d.\n", status
);
1070 aac_fib_complete(cmd_fibcontext
);
1074 /* Function: setinqserial
1076 * Arguments: [1] pointer to void [1] int
1078 * Purpose: Sets SCSI Unit Serial number.
1079 * This is a fake. We should read a proper
1080 * serial number from the container. <SuSE>But
1081 * without docs it's quite hard to do it :-)
1082 * So this will have to do in the meantime.</SuSE>
1085 static int setinqserial(struct aac_dev
*dev
, void *data
, int cid
)
1088 * This breaks array migration.
1090 return snprintf((char *)(data
), sizeof(struct scsi_inq
) - 4, "%08X%02X",
1091 le32_to_cpu(dev
->adapter_info
.serial
[0]), cid
);
1094 static inline void set_sense(struct sense_data
*sense_data
, u8 sense_key
,
1095 u8 sense_code
, u8 a_sense_code
, u8 bit_pointer
, u16 field_pointer
)
1097 u8
*sense_buf
= (u8
*)sense_data
;
1098 /* Sense data valid, err code 70h */
1099 sense_buf
[0] = 0x70; /* No info field */
1100 sense_buf
[1] = 0; /* Segment number, always zero */
1102 sense_buf
[2] = sense_key
; /* Sense key */
1104 sense_buf
[12] = sense_code
; /* Additional sense code */
1105 sense_buf
[13] = a_sense_code
; /* Additional sense code qualifier */
1107 if (sense_key
== ILLEGAL_REQUEST
) {
1108 sense_buf
[7] = 10; /* Additional sense length */
1110 sense_buf
[15] = bit_pointer
;
1111 /* Illegal parameter is in the parameter block */
1112 if (sense_code
== SENCODE_INVALID_CDB_FIELD
)
1113 sense_buf
[15] |= 0xc0;/* Std sense key specific field */
1114 /* Illegal parameter is in the CDB block */
1115 sense_buf
[16] = field_pointer
>> 8; /* MSB */
1116 sense_buf
[17] = field_pointer
; /* LSB */
1118 sense_buf
[7] = 6; /* Additional sense length */
1121 static int aac_bounds_32(struct aac_dev
* dev
, struct scsi_cmnd
* cmd
, u64 lba
)
1123 if (lba
& 0xffffffff00000000LL
) {
1124 int cid
= scmd_id(cmd
);
1125 dprintk((KERN_DEBUG
"aacraid: Illegal lba\n"));
1126 cmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
1127 SAM_STAT_CHECK_CONDITION
;
1128 set_sense(&dev
->fsa_dev
[cid
].sense_data
,
1129 HARDWARE_ERROR
, SENCODE_INTERNAL_TARGET_FAILURE
,
1130 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0);
1131 memcpy(cmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1132 min_t(size_t, sizeof(dev
->fsa_dev
[cid
].sense_data
),
1133 SCSI_SENSE_BUFFERSIZE
));
1134 cmd
->scsi_done(cmd
);
1140 static int aac_bounds_64(struct aac_dev
* dev
, struct scsi_cmnd
* cmd
, u64 lba
)
1145 static void io_callback(void *context
, struct fib
* fibptr
);
1147 static int aac_read_raw_io(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
1149 struct aac_dev
*dev
= fib
->dev
;
1150 u16 fibsize
, command
;
1154 if ((dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE2
||
1155 dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE3
) &&
1157 struct aac_raw_io2
*readcmd2
;
1158 readcmd2
= (struct aac_raw_io2
*) fib_data(fib
);
1159 memset(readcmd2
, 0, sizeof(struct aac_raw_io2
));
1160 readcmd2
->blockLow
= cpu_to_le32((u32
)(lba
&0xffffffff));
1161 readcmd2
->blockHigh
= cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
1162 readcmd2
->byteCount
= cpu_to_le32(count
*
1163 dev
->fsa_dev
[scmd_id(cmd
)].block_size
);
1164 readcmd2
->cid
= cpu_to_le16(scmd_id(cmd
));
1165 readcmd2
->flags
= cpu_to_le16(RIO2_IO_TYPE_READ
);
1166 ret
= aac_build_sgraw2(cmd
, readcmd2
,
1167 dev
->scsi_host_ptr
->sg_tablesize
);
1170 command
= ContainerRawIo2
;
1171 fibsize
= sizeof(struct aac_raw_io2
) +
1172 ((le32_to_cpu(readcmd2
->sgeCnt
)-1) * sizeof(struct sge_ieee1212
));
1174 struct aac_raw_io
*readcmd
;
1175 readcmd
= (struct aac_raw_io
*) fib_data(fib
);
1176 readcmd
->block
[0] = cpu_to_le32((u32
)(lba
&0xffffffff));
1177 readcmd
->block
[1] = cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
1178 readcmd
->count
= cpu_to_le32(count
*
1179 dev
->fsa_dev
[scmd_id(cmd
)].block_size
);
1180 readcmd
->cid
= cpu_to_le16(scmd_id(cmd
));
1181 readcmd
->flags
= cpu_to_le16(RIO_TYPE_READ
);
1182 readcmd
->bpTotal
= 0;
1183 readcmd
->bpComplete
= 0;
1184 ret
= aac_build_sgraw(cmd
, &readcmd
->sg
);
1187 command
= ContainerRawIo
;
1188 fibsize
= sizeof(struct aac_raw_io
) +
1189 ((le32_to_cpu(readcmd
->sg
.count
)-1) * sizeof(struct sgentryraw
));
1192 BUG_ON(fibsize
> (fib
->dev
->max_fib_size
- sizeof(struct aac_fibhdr
)));
1194 * Now send the Fib to the adapter
1196 return aac_fib_send(command
,
1201 (fib_callback
) io_callback
,
1205 static int aac_read_block64(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
1208 struct aac_read64
*readcmd
;
1212 readcmd
= (struct aac_read64
*) fib_data(fib
);
1213 readcmd
->command
= cpu_to_le32(VM_CtHostRead64
);
1214 readcmd
->cid
= cpu_to_le16(scmd_id(cmd
));
1215 readcmd
->sector_count
= cpu_to_le16(count
);
1216 readcmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
1220 ret
= aac_build_sg64(cmd
, &readcmd
->sg
);
1223 fibsize
= sizeof(struct aac_read64
) +
1224 ((le32_to_cpu(readcmd
->sg
.count
) - 1) *
1225 sizeof (struct sgentry64
));
1226 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
1227 sizeof(struct aac_fibhdr
)));
1229 * Now send the Fib to the adapter
1231 return aac_fib_send(ContainerCommand64
,
1236 (fib_callback
) io_callback
,
1240 static int aac_read_block(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
1243 struct aac_read
*readcmd
;
1244 struct aac_dev
*dev
= fib
->dev
;
1248 readcmd
= (struct aac_read
*) fib_data(fib
);
1249 readcmd
->command
= cpu_to_le32(VM_CtBlockRead
);
1250 readcmd
->cid
= cpu_to_le32(scmd_id(cmd
));
1251 readcmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
1252 readcmd
->count
= cpu_to_le32(count
*
1253 dev
->fsa_dev
[scmd_id(cmd
)].block_size
);
1255 ret
= aac_build_sg(cmd
, &readcmd
->sg
);
1258 fibsize
= sizeof(struct aac_read
) +
1259 ((le32_to_cpu(readcmd
->sg
.count
) - 1) *
1260 sizeof (struct sgentry
));
1261 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
1262 sizeof(struct aac_fibhdr
)));
1264 * Now send the Fib to the adapter
1266 return aac_fib_send(ContainerCommand
,
1271 (fib_callback
) io_callback
,
1275 static int aac_write_raw_io(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
, int fua
)
1277 struct aac_dev
*dev
= fib
->dev
;
1278 u16 fibsize
, command
;
1282 if ((dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE2
||
1283 dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE3
) &&
1285 struct aac_raw_io2
*writecmd2
;
1286 writecmd2
= (struct aac_raw_io2
*) fib_data(fib
);
1287 memset(writecmd2
, 0, sizeof(struct aac_raw_io2
));
1288 writecmd2
->blockLow
= cpu_to_le32((u32
)(lba
&0xffffffff));
1289 writecmd2
->blockHigh
= cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
1290 writecmd2
->byteCount
= cpu_to_le32(count
*
1291 dev
->fsa_dev
[scmd_id(cmd
)].block_size
);
1292 writecmd2
->cid
= cpu_to_le16(scmd_id(cmd
));
1293 writecmd2
->flags
= (fua
&& ((aac_cache
& 5) != 1) &&
1294 (((aac_cache
& 5) != 5) || !fib
->dev
->cache_protected
)) ?
1295 cpu_to_le16(RIO2_IO_TYPE_WRITE
|RIO2_IO_SUREWRITE
) :
1296 cpu_to_le16(RIO2_IO_TYPE_WRITE
);
1297 ret
= aac_build_sgraw2(cmd
, writecmd2
,
1298 dev
->scsi_host_ptr
->sg_tablesize
);
1301 command
= ContainerRawIo2
;
1302 fibsize
= sizeof(struct aac_raw_io2
) +
1303 ((le32_to_cpu(writecmd2
->sgeCnt
)-1) * sizeof(struct sge_ieee1212
));
1305 struct aac_raw_io
*writecmd
;
1306 writecmd
= (struct aac_raw_io
*) fib_data(fib
);
1307 writecmd
->block
[0] = cpu_to_le32((u32
)(lba
&0xffffffff));
1308 writecmd
->block
[1] = cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
1309 writecmd
->count
= cpu_to_le32(count
*
1310 dev
->fsa_dev
[scmd_id(cmd
)].block_size
);
1311 writecmd
->cid
= cpu_to_le16(scmd_id(cmd
));
1312 writecmd
->flags
= (fua
&& ((aac_cache
& 5) != 1) &&
1313 (((aac_cache
& 5) != 5) || !fib
->dev
->cache_protected
)) ?
1314 cpu_to_le16(RIO_TYPE_WRITE
|RIO_SUREWRITE
) :
1315 cpu_to_le16(RIO_TYPE_WRITE
);
1316 writecmd
->bpTotal
= 0;
1317 writecmd
->bpComplete
= 0;
1318 ret
= aac_build_sgraw(cmd
, &writecmd
->sg
);
1321 command
= ContainerRawIo
;
1322 fibsize
= sizeof(struct aac_raw_io
) +
1323 ((le32_to_cpu(writecmd
->sg
.count
)-1) * sizeof (struct sgentryraw
));
1326 BUG_ON(fibsize
> (fib
->dev
->max_fib_size
- sizeof(struct aac_fibhdr
)));
1328 * Now send the Fib to the adapter
1330 return aac_fib_send(command
,
1335 (fib_callback
) io_callback
,
1339 static int aac_write_block64(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
, int fua
)
1342 struct aac_write64
*writecmd
;
1346 writecmd
= (struct aac_write64
*) fib_data(fib
);
1347 writecmd
->command
= cpu_to_le32(VM_CtHostWrite64
);
1348 writecmd
->cid
= cpu_to_le16(scmd_id(cmd
));
1349 writecmd
->sector_count
= cpu_to_le16(count
);
1350 writecmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
1352 writecmd
->flags
= 0;
1354 ret
= aac_build_sg64(cmd
, &writecmd
->sg
);
1357 fibsize
= sizeof(struct aac_write64
) +
1358 ((le32_to_cpu(writecmd
->sg
.count
) - 1) *
1359 sizeof (struct sgentry64
));
1360 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
1361 sizeof(struct aac_fibhdr
)));
1363 * Now send the Fib to the adapter
1365 return aac_fib_send(ContainerCommand64
,
1370 (fib_callback
) io_callback
,
1374 static int aac_write_block(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
, int fua
)
1377 struct aac_write
*writecmd
;
1378 struct aac_dev
*dev
= fib
->dev
;
1382 writecmd
= (struct aac_write
*) fib_data(fib
);
1383 writecmd
->command
= cpu_to_le32(VM_CtBlockWrite
);
1384 writecmd
->cid
= cpu_to_le32(scmd_id(cmd
));
1385 writecmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
1386 writecmd
->count
= cpu_to_le32(count
*
1387 dev
->fsa_dev
[scmd_id(cmd
)].block_size
);
1388 writecmd
->sg
.count
= cpu_to_le32(1);
1389 /* ->stable is not used - it did mean which type of write */
1391 ret
= aac_build_sg(cmd
, &writecmd
->sg
);
1394 fibsize
= sizeof(struct aac_write
) +
1395 ((le32_to_cpu(writecmd
->sg
.count
) - 1) *
1396 sizeof (struct sgentry
));
1397 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
1398 sizeof(struct aac_fibhdr
)));
1400 * Now send the Fib to the adapter
1402 return aac_fib_send(ContainerCommand
,
1407 (fib_callback
) io_callback
,
1411 static struct aac_srb
* aac_scsi_common(struct fib
* fib
, struct scsi_cmnd
* cmd
)
1413 struct aac_srb
* srbcmd
;
1418 switch(cmd
->sc_data_direction
){
1422 case DMA_BIDIRECTIONAL
:
1423 flag
= SRB_DataIn
| SRB_DataOut
;
1425 case DMA_FROM_DEVICE
:
1429 default: /* shuts up some versions of gcc */
1430 flag
= SRB_NoDataXfer
;
1434 srbcmd
= (struct aac_srb
*) fib_data(fib
);
1435 srbcmd
->function
= cpu_to_le32(SRBF_ExecuteScsi
);
1436 srbcmd
->channel
= cpu_to_le32(aac_logical_to_phys(scmd_channel(cmd
)));
1437 srbcmd
->id
= cpu_to_le32(scmd_id(cmd
));
1438 srbcmd
->lun
= cpu_to_le32(cmd
->device
->lun
);
1439 srbcmd
->flags
= cpu_to_le32(flag
);
1440 timeout
= cmd
->request
->timeout
/HZ
;
1443 srbcmd
->timeout
= cpu_to_le32(timeout
); // timeout in seconds
1444 srbcmd
->retry_limit
= 0; /* Obsolete parameter */
1445 srbcmd
->cdb_size
= cpu_to_le32(cmd
->cmd_len
);
1449 static void aac_srb_callback(void *context
, struct fib
* fibptr
);
1451 static int aac_scsi_64(struct fib
* fib
, struct scsi_cmnd
* cmd
)
1454 struct aac_srb
* srbcmd
= aac_scsi_common(fib
, cmd
);
1457 ret
= aac_build_sg64(cmd
, (struct sgmap64
*) &srbcmd
->sg
);
1460 srbcmd
->count
= cpu_to_le32(scsi_bufflen(cmd
));
1462 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
1463 memcpy(srbcmd
->cdb
, cmd
->cmnd
, cmd
->cmd_len
);
1465 * Build Scatter/Gather list
1467 fibsize
= sizeof (struct aac_srb
) - sizeof (struct sgentry
) +
1468 ((le32_to_cpu(srbcmd
->sg
.count
) & 0xff) *
1469 sizeof (struct sgentry64
));
1470 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
1471 sizeof(struct aac_fibhdr
)));
1474 * Now send the Fib to the adapter
1476 return aac_fib_send(ScsiPortCommand64
, fib
,
1477 fibsize
, FsaNormal
, 0, 1,
1478 (fib_callback
) aac_srb_callback
,
1482 static int aac_scsi_32(struct fib
* fib
, struct scsi_cmnd
* cmd
)
1485 struct aac_srb
* srbcmd
= aac_scsi_common(fib
, cmd
);
1488 ret
= aac_build_sg(cmd
, (struct sgmap
*)&srbcmd
->sg
);
1491 srbcmd
->count
= cpu_to_le32(scsi_bufflen(cmd
));
1493 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
1494 memcpy(srbcmd
->cdb
, cmd
->cmnd
, cmd
->cmd_len
);
1496 * Build Scatter/Gather list
1498 fibsize
= sizeof (struct aac_srb
) +
1499 (((le32_to_cpu(srbcmd
->sg
.count
) & 0xff) - 1) *
1500 sizeof (struct sgentry
));
1501 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
1502 sizeof(struct aac_fibhdr
)));
1505 * Now send the Fib to the adapter
1507 return aac_fib_send(ScsiPortCommand
, fib
, fibsize
, FsaNormal
, 0, 1,
1508 (fib_callback
) aac_srb_callback
, (void *) cmd
);
1511 static int aac_scsi_32_64(struct fib
* fib
, struct scsi_cmnd
* cmd
)
1513 if ((sizeof(dma_addr_t
) > 4) && fib
->dev
->needs_dac
&&
1514 (fib
->dev
->adapter_info
.options
& AAC_OPT_SGMAP_HOST64
))
1516 return aac_scsi_32(fib
, cmd
);
1519 int aac_issue_bmic_identify(struct aac_dev
*dev
, u32 bus
, u32 target
)
1522 struct aac_srb
*srbcmd
;
1523 struct sgmap64
*sg64
;
1524 struct aac_ciss_identify_pd
*identify_resp
;
1527 u16 fibsize
, datasize
;
1528 int rcode
= -ENOMEM
;
1530 fibptr
= aac_fib_alloc(dev
);
1534 fibsize
= sizeof(struct aac_srb
) -
1535 sizeof(struct sgentry
) + sizeof(struct sgentry64
);
1536 datasize
= sizeof(struct aac_ciss_identify_pd
);
1538 identify_resp
= pci_alloc_consistent(dev
->pdev
, datasize
, &addr
);
1543 vbus
= (u32
)le16_to_cpu(dev
->supplement_adapter_info
.VirtDeviceBus
);
1544 vid
= (u32
)le16_to_cpu(dev
->supplement_adapter_info
.VirtDeviceTarget
);
1546 aac_fib_init(fibptr
);
1548 srbcmd
= (struct aac_srb
*) fib_data(fibptr
);
1549 srbcmd
->function
= cpu_to_le32(SRBF_ExecuteScsi
);
1550 srbcmd
->channel
= cpu_to_le32(vbus
);
1551 srbcmd
->id
= cpu_to_le32(vid
);
1553 srbcmd
->flags
= cpu_to_le32(SRB_DataIn
);
1554 srbcmd
->timeout
= cpu_to_le32(10);
1555 srbcmd
->retry_limit
= 0;
1556 srbcmd
->cdb_size
= cpu_to_le32(12);
1557 srbcmd
->count
= cpu_to_le32(datasize
);
1559 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
1560 srbcmd
->cdb
[0] = 0x26;
1561 srbcmd
->cdb
[2] = (u8
)((AAC_MAX_LUN
+ target
) & 0x00FF);
1562 srbcmd
->cdb
[6] = CISS_IDENTIFY_PHYSICAL_DEVICE
;
1564 sg64
= (struct sgmap64
*)&srbcmd
->sg
;
1565 sg64
->count
= cpu_to_le32(1);
1566 sg64
->sg
[0].addr
[1] = cpu_to_le32((u32
)(((addr
) >> 16) >> 16));
1567 sg64
->sg
[0].addr
[0] = cpu_to_le32((u32
)(addr
& 0xffffffff));
1568 sg64
->sg
[0].count
= cpu_to_le32(datasize
);
1570 rcode
= aac_fib_send(ScsiPortCommand64
,
1571 fibptr
, fibsize
, FsaNormal
, 1, 1, NULL
, NULL
);
1573 if (identify_resp
->current_queue_depth_limit
<= 0 ||
1574 identify_resp
->current_queue_depth_limit
> 32)
1575 dev
->hba_map
[bus
][target
].qd_limit
= 32;
1577 dev
->hba_map
[bus
][target
].qd_limit
=
1578 identify_resp
->current_queue_depth_limit
;
1580 pci_free_consistent(dev
->pdev
, datasize
, (void *)identify_resp
, addr
);
1582 aac_fib_complete(fibptr
);
1585 aac_fib_free(fibptr
);
1591 * aac_update hba_map()- update current hba map with data from FW
1592 * @dev: aac_dev structure
1593 * @phys_luns: FW information from report phys luns
1595 * Update our hba map with the information gathered from the FW
1597 void aac_update_hba_map(struct aac_dev
*dev
,
1598 struct aac_ciss_phys_luns_resp
*phys_luns
, int rescan
)
1600 /* ok and extended reporting */
1601 u32 lun_count
, nexus
;
1603 u8 expose_flag
, attribs
;
1606 lun_count
= ((phys_luns
->list_length
[0] << 24)
1607 + (phys_luns
->list_length
[1] << 16)
1608 + (phys_luns
->list_length
[2] << 8)
1609 + (phys_luns
->list_length
[3])) / 24;
1611 for (i
= 0; i
< lun_count
; ++i
) {
1613 bus
= phys_luns
->lun
[i
].level2
[1] & 0x3f;
1614 target
= phys_luns
->lun
[i
].level2
[0];
1615 expose_flag
= phys_luns
->lun
[i
].bus
>> 6;
1616 attribs
= phys_luns
->lun
[i
].node_ident
[9];
1617 nexus
= *((u32
*) &phys_luns
->lun
[i
].node_ident
[12]);
1619 if (bus
>= AAC_MAX_BUSES
|| target
>= AAC_MAX_TARGETS
)
1622 dev
->hba_map
[bus
][target
].expose
= expose_flag
;
1624 if (expose_flag
!= 0) {
1625 devtype
= AAC_DEVTYPE_RAID_MEMBER
;
1626 goto update_devtype
;
1629 if (nexus
!= 0 && (attribs
& 8)) {
1630 devtype
= AAC_DEVTYPE_NATIVE_RAW
;
1631 dev
->hba_map
[bus
][target
].rmw_nexus
=
1634 devtype
= AAC_DEVTYPE_ARC_RAW
;
1636 if (devtype
!= AAC_DEVTYPE_NATIVE_RAW
)
1637 goto update_devtype
;
1639 if (aac_issue_bmic_identify(dev
, bus
, target
) < 0)
1640 dev
->hba_map
[bus
][target
].qd_limit
= 32;
1643 if (rescan
== AAC_INIT
)
1644 dev
->hba_map
[bus
][target
].devtype
= devtype
;
1646 dev
->hba_map
[bus
][target
].new_devtype
= devtype
;
1651 * aac_report_phys_luns() Process topology change
1652 * @dev: aac_dev structure
1653 * @fibptr: fib pointer
1655 * Execute a CISS REPORT PHYS LUNS and process the results into
1656 * the current hba_map.
1658 int aac_report_phys_luns(struct aac_dev
*dev
, struct fib
*fibptr
, int rescan
)
1660 int fibsize
, datasize
;
1661 struct aac_ciss_phys_luns_resp
*phys_luns
;
1662 struct aac_srb
*srbcmd
;
1663 struct sgmap64
*sg64
;
1668 /* Thor SA Firmware -> CISS_REPORT_PHYSICAL_LUNS */
1669 fibsize
= sizeof(struct aac_srb
) - sizeof(struct sgentry
)
1670 + sizeof(struct sgentry64
);
1671 datasize
= sizeof(struct aac_ciss_phys_luns_resp
)
1672 + (AAC_MAX_TARGETS
- 1) * sizeof(struct _ciss_lun
);
1674 phys_luns
= (struct aac_ciss_phys_luns_resp
*) pci_alloc_consistent(
1675 dev
->pdev
, datasize
, &addr
);
1677 if (phys_luns
== NULL
) {
1682 vbus
= (u32
) le16_to_cpu(
1683 dev
->supplement_adapter_info
.VirtDeviceBus
);
1684 vid
= (u32
) le16_to_cpu(
1685 dev
->supplement_adapter_info
.VirtDeviceTarget
);
1687 aac_fib_init(fibptr
);
1689 srbcmd
= (struct aac_srb
*) fib_data(fibptr
);
1690 srbcmd
->function
= cpu_to_le32(SRBF_ExecuteScsi
);
1691 srbcmd
->channel
= cpu_to_le32(vbus
);
1692 srbcmd
->id
= cpu_to_le32(vid
);
1694 srbcmd
->flags
= cpu_to_le32(SRB_DataIn
);
1695 srbcmd
->timeout
= cpu_to_le32(10);
1696 srbcmd
->retry_limit
= 0;
1697 srbcmd
->cdb_size
= cpu_to_le32(12);
1698 srbcmd
->count
= cpu_to_le32(datasize
);
1700 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
1701 srbcmd
->cdb
[0] = CISS_REPORT_PHYSICAL_LUNS
;
1702 srbcmd
->cdb
[1] = 2; /* extended reporting */
1703 srbcmd
->cdb
[8] = (u8
)(datasize
>> 8);
1704 srbcmd
->cdb
[9] = (u8
)(datasize
);
1706 sg64
= (struct sgmap64
*) &srbcmd
->sg
;
1707 sg64
->count
= cpu_to_le32(1);
1708 sg64
->sg
[0].addr
[1] = cpu_to_le32(upper_32_bits(addr
));
1709 sg64
->sg
[0].addr
[0] = cpu_to_le32(lower_32_bits(addr
));
1710 sg64
->sg
[0].count
= cpu_to_le32(datasize
);
1712 rcode
= aac_fib_send(ScsiPortCommand64
, fibptr
, fibsize
,
1713 FsaNormal
, 1, 1, NULL
, NULL
);
1716 if (rcode
>= 0 && phys_luns
->resp_flag
== 2) {
1717 /* ok and extended reporting */
1718 aac_update_hba_map(dev
, phys_luns
, rescan
);
1721 pci_free_consistent(dev
->pdev
, datasize
, (void *) phys_luns
, addr
);
1726 int aac_get_adapter_info(struct aac_dev
* dev
)
1730 u32 tmp
, bus
, target
;
1731 struct aac_adapter_info
*info
;
1732 struct aac_bus_info
*command
;
1733 struct aac_bus_info_response
*bus_info
;
1735 if (!(fibptr
= aac_fib_alloc(dev
)))
1738 aac_fib_init(fibptr
);
1739 info
= (struct aac_adapter_info
*) fib_data(fibptr
);
1740 memset(info
,0,sizeof(*info
));
1742 rcode
= aac_fib_send(RequestAdapterInfo
,
1746 -1, 1, /* First `interrupt' command uses special wait */
1751 /* FIB should be freed only after
1752 * getting the response from the F/W */
1753 if (rcode
!= -ERESTARTSYS
) {
1754 aac_fib_complete(fibptr
);
1755 aac_fib_free(fibptr
);
1759 memcpy(&dev
->adapter_info
, info
, sizeof(*info
));
1761 dev
->supplement_adapter_info
.VirtDeviceBus
= 0xffff;
1762 if (dev
->adapter_info
.options
& AAC_OPT_SUPPLEMENT_ADAPTER_INFO
) {
1763 struct aac_supplement_adapter_info
* sinfo
;
1765 aac_fib_init(fibptr
);
1767 sinfo
= (struct aac_supplement_adapter_info
*) fib_data(fibptr
);
1769 memset(sinfo
,0,sizeof(*sinfo
));
1771 rcode
= aac_fib_send(RequestSupplementAdapterInfo
,
1780 memcpy(&dev
->supplement_adapter_info
, sinfo
, sizeof(*sinfo
));
1781 if (rcode
== -ERESTARTSYS
) {
1782 fibptr
= aac_fib_alloc(dev
);
1789 /* reset all previous mapped devices (i.e. for init. after IOP_RESET) */
1790 for (bus
= 0; bus
< AAC_MAX_BUSES
; bus
++) {
1791 for (target
= 0; target
< AAC_MAX_TARGETS
; target
++) {
1792 dev
->hba_map
[bus
][target
].devtype
= 0;
1793 dev
->hba_map
[bus
][target
].qd_limit
= 0;
1801 aac_fib_init(fibptr
);
1803 bus_info
= (struct aac_bus_info_response
*) fib_data(fibptr
);
1805 memset(bus_info
, 0, sizeof(*bus_info
));
1807 command
= (struct aac_bus_info
*)bus_info
;
1809 command
->Command
= cpu_to_le32(VM_Ioctl
);
1810 command
->ObjType
= cpu_to_le32(FT_DRIVE
);
1811 command
->MethodId
= cpu_to_le32(1);
1812 command
->CtlCmd
= cpu_to_le32(GetBusInfo
);
1814 rcode
= aac_fib_send(ContainerCommand
,
1821 /* reasoned default */
1822 dev
->maximum_num_physicals
= 16;
1823 if (rcode
>= 0 && le32_to_cpu(bus_info
->Status
) == ST_OK
) {
1824 dev
->maximum_num_physicals
= le32_to_cpu(bus_info
->TargetsPerBus
);
1825 dev
->maximum_num_channels
= le32_to_cpu(bus_info
->BusCount
);
1828 if (!dev
->sync_mode
&& dev
->sa_firmware
&&
1829 dev
->supplement_adapter_info
.VirtDeviceBus
!= 0xffff) {
1830 /* Thor SA Firmware -> CISS_REPORT_PHYSICAL_LUNS */
1831 rcode
= aac_report_phys_luns(dev
, fibptr
, AAC_INIT
);
1834 if (!dev
->in_reset
) {
1836 tmp
= le32_to_cpu(dev
->adapter_info
.kernelrev
);
1837 printk(KERN_INFO
"%s%d: kernel %d.%d-%d[%d] %.*s\n",
1843 le32_to_cpu(dev
->adapter_info
.kernelbuild
),
1844 (int)sizeof(dev
->supplement_adapter_info
.BuildDate
),
1845 dev
->supplement_adapter_info
.BuildDate
);
1846 tmp
= le32_to_cpu(dev
->adapter_info
.monitorrev
);
1847 printk(KERN_INFO
"%s%d: monitor %d.%d-%d[%d]\n",
1849 tmp
>>24,(tmp
>>16)&0xff,tmp
&0xff,
1850 le32_to_cpu(dev
->adapter_info
.monitorbuild
));
1851 tmp
= le32_to_cpu(dev
->adapter_info
.biosrev
);
1852 printk(KERN_INFO
"%s%d: bios %d.%d-%d[%d]\n",
1854 tmp
>>24,(tmp
>>16)&0xff,tmp
&0xff,
1855 le32_to_cpu(dev
->adapter_info
.biosbuild
));
1857 if (aac_get_serial_number(
1858 shost_to_class(dev
->scsi_host_ptr
), buffer
))
1859 printk(KERN_INFO
"%s%d: serial %s",
1860 dev
->name
, dev
->id
, buffer
);
1861 if (dev
->supplement_adapter_info
.VpdInfo
.Tsid
[0]) {
1862 printk(KERN_INFO
"%s%d: TSID %.*s\n",
1864 (int)sizeof(dev
->supplement_adapter_info
.VpdInfo
.Tsid
),
1865 dev
->supplement_adapter_info
.VpdInfo
.Tsid
);
1867 if (!aac_check_reset
|| ((aac_check_reset
== 1) &&
1868 (dev
->supplement_adapter_info
.SupportedOptions2
&
1869 AAC_OPTION_IGNORE_RESET
))) {
1870 printk(KERN_INFO
"%s%d: Reset Adapter Ignored\n",
1871 dev
->name
, dev
->id
);
1875 dev
->cache_protected
= 0;
1876 dev
->jbod
= ((dev
->supplement_adapter_info
.FeatureBits
&
1877 AAC_FEATURE_JBOD
) != 0);
1878 dev
->nondasd_support
= 0;
1879 dev
->raid_scsi_mode
= 0;
1880 if(dev
->adapter_info
.options
& AAC_OPT_NONDASD
)
1881 dev
->nondasd_support
= 1;
1884 * If the firmware supports ROMB RAID/SCSI mode and we are currently
1885 * in RAID/SCSI mode, set the flag. For now if in this mode we will
1886 * force nondasd support on. If we decide to allow the non-dasd flag
1887 * additional changes changes will have to be made to support
1888 * RAID/SCSI. the function aac_scsi_cmd in this module will have to be
1889 * changed to support the new dev->raid_scsi_mode flag instead of
1890 * leaching off of the dev->nondasd_support flag. Also in linit.c the
1891 * function aac_detect will have to be modified where it sets up the
1892 * max number of channels based on the aac->nondasd_support flag only.
1894 if ((dev
->adapter_info
.options
& AAC_OPT_SCSI_MANAGED
) &&
1895 (dev
->adapter_info
.options
& AAC_OPT_RAID_SCSI_MODE
)) {
1896 dev
->nondasd_support
= 1;
1897 dev
->raid_scsi_mode
= 1;
1899 if (dev
->raid_scsi_mode
!= 0)
1900 printk(KERN_INFO
"%s%d: ROMB RAID/SCSI mode enabled\n",
1901 dev
->name
, dev
->id
);
1904 dev
->nondasd_support
= (nondasd
!=0);
1905 if (dev
->nondasd_support
&& !dev
->in_reset
)
1906 printk(KERN_INFO
"%s%d: Non-DASD support enabled.\n",dev
->name
, dev
->id
);
1908 if (dma_get_required_mask(&dev
->pdev
->dev
) > DMA_BIT_MASK(32))
1910 dev
->dac_support
= 0;
1911 if ((sizeof(dma_addr_t
) > 4) && dev
->needs_dac
&&
1912 (dev
->adapter_info
.options
& AAC_OPT_SGMAP_HOST64
)) {
1914 printk(KERN_INFO
"%s%d: 64bit support enabled.\n",
1915 dev
->name
, dev
->id
);
1916 dev
->dac_support
= 1;
1920 dev
->dac_support
= (dacmode
!=0);
1923 /* avoid problems with AAC_QUIRK_SCSI_32 controllers */
1924 if (dev
->dac_support
&& (aac_get_driver_ident(dev
->cardtype
)->quirks
1925 & AAC_QUIRK_SCSI_32
)) {
1926 dev
->nondasd_support
= 0;
1928 expose_physicals
= 0;
1931 if(dev
->dac_support
!= 0) {
1932 if (!pci_set_dma_mask(dev
->pdev
, DMA_BIT_MASK(64)) &&
1933 !pci_set_consistent_dma_mask(dev
->pdev
, DMA_BIT_MASK(64))) {
1935 printk(KERN_INFO
"%s%d: 64 Bit DAC enabled\n",
1936 dev
->name
, dev
->id
);
1937 } else if (!pci_set_dma_mask(dev
->pdev
, DMA_BIT_MASK(32)) &&
1938 !pci_set_consistent_dma_mask(dev
->pdev
, DMA_BIT_MASK(32))) {
1939 printk(KERN_INFO
"%s%d: DMA mask set failed, 64 Bit DAC disabled\n",
1940 dev
->name
, dev
->id
);
1941 dev
->dac_support
= 0;
1943 printk(KERN_WARNING
"%s%d: No suitable DMA available.\n",
1944 dev
->name
, dev
->id
);
1949 * Deal with configuring for the individualized limits of each packet
1952 dev
->a_ops
.adapter_scsi
= (dev
->dac_support
)
1953 ? ((aac_get_driver_ident(dev
->cardtype
)->quirks
& AAC_QUIRK_SCSI_32
)
1957 if (dev
->raw_io_interface
) {
1958 dev
->a_ops
.adapter_bounds
= (dev
->raw_io_64
)
1961 dev
->a_ops
.adapter_read
= aac_read_raw_io
;
1962 dev
->a_ops
.adapter_write
= aac_write_raw_io
;
1964 dev
->a_ops
.adapter_bounds
= aac_bounds_32
;
1965 dev
->scsi_host_ptr
->sg_tablesize
= (dev
->max_fib_size
-
1966 sizeof(struct aac_fibhdr
) -
1967 sizeof(struct aac_write
) + sizeof(struct sgentry
)) /
1968 sizeof(struct sgentry
);
1969 if (dev
->dac_support
) {
1970 dev
->a_ops
.adapter_read
= aac_read_block64
;
1971 dev
->a_ops
.adapter_write
= aac_write_block64
;
1973 * 38 scatter gather elements
1975 dev
->scsi_host_ptr
->sg_tablesize
=
1976 (dev
->max_fib_size
-
1977 sizeof(struct aac_fibhdr
) -
1978 sizeof(struct aac_write64
) +
1979 sizeof(struct sgentry64
)) /
1980 sizeof(struct sgentry64
);
1982 dev
->a_ops
.adapter_read
= aac_read_block
;
1983 dev
->a_ops
.adapter_write
= aac_write_block
;
1985 dev
->scsi_host_ptr
->max_sectors
= AAC_MAX_32BIT_SGBCOUNT
;
1986 if (!(dev
->adapter_info
.options
& AAC_OPT_NEW_COMM
)) {
1988 * Worst case size that could cause sg overflow when
1989 * we break up SG elements that are larger than 64KB.
1990 * Would be nice if we could tell the SCSI layer what
1991 * the maximum SG element size can be. Worst case is
1992 * (sg_tablesize-1) 4KB elements with one 64KB
1994 * 32bit -> 468 or 238KB 64bit -> 424 or 212KB
1996 dev
->scsi_host_ptr
->max_sectors
=
1997 (dev
->scsi_host_ptr
->sg_tablesize
* 8) + 112;
2000 /* FIB should be freed only after getting the response from the F/W */
2001 if (rcode
!= -ERESTARTSYS
) {
2002 aac_fib_complete(fibptr
);
2003 aac_fib_free(fibptr
);
2010 static void io_callback(void *context
, struct fib
* fibptr
)
2012 struct aac_dev
*dev
;
2013 struct aac_read_reply
*readreply
;
2014 struct scsi_cmnd
*scsicmd
;
2017 scsicmd
= (struct scsi_cmnd
*) context
;
2019 if (!aac_valid_context(scsicmd
, fibptr
))
2023 cid
= scmd_id(scsicmd
);
2025 if (nblank(dprintk(x
))) {
2027 switch (scsicmd
->cmnd
[0]) {
2030 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) |
2031 (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
2035 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
2036 ((u64
)scsicmd
->cmnd
[3] << 48) |
2037 ((u64
)scsicmd
->cmnd
[4] << 40) |
2038 ((u64
)scsicmd
->cmnd
[5] << 32) |
2039 ((u64
)scsicmd
->cmnd
[6] << 24) |
2040 (scsicmd
->cmnd
[7] << 16) |
2041 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
2045 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
2046 (scsicmd
->cmnd
[3] << 16) |
2047 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
2050 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
2051 (scsicmd
->cmnd
[3] << 16) |
2052 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
2056 "io_callback[cpu %d]: lba = %llu, t = %ld.\n",
2057 smp_processor_id(), (unsigned long long)lba
, jiffies
);
2060 BUG_ON(fibptr
== NULL
);
2062 scsi_dma_unmap(scsicmd
);
2064 readreply
= (struct aac_read_reply
*)fib_data(fibptr
);
2065 switch (le32_to_cpu(readreply
->status
)) {
2067 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
2069 dev
->fsa_dev
[cid
].sense_data
.sense_key
= NO_SENSE
;
2072 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
2073 SAM_STAT_CHECK_CONDITION
;
2074 set_sense(&dev
->fsa_dev
[cid
].sense_data
, NOT_READY
,
2075 SENCODE_BECOMING_READY
, ASENCODE_BECOMING_READY
, 0, 0);
2076 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
2077 min_t(size_t, sizeof(dev
->fsa_dev
[cid
].sense_data
),
2078 SCSI_SENSE_BUFFERSIZE
));
2081 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
2082 SAM_STAT_CHECK_CONDITION
;
2083 set_sense(&dev
->fsa_dev
[cid
].sense_data
, MEDIUM_ERROR
,
2084 SENCODE_UNRECOVERED_READ_ERROR
, ASENCODE_NO_SENSE
, 0, 0);
2085 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
2086 min_t(size_t, sizeof(dev
->fsa_dev
[cid
].sense_data
),
2087 SCSI_SENSE_BUFFERSIZE
));
2090 #ifdef AAC_DETAILED_STATUS_INFO
2091 printk(KERN_WARNING
"io_callback: io failed, status = %d\n",
2092 le32_to_cpu(readreply
->status
));
2094 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
2095 SAM_STAT_CHECK_CONDITION
;
2096 set_sense(&dev
->fsa_dev
[cid
].sense_data
,
2097 HARDWARE_ERROR
, SENCODE_INTERNAL_TARGET_FAILURE
,
2098 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0);
2099 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
2100 min_t(size_t, sizeof(dev
->fsa_dev
[cid
].sense_data
),
2101 SCSI_SENSE_BUFFERSIZE
));
2104 aac_fib_complete(fibptr
);
2106 scsicmd
->scsi_done(scsicmd
);
2109 static int aac_read(struct scsi_cmnd
* scsicmd
)
2114 struct aac_dev
*dev
;
2115 struct fib
* cmd_fibcontext
;
2118 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2120 * Get block address and transfer length
2122 switch (scsicmd
->cmnd
[0]) {
2124 dprintk((KERN_DEBUG
"aachba: received a read(6) command on id %d.\n", scmd_id(scsicmd
)));
2126 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) |
2127 (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
2128 count
= scsicmd
->cmnd
[4];
2134 dprintk((KERN_DEBUG
"aachba: received a read(16) command on id %d.\n", scmd_id(scsicmd
)));
2136 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
2137 ((u64
)scsicmd
->cmnd
[3] << 48) |
2138 ((u64
)scsicmd
->cmnd
[4] << 40) |
2139 ((u64
)scsicmd
->cmnd
[5] << 32) |
2140 ((u64
)scsicmd
->cmnd
[6] << 24) |
2141 (scsicmd
->cmnd
[7] << 16) |
2142 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
2143 count
= (scsicmd
->cmnd
[10] << 24) |
2144 (scsicmd
->cmnd
[11] << 16) |
2145 (scsicmd
->cmnd
[12] << 8) | scsicmd
->cmnd
[13];
2148 dprintk((KERN_DEBUG
"aachba: received a read(12) command on id %d.\n", scmd_id(scsicmd
)));
2150 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
2151 (scsicmd
->cmnd
[3] << 16) |
2152 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
2153 count
= (scsicmd
->cmnd
[6] << 24) |
2154 (scsicmd
->cmnd
[7] << 16) |
2155 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
2158 dprintk((KERN_DEBUG
"aachba: received a read(10) command on id %d.\n", scmd_id(scsicmd
)));
2160 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
2161 (scsicmd
->cmnd
[3] << 16) |
2162 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
2163 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
2167 if ((lba
+ count
) > (dev
->fsa_dev
[scmd_id(scsicmd
)].size
)) {
2168 cid
= scmd_id(scsicmd
);
2169 dprintk((KERN_DEBUG
"aacraid: Illegal lba\n"));
2170 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
2171 SAM_STAT_CHECK_CONDITION
;
2172 set_sense(&dev
->fsa_dev
[cid
].sense_data
,
2173 HARDWARE_ERROR
, SENCODE_INTERNAL_TARGET_FAILURE
,
2174 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0);
2175 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
2176 min_t(size_t, sizeof(dev
->fsa_dev
[cid
].sense_data
),
2177 SCSI_SENSE_BUFFERSIZE
));
2178 scsicmd
->scsi_done(scsicmd
);
2182 dprintk((KERN_DEBUG
"aac_read[cpu %d]: lba = %llu, t = %ld.\n",
2183 smp_processor_id(), (unsigned long long)lba
, jiffies
));
2184 if (aac_adapter_bounds(dev
,scsicmd
,lba
))
2187 * Alocate and initialize a Fib
2189 cmd_fibcontext
= aac_fib_alloc_tag(dev
, scsicmd
);
2191 status
= aac_adapter_read(cmd_fibcontext
, scsicmd
, lba
, count
);
2194 * Check that the command queued to the controller
2196 if (status
== -EINPROGRESS
) {
2197 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
2201 printk(KERN_WARNING
"aac_read: aac_fib_send failed with status: %d.\n", status
);
2203 * For some reason, the Fib didn't queue, return QUEUE_FULL
2205 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_TASK_SET_FULL
;
2206 scsicmd
->scsi_done(scsicmd
);
2207 aac_fib_complete(cmd_fibcontext
);
2208 aac_fib_free(cmd_fibcontext
);
2212 static int aac_write(struct scsi_cmnd
* scsicmd
)
2218 struct aac_dev
*dev
;
2219 struct fib
* cmd_fibcontext
;
2222 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2224 * Get block address and transfer length
2226 if (scsicmd
->cmnd
[0] == WRITE_6
) /* 6 byte command */
2228 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) | (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
2229 count
= scsicmd
->cmnd
[4];
2233 } else if (scsicmd
->cmnd
[0] == WRITE_16
) { /* 16 byte command */
2234 dprintk((KERN_DEBUG
"aachba: received a write(16) command on id %d.\n", scmd_id(scsicmd
)));
2236 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
2237 ((u64
)scsicmd
->cmnd
[3] << 48) |
2238 ((u64
)scsicmd
->cmnd
[4] << 40) |
2239 ((u64
)scsicmd
->cmnd
[5] << 32) |
2240 ((u64
)scsicmd
->cmnd
[6] << 24) |
2241 (scsicmd
->cmnd
[7] << 16) |
2242 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
2243 count
= (scsicmd
->cmnd
[10] << 24) | (scsicmd
->cmnd
[11] << 16) |
2244 (scsicmd
->cmnd
[12] << 8) | scsicmd
->cmnd
[13];
2245 fua
= scsicmd
->cmnd
[1] & 0x8;
2246 } else if (scsicmd
->cmnd
[0] == WRITE_12
) { /* 12 byte command */
2247 dprintk((KERN_DEBUG
"aachba: received a write(12) command on id %d.\n", scmd_id(scsicmd
)));
2249 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16)
2250 | (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
2251 count
= (scsicmd
->cmnd
[6] << 24) | (scsicmd
->cmnd
[7] << 16)
2252 | (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
2253 fua
= scsicmd
->cmnd
[1] & 0x8;
2255 dprintk((KERN_DEBUG
"aachba: received a write(10) command on id %d.\n", scmd_id(scsicmd
)));
2256 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16) | (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
2257 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
2258 fua
= scsicmd
->cmnd
[1] & 0x8;
2261 if ((lba
+ count
) > (dev
->fsa_dev
[scmd_id(scsicmd
)].size
)) {
2262 cid
= scmd_id(scsicmd
);
2263 dprintk((KERN_DEBUG
"aacraid: Illegal lba\n"));
2264 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
2265 SAM_STAT_CHECK_CONDITION
;
2266 set_sense(&dev
->fsa_dev
[cid
].sense_data
,
2267 HARDWARE_ERROR
, SENCODE_INTERNAL_TARGET_FAILURE
,
2268 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0);
2269 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
2270 min_t(size_t, sizeof(dev
->fsa_dev
[cid
].sense_data
),
2271 SCSI_SENSE_BUFFERSIZE
));
2272 scsicmd
->scsi_done(scsicmd
);
2276 dprintk((KERN_DEBUG
"aac_write[cpu %d]: lba = %llu, t = %ld.\n",
2277 smp_processor_id(), (unsigned long long)lba
, jiffies
));
2278 if (aac_adapter_bounds(dev
,scsicmd
,lba
))
2281 * Allocate and initialize a Fib then setup a BlockWrite command
2283 cmd_fibcontext
= aac_fib_alloc_tag(dev
, scsicmd
);
2285 status
= aac_adapter_write(cmd_fibcontext
, scsicmd
, lba
, count
, fua
);
2288 * Check that the command queued to the controller
2290 if (status
== -EINPROGRESS
) {
2291 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
2295 printk(KERN_WARNING
"aac_write: aac_fib_send failed with status: %d\n", status
);
2297 * For some reason, the Fib didn't queue, return QUEUE_FULL
2299 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_TASK_SET_FULL
;
2300 scsicmd
->scsi_done(scsicmd
);
2302 aac_fib_complete(cmd_fibcontext
);
2303 aac_fib_free(cmd_fibcontext
);
2307 static void synchronize_callback(void *context
, struct fib
*fibptr
)
2309 struct aac_synchronize_reply
*synchronizereply
;
2310 struct scsi_cmnd
*cmd
;
2314 if (!aac_valid_context(cmd
, fibptr
))
2317 dprintk((KERN_DEBUG
"synchronize_callback[cpu %d]: t = %ld.\n",
2318 smp_processor_id(), jiffies
));
2319 BUG_ON(fibptr
== NULL
);
2322 synchronizereply
= fib_data(fibptr
);
2323 if (le32_to_cpu(synchronizereply
->status
) == CT_OK
)
2324 cmd
->result
= DID_OK
<< 16 |
2325 COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
2327 struct scsi_device
*sdev
= cmd
->device
;
2328 struct aac_dev
*dev
= fibptr
->dev
;
2329 u32 cid
= sdev_id(sdev
);
2331 "synchronize_callback: synchronize failed, status = %d\n",
2332 le32_to_cpu(synchronizereply
->status
));
2333 cmd
->result
= DID_OK
<< 16 |
2334 COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
2335 set_sense(&dev
->fsa_dev
[cid
].sense_data
,
2336 HARDWARE_ERROR
, SENCODE_INTERNAL_TARGET_FAILURE
,
2337 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0);
2338 memcpy(cmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
2339 min_t(size_t, sizeof(dev
->fsa_dev
[cid
].sense_data
),
2340 SCSI_SENSE_BUFFERSIZE
));
2343 aac_fib_complete(fibptr
);
2344 aac_fib_free(fibptr
);
2345 cmd
->scsi_done(cmd
);
2348 static int aac_synchronize(struct scsi_cmnd
*scsicmd
)
2351 struct fib
*cmd_fibcontext
;
2352 struct aac_synchronize
*synchronizecmd
;
2353 struct scsi_cmnd
*cmd
;
2354 struct scsi_device
*sdev
= scsicmd
->device
;
2356 struct aac_dev
*aac
;
2357 u64 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16) |
2358 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
2359 u32 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
2360 unsigned long flags
;
2363 * Wait for all outstanding queued commands to complete to this
2364 * specific target (block).
2366 spin_lock_irqsave(&sdev
->list_lock
, flags
);
2367 list_for_each_entry(cmd
, &sdev
->cmd_list
, list
)
2368 if (cmd
->SCp
.phase
== AAC_OWNER_FIRMWARE
) {
2372 if (cmd
->cmnd
[0] == WRITE_6
) {
2373 cmnd_lba
= ((cmd
->cmnd
[1] & 0x1F) << 16) |
2374 (cmd
->cmnd
[2] << 8) |
2376 cmnd_count
= cmd
->cmnd
[4];
2377 if (cmnd_count
== 0)
2379 } else if (cmd
->cmnd
[0] == WRITE_16
) {
2380 cmnd_lba
= ((u64
)cmd
->cmnd
[2] << 56) |
2381 ((u64
)cmd
->cmnd
[3] << 48) |
2382 ((u64
)cmd
->cmnd
[4] << 40) |
2383 ((u64
)cmd
->cmnd
[5] << 32) |
2384 ((u64
)cmd
->cmnd
[6] << 24) |
2385 (cmd
->cmnd
[7] << 16) |
2386 (cmd
->cmnd
[8] << 8) |
2388 cmnd_count
= (cmd
->cmnd
[10] << 24) |
2389 (cmd
->cmnd
[11] << 16) |
2390 (cmd
->cmnd
[12] << 8) |
2392 } else if (cmd
->cmnd
[0] == WRITE_12
) {
2393 cmnd_lba
= ((u64
)cmd
->cmnd
[2] << 24) |
2394 (cmd
->cmnd
[3] << 16) |
2395 (cmd
->cmnd
[4] << 8) |
2397 cmnd_count
= (cmd
->cmnd
[6] << 24) |
2398 (cmd
->cmnd
[7] << 16) |
2399 (cmd
->cmnd
[8] << 8) |
2401 } else if (cmd
->cmnd
[0] == WRITE_10
) {
2402 cmnd_lba
= ((u64
)cmd
->cmnd
[2] << 24) |
2403 (cmd
->cmnd
[3] << 16) |
2404 (cmd
->cmnd
[4] << 8) |
2406 cmnd_count
= (cmd
->cmnd
[7] << 8) |
2410 if (((cmnd_lba
+ cmnd_count
) < lba
) ||
2411 (count
&& ((lba
+ count
) < cmnd_lba
)))
2417 spin_unlock_irqrestore(&sdev
->list_lock
, flags
);
2420 * Yield the processor (requeue for later)
2423 return SCSI_MLQUEUE_DEVICE_BUSY
;
2425 aac
= (struct aac_dev
*)sdev
->host
->hostdata
;
2427 return SCSI_MLQUEUE_HOST_BUSY
;
2430 * Allocate and initialize a Fib
2432 if (!(cmd_fibcontext
= aac_fib_alloc(aac
)))
2433 return SCSI_MLQUEUE_HOST_BUSY
;
2435 aac_fib_init(cmd_fibcontext
);
2437 synchronizecmd
= fib_data(cmd_fibcontext
);
2438 synchronizecmd
->command
= cpu_to_le32(VM_ContainerConfig
);
2439 synchronizecmd
->type
= cpu_to_le32(CT_FLUSH_CACHE
);
2440 synchronizecmd
->cid
= cpu_to_le32(scmd_id(scsicmd
));
2441 synchronizecmd
->count
=
2442 cpu_to_le32(sizeof(((struct aac_synchronize_reply
*)NULL
)->data
));
2445 * Now send the Fib to the adapter
2447 status
= aac_fib_send(ContainerCommand
,
2449 sizeof(struct aac_synchronize
),
2452 (fib_callback
)synchronize_callback
,
2456 * Check that the command queued to the controller
2458 if (status
== -EINPROGRESS
) {
2459 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
2464 "aac_synchronize: aac_fib_send failed with status: %d.\n", status
);
2465 aac_fib_complete(cmd_fibcontext
);
2466 aac_fib_free(cmd_fibcontext
);
2467 return SCSI_MLQUEUE_HOST_BUSY
;
2470 static void aac_start_stop_callback(void *context
, struct fib
*fibptr
)
2472 struct scsi_cmnd
*scsicmd
= context
;
2474 if (!aac_valid_context(scsicmd
, fibptr
))
2477 BUG_ON(fibptr
== NULL
);
2479 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
2481 aac_fib_complete(fibptr
);
2482 aac_fib_free(fibptr
);
2483 scsicmd
->scsi_done(scsicmd
);
2486 static int aac_start_stop(struct scsi_cmnd
*scsicmd
)
2489 struct fib
*cmd_fibcontext
;
2490 struct aac_power_management
*pmcmd
;
2491 struct scsi_device
*sdev
= scsicmd
->device
;
2492 struct aac_dev
*aac
= (struct aac_dev
*)sdev
->host
->hostdata
;
2494 if (!(aac
->supplement_adapter_info
.SupportedOptions2
&
2495 AAC_OPTION_POWER_MANAGEMENT
)) {
2496 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
2498 scsicmd
->scsi_done(scsicmd
);
2503 return SCSI_MLQUEUE_HOST_BUSY
;
2506 * Allocate and initialize a Fib
2508 cmd_fibcontext
= aac_fib_alloc_tag(aac
, scsicmd
);
2510 aac_fib_init(cmd_fibcontext
);
2512 pmcmd
= fib_data(cmd_fibcontext
);
2513 pmcmd
->command
= cpu_to_le32(VM_ContainerConfig
);
2514 pmcmd
->type
= cpu_to_le32(CT_POWER_MANAGEMENT
);
2515 /* Eject bit ignored, not relevant */
2516 pmcmd
->sub
= (scsicmd
->cmnd
[4] & 1) ?
2517 cpu_to_le32(CT_PM_START_UNIT
) : cpu_to_le32(CT_PM_STOP_UNIT
);
2518 pmcmd
->cid
= cpu_to_le32(sdev_id(sdev
));
2519 pmcmd
->parm
= (scsicmd
->cmnd
[1] & 1) ?
2520 cpu_to_le32(CT_PM_UNIT_IMMEDIATE
) : 0;
2523 * Now send the Fib to the adapter
2525 status
= aac_fib_send(ContainerCommand
,
2527 sizeof(struct aac_power_management
),
2530 (fib_callback
)aac_start_stop_callback
,
2534 * Check that the command queued to the controller
2536 if (status
== -EINPROGRESS
) {
2537 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
2541 aac_fib_complete(cmd_fibcontext
);
2542 aac_fib_free(cmd_fibcontext
);
2543 return SCSI_MLQUEUE_HOST_BUSY
;
2547 * aac_scsi_cmd() - Process SCSI command
2548 * @scsicmd: SCSI command block
2550 * Emulate a SCSI command and queue the required request for the
2554 int aac_scsi_cmd(struct scsi_cmnd
* scsicmd
)
2557 struct Scsi_Host
*host
= scsicmd
->device
->host
;
2558 struct aac_dev
*dev
= (struct aac_dev
*)host
->hostdata
;
2559 struct fsa_dev_info
*fsa_dev_ptr
= dev
->fsa_dev
;
2561 if (fsa_dev_ptr
== NULL
)
2564 * If the bus, id or lun is out of range, return fail
2565 * Test does not apply to ID 16, the pseudo id for the controller
2568 cid
= scmd_id(scsicmd
);
2569 if (cid
!= host
->this_id
) {
2570 if (scmd_channel(scsicmd
) == CONTAINER_CHANNEL
) {
2571 if((cid
>= dev
->maximum_num_containers
) ||
2572 (scsicmd
->device
->lun
!= 0)) {
2573 scsicmd
->result
= DID_NO_CONNECT
<< 16;
2578 * If the target container doesn't exist, it may have
2579 * been newly created
2581 if (((fsa_dev_ptr
[cid
].valid
& 1) == 0) ||
2582 (fsa_dev_ptr
[cid
].sense_data
.sense_key
==
2584 switch (scsicmd
->cmnd
[0]) {
2585 case SERVICE_ACTION_IN_16
:
2586 if (!(dev
->raw_io_interface
) ||
2587 !(dev
->raw_io_64
) ||
2588 ((scsicmd
->cmnd
[1] & 0x1f) != SAI_READ_CAPACITY_16
))
2592 case TEST_UNIT_READY
:
2595 return _aac_probe_container(scsicmd
,
2596 aac_probe_container_callback2
);
2601 } else { /* check for physical non-dasd devices */
2602 if (dev
->nondasd_support
|| expose_physicals
||
2606 return aac_send_srb_fib(scsicmd
);
2608 scsicmd
->result
= DID_NO_CONNECT
<< 16;
2614 * else Command for the controller itself
2616 else if ((scsicmd
->cmnd
[0] != INQUIRY
) && /* only INQUIRY & TUR cmnd supported for controller */
2617 (scsicmd
->cmnd
[0] != TEST_UNIT_READY
))
2619 dprintk((KERN_WARNING
"Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd
->cmnd
[0]));
2620 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
2621 set_sense(&dev
->fsa_dev
[cid
].sense_data
,
2622 ILLEGAL_REQUEST
, SENCODE_INVALID_COMMAND
,
2623 ASENCODE_INVALID_COMMAND
, 0, 0);
2624 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
2625 min_t(size_t, sizeof(dev
->fsa_dev
[cid
].sense_data
),
2626 SCSI_SENSE_BUFFERSIZE
));
2630 switch (scsicmd
->cmnd
[0]) {
2637 return aac_read(scsicmd
);
2645 return aac_write(scsicmd
);
2647 case SYNCHRONIZE_CACHE
:
2648 if (((aac_cache
& 6) == 6) && dev
->cache_protected
) {
2649 scsicmd
->result
= AAC_STAT_GOOD
;
2652 /* Issue FIB to tell Firmware to flush it's cache */
2653 if ((aac_cache
& 6) != 2)
2654 return aac_synchronize(scsicmd
);
2657 struct inquiry_data inq_data
;
2659 dprintk((KERN_DEBUG
"INQUIRY command, ID: %d.\n", cid
));
2660 memset(&inq_data
, 0, sizeof (struct inquiry_data
));
2662 if ((scsicmd
->cmnd
[1] & 0x1) && aac_wwn
) {
2663 char *arr
= (char *)&inq_data
;
2666 arr
[0] = (scmd_id(scsicmd
) == host
->this_id
) ?
2667 INQD_PDT_PROC
: INQD_PDT_DA
;
2668 if (scsicmd
->cmnd
[2] == 0) {
2669 /* supported vital product data pages */
2674 arr
[1] = scsicmd
->cmnd
[2];
2675 scsi_sg_copy_from_buffer(scsicmd
, &inq_data
,
2677 scsicmd
->result
= AAC_STAT_GOOD
;
2678 } else if (scsicmd
->cmnd
[2] == 0x80) {
2679 /* unit serial number page */
2680 arr
[3] = setinqserial(dev
, &arr
[4],
2682 arr
[1] = scsicmd
->cmnd
[2];
2683 scsi_sg_copy_from_buffer(scsicmd
, &inq_data
,
2686 return aac_get_container_serial(
2688 scsicmd
->result
= AAC_STAT_GOOD
;
2689 } else if (scsicmd
->cmnd
[2] == 0x83) {
2690 /* vpd page 0x83 - Device Identification Page */
2691 char *sno
= (char *)&inq_data
;
2692 sno
[3] = setinqserial(dev
, &sno
[4],
2695 return aac_get_container_serial(
2697 scsicmd
->result
= AAC_STAT_GOOD
;
2699 /* vpd page not implemented */
2700 scsicmd
->result
= DID_OK
<< 16 |
2701 COMMAND_COMPLETE
<< 8 |
2702 SAM_STAT_CHECK_CONDITION
;
2703 set_sense(&dev
->fsa_dev
[cid
].sense_data
,
2704 ILLEGAL_REQUEST
, SENCODE_INVALID_CDB_FIELD
,
2705 ASENCODE_NO_SENSE
, 7, 2);
2706 memcpy(scsicmd
->sense_buffer
,
2707 &dev
->fsa_dev
[cid
].sense_data
,
2709 sizeof(dev
->fsa_dev
[cid
].sense_data
),
2710 SCSI_SENSE_BUFFERSIZE
));
2714 inq_data
.inqd_ver
= 2; /* claim compliance to SCSI-2 */
2715 inq_data
.inqd_rdf
= 2; /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */
2716 inq_data
.inqd_len
= 31;
2717 /*Format for "pad2" is RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
2718 inq_data
.inqd_pad2
= 0x32 ; /*WBus16|Sync|CmdQue */
2720 * Set the Vendor, Product, and Revision Level
2721 * see: <vendor>.c i.e. aac.c
2723 if (cid
== host
->this_id
) {
2724 setinqstr(dev
, (void *) (inq_data
.inqd_vid
), ARRAY_SIZE(container_types
));
2725 inq_data
.inqd_pdt
= INQD_PDT_PROC
; /* Processor device */
2726 scsi_sg_copy_from_buffer(scsicmd
, &inq_data
,
2728 scsicmd
->result
= AAC_STAT_GOOD
;
2733 setinqstr(dev
, (void *) (inq_data
.inqd_vid
), fsa_dev_ptr
[cid
].type
);
2734 inq_data
.inqd_pdt
= INQD_PDT_DA
; /* Direct/random access device */
2735 scsi_sg_copy_from_buffer(scsicmd
, &inq_data
, sizeof(inq_data
));
2736 return aac_get_container_name(scsicmd
);
2738 case SERVICE_ACTION_IN_16
:
2739 if (!(dev
->raw_io_interface
) ||
2740 !(dev
->raw_io_64
) ||
2741 ((scsicmd
->cmnd
[1] & 0x1f) != SAI_READ_CAPACITY_16
))
2746 unsigned int alloc_len
;
2748 dprintk((KERN_DEBUG
"READ CAPACITY_16 command.\n"));
2749 capacity
= fsa_dev_ptr
[cid
].size
- 1;
2750 cp
[0] = (capacity
>> 56) & 0xff;
2751 cp
[1] = (capacity
>> 48) & 0xff;
2752 cp
[2] = (capacity
>> 40) & 0xff;
2753 cp
[3] = (capacity
>> 32) & 0xff;
2754 cp
[4] = (capacity
>> 24) & 0xff;
2755 cp
[5] = (capacity
>> 16) & 0xff;
2756 cp
[6] = (capacity
>> 8) & 0xff;
2757 cp
[7] = (capacity
>> 0) & 0xff;
2758 cp
[8] = (fsa_dev_ptr
[cid
].block_size
>> 24) & 0xff;
2759 cp
[9] = (fsa_dev_ptr
[cid
].block_size
>> 16) & 0xff;
2760 cp
[10] = (fsa_dev_ptr
[cid
].block_size
>> 8) & 0xff;
2761 cp
[11] = (fsa_dev_ptr
[cid
].block_size
) & 0xff;
2764 alloc_len
= ((scsicmd
->cmnd
[10] << 24)
2765 + (scsicmd
->cmnd
[11] << 16)
2766 + (scsicmd
->cmnd
[12] << 8) + scsicmd
->cmnd
[13]);
2768 alloc_len
= min_t(size_t, alloc_len
, sizeof(cp
));
2769 scsi_sg_copy_from_buffer(scsicmd
, cp
, alloc_len
);
2770 if (alloc_len
< scsi_bufflen(scsicmd
))
2771 scsi_set_resid(scsicmd
,
2772 scsi_bufflen(scsicmd
) - alloc_len
);
2774 /* Do not cache partition table for arrays */
2775 scsicmd
->device
->removable
= 1;
2777 scsicmd
->result
= AAC_STAT_GOOD
;
2786 dprintk((KERN_DEBUG
"READ CAPACITY command.\n"));
2787 if (fsa_dev_ptr
[cid
].size
<= 0x100000000ULL
)
2788 capacity
= fsa_dev_ptr
[cid
].size
- 1;
2792 cp
[0] = (capacity
>> 24) & 0xff;
2793 cp
[1] = (capacity
>> 16) & 0xff;
2794 cp
[2] = (capacity
>> 8) & 0xff;
2795 cp
[3] = (capacity
>> 0) & 0xff;
2796 cp
[4] = (fsa_dev_ptr
[cid
].block_size
>> 24) & 0xff;
2797 cp
[5] = (fsa_dev_ptr
[cid
].block_size
>> 16) & 0xff;
2798 cp
[6] = (fsa_dev_ptr
[cid
].block_size
>> 8) & 0xff;
2799 cp
[7] = (fsa_dev_ptr
[cid
].block_size
) & 0xff;
2800 scsi_sg_copy_from_buffer(scsicmd
, cp
, sizeof(cp
));
2801 /* Do not cache partition table for arrays */
2802 scsicmd
->device
->removable
= 1;
2803 scsicmd
->result
= AAC_STAT_GOOD
;
2809 int mode_buf_length
= 4;
2813 if (fsa_dev_ptr
[cid
].size
<= 0x100000000ULL
)
2814 capacity
= fsa_dev_ptr
[cid
].size
- 1;
2818 dprintk((KERN_DEBUG
"MODE SENSE command.\n"));
2819 memset((char *)&mpd
, 0, sizeof(aac_modep_data
));
2821 /* Mode data length */
2822 mpd
.hd
.data_length
= sizeof(mpd
.hd
) - 1;
2823 /* Medium type - default */
2824 mpd
.hd
.med_type
= 0;
2825 /* Device-specific param,
2826 bit 8: 0/1 = write enabled/protected
2827 bit 4: 0/1 = FUA enabled */
2830 if (dev
->raw_io_interface
&& ((aac_cache
& 5) != 1))
2831 mpd
.hd
.dev_par
= 0x10;
2832 if (scsicmd
->cmnd
[1] & 0x8)
2833 mpd
.hd
.bd_length
= 0; /* Block descriptor length */
2835 mpd
.hd
.bd_length
= sizeof(mpd
.bd
);
2836 mpd
.hd
.data_length
+= mpd
.hd
.bd_length
;
2837 mpd
.bd
.block_length
[0] =
2838 (fsa_dev_ptr
[cid
].block_size
>> 16) & 0xff;
2839 mpd
.bd
.block_length
[1] =
2840 (fsa_dev_ptr
[cid
].block_size
>> 8) & 0xff;
2841 mpd
.bd
.block_length
[2] =
2842 fsa_dev_ptr
[cid
].block_size
& 0xff;
2844 mpd
.mpc_buf
[0] = scsicmd
->cmnd
[2];
2845 if (scsicmd
->cmnd
[2] == 0x1C) {
2847 mpd
.mpc_buf
[1] = 0xa;
2848 /* Mode data length */
2849 mpd
.hd
.data_length
= 23;
2851 /* Mode data length */
2852 mpd
.hd
.data_length
= 15;
2855 if (capacity
> 0xffffff) {
2856 mpd
.bd
.block_count
[0] = 0xff;
2857 mpd
.bd
.block_count
[1] = 0xff;
2858 mpd
.bd
.block_count
[2] = 0xff;
2860 mpd
.bd
.block_count
[0] = (capacity
>> 16) & 0xff;
2861 mpd
.bd
.block_count
[1] = (capacity
>> 8) & 0xff;
2862 mpd
.bd
.block_count
[2] = capacity
& 0xff;
2865 if (((scsicmd
->cmnd
[2] & 0x3f) == 8) ||
2866 ((scsicmd
->cmnd
[2] & 0x3f) == 0x3f)) {
2867 mpd
.hd
.data_length
+= 3;
2870 mpd
.mpc_buf
[2] = ((aac_cache
& 6) == 2)
2871 ? 0 : 0x04; /* WCE */
2872 mode_buf_length
= sizeof(mpd
);
2875 if (mode_buf_length
> scsicmd
->cmnd
[4])
2876 mode_buf_length
= scsicmd
->cmnd
[4];
2878 mode_buf_length
= sizeof(mpd
);
2879 scsi_sg_copy_from_buffer(scsicmd
,
2882 scsicmd
->result
= AAC_STAT_GOOD
;
2888 int mode_buf_length
= 8;
2889 aac_modep10_data mpd10
;
2891 if (fsa_dev_ptr
[cid
].size
<= 0x100000000ULL
)
2892 capacity
= fsa_dev_ptr
[cid
].size
- 1;
2896 dprintk((KERN_DEBUG
"MODE SENSE 10 byte command.\n"));
2897 memset((char *)&mpd10
, 0, sizeof(aac_modep10_data
));
2898 /* Mode data length (MSB) */
2899 mpd10
.hd
.data_length
[0] = 0;
2900 /* Mode data length (LSB) */
2901 mpd10
.hd
.data_length
[1] = sizeof(mpd10
.hd
) - 1;
2902 /* Medium type - default */
2903 mpd10
.hd
.med_type
= 0;
2904 /* Device-specific param,
2905 bit 8: 0/1 = write enabled/protected
2906 bit 4: 0/1 = FUA enabled */
2907 mpd10
.hd
.dev_par
= 0;
2909 if (dev
->raw_io_interface
&& ((aac_cache
& 5) != 1))
2910 mpd10
.hd
.dev_par
= 0x10;
2911 mpd10
.hd
.rsrvd
[0] = 0; /* reserved */
2912 mpd10
.hd
.rsrvd
[1] = 0; /* reserved */
2913 if (scsicmd
->cmnd
[1] & 0x8) {
2914 /* Block descriptor length (MSB) */
2915 mpd10
.hd
.bd_length
[0] = 0;
2916 /* Block descriptor length (LSB) */
2917 mpd10
.hd
.bd_length
[1] = 0;
2919 mpd10
.hd
.bd_length
[0] = 0;
2920 mpd10
.hd
.bd_length
[1] = sizeof(mpd10
.bd
);
2922 mpd10
.hd
.data_length
[1] += mpd10
.hd
.bd_length
[1];
2924 mpd10
.bd
.block_length
[0] =
2925 (fsa_dev_ptr
[cid
].block_size
>> 16) & 0xff;
2926 mpd10
.bd
.block_length
[1] =
2927 (fsa_dev_ptr
[cid
].block_size
>> 8) & 0xff;
2928 mpd10
.bd
.block_length
[2] =
2929 fsa_dev_ptr
[cid
].block_size
& 0xff;
2931 if (capacity
> 0xffffff) {
2932 mpd10
.bd
.block_count
[0] = 0xff;
2933 mpd10
.bd
.block_count
[1] = 0xff;
2934 mpd10
.bd
.block_count
[2] = 0xff;
2936 mpd10
.bd
.block_count
[0] =
2937 (capacity
>> 16) & 0xff;
2938 mpd10
.bd
.block_count
[1] =
2939 (capacity
>> 8) & 0xff;
2940 mpd10
.bd
.block_count
[2] =
2944 if (((scsicmd
->cmnd
[2] & 0x3f) == 8) ||
2945 ((scsicmd
->cmnd
[2] & 0x3f) == 0x3f)) {
2946 mpd10
.hd
.data_length
[1] += 3;
2947 mpd10
.mpc_buf
[0] = 8;
2948 mpd10
.mpc_buf
[1] = 1;
2949 mpd10
.mpc_buf
[2] = ((aac_cache
& 6) == 2)
2950 ? 0 : 0x04; /* WCE */
2951 mode_buf_length
= sizeof(mpd10
);
2952 if (mode_buf_length
> scsicmd
->cmnd
[8])
2953 mode_buf_length
= scsicmd
->cmnd
[8];
2955 scsi_sg_copy_from_buffer(scsicmd
,
2959 scsicmd
->result
= AAC_STAT_GOOD
;
2963 dprintk((KERN_DEBUG
"REQUEST SENSE command.\n"));
2964 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
2965 sizeof(struct sense_data
));
2966 memset(&dev
->fsa_dev
[cid
].sense_data
, 0,
2967 sizeof(struct sense_data
));
2968 scsicmd
->result
= AAC_STAT_GOOD
;
2971 case ALLOW_MEDIUM_REMOVAL
:
2972 dprintk((KERN_DEBUG
"LOCK command.\n"));
2973 if (scsicmd
->cmnd
[4])
2974 fsa_dev_ptr
[cid
].locked
= 1;
2976 fsa_dev_ptr
[cid
].locked
= 0;
2978 scsicmd
->result
= AAC_STAT_GOOD
;
2981 * These commands are all No-Ops
2983 case TEST_UNIT_READY
:
2984 if (fsa_dev_ptr
[cid
].sense_data
.sense_key
== NOT_READY
) {
2985 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
2986 SAM_STAT_CHECK_CONDITION
;
2987 set_sense(&dev
->fsa_dev
[cid
].sense_data
,
2988 NOT_READY
, SENCODE_BECOMING_READY
,
2989 ASENCODE_BECOMING_READY
, 0, 0);
2990 memcpy(scsicmd
->sense_buffer
,
2991 &dev
->fsa_dev
[cid
].sense_data
,
2993 sizeof(dev
->fsa_dev
[cid
].sense_data
),
2994 SCSI_SENSE_BUFFERSIZE
));
3000 case REASSIGN_BLOCKS
:
3002 scsicmd
->result
= AAC_STAT_GOOD
;
3006 return aac_start_stop(scsicmd
);
3011 * Unhandled commands
3013 dprintk((KERN_WARNING
"Unhandled SCSI Command: 0x%x.\n",
3015 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
3016 SAM_STAT_CHECK_CONDITION
;
3017 set_sense(&dev
->fsa_dev
[cid
].sense_data
,
3018 ILLEGAL_REQUEST
, SENCODE_INVALID_COMMAND
,
3019 ASENCODE_INVALID_COMMAND
, 0, 0);
3020 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
3022 sizeof(dev
->fsa_dev
[cid
].sense_data
),
3023 SCSI_SENSE_BUFFERSIZE
));
3028 scsicmd
->scsi_done(scsicmd
);
3032 static int query_disk(struct aac_dev
*dev
, void __user
*arg
)
3034 struct aac_query_disk qd
;
3035 struct fsa_dev_info
*fsa_dev_ptr
;
3037 fsa_dev_ptr
= dev
->fsa_dev
;
3040 if (copy_from_user(&qd
, arg
, sizeof (struct aac_query_disk
)))
3044 else if ((qd
.bus
== -1) && (qd
.id
== -1) && (qd
.lun
== -1))
3046 if (qd
.cnum
< 0 || qd
.cnum
>= dev
->maximum_num_containers
)
3048 qd
.instance
= dev
->scsi_host_ptr
->host_no
;
3050 qd
.id
= CONTAINER_TO_ID(qd
.cnum
);
3051 qd
.lun
= CONTAINER_TO_LUN(qd
.cnum
);
3053 else return -EINVAL
;
3055 qd
.valid
= fsa_dev_ptr
[qd
.cnum
].valid
!= 0;
3056 qd
.locked
= fsa_dev_ptr
[qd
.cnum
].locked
;
3057 qd
.deleted
= fsa_dev_ptr
[qd
.cnum
].deleted
;
3059 if (fsa_dev_ptr
[qd
.cnum
].devname
[0] == '\0')
3064 strlcpy(qd
.name
, fsa_dev_ptr
[qd
.cnum
].devname
,
3065 min(sizeof(qd
.name
), sizeof(fsa_dev_ptr
[qd
.cnum
].devname
) + 1));
3067 if (copy_to_user(arg
, &qd
, sizeof (struct aac_query_disk
)))
3072 static int force_delete_disk(struct aac_dev
*dev
, void __user
*arg
)
3074 struct aac_delete_disk dd
;
3075 struct fsa_dev_info
*fsa_dev_ptr
;
3077 fsa_dev_ptr
= dev
->fsa_dev
;
3081 if (copy_from_user(&dd
, arg
, sizeof (struct aac_delete_disk
)))
3084 if (dd
.cnum
>= dev
->maximum_num_containers
)
3087 * Mark this container as being deleted.
3089 fsa_dev_ptr
[dd
.cnum
].deleted
= 1;
3091 * Mark the container as no longer valid
3093 fsa_dev_ptr
[dd
.cnum
].valid
= 0;
3097 static int delete_disk(struct aac_dev
*dev
, void __user
*arg
)
3099 struct aac_delete_disk dd
;
3100 struct fsa_dev_info
*fsa_dev_ptr
;
3102 fsa_dev_ptr
= dev
->fsa_dev
;
3106 if (copy_from_user(&dd
, arg
, sizeof (struct aac_delete_disk
)))
3109 if (dd
.cnum
>= dev
->maximum_num_containers
)
3112 * If the container is locked, it can not be deleted by the API.
3114 if (fsa_dev_ptr
[dd
.cnum
].locked
)
3118 * Mark the container as no longer being valid.
3120 fsa_dev_ptr
[dd
.cnum
].valid
= 0;
3121 fsa_dev_ptr
[dd
.cnum
].devname
[0] = '\0';
3126 int aac_dev_ioctl(struct aac_dev
*dev
, int cmd
, void __user
*arg
)
3129 case FSACTL_QUERY_DISK
:
3130 return query_disk(dev
, arg
);
3131 case FSACTL_DELETE_DISK
:
3132 return delete_disk(dev
, arg
);
3133 case FSACTL_FORCE_DELETE_DISK
:
3134 return force_delete_disk(dev
, arg
);
3135 case FSACTL_GET_CONTAINERS
:
3136 return aac_get_containers(dev
);
3145 * @context: the context set in the fib - here it is scsi cmd
3146 * @fibptr: pointer to the fib
3148 * Handles the completion of a scsi command to a non dasd device
3152 static void aac_srb_callback(void *context
, struct fib
* fibptr
)
3154 struct aac_dev
*dev
;
3155 struct aac_srb_reply
*srbreply
;
3156 struct scsi_cmnd
*scsicmd
;
3158 scsicmd
= (struct scsi_cmnd
*) context
;
3160 if (!aac_valid_context(scsicmd
, fibptr
))
3163 BUG_ON(fibptr
== NULL
);
3167 srbreply
= (struct aac_srb_reply
*) fib_data(fibptr
);
3169 scsicmd
->sense_buffer
[0] = '\0'; /* Initialize sense valid flag to false */
3171 if (fibptr
->flags
& FIB_CONTEXT_FLAG_FASTRESP
) {
3173 srbreply
->srb_status
= cpu_to_le32(SRB_STATUS_SUCCESS
);
3174 srbreply
->scsi_status
= cpu_to_le32(SAM_STAT_GOOD
);
3177 * Calculate resid for sg
3179 scsi_set_resid(scsicmd
, scsi_bufflen(scsicmd
)
3180 - le32_to_cpu(srbreply
->data_xfer_length
));
3184 scsi_dma_unmap(scsicmd
);
3186 /* expose physical device if expose_physicald flag is on */
3187 if (scsicmd
->cmnd
[0] == INQUIRY
&& !(scsicmd
->cmnd
[1] & 0x01)
3188 && expose_physicals
> 0)
3189 aac_expose_phy_device(scsicmd
);
3192 * First check the fib status
3195 if (le32_to_cpu(srbreply
->status
) != ST_OK
) {
3198 pr_warn("aac_srb_callback: srb failed, status = %d\n",
3199 le32_to_cpu(srbreply
->status
));
3200 len
= min_t(u32
, le32_to_cpu(srbreply
->sense_data_size
),
3201 SCSI_SENSE_BUFFERSIZE
);
3202 scsicmd
->result
= DID_ERROR
<< 16
3203 | COMMAND_COMPLETE
<< 8
3204 | SAM_STAT_CHECK_CONDITION
;
3205 memcpy(scsicmd
->sense_buffer
,
3206 srbreply
->sense_data
, len
);
3210 * Next check the srb status
3212 switch ((le32_to_cpu(srbreply
->srb_status
))&0x3f) {
3213 case SRB_STATUS_ERROR_RECOVERY
:
3214 case SRB_STATUS_PENDING
:
3215 case SRB_STATUS_SUCCESS
:
3216 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
3218 case SRB_STATUS_DATA_OVERRUN
:
3219 switch (scsicmd
->cmnd
[0]) {
3228 if (le32_to_cpu(srbreply
->data_xfer_length
)
3229 < scsicmd
->underflow
)
3230 pr_warn("aacraid: SCSI CMD underflow\n");
3232 pr_warn("aacraid: SCSI CMD Data Overrun\n");
3233 scsicmd
->result
= DID_ERROR
<< 16
3234 | COMMAND_COMPLETE
<< 8;
3237 scsicmd
->result
= DID_OK
<< 16
3238 | COMMAND_COMPLETE
<< 8;
3241 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
3245 case SRB_STATUS_ABORTED
:
3246 scsicmd
->result
= DID_ABORT
<< 16 | ABORT
<< 8;
3248 case SRB_STATUS_ABORT_FAILED
:
3250 * Not sure about this one - but assuming the
3251 * hba was trying to abort for some reason
3253 scsicmd
->result
= DID_ERROR
<< 16 | ABORT
<< 8;
3255 case SRB_STATUS_PARITY_ERROR
:
3256 scsicmd
->result
= DID_PARITY
<< 16
3257 | MSG_PARITY_ERROR
<< 8;
3259 case SRB_STATUS_NO_DEVICE
:
3260 case SRB_STATUS_INVALID_PATH_ID
:
3261 case SRB_STATUS_INVALID_TARGET_ID
:
3262 case SRB_STATUS_INVALID_LUN
:
3263 case SRB_STATUS_SELECTION_TIMEOUT
:
3264 scsicmd
->result
= DID_NO_CONNECT
<< 16
3265 | COMMAND_COMPLETE
<< 8;
3268 case SRB_STATUS_COMMAND_TIMEOUT
:
3269 case SRB_STATUS_TIMEOUT
:
3270 scsicmd
->result
= DID_TIME_OUT
<< 16
3271 | COMMAND_COMPLETE
<< 8;
3274 case SRB_STATUS_BUSY
:
3275 scsicmd
->result
= DID_BUS_BUSY
<< 16
3276 | COMMAND_COMPLETE
<< 8;
3279 case SRB_STATUS_BUS_RESET
:
3280 scsicmd
->result
= DID_RESET
<< 16
3281 | COMMAND_COMPLETE
<< 8;
3284 case SRB_STATUS_MESSAGE_REJECTED
:
3285 scsicmd
->result
= DID_ERROR
<< 16
3286 | MESSAGE_REJECT
<< 8;
3288 case SRB_STATUS_REQUEST_FLUSHED
:
3289 case SRB_STATUS_ERROR
:
3290 case SRB_STATUS_INVALID_REQUEST
:
3291 case SRB_STATUS_REQUEST_SENSE_FAILED
:
3292 case SRB_STATUS_NO_HBA
:
3293 case SRB_STATUS_UNEXPECTED_BUS_FREE
:
3294 case SRB_STATUS_PHASE_SEQUENCE_FAILURE
:
3295 case SRB_STATUS_BAD_SRB_BLOCK_LENGTH
:
3296 case SRB_STATUS_DELAYED_RETRY
:
3297 case SRB_STATUS_BAD_FUNCTION
:
3298 case SRB_STATUS_NOT_STARTED
:
3299 case SRB_STATUS_NOT_IN_USE
:
3300 case SRB_STATUS_FORCE_ABORT
:
3301 case SRB_STATUS_DOMAIN_VALIDATION_FAIL
:
3303 #ifdef AAC_DETAILED_STATUS_INFO
3304 pr_info("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x -scsi status 0x%x\n",
3305 le32_to_cpu(srbreply
->srb_status
) & 0x3F,
3306 aac_get_status_string(
3307 le32_to_cpu(srbreply
->srb_status
) & 0x3F),
3309 le32_to_cpu(srbreply
->scsi_status
));
3312 * When the CC bit is SET by the host in ATA pass thru CDB,
3313 * driver is supposed to return DID_OK
3315 * When the CC bit is RESET by the host, driver should
3318 if ((scsicmd
->cmnd
[0] == ATA_12
)
3319 || (scsicmd
->cmnd
[0] == ATA_16
)) {
3321 if (scsicmd
->cmnd
[2] & (0x01 << 5)) {
3322 scsicmd
->result
= DID_OK
<< 16
3323 | COMMAND_COMPLETE
<< 8;
3326 scsicmd
->result
= DID_ERROR
<< 16
3327 | COMMAND_COMPLETE
<< 8;
3331 scsicmd
->result
= DID_ERROR
<< 16
3332 | COMMAND_COMPLETE
<< 8;
3336 if (le32_to_cpu(srbreply
->scsi_status
)
3337 == SAM_STAT_CHECK_CONDITION
) {
3340 scsicmd
->result
|= SAM_STAT_CHECK_CONDITION
;
3341 len
= min_t(u32
, le32_to_cpu(srbreply
->sense_data_size
),
3342 SCSI_SENSE_BUFFERSIZE
);
3343 #ifdef AAC_DETAILED_STATUS_INFO
3344 pr_warn("aac_srb_callback: check condition, status = %d len=%d\n",
3345 le32_to_cpu(srbreply
->status
), len
);
3347 memcpy(scsicmd
->sense_buffer
,
3348 srbreply
->sense_data
, len
);
3352 * OR in the scsi status (already shifted up a bit)
3354 scsicmd
->result
|= le32_to_cpu(srbreply
->scsi_status
);
3356 aac_fib_complete(fibptr
);
3357 scsicmd
->scsi_done(scsicmd
);
3363 * @scsicmd: the scsi command block
3365 * This routine will form a FIB and fill in the aac_srb from the
3366 * scsicmd passed in.
3369 static int aac_send_srb_fib(struct scsi_cmnd
* scsicmd
)
3371 struct fib
* cmd_fibcontext
;
3372 struct aac_dev
* dev
;
3375 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
3376 if (scmd_id(scsicmd
) >= dev
->maximum_num_physicals
||
3377 scsicmd
->device
->lun
> 7) {
3378 scsicmd
->result
= DID_NO_CONNECT
<< 16;
3379 scsicmd
->scsi_done(scsicmd
);
3384 * Allocate and initialize a Fib then setup a BlockWrite command
3386 cmd_fibcontext
= aac_fib_alloc_tag(dev
, scsicmd
);
3388 status
= aac_adapter_scsi(cmd_fibcontext
, scsicmd
);
3391 * Check that the command queued to the controller
3393 if (status
== -EINPROGRESS
) {
3394 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
3398 printk(KERN_WARNING
"aac_srb: aac_fib_send failed with status: %d\n", status
);
3399 aac_fib_complete(cmd_fibcontext
);
3400 aac_fib_free(cmd_fibcontext
);
3405 static long aac_build_sg(struct scsi_cmnd
*scsicmd
, struct sgmap
*psg
)
3407 struct aac_dev
*dev
;
3408 unsigned long byte_count
= 0;
3411 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
3412 // Get rid of old data
3414 psg
->sg
[0].addr
= 0;
3415 psg
->sg
[0].count
= 0;
3417 nseg
= scsi_dma_map(scsicmd
);
3421 struct scatterlist
*sg
;
3424 psg
->count
= cpu_to_le32(nseg
);
3426 scsi_for_each_sg(scsicmd
, sg
, nseg
, i
) {
3427 psg
->sg
[i
].addr
= cpu_to_le32(sg_dma_address(sg
));
3428 psg
->sg
[i
].count
= cpu_to_le32(sg_dma_len(sg
));
3429 byte_count
+= sg_dma_len(sg
);
3431 /* hba wants the size to be exact */
3432 if (byte_count
> scsi_bufflen(scsicmd
)) {
3433 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
3434 (byte_count
- scsi_bufflen(scsicmd
));
3435 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
3436 byte_count
= scsi_bufflen(scsicmd
);
3438 /* Check for command underflow */
3439 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
3440 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
3441 byte_count
, scsicmd
->underflow
);
3448 static long aac_build_sg64(struct scsi_cmnd
*scsicmd
, struct sgmap64
*psg
)
3450 struct aac_dev
*dev
;
3451 unsigned long byte_count
= 0;
3455 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
3456 // Get rid of old data
3458 psg
->sg
[0].addr
[0] = 0;
3459 psg
->sg
[0].addr
[1] = 0;
3460 psg
->sg
[0].count
= 0;
3462 nseg
= scsi_dma_map(scsicmd
);
3466 struct scatterlist
*sg
;
3469 scsi_for_each_sg(scsicmd
, sg
, nseg
, i
) {
3470 int count
= sg_dma_len(sg
);
3471 addr
= sg_dma_address(sg
);
3472 psg
->sg
[i
].addr
[0] = cpu_to_le32(addr
& 0xffffffff);
3473 psg
->sg
[i
].addr
[1] = cpu_to_le32(addr
>>32);
3474 psg
->sg
[i
].count
= cpu_to_le32(count
);
3475 byte_count
+= count
;
3477 psg
->count
= cpu_to_le32(nseg
);
3478 /* hba wants the size to be exact */
3479 if (byte_count
> scsi_bufflen(scsicmd
)) {
3480 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
3481 (byte_count
- scsi_bufflen(scsicmd
));
3482 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
3483 byte_count
= scsi_bufflen(scsicmd
);
3485 /* Check for command underflow */
3486 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
3487 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
3488 byte_count
, scsicmd
->underflow
);
3494 static long aac_build_sgraw(struct scsi_cmnd
*scsicmd
, struct sgmapraw
*psg
)
3496 unsigned long byte_count
= 0;
3499 // Get rid of old data
3501 psg
->sg
[0].next
= 0;
3502 psg
->sg
[0].prev
= 0;
3503 psg
->sg
[0].addr
[0] = 0;
3504 psg
->sg
[0].addr
[1] = 0;
3505 psg
->sg
[0].count
= 0;
3506 psg
->sg
[0].flags
= 0;
3508 nseg
= scsi_dma_map(scsicmd
);
3512 struct scatterlist
*sg
;
3515 scsi_for_each_sg(scsicmd
, sg
, nseg
, i
) {
3516 int count
= sg_dma_len(sg
);
3517 u64 addr
= sg_dma_address(sg
);
3518 psg
->sg
[i
].next
= 0;
3519 psg
->sg
[i
].prev
= 0;
3520 psg
->sg
[i
].addr
[1] = cpu_to_le32((u32
)(addr
>>32));
3521 psg
->sg
[i
].addr
[0] = cpu_to_le32((u32
)(addr
& 0xffffffff));
3522 psg
->sg
[i
].count
= cpu_to_le32(count
);
3523 psg
->sg
[i
].flags
= 0;
3524 byte_count
+= count
;
3526 psg
->count
= cpu_to_le32(nseg
);
3527 /* hba wants the size to be exact */
3528 if (byte_count
> scsi_bufflen(scsicmd
)) {
3529 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
3530 (byte_count
- scsi_bufflen(scsicmd
));
3531 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
3532 byte_count
= scsi_bufflen(scsicmd
);
3534 /* Check for command underflow */
3535 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
3536 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
3537 byte_count
, scsicmd
->underflow
);
3543 static long aac_build_sgraw2(struct scsi_cmnd
*scsicmd
,
3544 struct aac_raw_io2
*rio2
, int sg_max
)
3546 unsigned long byte_count
= 0;
3549 nseg
= scsi_dma_map(scsicmd
);
3553 struct scatterlist
*sg
;
3554 int i
, conformable
= 0;
3555 u32 min_size
= PAGE_SIZE
, cur_size
;
3557 scsi_for_each_sg(scsicmd
, sg
, nseg
, i
) {
3558 int count
= sg_dma_len(sg
);
3559 u64 addr
= sg_dma_address(sg
);
3561 BUG_ON(i
>= sg_max
);
3562 rio2
->sge
[i
].addrHigh
= cpu_to_le32((u32
)(addr
>>32));
3563 rio2
->sge
[i
].addrLow
= cpu_to_le32((u32
)(addr
& 0xffffffff));
3564 cur_size
= cpu_to_le32(count
);
3565 rio2
->sge
[i
].length
= cur_size
;
3566 rio2
->sge
[i
].flags
= 0;
3569 rio2
->sgeFirstSize
= cur_size
;
3570 } else if (i
== 1) {
3571 rio2
->sgeNominalSize
= cur_size
;
3572 min_size
= cur_size
;
3573 } else if ((i
+1) < nseg
&& cur_size
!= rio2
->sgeNominalSize
) {
3575 if (cur_size
< min_size
)
3576 min_size
= cur_size
;
3578 byte_count
+= count
;
3581 /* hba wants the size to be exact */
3582 if (byte_count
> scsi_bufflen(scsicmd
)) {
3583 u32 temp
= le32_to_cpu(rio2
->sge
[i
-1].length
) -
3584 (byte_count
- scsi_bufflen(scsicmd
));
3585 rio2
->sge
[i
-1].length
= cpu_to_le32(temp
);
3586 byte_count
= scsi_bufflen(scsicmd
);
3589 rio2
->sgeCnt
= cpu_to_le32(nseg
);
3590 rio2
->flags
|= cpu_to_le16(RIO2_SG_FORMAT_IEEE1212
);
3591 /* not conformable: evaluate required sg elements */
3593 int j
, nseg_new
= nseg
, err_found
;
3594 for (i
= min_size
/ PAGE_SIZE
; i
>= 1; --i
) {
3597 for (j
= 1; j
< nseg
- 1; ++j
) {
3598 if (rio2
->sge
[j
].length
% (i
*PAGE_SIZE
)) {
3602 nseg_new
+= (rio2
->sge
[j
].length
/ (i
*PAGE_SIZE
));
3607 if (i
> 0 && nseg_new
<= sg_max
)
3608 aac_convert_sgraw2(rio2
, i
, nseg
, nseg_new
);
3610 rio2
->flags
|= cpu_to_le16(RIO2_SGL_CONFORMANT
);
3612 /* Check for command underflow */
3613 if (scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)) {
3614 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
3615 byte_count
, scsicmd
->underflow
);
3622 static int aac_convert_sgraw2(struct aac_raw_io2
*rio2
, int pages
, int nseg
, int nseg_new
)
3624 struct sge_ieee1212
*sge
;
3628 if (aac_convert_sgl
== 0)
3631 sge
= kmalloc(nseg_new
* sizeof(struct sge_ieee1212
), GFP_ATOMIC
);
3635 for (i
= 1, pos
= 1; i
< nseg
-1; ++i
) {
3636 for (j
= 0; j
< rio2
->sge
[i
].length
/ (pages
* PAGE_SIZE
); ++j
) {
3637 addr_low
= rio2
->sge
[i
].addrLow
+ j
* pages
* PAGE_SIZE
;
3638 sge
[pos
].addrLow
= addr_low
;
3639 sge
[pos
].addrHigh
= rio2
->sge
[i
].addrHigh
;
3640 if (addr_low
< rio2
->sge
[i
].addrLow
)
3641 sge
[pos
].addrHigh
++;
3642 sge
[pos
].length
= pages
* PAGE_SIZE
;
3647 sge
[pos
] = rio2
->sge
[nseg
-1];
3648 memcpy(&rio2
->sge
[1], &sge
[1], (nseg_new
-1)*sizeof(struct sge_ieee1212
));
3651 rio2
->sgeCnt
= cpu_to_le32(nseg_new
);
3652 rio2
->flags
|= cpu_to_le16(RIO2_SGL_CONFORMANT
);
3653 rio2
->sgeNominalSize
= pages
* PAGE_SIZE
;
3657 #ifdef AAC_DETAILED_STATUS_INFO
3659 struct aac_srb_status_info
{
3665 static struct aac_srb_status_info srb_status_info
[] = {
3666 { SRB_STATUS_PENDING
, "Pending Status"},
3667 { SRB_STATUS_SUCCESS
, "Success"},
3668 { SRB_STATUS_ABORTED
, "Aborted Command"},
3669 { SRB_STATUS_ABORT_FAILED
, "Abort Failed"},
3670 { SRB_STATUS_ERROR
, "Error Event"},
3671 { SRB_STATUS_BUSY
, "Device Busy"},
3672 { SRB_STATUS_INVALID_REQUEST
, "Invalid Request"},
3673 { SRB_STATUS_INVALID_PATH_ID
, "Invalid Path ID"},
3674 { SRB_STATUS_NO_DEVICE
, "No Device"},
3675 { SRB_STATUS_TIMEOUT
, "Timeout"},
3676 { SRB_STATUS_SELECTION_TIMEOUT
, "Selection Timeout"},
3677 { SRB_STATUS_COMMAND_TIMEOUT
, "Command Timeout"},
3678 { SRB_STATUS_MESSAGE_REJECTED
, "Message Rejected"},
3679 { SRB_STATUS_BUS_RESET
, "Bus Reset"},
3680 { SRB_STATUS_PARITY_ERROR
, "Parity Error"},
3681 { SRB_STATUS_REQUEST_SENSE_FAILED
,"Request Sense Failed"},
3682 { SRB_STATUS_NO_HBA
, "No HBA"},
3683 { SRB_STATUS_DATA_OVERRUN
, "Data Overrun/Data Underrun"},
3684 { SRB_STATUS_UNEXPECTED_BUS_FREE
,"Unexpected Bus Free"},
3685 { SRB_STATUS_PHASE_SEQUENCE_FAILURE
,"Phase Error"},
3686 { SRB_STATUS_BAD_SRB_BLOCK_LENGTH
,"Bad Srb Block Length"},
3687 { SRB_STATUS_REQUEST_FLUSHED
, "Request Flushed"},
3688 { SRB_STATUS_DELAYED_RETRY
, "Delayed Retry"},
3689 { SRB_STATUS_INVALID_LUN
, "Invalid LUN"},
3690 { SRB_STATUS_INVALID_TARGET_ID
, "Invalid TARGET ID"},
3691 { SRB_STATUS_BAD_FUNCTION
, "Bad Function"},
3692 { SRB_STATUS_ERROR_RECOVERY
, "Error Recovery"},
3693 { SRB_STATUS_NOT_STARTED
, "Not Started"},
3694 { SRB_STATUS_NOT_IN_USE
, "Not In Use"},
3695 { SRB_STATUS_FORCE_ABORT
, "Force Abort"},
3696 { SRB_STATUS_DOMAIN_VALIDATION_FAIL
,"Domain Validation Failure"},
3697 { 0xff, "Unknown Error"}
3700 char *aac_get_status_string(u32 status
)
3704 for (i
= 0; i
< ARRAY_SIZE(srb_status_info
); i
++)
3705 if (srb_status_info
[i
].status
== status
)
3706 return srb_status_info
[i
].str
;
3708 return "Bad Status Code";