2 * Adaptec AAC series RAID controller driver
3 * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com>
5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux.
8 * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com)
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; see the file COPYING. If not, write to
22 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <linux/kernel.h>
27 #include <linux/init.h>
28 #include <linux/types.h>
29 #include <linux/pci.h>
30 #include <linux/spinlock.h>
31 #include <linux/slab.h>
32 #include <linux/completion.h>
33 #include <linux/blkdev.h>
34 #include <linux/dma-mapping.h>
35 #include <asm/semaphore.h>
36 #include <asm/uaccess.h>
38 #include <scsi/scsi.h>
39 #include <scsi/scsi_cmnd.h>
40 #include <scsi/scsi_device.h>
41 #include <scsi/scsi_host.h>
45 /* values for inqd_pdt: Peripheral device type in plain English */
46 #define INQD_PDT_DA 0x00 /* Direct-access (DISK) device */
47 #define INQD_PDT_PROC 0x03 /* Processor device */
48 #define INQD_PDT_CHNGR 0x08 /* Changer (jukebox, scsi2) */
49 #define INQD_PDT_COMM 0x09 /* Communication device (scsi2) */
50 #define INQD_PDT_NOLUN2 0x1f /* Unknown Device (scsi2) */
51 #define INQD_PDT_NOLUN 0x7f /* Logical Unit Not Present */
53 #define INQD_PDT_DMASK 0x1F /* Peripheral Device Type Mask */
54 #define INQD_PDT_QMASK 0xE0 /* Peripheral Device Qualifer Mask */
60 #define SENCODE_NO_SENSE 0x00
61 #define SENCODE_END_OF_DATA 0x00
62 #define SENCODE_BECOMING_READY 0x04
63 #define SENCODE_INIT_CMD_REQUIRED 0x04
64 #define SENCODE_PARAM_LIST_LENGTH_ERROR 0x1A
65 #define SENCODE_INVALID_COMMAND 0x20
66 #define SENCODE_LBA_OUT_OF_RANGE 0x21
67 #define SENCODE_INVALID_CDB_FIELD 0x24
68 #define SENCODE_LUN_NOT_SUPPORTED 0x25
69 #define SENCODE_INVALID_PARAM_FIELD 0x26
70 #define SENCODE_PARAM_NOT_SUPPORTED 0x26
71 #define SENCODE_PARAM_VALUE_INVALID 0x26
72 #define SENCODE_RESET_OCCURRED 0x29
73 #define SENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x3E
74 #define SENCODE_INQUIRY_DATA_CHANGED 0x3F
75 #define SENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x39
76 #define SENCODE_DIAGNOSTIC_FAILURE 0x40
77 #define SENCODE_INTERNAL_TARGET_FAILURE 0x44
78 #define SENCODE_INVALID_MESSAGE_ERROR 0x49
79 #define SENCODE_LUN_FAILED_SELF_CONFIG 0x4c
80 #define SENCODE_OVERLAPPED_COMMAND 0x4E
83 * Additional sense codes
86 #define ASENCODE_NO_SENSE 0x00
87 #define ASENCODE_END_OF_DATA 0x05
88 #define ASENCODE_BECOMING_READY 0x01
89 #define ASENCODE_INIT_CMD_REQUIRED 0x02
90 #define ASENCODE_PARAM_LIST_LENGTH_ERROR 0x00
91 #define ASENCODE_INVALID_COMMAND 0x00
92 #define ASENCODE_LBA_OUT_OF_RANGE 0x00
93 #define ASENCODE_INVALID_CDB_FIELD 0x00
94 #define ASENCODE_LUN_NOT_SUPPORTED 0x00
95 #define ASENCODE_INVALID_PARAM_FIELD 0x00
96 #define ASENCODE_PARAM_NOT_SUPPORTED 0x01
97 #define ASENCODE_PARAM_VALUE_INVALID 0x02
98 #define ASENCODE_RESET_OCCURRED 0x00
99 #define ASENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x00
100 #define ASENCODE_INQUIRY_DATA_CHANGED 0x03
101 #define ASENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x00
102 #define ASENCODE_DIAGNOSTIC_FAILURE 0x80
103 #define ASENCODE_INTERNAL_TARGET_FAILURE 0x00
104 #define ASENCODE_INVALID_MESSAGE_ERROR 0x00
105 #define ASENCODE_LUN_FAILED_SELF_CONFIG 0x00
106 #define ASENCODE_OVERLAPPED_COMMAND 0x00
108 #define BYTE0(x) (unsigned char)(x)
109 #define BYTE1(x) (unsigned char)((x) >> 8)
110 #define BYTE2(x) (unsigned char)((x) >> 16)
111 #define BYTE3(x) (unsigned char)((x) >> 24)
113 /*------------------------------------------------------------------------------
114 * S T R U C T S / T Y P E D E F S
115 *----------------------------------------------------------------------------*/
116 /* SCSI inquiry data */
117 struct inquiry_data
{
118 u8 inqd_pdt
; /* Peripheral qualifier | Peripheral Device Type */
119 u8 inqd_dtq
; /* RMB | Device Type Qualifier */
120 u8 inqd_ver
; /* ISO version | ECMA version | ANSI-approved version */
121 u8 inqd_rdf
; /* AENC | TrmIOP | Response data format */
122 u8 inqd_len
; /* Additional length (n-4) */
123 u8 inqd_pad1
[2];/* Reserved - must be zero */
124 u8 inqd_pad2
; /* RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
125 u8 inqd_vid
[8]; /* Vendor ID */
126 u8 inqd_pid
[16];/* Product ID */
127 u8 inqd_prl
[4]; /* Product Revision Level */
131 * M O D U L E G L O B A L S
134 static unsigned long aac_build_sg(struct scsi_cmnd
* scsicmd
, struct sgmap
* sgmap
);
135 static unsigned long aac_build_sg64(struct scsi_cmnd
* scsicmd
, struct sgmap64
* psg
);
136 static unsigned long aac_build_sgraw(struct scsi_cmnd
* scsicmd
, struct sgmapraw
* psg
);
137 static int aac_send_srb_fib(struct scsi_cmnd
* scsicmd
);
138 #ifdef AAC_DETAILED_STATUS_INFO
139 static char *aac_get_status_string(u32 status
);
143 * Non dasd selection is handled entirely in aachba now
146 static int nondasd
= -1;
147 static int dacmode
= -1;
150 int startup_timeout
= 180;
151 int aif_timeout
= 120;
153 module_param(nondasd
, int, S_IRUGO
|S_IWUSR
);
154 MODULE_PARM_DESC(nondasd
, "Control scanning of hba for nondasd devices. 0=off, 1=on");
155 module_param(dacmode
, int, S_IRUGO
|S_IWUSR
);
156 MODULE_PARM_DESC(dacmode
, "Control whether dma addressing is using 64 bit DAC. 0=off, 1=on");
157 module_param_named(commit
, aac_commit
, int, S_IRUGO
|S_IWUSR
);
158 MODULE_PARM_DESC(commit
, "Control whether a COMMIT_CONFIG is issued to the adapter for foreign arrays.\nThis is typically needed in systems that do not have a BIOS. 0=off, 1=on");
159 module_param(startup_timeout
, int, S_IRUGO
|S_IWUSR
);
160 MODULE_PARM_DESC(startup_timeout
, "The duration of time in seconds to wait for adapter to have it's kernel up and\nrunning. This is typically adjusted for large systems that do not have a BIOS.");
161 module_param(aif_timeout
, int, S_IRUGO
|S_IWUSR
);
162 MODULE_PARM_DESC(aif_timeout
, "The duration of time in seconds to wait for applications to pick up AIFs before\nderegistering them. This is typically adjusted for heavily burdened systems.");
165 module_param(numacb
, int, S_IRUGO
|S_IWUSR
);
166 MODULE_PARM_DESC(numacb
, "Request a limit to the number of adapter control blocks (FIB) allocated. Valid values are 512 and down. Default is to use suggestion from Firmware.");
169 module_param(acbsize
, int, S_IRUGO
|S_IWUSR
);
170 MODULE_PARM_DESC(acbsize
, "Request a specific adapter control block (FIB) size. Valid values are 512, 2048, 4096 and 8192. Default is to use suggestion from Firmware.");
172 int update_interval
= 30 * 60;
173 module_param(update_interval
, int, S_IRUGO
|S_IWUSR
);
174 MODULE_PARM_DESC(update_interval
, "Interval in seconds between time sync updates issued to adapter.");
176 int check_interval
= 24 * 60 * 60;
177 module_param(check_interval
, int, S_IRUGO
|S_IWUSR
);
178 MODULE_PARM_DESC(check_interval
, "Interval in seconds between adapter health checks.");
181 module_param(check_reset
, int, S_IRUGO
|S_IWUSR
);
182 MODULE_PARM_DESC(check_reset
, "If adapter fails health check, reset the adapter.");
184 int expose_physicals
= -1;
185 module_param(expose_physicals
, int, S_IRUGO
|S_IWUSR
);
186 MODULE_PARM_DESC(expose_physicals
, "Expose physical components of the arrays. -1=protect 0=off, 1=on");
188 int aac_reset_devices
= 0;
189 module_param_named(reset_devices
, aac_reset_devices
, int, S_IRUGO
|S_IWUSR
);
190 MODULE_PARM_DESC(reset_devices
, "Force an adapter reset at initialization.");
192 static inline int aac_valid_context(struct scsi_cmnd
*scsicmd
,
193 struct fib
*fibptr
) {
194 struct scsi_device
*device
;
196 if (unlikely(!scsicmd
|| !scsicmd
->scsi_done
)) {
197 dprintk((KERN_WARNING
"aac_valid_context: scsi command corrupt\n"))
199 aac_fib_complete(fibptr
);
200 aac_fib_free(fibptr
);
203 scsicmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
204 device
= scsicmd
->device
;
205 if (unlikely(!device
|| !scsi_device_online(device
))) {
206 dprintk((KERN_WARNING
"aac_valid_context: scsi device corrupt\n"));
207 aac_fib_complete(fibptr
);
208 aac_fib_free(fibptr
);
215 * aac_get_config_status - check the adapter configuration
216 * @common: adapter to query
218 * Query config status, and commit the configuration if needed.
220 int aac_get_config_status(struct aac_dev
*dev
, int commit_flag
)
225 if (!(fibptr
= aac_fib_alloc(dev
)))
228 aac_fib_init(fibptr
);
230 struct aac_get_config_status
*dinfo
;
231 dinfo
= (struct aac_get_config_status
*) fib_data(fibptr
);
233 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
234 dinfo
->type
= cpu_to_le32(CT_GET_CONFIG_STATUS
);
235 dinfo
->count
= cpu_to_le32(sizeof(((struct aac_get_config_status_resp
*)NULL
)->data
));
238 status
= aac_fib_send(ContainerCommand
,
240 sizeof (struct aac_get_config_status
),
245 printk(KERN_WARNING
"aac_get_config_status: SendFIB failed.\n");
247 struct aac_get_config_status_resp
*reply
248 = (struct aac_get_config_status_resp
*) fib_data(fibptr
);
249 dprintk((KERN_WARNING
250 "aac_get_config_status: response=%d status=%d action=%d\n",
251 le32_to_cpu(reply
->response
),
252 le32_to_cpu(reply
->status
),
253 le32_to_cpu(reply
->data
.action
)));
254 if ((le32_to_cpu(reply
->response
) != ST_OK
) ||
255 (le32_to_cpu(reply
->status
) != CT_OK
) ||
256 (le32_to_cpu(reply
->data
.action
) > CFACT_PAUSE
)) {
257 printk(KERN_WARNING
"aac_get_config_status: Will not issue the Commit Configuration\n");
261 aac_fib_complete(fibptr
);
262 /* Send a CT_COMMIT_CONFIG to enable discovery of devices */
264 if ((aac_commit
== 1) || commit_flag
) {
265 struct aac_commit_config
* dinfo
;
266 aac_fib_init(fibptr
);
267 dinfo
= (struct aac_commit_config
*) fib_data(fibptr
);
269 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
270 dinfo
->type
= cpu_to_le32(CT_COMMIT_CONFIG
);
272 status
= aac_fib_send(ContainerCommand
,
274 sizeof (struct aac_commit_config
),
278 aac_fib_complete(fibptr
);
279 } else if (aac_commit
== 0) {
281 "aac_get_config_status: Foreign device configurations are being ignored\n");
284 aac_fib_free(fibptr
);
289 * aac_get_containers - list containers
290 * @common: adapter to probe
292 * Make a list of all containers on this controller
294 int aac_get_containers(struct aac_dev
*dev
)
296 struct fsa_dev_info
*fsa_dev_ptr
;
300 struct aac_get_container_count
*dinfo
;
301 struct aac_get_container_count_resp
*dresp
;
302 int maximum_num_containers
= MAXIMUM_NUM_CONTAINERS
;
304 if (!(fibptr
= aac_fib_alloc(dev
)))
307 aac_fib_init(fibptr
);
308 dinfo
= (struct aac_get_container_count
*) fib_data(fibptr
);
309 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
310 dinfo
->type
= cpu_to_le32(CT_GET_CONTAINER_COUNT
);
312 status
= aac_fib_send(ContainerCommand
,
314 sizeof (struct aac_get_container_count
),
319 dresp
= (struct aac_get_container_count_resp
*)fib_data(fibptr
);
320 maximum_num_containers
= le32_to_cpu(dresp
->ContainerSwitchEntries
);
321 aac_fib_complete(fibptr
);
323 aac_fib_free(fibptr
);
325 if (maximum_num_containers
< MAXIMUM_NUM_CONTAINERS
)
326 maximum_num_containers
= MAXIMUM_NUM_CONTAINERS
;
327 fsa_dev_ptr
= kzalloc(sizeof(*fsa_dev_ptr
) * maximum_num_containers
,
332 dev
->fsa_dev
= fsa_dev_ptr
;
333 dev
->maximum_num_containers
= maximum_num_containers
;
335 for (index
= 0; index
< dev
->maximum_num_containers
; ) {
336 fsa_dev_ptr
[index
].devname
[0] = '\0';
338 status
= aac_probe_container(dev
, index
);
341 printk(KERN_WARNING
"aac_get_containers: SendFIB failed.\n");
346 * If there are no more containers, then stop asking.
348 if (++index
>= status
)
354 static void aac_internal_transfer(struct scsi_cmnd
*scsicmd
, void *data
, unsigned int offset
, unsigned int len
)
358 struct scatterlist
*sg
= scsi_sglist(scsicmd
);
360 buf
= kmap_atomic(sg
->page
, KM_IRQ0
) + sg
->offset
;
361 transfer_len
= min(sg
->length
, len
+ offset
);
363 transfer_len
-= offset
;
364 if (buf
&& transfer_len
> 0)
365 memcpy(buf
+ offset
, data
, transfer_len
);
367 kunmap_atomic(buf
- sg
->offset
, KM_IRQ0
);
371 static void get_container_name_callback(void *context
, struct fib
* fibptr
)
373 struct aac_get_name_resp
* get_name_reply
;
374 struct scsi_cmnd
* scsicmd
;
376 scsicmd
= (struct scsi_cmnd
*) context
;
378 if (!aac_valid_context(scsicmd
, fibptr
))
381 dprintk((KERN_DEBUG
"get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies
));
382 BUG_ON(fibptr
== NULL
);
384 get_name_reply
= (struct aac_get_name_resp
*) fib_data(fibptr
);
385 /* Failure is irrelevant, using default value instead */
386 if ((le32_to_cpu(get_name_reply
->status
) == CT_OK
)
387 && (get_name_reply
->data
[0] != '\0')) {
388 char *sp
= get_name_reply
->data
;
389 sp
[sizeof(((struct aac_get_name_resp
*)NULL
)->data
)-1] = '\0';
393 char d
[sizeof(((struct inquiry_data
*)NULL
)->inqd_pid
)];
394 int count
= sizeof(d
);
397 *dp
++ = (*sp
) ? *sp
++ : ' ';
398 } while (--count
> 0);
399 aac_internal_transfer(scsicmd
, d
,
400 offsetof(struct inquiry_data
, inqd_pid
), sizeof(d
));
404 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
406 aac_fib_complete(fibptr
);
407 aac_fib_free(fibptr
);
408 scsicmd
->scsi_done(scsicmd
);
412 * aac_get_container_name - get container name, none blocking.
414 static int aac_get_container_name(struct scsi_cmnd
* scsicmd
)
417 struct aac_get_name
*dinfo
;
418 struct fib
* cmd_fibcontext
;
419 struct aac_dev
* dev
;
421 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
423 if (!(cmd_fibcontext
= aac_fib_alloc(dev
)))
426 aac_fib_init(cmd_fibcontext
);
427 dinfo
= (struct aac_get_name
*) fib_data(cmd_fibcontext
);
429 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
430 dinfo
->type
= cpu_to_le32(CT_READ_NAME
);
431 dinfo
->cid
= cpu_to_le32(scmd_id(scsicmd
));
432 dinfo
->count
= cpu_to_le32(sizeof(((struct aac_get_name_resp
*)NULL
)->data
));
434 status
= aac_fib_send(ContainerCommand
,
436 sizeof (struct aac_get_name
),
439 (fib_callback
) get_container_name_callback
,
443 * Check that the command queued to the controller
445 if (status
== -EINPROGRESS
) {
446 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
450 printk(KERN_WARNING
"aac_get_container_name: aac_fib_send failed with status: %d.\n", status
);
451 aac_fib_complete(cmd_fibcontext
);
452 aac_fib_free(cmd_fibcontext
);
456 static int aac_probe_container_callback2(struct scsi_cmnd
* scsicmd
)
458 struct fsa_dev_info
*fsa_dev_ptr
= ((struct aac_dev
*)(scsicmd
->device
->host
->hostdata
))->fsa_dev
;
460 if ((fsa_dev_ptr
[scmd_id(scsicmd
)].valid
& 1))
461 return aac_scsi_cmd(scsicmd
);
463 scsicmd
->result
= DID_NO_CONNECT
<< 16;
464 scsicmd
->scsi_done(scsicmd
);
468 static void _aac_probe_container2(void * context
, struct fib
* fibptr
)
470 struct fsa_dev_info
*fsa_dev_ptr
;
471 int (*callback
)(struct scsi_cmnd
*);
472 struct scsi_cmnd
* scsicmd
= (struct scsi_cmnd
*)context
;
475 if (!aac_valid_context(scsicmd
, fibptr
))
478 scsicmd
->SCp
.Status
= 0;
479 fsa_dev_ptr
= fibptr
->dev
->fsa_dev
;
481 struct aac_mount
* dresp
= (struct aac_mount
*) fib_data(fibptr
);
482 fsa_dev_ptr
+= scmd_id(scsicmd
);
484 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
485 (le32_to_cpu(dresp
->mnt
[0].vol
) != CT_NONE
) &&
486 (le32_to_cpu(dresp
->mnt
[0].state
) != FSCS_HIDDEN
)) {
487 fsa_dev_ptr
->valid
= 1;
488 fsa_dev_ptr
->type
= le32_to_cpu(dresp
->mnt
[0].vol
);
490 = ((u64
)le32_to_cpu(dresp
->mnt
[0].capacity
)) +
491 (((u64
)le32_to_cpu(dresp
->mnt
[0].capacityhigh
)) << 32);
492 fsa_dev_ptr
->ro
= ((le32_to_cpu(dresp
->mnt
[0].state
) & FSCS_READONLY
) != 0);
494 if ((fsa_dev_ptr
->valid
& 1) == 0)
495 fsa_dev_ptr
->valid
= 0;
496 scsicmd
->SCp
.Status
= le32_to_cpu(dresp
->count
);
498 aac_fib_complete(fibptr
);
499 aac_fib_free(fibptr
);
500 callback
= (int (*)(struct scsi_cmnd
*))(scsicmd
->SCp
.ptr
);
501 scsicmd
->SCp
.ptr
= NULL
;
502 (*callback
)(scsicmd
);
506 static void _aac_probe_container1(void * context
, struct fib
* fibptr
)
508 struct scsi_cmnd
* scsicmd
;
509 struct aac_mount
* dresp
;
510 struct aac_query_mount
*dinfo
;
513 dresp
= (struct aac_mount
*) fib_data(fibptr
);
514 dresp
->mnt
[0].capacityhigh
= 0;
515 if ((le32_to_cpu(dresp
->status
) != ST_OK
) ||
516 (le32_to_cpu(dresp
->mnt
[0].vol
) != CT_NONE
)) {
517 _aac_probe_container2(context
, fibptr
);
520 scsicmd
= (struct scsi_cmnd
*) context
;
522 if (!aac_valid_context(scsicmd
, fibptr
))
525 aac_fib_init(fibptr
);
527 dinfo
= (struct aac_query_mount
*)fib_data(fibptr
);
529 dinfo
->command
= cpu_to_le32(VM_NameServe64
);
530 dinfo
->count
= cpu_to_le32(scmd_id(scsicmd
));
531 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
533 status
= aac_fib_send(ContainerCommand
,
535 sizeof(struct aac_query_mount
),
538 _aac_probe_container2
,
541 * Check that the command queued to the controller
543 if (status
== -EINPROGRESS
)
544 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
545 else if (status
< 0) {
546 /* Inherit results from VM_NameServe, if any */
547 dresp
->status
= cpu_to_le32(ST_OK
);
548 _aac_probe_container2(context
, fibptr
);
552 static int _aac_probe_container(struct scsi_cmnd
* scsicmd
, int (*callback
)(struct scsi_cmnd
*))
555 int status
= -ENOMEM
;
557 if ((fibptr
= aac_fib_alloc((struct aac_dev
*)scsicmd
->device
->host
->hostdata
))) {
558 struct aac_query_mount
*dinfo
;
560 aac_fib_init(fibptr
);
562 dinfo
= (struct aac_query_mount
*)fib_data(fibptr
);
564 dinfo
->command
= cpu_to_le32(VM_NameServe
);
565 dinfo
->count
= cpu_to_le32(scmd_id(scsicmd
));
566 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
567 scsicmd
->SCp
.ptr
= (char *)callback
;
569 status
= aac_fib_send(ContainerCommand
,
571 sizeof(struct aac_query_mount
),
574 _aac_probe_container1
,
577 * Check that the command queued to the controller
579 if (status
== -EINPROGRESS
) {
580 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
584 scsicmd
->SCp
.ptr
= NULL
;
585 aac_fib_complete(fibptr
);
586 aac_fib_free(fibptr
);
590 struct fsa_dev_info
*fsa_dev_ptr
= ((struct aac_dev
*)(scsicmd
->device
->host
->hostdata
))->fsa_dev
;
592 fsa_dev_ptr
+= scmd_id(scsicmd
);
593 if ((fsa_dev_ptr
->valid
& 1) == 0) {
594 fsa_dev_ptr
->valid
= 0;
595 return (*callback
)(scsicmd
);
603 * aac_probe_container - query a logical volume
604 * @dev: device to query
605 * @cid: container identifier
607 * Queries the controller about the given volume. The volume information
608 * is updated in the struct fsa_dev_info structure rather than returned.
610 static int aac_probe_container_callback1(struct scsi_cmnd
* scsicmd
)
612 scsicmd
->device
= NULL
;
616 int aac_probe_container(struct aac_dev
*dev
, int cid
)
618 struct scsi_cmnd
*scsicmd
= kmalloc(sizeof(*scsicmd
), GFP_KERNEL
);
619 struct scsi_device
*scsidev
= kmalloc(sizeof(*scsidev
), GFP_KERNEL
);
622 if (!scsicmd
|| !scsidev
) {
627 scsicmd
->list
.next
= NULL
;
628 scsicmd
->scsi_done
= (void (*)(struct scsi_cmnd
*))aac_probe_container_callback1
;
630 scsicmd
->device
= scsidev
;
631 scsidev
->sdev_state
= 0;
633 scsidev
->host
= dev
->scsi_host_ptr
;
635 if (_aac_probe_container(scsicmd
, aac_probe_container_callback1
) == 0)
636 while (scsicmd
->device
== scsidev
)
639 status
= scsicmd
->SCp
.Status
;
644 /* Local Structure to set SCSI inquiry data strings */
646 char vid
[8]; /* Vendor ID */
647 char pid
[16]; /* Product ID */
648 char prl
[4]; /* Product Revision Level */
652 * InqStrCopy - string merge
653 * @a: string to copy from
654 * @b: string to copy to
656 * Copy a String from one location to another
660 static void inqstrcpy(char *a
, char *b
)
667 static char *container_types
[] = {
693 /* Function: setinqstr
695 * Arguments: [1] pointer to void [1] int
697 * Purpose: Sets SCSI inquiry data strings for vendor, product
698 * and revision level. Allows strings to be set in platform dependant
699 * files instead of in OS dependant driver source.
702 static void setinqstr(struct aac_dev
*dev
, void *data
, int tindex
)
704 struct scsi_inq
*str
;
706 str
= (struct scsi_inq
*)(data
); /* cast data to scsi inq block */
707 memset(str
, ' ', sizeof(*str
));
709 if (dev
->supplement_adapter_info
.AdapterTypeText
[0]) {
710 char * cp
= dev
->supplement_adapter_info
.AdapterTypeText
;
711 int c
= sizeof(str
->vid
);
712 while (*cp
&& *cp
!= ' ' && --c
)
716 inqstrcpy (dev
->supplement_adapter_info
.AdapterTypeText
,
719 while (*cp
&& *cp
!= ' ')
723 /* last six chars reserved for vol type */
725 if (strlen(cp
) > sizeof(str
->pid
)) {
726 c
= cp
[sizeof(str
->pid
)];
727 cp
[sizeof(str
->pid
)] = '\0';
729 inqstrcpy (cp
, str
->pid
);
731 cp
[sizeof(str
->pid
)] = c
;
733 struct aac_driver_ident
*mp
= aac_get_driver_ident(dev
->cardtype
);
735 inqstrcpy (mp
->vname
, str
->vid
);
736 /* last six chars reserved for vol type */
737 inqstrcpy (mp
->model
, str
->pid
);
740 if (tindex
< ARRAY_SIZE(container_types
)){
741 char *findit
= str
->pid
;
743 for ( ; *findit
!= ' '; findit
++); /* walk till we find a space */
744 /* RAID is superfluous in the context of a RAID device */
745 if (memcmp(findit
-4, "RAID", 4) == 0)
746 *(findit
-= 4) = ' ';
747 if (((findit
- str
->pid
) + strlen(container_types
[tindex
]))
748 < (sizeof(str
->pid
) + sizeof(str
->prl
)))
749 inqstrcpy (container_types
[tindex
], findit
+ 1);
751 inqstrcpy ("V1.0", str
->prl
);
754 static void set_sense(u8
*sense_buf
, u8 sense_key
, u8 sense_code
,
755 u8 a_sense_code
, u8 incorrect_length
,
756 u8 bit_pointer
, u16 field_pointer
,
759 sense_buf
[0] = 0xF0; /* Sense data valid, err code 70h (current error) */
760 sense_buf
[1] = 0; /* Segment number, always zero */
762 if (incorrect_length
) {
763 sense_buf
[2] = sense_key
| 0x20;/* Set ILI bit | sense key */
764 sense_buf
[3] = BYTE3(residue
);
765 sense_buf
[4] = BYTE2(residue
);
766 sense_buf
[5] = BYTE1(residue
);
767 sense_buf
[6] = BYTE0(residue
);
769 sense_buf
[2] = sense_key
; /* Sense key */
771 if (sense_key
== ILLEGAL_REQUEST
)
772 sense_buf
[7] = 10; /* Additional sense length */
774 sense_buf
[7] = 6; /* Additional sense length */
776 sense_buf
[12] = sense_code
; /* Additional sense code */
777 sense_buf
[13] = a_sense_code
; /* Additional sense code qualifier */
778 if (sense_key
== ILLEGAL_REQUEST
) {
781 if (sense_code
== SENCODE_INVALID_PARAM_FIELD
)
782 sense_buf
[15] = 0x80;/* Std sense key specific field */
783 /* Illegal parameter is in the parameter block */
785 if (sense_code
== SENCODE_INVALID_CDB_FIELD
)
786 sense_buf
[15] = 0xc0;/* Std sense key specific field */
787 /* Illegal parameter is in the CDB block */
788 sense_buf
[15] |= bit_pointer
;
789 sense_buf
[16] = field_pointer
>> 8; /* MSB */
790 sense_buf
[17] = field_pointer
; /* LSB */
794 static int aac_bounds_32(struct aac_dev
* dev
, struct scsi_cmnd
* cmd
, u64 lba
)
796 if (lba
& 0xffffffff00000000LL
) {
797 int cid
= scmd_id(cmd
);
798 dprintk((KERN_DEBUG
"aacraid: Illegal lba\n"));
799 cmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
800 SAM_STAT_CHECK_CONDITION
;
801 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
803 SENCODE_INTERNAL_TARGET_FAILURE
,
804 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
806 memcpy(cmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
807 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(cmd
->sense_buffer
))
808 ? sizeof(cmd
->sense_buffer
)
809 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
816 static int aac_bounds_64(struct aac_dev
* dev
, struct scsi_cmnd
* cmd
, u64 lba
)
821 static void io_callback(void *context
, struct fib
* fibptr
);
823 static int aac_read_raw_io(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
826 struct aac_raw_io
*readcmd
;
828 readcmd
= (struct aac_raw_io
*) fib_data(fib
);
829 readcmd
->block
[0] = cpu_to_le32((u32
)(lba
&0xffffffff));
830 readcmd
->block
[1] = cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
831 readcmd
->count
= cpu_to_le32(count
<<9);
832 readcmd
->cid
= cpu_to_le16(scmd_id(cmd
));
833 readcmd
->flags
= cpu_to_le16(IO_TYPE_READ
);
834 readcmd
->bpTotal
= 0;
835 readcmd
->bpComplete
= 0;
837 aac_build_sgraw(cmd
, &readcmd
->sg
);
838 fibsize
= sizeof(struct aac_raw_io
) + ((le32_to_cpu(readcmd
->sg
.count
) - 1) * sizeof (struct sgentryraw
));
839 BUG_ON(fibsize
> (fib
->dev
->max_fib_size
- sizeof(struct aac_fibhdr
)));
841 * Now send the Fib to the adapter
843 return aac_fib_send(ContainerRawIo
,
848 (fib_callback
) io_callback
,
852 static int aac_read_block64(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
855 struct aac_read64
*readcmd
;
857 readcmd
= (struct aac_read64
*) fib_data(fib
);
858 readcmd
->command
= cpu_to_le32(VM_CtHostRead64
);
859 readcmd
->cid
= cpu_to_le16(scmd_id(cmd
));
860 readcmd
->sector_count
= cpu_to_le16(count
);
861 readcmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
865 aac_build_sg64(cmd
, &readcmd
->sg
);
866 fibsize
= sizeof(struct aac_read64
) +
867 ((le32_to_cpu(readcmd
->sg
.count
) - 1) *
868 sizeof (struct sgentry64
));
869 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
870 sizeof(struct aac_fibhdr
)));
872 * Now send the Fib to the adapter
874 return aac_fib_send(ContainerCommand64
,
879 (fib_callback
) io_callback
,
883 static int aac_read_block(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
886 struct aac_read
*readcmd
;
888 readcmd
= (struct aac_read
*) fib_data(fib
);
889 readcmd
->command
= cpu_to_le32(VM_CtBlockRead
);
890 readcmd
->cid
= cpu_to_le16(scmd_id(cmd
));
891 readcmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
892 readcmd
->count
= cpu_to_le32(count
* 512);
894 aac_build_sg(cmd
, &readcmd
->sg
);
895 fibsize
= sizeof(struct aac_read
) +
896 ((le32_to_cpu(readcmd
->sg
.count
) - 1) *
897 sizeof (struct sgentry
));
898 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
899 sizeof(struct aac_fibhdr
)));
901 * Now send the Fib to the adapter
903 return aac_fib_send(ContainerCommand
,
908 (fib_callback
) io_callback
,
912 static int aac_write_raw_io(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
, int fua
)
915 struct aac_raw_io
*writecmd
;
917 writecmd
= (struct aac_raw_io
*) fib_data(fib
);
918 writecmd
->block
[0] = cpu_to_le32((u32
)(lba
&0xffffffff));
919 writecmd
->block
[1] = cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
920 writecmd
->count
= cpu_to_le32(count
<<9);
921 writecmd
->cid
= cpu_to_le16(scmd_id(cmd
));
922 writecmd
->flags
= fua
?
923 cpu_to_le16(IO_TYPE_WRITE
|IO_SUREWRITE
) :
924 cpu_to_le16(IO_TYPE_WRITE
);
925 writecmd
->bpTotal
= 0;
926 writecmd
->bpComplete
= 0;
928 aac_build_sgraw(cmd
, &writecmd
->sg
);
929 fibsize
= sizeof(struct aac_raw_io
) + ((le32_to_cpu(writecmd
->sg
.count
) - 1) * sizeof (struct sgentryraw
));
930 BUG_ON(fibsize
> (fib
->dev
->max_fib_size
- sizeof(struct aac_fibhdr
)));
932 * Now send the Fib to the adapter
934 return aac_fib_send(ContainerRawIo
,
939 (fib_callback
) io_callback
,
943 static int aac_write_block64(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
, int fua
)
946 struct aac_write64
*writecmd
;
948 writecmd
= (struct aac_write64
*) fib_data(fib
);
949 writecmd
->command
= cpu_to_le32(VM_CtHostWrite64
);
950 writecmd
->cid
= cpu_to_le16(scmd_id(cmd
));
951 writecmd
->sector_count
= cpu_to_le16(count
);
952 writecmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
956 aac_build_sg64(cmd
, &writecmd
->sg
);
957 fibsize
= sizeof(struct aac_write64
) +
958 ((le32_to_cpu(writecmd
->sg
.count
) - 1) *
959 sizeof (struct sgentry64
));
960 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
961 sizeof(struct aac_fibhdr
)));
963 * Now send the Fib to the adapter
965 return aac_fib_send(ContainerCommand64
,
970 (fib_callback
) io_callback
,
974 static int aac_write_block(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
, int fua
)
977 struct aac_write
*writecmd
;
979 writecmd
= (struct aac_write
*) fib_data(fib
);
980 writecmd
->command
= cpu_to_le32(VM_CtBlockWrite
);
981 writecmd
->cid
= cpu_to_le16(scmd_id(cmd
));
982 writecmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
983 writecmd
->count
= cpu_to_le32(count
* 512);
984 writecmd
->sg
.count
= cpu_to_le32(1);
985 /* ->stable is not used - it did mean which type of write */
987 aac_build_sg(cmd
, &writecmd
->sg
);
988 fibsize
= sizeof(struct aac_write
) +
989 ((le32_to_cpu(writecmd
->sg
.count
) - 1) *
990 sizeof (struct sgentry
));
991 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
992 sizeof(struct aac_fibhdr
)));
994 * Now send the Fib to the adapter
996 return aac_fib_send(ContainerCommand
,
1001 (fib_callback
) io_callback
,
1005 static struct aac_srb
* aac_scsi_common(struct fib
* fib
, struct scsi_cmnd
* cmd
)
1007 struct aac_srb
* srbcmd
;
1012 switch(cmd
->sc_data_direction
){
1016 case DMA_BIDIRECTIONAL
:
1017 flag
= SRB_DataIn
| SRB_DataOut
;
1019 case DMA_FROM_DEVICE
:
1023 default: /* shuts up some versions of gcc */
1024 flag
= SRB_NoDataXfer
;
1028 srbcmd
= (struct aac_srb
*) fib_data(fib
);
1029 srbcmd
->function
= cpu_to_le32(SRBF_ExecuteScsi
);
1030 srbcmd
->channel
= cpu_to_le32(aac_logical_to_phys(scmd_channel(cmd
)));
1031 srbcmd
->id
= cpu_to_le32(scmd_id(cmd
));
1032 srbcmd
->lun
= cpu_to_le32(cmd
->device
->lun
);
1033 srbcmd
->flags
= cpu_to_le32(flag
);
1034 timeout
= cmd
->timeout_per_command
/HZ
;
1037 srbcmd
->timeout
= cpu_to_le32(timeout
); // timeout in seconds
1038 srbcmd
->retry_limit
= 0; /* Obsolete parameter */
1039 srbcmd
->cdb_size
= cpu_to_le32(cmd
->cmd_len
);
1043 static void aac_srb_callback(void *context
, struct fib
* fibptr
);
1045 static int aac_scsi_64(struct fib
* fib
, struct scsi_cmnd
* cmd
)
1048 struct aac_srb
* srbcmd
= aac_scsi_common(fib
, cmd
);
1050 aac_build_sg64(cmd
, (struct sgmap64
*) &srbcmd
->sg
);
1051 srbcmd
->count
= cpu_to_le32(scsi_bufflen(cmd
));
1053 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
1054 memcpy(srbcmd
->cdb
, cmd
->cmnd
, cmd
->cmd_len
);
1056 * Build Scatter/Gather list
1058 fibsize
= sizeof (struct aac_srb
) - sizeof (struct sgentry
) +
1059 ((le32_to_cpu(srbcmd
->sg
.count
) & 0xff) *
1060 sizeof (struct sgentry64
));
1061 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
1062 sizeof(struct aac_fibhdr
)));
1065 * Now send the Fib to the adapter
1067 return aac_fib_send(ScsiPortCommand64
, fib
,
1068 fibsize
, FsaNormal
, 0, 1,
1069 (fib_callback
) aac_srb_callback
,
1073 static int aac_scsi_32(struct fib
* fib
, struct scsi_cmnd
* cmd
)
1076 struct aac_srb
* srbcmd
= aac_scsi_common(fib
, cmd
);
1078 aac_build_sg(cmd
, (struct sgmap
*)&srbcmd
->sg
);
1079 srbcmd
->count
= cpu_to_le32(scsi_bufflen(cmd
));
1081 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
1082 memcpy(srbcmd
->cdb
, cmd
->cmnd
, cmd
->cmd_len
);
1084 * Build Scatter/Gather list
1086 fibsize
= sizeof (struct aac_srb
) +
1087 (((le32_to_cpu(srbcmd
->sg
.count
) & 0xff) - 1) *
1088 sizeof (struct sgentry
));
1089 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
1090 sizeof(struct aac_fibhdr
)));
1093 * Now send the Fib to the adapter
1095 return aac_fib_send(ScsiPortCommand
, fib
, fibsize
, FsaNormal
, 0, 1,
1096 (fib_callback
) aac_srb_callback
, (void *) cmd
);
1099 int aac_get_adapter_info(struct aac_dev
* dev
)
1104 struct aac_adapter_info
*info
;
1105 struct aac_bus_info
*command
;
1106 struct aac_bus_info_response
*bus_info
;
1108 if (!(fibptr
= aac_fib_alloc(dev
)))
1111 aac_fib_init(fibptr
);
1112 info
= (struct aac_adapter_info
*) fib_data(fibptr
);
1113 memset(info
,0,sizeof(*info
));
1115 rcode
= aac_fib_send(RequestAdapterInfo
,
1119 -1, 1, /* First `interrupt' command uses special wait */
1124 aac_fib_complete(fibptr
);
1125 aac_fib_free(fibptr
);
1128 memcpy(&dev
->adapter_info
, info
, sizeof(*info
));
1130 if (dev
->adapter_info
.options
& AAC_OPT_SUPPLEMENT_ADAPTER_INFO
) {
1131 struct aac_supplement_adapter_info
* info
;
1133 aac_fib_init(fibptr
);
1135 info
= (struct aac_supplement_adapter_info
*) fib_data(fibptr
);
1137 memset(info
,0,sizeof(*info
));
1139 rcode
= aac_fib_send(RequestSupplementAdapterInfo
,
1148 memcpy(&dev
->supplement_adapter_info
, info
, sizeof(*info
));
1156 aac_fib_init(fibptr
);
1158 bus_info
= (struct aac_bus_info_response
*) fib_data(fibptr
);
1160 memset(bus_info
, 0, sizeof(*bus_info
));
1162 command
= (struct aac_bus_info
*)bus_info
;
1164 command
->Command
= cpu_to_le32(VM_Ioctl
);
1165 command
->ObjType
= cpu_to_le32(FT_DRIVE
);
1166 command
->MethodId
= cpu_to_le32(1);
1167 command
->CtlCmd
= cpu_to_le32(GetBusInfo
);
1169 rcode
= aac_fib_send(ContainerCommand
,
1176 if (rcode
>= 0 && le32_to_cpu(bus_info
->Status
) == ST_OK
) {
1177 dev
->maximum_num_physicals
= le32_to_cpu(bus_info
->TargetsPerBus
);
1178 dev
->maximum_num_channels
= le32_to_cpu(bus_info
->BusCount
);
1181 if (!dev
->in_reset
) {
1183 tmp
= le32_to_cpu(dev
->adapter_info
.kernelrev
);
1184 printk(KERN_INFO
"%s%d: kernel %d.%d-%d[%d] %.*s\n",
1190 le32_to_cpu(dev
->adapter_info
.kernelbuild
),
1191 (int)sizeof(dev
->supplement_adapter_info
.BuildDate
),
1192 dev
->supplement_adapter_info
.BuildDate
);
1193 tmp
= le32_to_cpu(dev
->adapter_info
.monitorrev
);
1194 printk(KERN_INFO
"%s%d: monitor %d.%d-%d[%d]\n",
1196 tmp
>>24,(tmp
>>16)&0xff,tmp
&0xff,
1197 le32_to_cpu(dev
->adapter_info
.monitorbuild
));
1198 tmp
= le32_to_cpu(dev
->adapter_info
.biosrev
);
1199 printk(KERN_INFO
"%s%d: bios %d.%d-%d[%d]\n",
1201 tmp
>>24,(tmp
>>16)&0xff,tmp
&0xff,
1202 le32_to_cpu(dev
->adapter_info
.biosbuild
));
1204 if (aac_show_serial_number(
1205 shost_to_class(dev
->scsi_host_ptr
), buffer
))
1206 printk(KERN_INFO
"%s%d: serial %s",
1207 dev
->name
, dev
->id
, buffer
);
1208 if (dev
->supplement_adapter_info
.VpdInfo
.Tsid
[0]) {
1209 printk(KERN_INFO
"%s%d: TSID %.*s\n",
1211 (int)sizeof(dev
->supplement_adapter_info
.VpdInfo
.Tsid
),
1212 dev
->supplement_adapter_info
.VpdInfo
.Tsid
);
1215 (dev
->supplement_adapter_info
.SupportedOptions2
&
1216 le32_to_cpu(AAC_OPTION_IGNORE_RESET
))) {
1217 printk(KERN_INFO
"%s%d: Reset Adapter Ignored\n",
1218 dev
->name
, dev
->id
);
1222 dev
->nondasd_support
= 0;
1223 dev
->raid_scsi_mode
= 0;
1224 if(dev
->adapter_info
.options
& AAC_OPT_NONDASD
){
1225 dev
->nondasd_support
= 1;
1229 * If the firmware supports ROMB RAID/SCSI mode and we are currently
1230 * in RAID/SCSI mode, set the flag. For now if in this mode we will
1231 * force nondasd support on. If we decide to allow the non-dasd flag
1232 * additional changes changes will have to be made to support
1233 * RAID/SCSI. the function aac_scsi_cmd in this module will have to be
1234 * changed to support the new dev->raid_scsi_mode flag instead of
1235 * leaching off of the dev->nondasd_support flag. Also in linit.c the
1236 * function aac_detect will have to be modified where it sets up the
1237 * max number of channels based on the aac->nondasd_support flag only.
1239 if ((dev
->adapter_info
.options
& AAC_OPT_SCSI_MANAGED
) &&
1240 (dev
->adapter_info
.options
& AAC_OPT_RAID_SCSI_MODE
)) {
1241 dev
->nondasd_support
= 1;
1242 dev
->raid_scsi_mode
= 1;
1244 if (dev
->raid_scsi_mode
!= 0)
1245 printk(KERN_INFO
"%s%d: ROMB RAID/SCSI mode enabled\n",
1246 dev
->name
, dev
->id
);
1249 dev
->nondasd_support
= (nondasd
!=0);
1251 if(dev
->nondasd_support
!= 0){
1252 printk(KERN_INFO
"%s%d: Non-DASD support enabled.\n",dev
->name
, dev
->id
);
1255 dev
->dac_support
= 0;
1256 if( (sizeof(dma_addr_t
) > 4) && (dev
->adapter_info
.options
& AAC_OPT_SGMAP_HOST64
)){
1257 printk(KERN_INFO
"%s%d: 64bit support enabled.\n", dev
->name
, dev
->id
);
1258 dev
->dac_support
= 1;
1262 dev
->dac_support
= (dacmode
!=0);
1264 if(dev
->dac_support
!= 0) {
1265 if (!pci_set_dma_mask(dev
->pdev
, DMA_64BIT_MASK
) &&
1266 !pci_set_consistent_dma_mask(dev
->pdev
, DMA_64BIT_MASK
)) {
1267 printk(KERN_INFO
"%s%d: 64 Bit DAC enabled\n",
1268 dev
->name
, dev
->id
);
1269 } else if (!pci_set_dma_mask(dev
->pdev
, DMA_32BIT_MASK
) &&
1270 !pci_set_consistent_dma_mask(dev
->pdev
, DMA_32BIT_MASK
)) {
1271 printk(KERN_INFO
"%s%d: DMA mask set failed, 64 Bit DAC disabled\n",
1272 dev
->name
, dev
->id
);
1273 dev
->dac_support
= 0;
1275 printk(KERN_WARNING
"%s%d: No suitable DMA available.\n",
1276 dev
->name
, dev
->id
);
1281 * Deal with configuring for the individualized limits of each packet
1284 dev
->a_ops
.adapter_scsi
= (dev
->dac_support
)
1287 if (dev
->raw_io_interface
) {
1288 dev
->a_ops
.adapter_bounds
= (dev
->raw_io_64
)
1291 dev
->a_ops
.adapter_read
= aac_read_raw_io
;
1292 dev
->a_ops
.adapter_write
= aac_write_raw_io
;
1294 dev
->a_ops
.adapter_bounds
= aac_bounds_32
;
1295 dev
->scsi_host_ptr
->sg_tablesize
= (dev
->max_fib_size
-
1296 sizeof(struct aac_fibhdr
) -
1297 sizeof(struct aac_write
) + sizeof(struct sgentry
)) /
1298 sizeof(struct sgentry
);
1299 if (dev
->dac_support
) {
1300 dev
->a_ops
.adapter_read
= aac_read_block64
;
1301 dev
->a_ops
.adapter_write
= aac_write_block64
;
1303 * 38 scatter gather elements
1305 dev
->scsi_host_ptr
->sg_tablesize
=
1306 (dev
->max_fib_size
-
1307 sizeof(struct aac_fibhdr
) -
1308 sizeof(struct aac_write64
) +
1309 sizeof(struct sgentry64
)) /
1310 sizeof(struct sgentry64
);
1312 dev
->a_ops
.adapter_read
= aac_read_block
;
1313 dev
->a_ops
.adapter_write
= aac_write_block
;
1315 dev
->scsi_host_ptr
->max_sectors
= AAC_MAX_32BIT_SGBCOUNT
;
1316 if(!(dev
->adapter_info
.options
& AAC_OPT_NEW_COMM
)) {
1318 * Worst case size that could cause sg overflow when
1319 * we break up SG elements that are larger than 64KB.
1320 * Would be nice if we could tell the SCSI layer what
1321 * the maximum SG element size can be. Worst case is
1322 * (sg_tablesize-1) 4KB elements with one 64KB
1324 * 32bit -> 468 or 238KB 64bit -> 424 or 212KB
1326 dev
->scsi_host_ptr
->max_sectors
=
1327 (dev
->scsi_host_ptr
->sg_tablesize
* 8) + 112;
1331 aac_fib_complete(fibptr
);
1332 aac_fib_free(fibptr
);
1338 static void io_callback(void *context
, struct fib
* fibptr
)
1340 struct aac_dev
*dev
;
1341 struct aac_read_reply
*readreply
;
1342 struct scsi_cmnd
*scsicmd
;
1345 scsicmd
= (struct scsi_cmnd
*) context
;
1347 if (!aac_valid_context(scsicmd
, fibptr
))
1351 cid
= scmd_id(scsicmd
);
1353 if (nblank(dprintk(x
))) {
1355 switch (scsicmd
->cmnd
[0]) {
1358 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) |
1359 (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1363 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1364 ((u64
)scsicmd
->cmnd
[3] << 48) |
1365 ((u64
)scsicmd
->cmnd
[4] << 40) |
1366 ((u64
)scsicmd
->cmnd
[5] << 32) |
1367 ((u64
)scsicmd
->cmnd
[6] << 24) |
1368 (scsicmd
->cmnd
[7] << 16) |
1369 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1373 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1374 (scsicmd
->cmnd
[3] << 16) |
1375 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1378 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1379 (scsicmd
->cmnd
[3] << 16) |
1380 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1384 "io_callback[cpu %d]: lba = %llu, t = %ld.\n",
1385 smp_processor_id(), (unsigned long long)lba
, jiffies
);
1388 BUG_ON(fibptr
== NULL
);
1390 scsi_dma_unmap(scsicmd
);
1392 readreply
= (struct aac_read_reply
*)fib_data(fibptr
);
1393 if (le32_to_cpu(readreply
->status
) == ST_OK
)
1394 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1396 #ifdef AAC_DETAILED_STATUS_INFO
1397 printk(KERN_WARNING
"io_callback: io failed, status = %d\n",
1398 le32_to_cpu(readreply
->status
));
1400 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1401 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1403 SENCODE_INTERNAL_TARGET_FAILURE
,
1404 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
1406 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1407 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1408 ? sizeof(scsicmd
->sense_buffer
)
1409 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1411 aac_fib_complete(fibptr
);
1412 aac_fib_free(fibptr
);
1414 scsicmd
->scsi_done(scsicmd
);
1417 static int aac_read(struct scsi_cmnd
* scsicmd
)
1422 struct aac_dev
*dev
;
1423 struct fib
* cmd_fibcontext
;
1425 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1427 * Get block address and transfer length
1429 switch (scsicmd
->cmnd
[0]) {
1431 dprintk((KERN_DEBUG
"aachba: received a read(6) command on id %d.\n", scmd_id(scsicmd
)));
1433 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) |
1434 (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1435 count
= scsicmd
->cmnd
[4];
1441 dprintk((KERN_DEBUG
"aachba: received a read(16) command on id %d.\n", scmd_id(scsicmd
)));
1443 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1444 ((u64
)scsicmd
->cmnd
[3] << 48) |
1445 ((u64
)scsicmd
->cmnd
[4] << 40) |
1446 ((u64
)scsicmd
->cmnd
[5] << 32) |
1447 ((u64
)scsicmd
->cmnd
[6] << 24) |
1448 (scsicmd
->cmnd
[7] << 16) |
1449 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1450 count
= (scsicmd
->cmnd
[10] << 24) |
1451 (scsicmd
->cmnd
[11] << 16) |
1452 (scsicmd
->cmnd
[12] << 8) | scsicmd
->cmnd
[13];
1455 dprintk((KERN_DEBUG
"aachba: received a read(12) command on id %d.\n", scmd_id(scsicmd
)));
1457 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1458 (scsicmd
->cmnd
[3] << 16) |
1459 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1460 count
= (scsicmd
->cmnd
[6] << 24) |
1461 (scsicmd
->cmnd
[7] << 16) |
1462 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1465 dprintk((KERN_DEBUG
"aachba: received a read(10) command on id %d.\n", scmd_id(scsicmd
)));
1467 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1468 (scsicmd
->cmnd
[3] << 16) |
1469 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1470 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
1473 dprintk((KERN_DEBUG
"aac_read[cpu %d]: lba = %llu, t = %ld.\n",
1474 smp_processor_id(), (unsigned long long)lba
, jiffies
));
1475 if (aac_adapter_bounds(dev
,scsicmd
,lba
))
1478 * Alocate and initialize a Fib
1480 if (!(cmd_fibcontext
= aac_fib_alloc(dev
))) {
1484 status
= aac_adapter_read(cmd_fibcontext
, scsicmd
, lba
, count
);
1487 * Check that the command queued to the controller
1489 if (status
== -EINPROGRESS
) {
1490 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1494 printk(KERN_WARNING
"aac_read: aac_fib_send failed with status: %d.\n", status
);
1496 * For some reason, the Fib didn't queue, return QUEUE_FULL
1498 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_TASK_SET_FULL
;
1499 scsicmd
->scsi_done(scsicmd
);
1500 aac_fib_complete(cmd_fibcontext
);
1501 aac_fib_free(cmd_fibcontext
);
1505 static int aac_write(struct scsi_cmnd
* scsicmd
)
1511 struct aac_dev
*dev
;
1512 struct fib
* cmd_fibcontext
;
1514 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1516 * Get block address and transfer length
1518 if (scsicmd
->cmnd
[0] == WRITE_6
) /* 6 byte command */
1520 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) | (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1521 count
= scsicmd
->cmnd
[4];
1525 } else if (scsicmd
->cmnd
[0] == WRITE_16
) { /* 16 byte command */
1526 dprintk((KERN_DEBUG
"aachba: received a write(16) command on id %d.\n", scmd_id(scsicmd
)));
1528 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1529 ((u64
)scsicmd
->cmnd
[3] << 48) |
1530 ((u64
)scsicmd
->cmnd
[4] << 40) |
1531 ((u64
)scsicmd
->cmnd
[5] << 32) |
1532 ((u64
)scsicmd
->cmnd
[6] << 24) |
1533 (scsicmd
->cmnd
[7] << 16) |
1534 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1535 count
= (scsicmd
->cmnd
[10] << 24) | (scsicmd
->cmnd
[11] << 16) |
1536 (scsicmd
->cmnd
[12] << 8) | scsicmd
->cmnd
[13];
1537 fua
= scsicmd
->cmnd
[1] & 0x8;
1538 } else if (scsicmd
->cmnd
[0] == WRITE_12
) { /* 12 byte command */
1539 dprintk((KERN_DEBUG
"aachba: received a write(12) command on id %d.\n", scmd_id(scsicmd
)));
1541 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16)
1542 | (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1543 count
= (scsicmd
->cmnd
[6] << 24) | (scsicmd
->cmnd
[7] << 16)
1544 | (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1545 fua
= scsicmd
->cmnd
[1] & 0x8;
1547 dprintk((KERN_DEBUG
"aachba: received a write(10) command on id %d.\n", scmd_id(scsicmd
)));
1548 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16) | (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1549 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
1550 fua
= scsicmd
->cmnd
[1] & 0x8;
1552 dprintk((KERN_DEBUG
"aac_write[cpu %d]: lba = %llu, t = %ld.\n",
1553 smp_processor_id(), (unsigned long long)lba
, jiffies
));
1554 if (aac_adapter_bounds(dev
,scsicmd
,lba
))
1557 * Allocate and initialize a Fib then setup a BlockWrite command
1559 if (!(cmd_fibcontext
= aac_fib_alloc(dev
))) {
1560 scsicmd
->result
= DID_ERROR
<< 16;
1561 scsicmd
->scsi_done(scsicmd
);
1565 status
= aac_adapter_write(cmd_fibcontext
, scsicmd
, lba
, count
, fua
);
1568 * Check that the command queued to the controller
1570 if (status
== -EINPROGRESS
) {
1571 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1575 printk(KERN_WARNING
"aac_write: aac_fib_send failed with status: %d\n", status
);
1577 * For some reason, the Fib didn't queue, return QUEUE_FULL
1579 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_TASK_SET_FULL
;
1580 scsicmd
->scsi_done(scsicmd
);
1582 aac_fib_complete(cmd_fibcontext
);
1583 aac_fib_free(cmd_fibcontext
);
1587 static void synchronize_callback(void *context
, struct fib
*fibptr
)
1589 struct aac_synchronize_reply
*synchronizereply
;
1590 struct scsi_cmnd
*cmd
;
1594 if (!aac_valid_context(cmd
, fibptr
))
1597 dprintk((KERN_DEBUG
"synchronize_callback[cpu %d]: t = %ld.\n",
1598 smp_processor_id(), jiffies
));
1599 BUG_ON(fibptr
== NULL
);
1602 synchronizereply
= fib_data(fibptr
);
1603 if (le32_to_cpu(synchronizereply
->status
) == CT_OK
)
1604 cmd
->result
= DID_OK
<< 16 |
1605 COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1607 struct scsi_device
*sdev
= cmd
->device
;
1608 struct aac_dev
*dev
= fibptr
->dev
;
1609 u32 cid
= sdev_id(sdev
);
1611 "synchronize_callback: synchronize failed, status = %d\n",
1612 le32_to_cpu(synchronizereply
->status
));
1613 cmd
->result
= DID_OK
<< 16 |
1614 COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1615 set_sense((u8
*)&dev
->fsa_dev
[cid
].sense_data
,
1617 SENCODE_INTERNAL_TARGET_FAILURE
,
1618 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
1620 memcpy(cmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1621 min(sizeof(dev
->fsa_dev
[cid
].sense_data
),
1622 sizeof(cmd
->sense_buffer
)));
1625 aac_fib_complete(fibptr
);
1626 aac_fib_free(fibptr
);
1627 cmd
->scsi_done(cmd
);
1630 static int aac_synchronize(struct scsi_cmnd
*scsicmd
)
1633 struct fib
*cmd_fibcontext
;
1634 struct aac_synchronize
*synchronizecmd
;
1635 struct scsi_cmnd
*cmd
;
1636 struct scsi_device
*sdev
= scsicmd
->device
;
1638 struct aac_dev
*aac
;
1639 unsigned long flags
;
1642 * Wait for all outstanding queued commands to complete to this
1643 * specific target (block).
1645 spin_lock_irqsave(&sdev
->list_lock
, flags
);
1646 list_for_each_entry(cmd
, &sdev
->cmd_list
, list
)
1647 if (cmd
!= scsicmd
&& cmd
->SCp
.phase
== AAC_OWNER_FIRMWARE
) {
1652 spin_unlock_irqrestore(&sdev
->list_lock
, flags
);
1655 * Yield the processor (requeue for later)
1658 return SCSI_MLQUEUE_DEVICE_BUSY
;
1660 aac
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1662 return SCSI_MLQUEUE_HOST_BUSY
;
1665 * Allocate and initialize a Fib
1667 if (!(cmd_fibcontext
= aac_fib_alloc(aac
)))
1668 return SCSI_MLQUEUE_HOST_BUSY
;
1670 aac_fib_init(cmd_fibcontext
);
1672 synchronizecmd
= fib_data(cmd_fibcontext
);
1673 synchronizecmd
->command
= cpu_to_le32(VM_ContainerConfig
);
1674 synchronizecmd
->type
= cpu_to_le32(CT_FLUSH_CACHE
);
1675 synchronizecmd
->cid
= cpu_to_le32(scmd_id(scsicmd
));
1676 synchronizecmd
->count
=
1677 cpu_to_le32(sizeof(((struct aac_synchronize_reply
*)NULL
)->data
));
1680 * Now send the Fib to the adapter
1682 status
= aac_fib_send(ContainerCommand
,
1684 sizeof(struct aac_synchronize
),
1687 (fib_callback
)synchronize_callback
,
1691 * Check that the command queued to the controller
1693 if (status
== -EINPROGRESS
) {
1694 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1699 "aac_synchronize: aac_fib_send failed with status: %d.\n", status
);
1700 aac_fib_complete(cmd_fibcontext
);
1701 aac_fib_free(cmd_fibcontext
);
1702 return SCSI_MLQUEUE_HOST_BUSY
;
1706 * aac_scsi_cmd() - Process SCSI command
1707 * @scsicmd: SCSI command block
1709 * Emulate a SCSI command and queue the required request for the
1713 int aac_scsi_cmd(struct scsi_cmnd
* scsicmd
)
1716 struct Scsi_Host
*host
= scsicmd
->device
->host
;
1717 struct aac_dev
*dev
= (struct aac_dev
*)host
->hostdata
;
1718 struct fsa_dev_info
*fsa_dev_ptr
= dev
->fsa_dev
;
1720 if (fsa_dev_ptr
== NULL
)
1723 * If the bus, id or lun is out of range, return fail
1724 * Test does not apply to ID 16, the pseudo id for the controller
1727 cid
= scmd_id(scsicmd
);
1728 if (cid
!= host
->this_id
) {
1729 if (scmd_channel(scsicmd
) == CONTAINER_CHANNEL
) {
1730 if((cid
>= dev
->maximum_num_containers
) ||
1731 (scsicmd
->device
->lun
!= 0)) {
1732 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1733 scsicmd
->scsi_done(scsicmd
);
1738 * If the target container doesn't exist, it may have
1739 * been newly created
1741 if ((fsa_dev_ptr
[cid
].valid
& 1) == 0) {
1742 switch (scsicmd
->cmnd
[0]) {
1743 case SERVICE_ACTION_IN
:
1744 if (!(dev
->raw_io_interface
) ||
1745 !(dev
->raw_io_64
) ||
1746 ((scsicmd
->cmnd
[1] & 0x1f) != SAI_READ_CAPACITY_16
))
1750 case TEST_UNIT_READY
:
1753 return _aac_probe_container(scsicmd
,
1754 aac_probe_container_callback2
);
1759 } else { /* check for physical non-dasd devices */
1760 if ((dev
->nondasd_support
== 1) || expose_physicals
) {
1763 return aac_send_srb_fib(scsicmd
);
1765 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1766 scsicmd
->scsi_done(scsicmd
);
1772 * else Command for the controller itself
1774 else if ((scsicmd
->cmnd
[0] != INQUIRY
) && /* only INQUIRY & TUR cmnd supported for controller */
1775 (scsicmd
->cmnd
[0] != TEST_UNIT_READY
))
1777 dprintk((KERN_WARNING
"Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd
->cmnd
[0]));
1778 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1779 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1781 SENCODE_INVALID_COMMAND
,
1782 ASENCODE_INVALID_COMMAND
, 0, 0, 0, 0);
1783 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1784 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1785 ? sizeof(scsicmd
->sense_buffer
)
1786 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1787 scsicmd
->scsi_done(scsicmd
);
1792 /* Handle commands here that don't really require going out to the adapter */
1793 switch (scsicmd
->cmnd
[0]) {
1796 struct inquiry_data inq_data
;
1798 dprintk((KERN_DEBUG
"INQUIRY command, ID: %d.\n", cid
));
1799 memset(&inq_data
, 0, sizeof (struct inquiry_data
));
1801 inq_data
.inqd_ver
= 2; /* claim compliance to SCSI-2 */
1802 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 */
1803 inq_data
.inqd_len
= 31;
1804 /*Format for "pad2" is RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
1805 inq_data
.inqd_pad2
= 0x32 ; /*WBus16|Sync|CmdQue */
1807 * Set the Vendor, Product, and Revision Level
1808 * see: <vendor>.c i.e. aac.c
1810 if (cid
== host
->this_id
) {
1811 setinqstr(dev
, (void *) (inq_data
.inqd_vid
), ARRAY_SIZE(container_types
));
1812 inq_data
.inqd_pdt
= INQD_PDT_PROC
; /* Processor device */
1813 aac_internal_transfer(scsicmd
, &inq_data
, 0, sizeof(inq_data
));
1814 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1815 scsicmd
->scsi_done(scsicmd
);
1820 setinqstr(dev
, (void *) (inq_data
.inqd_vid
), fsa_dev_ptr
[cid
].type
);
1821 inq_data
.inqd_pdt
= INQD_PDT_DA
; /* Direct/random access device */
1822 aac_internal_transfer(scsicmd
, &inq_data
, 0, sizeof(inq_data
));
1823 return aac_get_container_name(scsicmd
);
1825 case SERVICE_ACTION_IN
:
1826 if (!(dev
->raw_io_interface
) ||
1827 !(dev
->raw_io_64
) ||
1828 ((scsicmd
->cmnd
[1] & 0x1f) != SAI_READ_CAPACITY_16
))
1834 dprintk((KERN_DEBUG
"READ CAPACITY_16 command.\n"));
1835 capacity
= fsa_dev_ptr
[cid
].size
- 1;
1836 cp
[0] = (capacity
>> 56) & 0xff;
1837 cp
[1] = (capacity
>> 48) & 0xff;
1838 cp
[2] = (capacity
>> 40) & 0xff;
1839 cp
[3] = (capacity
>> 32) & 0xff;
1840 cp
[4] = (capacity
>> 24) & 0xff;
1841 cp
[5] = (capacity
>> 16) & 0xff;
1842 cp
[6] = (capacity
>> 8) & 0xff;
1843 cp
[7] = (capacity
>> 0) & 0xff;
1849 aac_internal_transfer(scsicmd
, cp
, 0,
1850 min_t(size_t, scsicmd
->cmnd
[13], sizeof(cp
)));
1851 if (sizeof(cp
) < scsicmd
->cmnd
[13]) {
1852 unsigned int len
, offset
= sizeof(cp
);
1854 memset(cp
, 0, offset
);
1856 len
= min_t(size_t, scsicmd
->cmnd
[13] - offset
,
1858 aac_internal_transfer(scsicmd
, cp
, offset
, len
);
1859 } while ((offset
+= len
) < scsicmd
->cmnd
[13]);
1862 /* Do not cache partition table for arrays */
1863 scsicmd
->device
->removable
= 1;
1865 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1866 scsicmd
->scsi_done(scsicmd
);
1876 dprintk((KERN_DEBUG
"READ CAPACITY command.\n"));
1877 if (fsa_dev_ptr
[cid
].size
<= 0x100000000ULL
)
1878 capacity
= fsa_dev_ptr
[cid
].size
- 1;
1882 cp
[0] = (capacity
>> 24) & 0xff;
1883 cp
[1] = (capacity
>> 16) & 0xff;
1884 cp
[2] = (capacity
>> 8) & 0xff;
1885 cp
[3] = (capacity
>> 0) & 0xff;
1890 aac_internal_transfer(scsicmd
, cp
, 0, sizeof(cp
));
1891 /* Do not cache partition table for arrays */
1892 scsicmd
->device
->removable
= 1;
1894 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1895 scsicmd
->scsi_done(scsicmd
);
1903 int mode_buf_length
= 4;
1905 dprintk((KERN_DEBUG
"MODE SENSE command.\n"));
1906 mode_buf
[0] = 3; /* Mode data length */
1907 mode_buf
[1] = 0; /* Medium type - default */
1908 mode_buf
[2] = 0; /* Device-specific param,
1909 bit 8: 0/1 = write enabled/protected
1910 bit 4: 0/1 = FUA enabled */
1911 if (dev
->raw_io_interface
)
1913 mode_buf
[3] = 0; /* Block descriptor length */
1914 if (((scsicmd
->cmnd
[2] & 0x3f) == 8) ||
1915 ((scsicmd
->cmnd
[2] & 0x3f) == 0x3f)) {
1919 mode_buf
[6] = 0x04; /* WCE */
1920 mode_buf_length
= 7;
1921 if (mode_buf_length
> scsicmd
->cmnd
[4])
1922 mode_buf_length
= scsicmd
->cmnd
[4];
1924 aac_internal_transfer(scsicmd
, mode_buf
, 0, mode_buf_length
);
1925 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1926 scsicmd
->scsi_done(scsicmd
);
1933 int mode_buf_length
= 8;
1935 dprintk((KERN_DEBUG
"MODE SENSE 10 byte command.\n"));
1936 mode_buf
[0] = 0; /* Mode data length (MSB) */
1937 mode_buf
[1] = 6; /* Mode data length (LSB) */
1938 mode_buf
[2] = 0; /* Medium type - default */
1939 mode_buf
[3] = 0; /* Device-specific param,
1940 bit 8: 0/1 = write enabled/protected
1941 bit 4: 0/1 = FUA enabled */
1942 if (dev
->raw_io_interface
)
1944 mode_buf
[4] = 0; /* reserved */
1945 mode_buf
[5] = 0; /* reserved */
1946 mode_buf
[6] = 0; /* Block descriptor length (MSB) */
1947 mode_buf
[7] = 0; /* Block descriptor length (LSB) */
1948 if (((scsicmd
->cmnd
[2] & 0x3f) == 8) ||
1949 ((scsicmd
->cmnd
[2] & 0x3f) == 0x3f)) {
1953 mode_buf
[10] = 0x04; /* WCE */
1954 mode_buf_length
= 11;
1955 if (mode_buf_length
> scsicmd
->cmnd
[8])
1956 mode_buf_length
= scsicmd
->cmnd
[8];
1958 aac_internal_transfer(scsicmd
, mode_buf
, 0, mode_buf_length
);
1960 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1961 scsicmd
->scsi_done(scsicmd
);
1966 dprintk((KERN_DEBUG
"REQUEST SENSE command.\n"));
1967 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
, sizeof (struct sense_data
));
1968 memset(&dev
->fsa_dev
[cid
].sense_data
, 0, sizeof (struct sense_data
));
1969 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1970 scsicmd
->scsi_done(scsicmd
);
1973 case ALLOW_MEDIUM_REMOVAL
:
1974 dprintk((KERN_DEBUG
"LOCK command.\n"));
1975 if (scsicmd
->cmnd
[4])
1976 fsa_dev_ptr
[cid
].locked
= 1;
1978 fsa_dev_ptr
[cid
].locked
= 0;
1980 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1981 scsicmd
->scsi_done(scsicmd
);
1984 * These commands are all No-Ops
1986 case TEST_UNIT_READY
:
1990 case REASSIGN_BLOCKS
:
1993 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1994 scsicmd
->scsi_done(scsicmd
);
1998 switch (scsicmd
->cmnd
[0])
2007 * Hack to keep track of ordinal number of the device that
2008 * corresponds to a container. Needed to convert
2009 * containers to /dev/sd device names
2012 if (scsicmd
->request
->rq_disk
)
2013 strlcpy(fsa_dev_ptr
[cid
].devname
,
2014 scsicmd
->request
->rq_disk
->disk_name
,
2015 min(sizeof(fsa_dev_ptr
[cid
].devname
),
2016 sizeof(scsicmd
->request
->rq_disk
->disk_name
) + 1));
2018 return aac_read(scsicmd
);
2026 return aac_write(scsicmd
);
2028 case SYNCHRONIZE_CACHE
:
2029 /* Issue FIB to tell Firmware to flush it's cache */
2030 return aac_synchronize(scsicmd
);
2034 * Unhandled commands
2036 dprintk((KERN_WARNING
"Unhandled SCSI Command: 0x%x.\n", scsicmd
->cmnd
[0]));
2037 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
2038 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
2039 ILLEGAL_REQUEST
, SENCODE_INVALID_COMMAND
,
2040 ASENCODE_INVALID_COMMAND
, 0, 0, 0, 0);
2041 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
2042 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
2043 ? sizeof(scsicmd
->sense_buffer
)
2044 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
2045 scsicmd
->scsi_done(scsicmd
);
2050 static int query_disk(struct aac_dev
*dev
, void __user
*arg
)
2052 struct aac_query_disk qd
;
2053 struct fsa_dev_info
*fsa_dev_ptr
;
2055 fsa_dev_ptr
= dev
->fsa_dev
;
2058 if (copy_from_user(&qd
, arg
, sizeof (struct aac_query_disk
)))
2062 else if ((qd
.bus
== -1) && (qd
.id
== -1) && (qd
.lun
== -1))
2064 if (qd
.cnum
< 0 || qd
.cnum
>= dev
->maximum_num_containers
)
2066 qd
.instance
= dev
->scsi_host_ptr
->host_no
;
2068 qd
.id
= CONTAINER_TO_ID(qd
.cnum
);
2069 qd
.lun
= CONTAINER_TO_LUN(qd
.cnum
);
2071 else return -EINVAL
;
2073 qd
.valid
= fsa_dev_ptr
[qd
.cnum
].valid
;
2074 qd
.locked
= fsa_dev_ptr
[qd
.cnum
].locked
;
2075 qd
.deleted
= fsa_dev_ptr
[qd
.cnum
].deleted
;
2077 if (fsa_dev_ptr
[qd
.cnum
].devname
[0] == '\0')
2082 strlcpy(qd
.name
, fsa_dev_ptr
[qd
.cnum
].devname
,
2083 min(sizeof(qd
.name
), sizeof(fsa_dev_ptr
[qd
.cnum
].devname
) + 1));
2085 if (copy_to_user(arg
, &qd
, sizeof (struct aac_query_disk
)))
2090 static int force_delete_disk(struct aac_dev
*dev
, void __user
*arg
)
2092 struct aac_delete_disk dd
;
2093 struct fsa_dev_info
*fsa_dev_ptr
;
2095 fsa_dev_ptr
= dev
->fsa_dev
;
2099 if (copy_from_user(&dd
, arg
, sizeof (struct aac_delete_disk
)))
2102 if (dd
.cnum
>= dev
->maximum_num_containers
)
2105 * Mark this container as being deleted.
2107 fsa_dev_ptr
[dd
.cnum
].deleted
= 1;
2109 * Mark the container as no longer valid
2111 fsa_dev_ptr
[dd
.cnum
].valid
= 0;
2115 static int delete_disk(struct aac_dev
*dev
, void __user
*arg
)
2117 struct aac_delete_disk dd
;
2118 struct fsa_dev_info
*fsa_dev_ptr
;
2120 fsa_dev_ptr
= dev
->fsa_dev
;
2124 if (copy_from_user(&dd
, arg
, sizeof (struct aac_delete_disk
)))
2127 if (dd
.cnum
>= dev
->maximum_num_containers
)
2130 * If the container is locked, it can not be deleted by the API.
2132 if (fsa_dev_ptr
[dd
.cnum
].locked
)
2136 * Mark the container as no longer being valid.
2138 fsa_dev_ptr
[dd
.cnum
].valid
= 0;
2139 fsa_dev_ptr
[dd
.cnum
].devname
[0] = '\0';
2144 int aac_dev_ioctl(struct aac_dev
*dev
, int cmd
, void __user
*arg
)
2147 case FSACTL_QUERY_DISK
:
2148 return query_disk(dev
, arg
);
2149 case FSACTL_DELETE_DISK
:
2150 return delete_disk(dev
, arg
);
2151 case FSACTL_FORCE_DELETE_DISK
:
2152 return force_delete_disk(dev
, arg
);
2153 case FSACTL_GET_CONTAINERS
:
2154 return aac_get_containers(dev
);
2163 * @context: the context set in the fib - here it is scsi cmd
2164 * @fibptr: pointer to the fib
2166 * Handles the completion of a scsi command to a non dasd device
2170 static void aac_srb_callback(void *context
, struct fib
* fibptr
)
2172 struct aac_dev
*dev
;
2173 struct aac_srb_reply
*srbreply
;
2174 struct scsi_cmnd
*scsicmd
;
2176 scsicmd
= (struct scsi_cmnd
*) context
;
2178 if (!aac_valid_context(scsicmd
, fibptr
))
2181 BUG_ON(fibptr
== NULL
);
2185 srbreply
= (struct aac_srb_reply
*) fib_data(fibptr
);
2187 scsicmd
->sense_buffer
[0] = '\0'; /* Initialize sense valid flag to false */
2189 * Calculate resid for sg
2192 scsi_set_resid(scsicmd
, scsi_bufflen(scsicmd
)
2193 - le32_to_cpu(srbreply
->data_xfer_length
));
2195 scsi_dma_unmap(scsicmd
);
2198 * First check the fib status
2201 if (le32_to_cpu(srbreply
->status
) != ST_OK
){
2203 printk(KERN_WARNING
"aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply
->status
));
2204 len
= (le32_to_cpu(srbreply
->sense_data_size
) >
2205 sizeof(scsicmd
->sense_buffer
)) ?
2206 sizeof(scsicmd
->sense_buffer
) :
2207 le32_to_cpu(srbreply
->sense_data_size
);
2208 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
2209 memcpy(scsicmd
->sense_buffer
, srbreply
->sense_data
, len
);
2213 * Next check the srb status
2215 switch( (le32_to_cpu(srbreply
->srb_status
))&0x3f){
2216 case SRB_STATUS_ERROR_RECOVERY
:
2217 case SRB_STATUS_PENDING
:
2218 case SRB_STATUS_SUCCESS
:
2219 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
2221 case SRB_STATUS_DATA_OVERRUN
:
2222 switch(scsicmd
->cmnd
[0]){
2231 if(le32_to_cpu(srbreply
->data_xfer_length
) < scsicmd
->underflow
) {
2232 printk(KERN_WARNING
"aacraid: SCSI CMD underflow\n");
2234 printk(KERN_WARNING
"aacraid: SCSI CMD Data Overrun\n");
2236 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8;
2239 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
2243 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
2247 case SRB_STATUS_ABORTED
:
2248 scsicmd
->result
= DID_ABORT
<< 16 | ABORT
<< 8;
2250 case SRB_STATUS_ABORT_FAILED
:
2251 // Not sure about this one - but assuming the hba was trying to abort for some reason
2252 scsicmd
->result
= DID_ERROR
<< 16 | ABORT
<< 8;
2254 case SRB_STATUS_PARITY_ERROR
:
2255 scsicmd
->result
= DID_PARITY
<< 16 | MSG_PARITY_ERROR
<< 8;
2257 case SRB_STATUS_NO_DEVICE
:
2258 case SRB_STATUS_INVALID_PATH_ID
:
2259 case SRB_STATUS_INVALID_TARGET_ID
:
2260 case SRB_STATUS_INVALID_LUN
:
2261 case SRB_STATUS_SELECTION_TIMEOUT
:
2262 scsicmd
->result
= DID_NO_CONNECT
<< 16 | COMMAND_COMPLETE
<< 8;
2265 case SRB_STATUS_COMMAND_TIMEOUT
:
2266 case SRB_STATUS_TIMEOUT
:
2267 scsicmd
->result
= DID_TIME_OUT
<< 16 | COMMAND_COMPLETE
<< 8;
2270 case SRB_STATUS_BUSY
:
2271 scsicmd
->result
= DID_BUS_BUSY
<< 16 | COMMAND_COMPLETE
<< 8;
2274 case SRB_STATUS_BUS_RESET
:
2275 scsicmd
->result
= DID_RESET
<< 16 | COMMAND_COMPLETE
<< 8;
2278 case SRB_STATUS_MESSAGE_REJECTED
:
2279 scsicmd
->result
= DID_ERROR
<< 16 | MESSAGE_REJECT
<< 8;
2281 case SRB_STATUS_REQUEST_FLUSHED
:
2282 case SRB_STATUS_ERROR
:
2283 case SRB_STATUS_INVALID_REQUEST
:
2284 case SRB_STATUS_REQUEST_SENSE_FAILED
:
2285 case SRB_STATUS_NO_HBA
:
2286 case SRB_STATUS_UNEXPECTED_BUS_FREE
:
2287 case SRB_STATUS_PHASE_SEQUENCE_FAILURE
:
2288 case SRB_STATUS_BAD_SRB_BLOCK_LENGTH
:
2289 case SRB_STATUS_DELAYED_RETRY
:
2290 case SRB_STATUS_BAD_FUNCTION
:
2291 case SRB_STATUS_NOT_STARTED
:
2292 case SRB_STATUS_NOT_IN_USE
:
2293 case SRB_STATUS_FORCE_ABORT
:
2294 case SRB_STATUS_DOMAIN_VALIDATION_FAIL
:
2296 #ifdef AAC_DETAILED_STATUS_INFO
2297 printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",
2298 le32_to_cpu(srbreply
->srb_status
) & 0x3F,
2299 aac_get_status_string(
2300 le32_to_cpu(srbreply
->srb_status
) & 0x3F),
2302 le32_to_cpu(srbreply
->scsi_status
));
2304 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8;
2307 if (le32_to_cpu(srbreply
->scsi_status
) == 0x02 ){ // Check Condition
2309 scsicmd
->result
|= SAM_STAT_CHECK_CONDITION
;
2310 len
= (le32_to_cpu(srbreply
->sense_data_size
) >
2311 sizeof(scsicmd
->sense_buffer
)) ?
2312 sizeof(scsicmd
->sense_buffer
) :
2313 le32_to_cpu(srbreply
->sense_data_size
);
2314 #ifdef AAC_DETAILED_STATUS_INFO
2315 printk(KERN_WARNING
"aac_srb_callback: check condition, status = %d len=%d\n",
2316 le32_to_cpu(srbreply
->status
), len
);
2318 memcpy(scsicmd
->sense_buffer
, srbreply
->sense_data
, len
);
2322 * OR in the scsi status (already shifted up a bit)
2324 scsicmd
->result
|= le32_to_cpu(srbreply
->scsi_status
);
2326 aac_fib_complete(fibptr
);
2327 aac_fib_free(fibptr
);
2328 scsicmd
->scsi_done(scsicmd
);
2334 * @scsicmd: the scsi command block
2336 * This routine will form a FIB and fill in the aac_srb from the
2337 * scsicmd passed in.
2340 static int aac_send_srb_fib(struct scsi_cmnd
* scsicmd
)
2342 struct fib
* cmd_fibcontext
;
2343 struct aac_dev
* dev
;
2346 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2347 if (scmd_id(scsicmd
) >= dev
->maximum_num_physicals
||
2348 scsicmd
->device
->lun
> 7) {
2349 scsicmd
->result
= DID_NO_CONNECT
<< 16;
2350 scsicmd
->scsi_done(scsicmd
);
2355 * Allocate and initialize a Fib then setup a BlockWrite command
2357 if (!(cmd_fibcontext
= aac_fib_alloc(dev
))) {
2360 status
= aac_adapter_scsi(cmd_fibcontext
, scsicmd
);
2363 * Check that the command queued to the controller
2365 if (status
== -EINPROGRESS
) {
2366 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
2370 printk(KERN_WARNING
"aac_srb: aac_fib_send failed with status: %d\n", status
);
2371 aac_fib_complete(cmd_fibcontext
);
2372 aac_fib_free(cmd_fibcontext
);
2377 static unsigned long aac_build_sg(struct scsi_cmnd
* scsicmd
, struct sgmap
* psg
)
2379 struct aac_dev
*dev
;
2380 unsigned long byte_count
= 0;
2383 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2384 // Get rid of old data
2386 psg
->sg
[0].addr
= 0;
2387 psg
->sg
[0].count
= 0;
2389 nseg
= scsi_dma_map(scsicmd
);
2392 struct scatterlist
*sg
;
2395 psg
->count
= cpu_to_le32(nseg
);
2397 scsi_for_each_sg(scsicmd
, sg
, nseg
, i
) {
2398 psg
->sg
[i
].addr
= cpu_to_le32(sg_dma_address(sg
));
2399 psg
->sg
[i
].count
= cpu_to_le32(sg_dma_len(sg
));
2400 byte_count
+= sg_dma_len(sg
);
2402 /* hba wants the size to be exact */
2403 if (byte_count
> scsi_bufflen(scsicmd
)) {
2404 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2405 (byte_count
- scsi_bufflen(scsicmd
));
2406 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2407 byte_count
= scsi_bufflen(scsicmd
);
2409 /* Check for command underflow */
2410 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2411 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2412 byte_count
, scsicmd
->underflow
);
2419 static unsigned long aac_build_sg64(struct scsi_cmnd
* scsicmd
, struct sgmap64
* psg
)
2421 struct aac_dev
*dev
;
2422 unsigned long byte_count
= 0;
2426 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2427 // Get rid of old data
2429 psg
->sg
[0].addr
[0] = 0;
2430 psg
->sg
[0].addr
[1] = 0;
2431 psg
->sg
[0].count
= 0;
2433 nseg
= scsi_dma_map(scsicmd
);
2436 struct scatterlist
*sg
;
2439 scsi_for_each_sg(scsicmd
, sg
, nseg
, i
) {
2440 int count
= sg_dma_len(sg
);
2441 addr
= sg_dma_address(sg
);
2442 psg
->sg
[i
].addr
[0] = cpu_to_le32(addr
& 0xffffffff);
2443 psg
->sg
[i
].addr
[1] = cpu_to_le32(addr
>>32);
2444 psg
->sg
[i
].count
= cpu_to_le32(count
);
2445 byte_count
+= count
;
2447 psg
->count
= cpu_to_le32(nseg
);
2448 /* hba wants the size to be exact */
2449 if (byte_count
> scsi_bufflen(scsicmd
)) {
2450 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2451 (byte_count
- scsi_bufflen(scsicmd
));
2452 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2453 byte_count
= scsi_bufflen(scsicmd
);
2455 /* Check for command underflow */
2456 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2457 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2458 byte_count
, scsicmd
->underflow
);
2464 static unsigned long aac_build_sgraw(struct scsi_cmnd
* scsicmd
, struct sgmapraw
* psg
)
2466 unsigned long byte_count
= 0;
2469 // Get rid of old data
2471 psg
->sg
[0].next
= 0;
2472 psg
->sg
[0].prev
= 0;
2473 psg
->sg
[0].addr
[0] = 0;
2474 psg
->sg
[0].addr
[1] = 0;
2475 psg
->sg
[0].count
= 0;
2476 psg
->sg
[0].flags
= 0;
2478 nseg
= scsi_dma_map(scsicmd
);
2481 struct scatterlist
*sg
;
2484 scsi_for_each_sg(scsicmd
, sg
, nseg
, i
) {
2485 int count
= sg_dma_len(sg
);
2486 u64 addr
= sg_dma_address(sg
);
2487 psg
->sg
[i
].next
= 0;
2488 psg
->sg
[i
].prev
= 0;
2489 psg
->sg
[i
].addr
[1] = cpu_to_le32((u32
)(addr
>>32));
2490 psg
->sg
[i
].addr
[0] = cpu_to_le32((u32
)(addr
& 0xffffffff));
2491 psg
->sg
[i
].count
= cpu_to_le32(count
);
2492 psg
->sg
[i
].flags
= 0;
2493 byte_count
+= count
;
2495 psg
->count
= cpu_to_le32(nseg
);
2496 /* hba wants the size to be exact */
2497 if (byte_count
> scsi_bufflen(scsicmd
)) {
2498 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2499 (byte_count
- scsi_bufflen(scsicmd
));
2500 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2501 byte_count
= scsi_bufflen(scsicmd
);
2503 /* Check for command underflow */
2504 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2505 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2506 byte_count
, scsicmd
->underflow
);
2512 #ifdef AAC_DETAILED_STATUS_INFO
2514 struct aac_srb_status_info
{
2520 static struct aac_srb_status_info srb_status_info
[] = {
2521 { SRB_STATUS_PENDING
, "Pending Status"},
2522 { SRB_STATUS_SUCCESS
, "Success"},
2523 { SRB_STATUS_ABORTED
, "Aborted Command"},
2524 { SRB_STATUS_ABORT_FAILED
, "Abort Failed"},
2525 { SRB_STATUS_ERROR
, "Error Event"},
2526 { SRB_STATUS_BUSY
, "Device Busy"},
2527 { SRB_STATUS_INVALID_REQUEST
, "Invalid Request"},
2528 { SRB_STATUS_INVALID_PATH_ID
, "Invalid Path ID"},
2529 { SRB_STATUS_NO_DEVICE
, "No Device"},
2530 { SRB_STATUS_TIMEOUT
, "Timeout"},
2531 { SRB_STATUS_SELECTION_TIMEOUT
, "Selection Timeout"},
2532 { SRB_STATUS_COMMAND_TIMEOUT
, "Command Timeout"},
2533 { SRB_STATUS_MESSAGE_REJECTED
, "Message Rejected"},
2534 { SRB_STATUS_BUS_RESET
, "Bus Reset"},
2535 { SRB_STATUS_PARITY_ERROR
, "Parity Error"},
2536 { SRB_STATUS_REQUEST_SENSE_FAILED
,"Request Sense Failed"},
2537 { SRB_STATUS_NO_HBA
, "No HBA"},
2538 { SRB_STATUS_DATA_OVERRUN
, "Data Overrun/Data Underrun"},
2539 { SRB_STATUS_UNEXPECTED_BUS_FREE
,"Unexpected Bus Free"},
2540 { SRB_STATUS_PHASE_SEQUENCE_FAILURE
,"Phase Error"},
2541 { SRB_STATUS_BAD_SRB_BLOCK_LENGTH
,"Bad Srb Block Length"},
2542 { SRB_STATUS_REQUEST_FLUSHED
, "Request Flushed"},
2543 { SRB_STATUS_DELAYED_RETRY
, "Delayed Retry"},
2544 { SRB_STATUS_INVALID_LUN
, "Invalid LUN"},
2545 { SRB_STATUS_INVALID_TARGET_ID
, "Invalid TARGET ID"},
2546 { SRB_STATUS_BAD_FUNCTION
, "Bad Function"},
2547 { SRB_STATUS_ERROR_RECOVERY
, "Error Recovery"},
2548 { SRB_STATUS_NOT_STARTED
, "Not Started"},
2549 { SRB_STATUS_NOT_IN_USE
, "Not In Use"},
2550 { SRB_STATUS_FORCE_ABORT
, "Force Abort"},
2551 { SRB_STATUS_DOMAIN_VALIDATION_FAIL
,"Domain Validation Failure"},
2552 { 0xff, "Unknown Error"}
2555 char *aac_get_status_string(u32 status
)
2559 for (i
= 0; i
< ARRAY_SIZE(srb_status_info
); i
++)
2560 if (srb_status_info
[i
].status
== status
)
2561 return srb_status_info
[i
].str
;
2563 return "Bad Status Code";