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 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/sched.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/dma-mapping.h>
36 #include <asm/semaphore.h>
37 #include <asm/uaccess.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_PARAM_LIST_LENGTH_ERROR 0x1A
66 #define SENCODE_INVALID_COMMAND 0x20
67 #define SENCODE_LBA_OUT_OF_RANGE 0x21
68 #define SENCODE_INVALID_CDB_FIELD 0x24
69 #define SENCODE_LUN_NOT_SUPPORTED 0x25
70 #define SENCODE_INVALID_PARAM_FIELD 0x26
71 #define SENCODE_PARAM_NOT_SUPPORTED 0x26
72 #define SENCODE_PARAM_VALUE_INVALID 0x26
73 #define SENCODE_RESET_OCCURRED 0x29
74 #define SENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x3E
75 #define SENCODE_INQUIRY_DATA_CHANGED 0x3F
76 #define SENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x39
77 #define SENCODE_DIAGNOSTIC_FAILURE 0x40
78 #define SENCODE_INTERNAL_TARGET_FAILURE 0x44
79 #define SENCODE_INVALID_MESSAGE_ERROR 0x49
80 #define SENCODE_LUN_FAILED_SELF_CONFIG 0x4c
81 #define SENCODE_OVERLAPPED_COMMAND 0x4E
84 * Additional sense codes
87 #define ASENCODE_NO_SENSE 0x00
88 #define ASENCODE_END_OF_DATA 0x05
89 #define ASENCODE_BECOMING_READY 0x01
90 #define ASENCODE_INIT_CMD_REQUIRED 0x02
91 #define ASENCODE_PARAM_LIST_LENGTH_ERROR 0x00
92 #define ASENCODE_INVALID_COMMAND 0x00
93 #define ASENCODE_LBA_OUT_OF_RANGE 0x00
94 #define ASENCODE_INVALID_CDB_FIELD 0x00
95 #define ASENCODE_LUN_NOT_SUPPORTED 0x00
96 #define ASENCODE_INVALID_PARAM_FIELD 0x00
97 #define ASENCODE_PARAM_NOT_SUPPORTED 0x01
98 #define ASENCODE_PARAM_VALUE_INVALID 0x02
99 #define ASENCODE_RESET_OCCURRED 0x00
100 #define ASENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x00
101 #define ASENCODE_INQUIRY_DATA_CHANGED 0x03
102 #define ASENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x00
103 #define ASENCODE_DIAGNOSTIC_FAILURE 0x80
104 #define ASENCODE_INTERNAL_TARGET_FAILURE 0x00
105 #define ASENCODE_INVALID_MESSAGE_ERROR 0x00
106 #define ASENCODE_LUN_FAILED_SELF_CONFIG 0x00
107 #define ASENCODE_OVERLAPPED_COMMAND 0x00
109 #define BYTE0(x) (unsigned char)(x)
110 #define BYTE1(x) (unsigned char)((x) >> 8)
111 #define BYTE2(x) (unsigned char)((x) >> 16)
112 #define BYTE3(x) (unsigned char)((x) >> 24)
114 /*------------------------------------------------------------------------------
115 * S T R U C T S / T Y P E D E F S
116 *----------------------------------------------------------------------------*/
117 /* SCSI inquiry data */
118 struct inquiry_data
{
119 u8 inqd_pdt
; /* Peripheral qualifier | Peripheral Device Type */
120 u8 inqd_dtq
; /* RMB | Device Type Qualifier */
121 u8 inqd_ver
; /* ISO version | ECMA version | ANSI-approved version */
122 u8 inqd_rdf
; /* AENC | TrmIOP | Response data format */
123 u8 inqd_len
; /* Additional length (n-4) */
124 u8 inqd_pad1
[2];/* Reserved - must be zero */
125 u8 inqd_pad2
; /* RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
126 u8 inqd_vid
[8]; /* Vendor ID */
127 u8 inqd_pid
[16];/* Product ID */
128 u8 inqd_prl
[4]; /* Product Revision Level */
132 * M O D U L E G L O B A L S
135 static unsigned long aac_build_sg(struct scsi_cmnd
* scsicmd
, struct sgmap
* sgmap
);
136 static unsigned long aac_build_sg64(struct scsi_cmnd
* scsicmd
, struct sgmap64
* psg
);
137 static unsigned long aac_build_sgraw(struct scsi_cmnd
* scsicmd
, struct sgmapraw
* psg
);
138 static int aac_send_srb_fib(struct scsi_cmnd
* scsicmd
);
139 #ifdef AAC_DETAILED_STATUS_INFO
140 static char *aac_get_status_string(u32 status
);
144 * Non dasd selection is handled entirely in aachba now
147 static int nondasd
= -1;
148 static int dacmode
= -1;
150 static int commit
= -1;
151 int startup_timeout
= 180;
152 int aif_timeout
= 120;
154 module_param(nondasd
, int, S_IRUGO
|S_IWUSR
);
155 MODULE_PARM_DESC(nondasd
, "Control scanning of hba for nondasd devices. 0=off, 1=on");
156 module_param(dacmode
, int, S_IRUGO
|S_IWUSR
);
157 MODULE_PARM_DESC(dacmode
, "Control whether dma addressing is using 64 bit DAC. 0=off, 1=on");
158 module_param(commit
, int, S_IRUGO
|S_IWUSR
);
159 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");
160 module_param(startup_timeout
, int, S_IRUGO
|S_IWUSR
);
161 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.");
162 module_param(aif_timeout
, int, S_IRUGO
|S_IWUSR
);
163 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.");
166 module_param(numacb
, int, S_IRUGO
|S_IWUSR
);
167 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.");
170 module_param(acbsize
, int, S_IRUGO
|S_IWUSR
);
171 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.");
173 int expose_physicals
= 0;
174 module_param(expose_physicals
, int, S_IRUGO
|S_IWUSR
);
175 MODULE_PARM_DESC(expose_physicals
, "Expose physical components of the arrays. 0=off, 1=on");
177 * aac_get_config_status - check the adapter configuration
178 * @common: adapter to query
180 * Query config status, and commit the configuration if needed.
182 int aac_get_config_status(struct aac_dev
*dev
, int commit_flag
)
187 if (!(fibptr
= aac_fib_alloc(dev
)))
190 aac_fib_init(fibptr
);
192 struct aac_get_config_status
*dinfo
;
193 dinfo
= (struct aac_get_config_status
*) fib_data(fibptr
);
195 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
196 dinfo
->type
= cpu_to_le32(CT_GET_CONFIG_STATUS
);
197 dinfo
->count
= cpu_to_le32(sizeof(((struct aac_get_config_status_resp
*)NULL
)->data
));
200 status
= aac_fib_send(ContainerCommand
,
202 sizeof (struct aac_get_config_status
),
207 printk(KERN_WARNING
"aac_get_config_status: SendFIB failed.\n");
209 struct aac_get_config_status_resp
*reply
210 = (struct aac_get_config_status_resp
*) fib_data(fibptr
);
211 dprintk((KERN_WARNING
212 "aac_get_config_status: response=%d status=%d action=%d\n",
213 le32_to_cpu(reply
->response
),
214 le32_to_cpu(reply
->status
),
215 le32_to_cpu(reply
->data
.action
)));
216 if ((le32_to_cpu(reply
->response
) != ST_OK
) ||
217 (le32_to_cpu(reply
->status
) != CT_OK
) ||
218 (le32_to_cpu(reply
->data
.action
) > CFACT_PAUSE
)) {
219 printk(KERN_WARNING
"aac_get_config_status: Will not issue the Commit Configuration\n");
223 aac_fib_complete(fibptr
);
224 /* Send a CT_COMMIT_CONFIG to enable discovery of devices */
226 if ((commit
== 1) || commit_flag
) {
227 struct aac_commit_config
* dinfo
;
228 aac_fib_init(fibptr
);
229 dinfo
= (struct aac_commit_config
*) fib_data(fibptr
);
231 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
232 dinfo
->type
= cpu_to_le32(CT_COMMIT_CONFIG
);
234 status
= aac_fib_send(ContainerCommand
,
236 sizeof (struct aac_commit_config
),
240 aac_fib_complete(fibptr
);
241 } else if (commit
== 0) {
243 "aac_get_config_status: Foreign device configurations are being ignored\n");
246 aac_fib_free(fibptr
);
251 * aac_get_containers - list containers
252 * @common: adapter to probe
254 * Make a list of all containers on this controller
256 int aac_get_containers(struct aac_dev
*dev
)
258 struct fsa_dev_info
*fsa_dev_ptr
;
263 struct aac_get_container_count
*dinfo
;
264 struct aac_get_container_count_resp
*dresp
;
265 int maximum_num_containers
= MAXIMUM_NUM_CONTAINERS
;
267 instance
= dev
->scsi_host_ptr
->unique_id
;
269 if (!(fibptr
= aac_fib_alloc(dev
)))
272 aac_fib_init(fibptr
);
273 dinfo
= (struct aac_get_container_count
*) fib_data(fibptr
);
274 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
275 dinfo
->type
= cpu_to_le32(CT_GET_CONTAINER_COUNT
);
277 status
= aac_fib_send(ContainerCommand
,
279 sizeof (struct aac_get_container_count
),
284 dresp
= (struct aac_get_container_count_resp
*)fib_data(fibptr
);
285 maximum_num_containers
= le32_to_cpu(dresp
->ContainerSwitchEntries
);
286 aac_fib_complete(fibptr
);
289 if (maximum_num_containers
< MAXIMUM_NUM_CONTAINERS
)
290 maximum_num_containers
= MAXIMUM_NUM_CONTAINERS
;
291 fsa_dev_ptr
= (struct fsa_dev_info
*) kmalloc(
292 sizeof(*fsa_dev_ptr
) * maximum_num_containers
, GFP_KERNEL
);
294 aac_fib_free(fibptr
);
297 memset(fsa_dev_ptr
, 0, sizeof(*fsa_dev_ptr
) * maximum_num_containers
);
299 dev
->fsa_dev
= fsa_dev_ptr
;
300 dev
->maximum_num_containers
= maximum_num_containers
;
302 for (index
= 0; index
< dev
->maximum_num_containers
; index
++) {
303 struct aac_query_mount
*dinfo
;
304 struct aac_mount
*dresp
;
306 fsa_dev_ptr
[index
].devname
[0] = '\0';
308 aac_fib_init(fibptr
);
309 dinfo
= (struct aac_query_mount
*) fib_data(fibptr
);
311 dinfo
->command
= cpu_to_le32(VM_NameServe
);
312 dinfo
->count
= cpu_to_le32(index
);
313 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
315 status
= aac_fib_send(ContainerCommand
,
317 sizeof (struct aac_query_mount
),
322 printk(KERN_WARNING
"aac_get_containers: SendFIB failed.\n");
325 dresp
= (struct aac_mount
*)fib_data(fibptr
);
327 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
328 (le32_to_cpu(dresp
->mnt
[0].vol
) == CT_NONE
)) {
329 dinfo
->command
= cpu_to_le32(VM_NameServe64
);
330 dinfo
->count
= cpu_to_le32(index
);
331 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
333 if (aac_fib_send(ContainerCommand
,
335 sizeof(struct aac_query_mount
),
341 dresp
->mnt
[0].capacityhigh
= 0;
344 "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%llu\n",
345 (int)index
, (int)le32_to_cpu(dresp
->status
),
346 (int)le32_to_cpu(dresp
->mnt
[0].vol
),
347 (int)le32_to_cpu(dresp
->mnt
[0].state
),
348 ((u64
)le32_to_cpu(dresp
->mnt
[0].capacity
)) +
349 (((u64
)le32_to_cpu(dresp
->mnt
[0].capacityhigh
)) << 32)));
350 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
351 (le32_to_cpu(dresp
->mnt
[0].vol
) != CT_NONE
) &&
352 (le32_to_cpu(dresp
->mnt
[0].state
) != FSCS_HIDDEN
)) {
353 fsa_dev_ptr
[index
].valid
= 1;
354 fsa_dev_ptr
[index
].type
= le32_to_cpu(dresp
->mnt
[0].vol
);
355 fsa_dev_ptr
[index
].size
356 = ((u64
)le32_to_cpu(dresp
->mnt
[0].capacity
)) +
357 (((u64
)le32_to_cpu(dresp
->mnt
[0].capacityhigh
)) << 32);
358 if (le32_to_cpu(dresp
->mnt
[0].state
) & FSCS_READONLY
)
359 fsa_dev_ptr
[index
].ro
= 1;
361 aac_fib_complete(fibptr
);
363 * If there are no more containers, then stop asking.
365 if ((index
+ 1) >= le32_to_cpu(dresp
->count
)){
369 aac_fib_free(fibptr
);
373 static void aac_internal_transfer(struct scsi_cmnd
*scsicmd
, void *data
, unsigned int offset
, unsigned int len
)
376 unsigned int transfer_len
;
377 struct scatterlist
*sg
= scsicmd
->request_buffer
;
379 if (scsicmd
->use_sg
) {
380 buf
= kmap_atomic(sg
->page
, KM_IRQ0
) + sg
->offset
;
381 transfer_len
= min(sg
->length
, len
+ offset
);
383 buf
= scsicmd
->request_buffer
;
384 transfer_len
= min(scsicmd
->request_bufflen
, len
+ offset
);
387 memcpy(buf
+ offset
, data
, transfer_len
- offset
);
390 kunmap_atomic(buf
- sg
->offset
, KM_IRQ0
);
394 static void get_container_name_callback(void *context
, struct fib
* fibptr
)
396 struct aac_get_name_resp
* get_name_reply
;
397 struct scsi_cmnd
* scsicmd
;
399 scsicmd
= (struct scsi_cmnd
*) context
;
400 scsicmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
402 dprintk((KERN_DEBUG
"get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies
));
403 BUG_ON(fibptr
== NULL
);
405 get_name_reply
= (struct aac_get_name_resp
*) fib_data(fibptr
);
406 /* Failure is irrelevant, using default value instead */
407 if ((le32_to_cpu(get_name_reply
->status
) == CT_OK
)
408 && (get_name_reply
->data
[0] != '\0')) {
409 char *sp
= get_name_reply
->data
;
410 sp
[sizeof(((struct aac_get_name_resp
*)NULL
)->data
)-1] = '\0';
414 char d
[sizeof(((struct inquiry_data
*)NULL
)->inqd_pid
)];
415 int count
= sizeof(d
);
418 *dp
++ = (*sp
) ? *sp
++ : ' ';
419 } while (--count
> 0);
420 aac_internal_transfer(scsicmd
, d
,
421 offsetof(struct inquiry_data
, inqd_pid
), sizeof(d
));
425 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
427 aac_fib_complete(fibptr
);
428 aac_fib_free(fibptr
);
429 scsicmd
->scsi_done(scsicmd
);
433 * aac_get_container_name - get container name, none blocking.
435 static int aac_get_container_name(struct scsi_cmnd
* scsicmd
, int cid
)
438 struct aac_get_name
*dinfo
;
439 struct fib
* cmd_fibcontext
;
440 struct aac_dev
* dev
;
442 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
444 if (!(cmd_fibcontext
= aac_fib_alloc(dev
)))
447 aac_fib_init(cmd_fibcontext
);
448 dinfo
= (struct aac_get_name
*) fib_data(cmd_fibcontext
);
450 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
451 dinfo
->type
= cpu_to_le32(CT_READ_NAME
);
452 dinfo
->cid
= cpu_to_le32(cid
);
453 dinfo
->count
= cpu_to_le32(sizeof(((struct aac_get_name_resp
*)NULL
)->data
));
455 status
= aac_fib_send(ContainerCommand
,
457 sizeof (struct aac_get_name
),
460 (fib_callback
) get_container_name_callback
,
464 * Check that the command queued to the controller
466 if (status
== -EINPROGRESS
) {
467 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
471 printk(KERN_WARNING
"aac_get_container_name: aac_fib_send failed with status: %d.\n", status
);
472 aac_fib_complete(cmd_fibcontext
);
473 aac_fib_free(cmd_fibcontext
);
478 * aac_probe_container - query a logical volume
479 * @dev: device to query
480 * @cid: container identifier
482 * Queries the controller about the given volume. The volume information
483 * is updated in the struct fsa_dev_info structure rather than returned.
486 int aac_probe_container(struct aac_dev
*dev
, int cid
)
488 struct fsa_dev_info
*fsa_dev_ptr
;
490 struct aac_query_mount
*dinfo
;
491 struct aac_mount
*dresp
;
495 fsa_dev_ptr
= dev
->fsa_dev
;
498 instance
= dev
->scsi_host_ptr
->unique_id
;
500 if (!(fibptr
= aac_fib_alloc(dev
)))
503 aac_fib_init(fibptr
);
505 dinfo
= (struct aac_query_mount
*)fib_data(fibptr
);
507 dinfo
->command
= cpu_to_le32(VM_NameServe
);
508 dinfo
->count
= cpu_to_le32(cid
);
509 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
511 status
= aac_fib_send(ContainerCommand
,
513 sizeof(struct aac_query_mount
),
518 printk(KERN_WARNING
"aacraid: aac_probe_container query failed.\n");
522 dresp
= (struct aac_mount
*) fib_data(fibptr
);
524 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
525 (le32_to_cpu(dresp
->mnt
[0].vol
) == CT_NONE
)) {
526 dinfo
->command
= cpu_to_le32(VM_NameServe64
);
527 dinfo
->count
= cpu_to_le32(cid
);
528 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
530 if (aac_fib_send(ContainerCommand
,
532 sizeof(struct aac_query_mount
),
538 dresp
->mnt
[0].capacityhigh
= 0;
540 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
541 (le32_to_cpu(dresp
->mnt
[0].vol
) != CT_NONE
) &&
542 (le32_to_cpu(dresp
->mnt
[0].state
) != FSCS_HIDDEN
)) {
543 fsa_dev_ptr
[cid
].valid
= 1;
544 fsa_dev_ptr
[cid
].type
= le32_to_cpu(dresp
->mnt
[0].vol
);
545 fsa_dev_ptr
[cid
].size
546 = ((u64
)le32_to_cpu(dresp
->mnt
[0].capacity
)) +
547 (((u64
)le32_to_cpu(dresp
->mnt
[0].capacityhigh
)) << 32);
548 if (le32_to_cpu(dresp
->mnt
[0].state
) & FSCS_READONLY
)
549 fsa_dev_ptr
[cid
].ro
= 1;
553 aac_fib_complete(fibptr
);
554 aac_fib_free(fibptr
);
559 /* Local Structure to set SCSI inquiry data strings */
561 char vid
[8]; /* Vendor ID */
562 char pid
[16]; /* Product ID */
563 char prl
[4]; /* Product Revision Level */
567 * InqStrCopy - string merge
568 * @a: string to copy from
569 * @b: string to copy to
571 * Copy a String from one location to another
575 static void inqstrcpy(char *a
, char *b
)
582 static char *container_types
[] = {
608 /* Function: setinqstr
610 * Arguments: [1] pointer to void [1] int
612 * Purpose: Sets SCSI inquiry data strings for vendor, product
613 * and revision level. Allows strings to be set in platform dependant
614 * files instead of in OS dependant driver source.
617 static void setinqstr(struct aac_dev
*dev
, void *data
, int tindex
)
619 struct scsi_inq
*str
;
621 str
= (struct scsi_inq
*)(data
); /* cast data to scsi inq block */
622 memset(str
, ' ', sizeof(*str
));
624 if (dev
->supplement_adapter_info
.AdapterTypeText
[0]) {
625 char * cp
= dev
->supplement_adapter_info
.AdapterTypeText
;
626 int c
= sizeof(str
->vid
);
627 while (*cp
&& *cp
!= ' ' && --c
)
631 inqstrcpy (dev
->supplement_adapter_info
.AdapterTypeText
,
634 while (*cp
&& *cp
!= ' ')
638 /* last six chars reserved for vol type */
640 if (strlen(cp
) > sizeof(str
->pid
)) {
641 c
= cp
[sizeof(str
->pid
)];
642 cp
[sizeof(str
->pid
)] = '\0';
644 inqstrcpy (cp
, str
->pid
);
646 cp
[sizeof(str
->pid
)] = c
;
648 struct aac_driver_ident
*mp
= aac_get_driver_ident(dev
->cardtype
);
650 inqstrcpy (mp
->vname
, str
->vid
);
651 /* last six chars reserved for vol type */
652 inqstrcpy (mp
->model
, str
->pid
);
655 if (tindex
< ARRAY_SIZE(container_types
)){
656 char *findit
= str
->pid
;
658 for ( ; *findit
!= ' '; findit
++); /* walk till we find a space */
659 /* RAID is superfluous in the context of a RAID device */
660 if (memcmp(findit
-4, "RAID", 4) == 0)
661 *(findit
-= 4) = ' ';
662 if (((findit
- str
->pid
) + strlen(container_types
[tindex
]))
663 < (sizeof(str
->pid
) + sizeof(str
->prl
)))
664 inqstrcpy (container_types
[tindex
], findit
+ 1);
666 inqstrcpy ("V1.0", str
->prl
);
669 static void set_sense(u8
*sense_buf
, u8 sense_key
, u8 sense_code
,
670 u8 a_sense_code
, u8 incorrect_length
,
671 u8 bit_pointer
, u16 field_pointer
,
674 sense_buf
[0] = 0xF0; /* Sense data valid, err code 70h (current error) */
675 sense_buf
[1] = 0; /* Segment number, always zero */
677 if (incorrect_length
) {
678 sense_buf
[2] = sense_key
| 0x20;/* Set ILI bit | sense key */
679 sense_buf
[3] = BYTE3(residue
);
680 sense_buf
[4] = BYTE2(residue
);
681 sense_buf
[5] = BYTE1(residue
);
682 sense_buf
[6] = BYTE0(residue
);
684 sense_buf
[2] = sense_key
; /* Sense key */
686 if (sense_key
== ILLEGAL_REQUEST
)
687 sense_buf
[7] = 10; /* Additional sense length */
689 sense_buf
[7] = 6; /* Additional sense length */
691 sense_buf
[12] = sense_code
; /* Additional sense code */
692 sense_buf
[13] = a_sense_code
; /* Additional sense code qualifier */
693 if (sense_key
== ILLEGAL_REQUEST
) {
696 if (sense_code
== SENCODE_INVALID_PARAM_FIELD
)
697 sense_buf
[15] = 0x80;/* Std sense key specific field */
698 /* Illegal parameter is in the parameter block */
700 if (sense_code
== SENCODE_INVALID_CDB_FIELD
)
701 sense_buf
[15] = 0xc0;/* Std sense key specific field */
702 /* Illegal parameter is in the CDB block */
703 sense_buf
[15] |= bit_pointer
;
704 sense_buf
[16] = field_pointer
>> 8; /* MSB */
705 sense_buf
[17] = field_pointer
; /* LSB */
709 int aac_get_adapter_info(struct aac_dev
* dev
)
714 struct aac_adapter_info
*info
;
715 struct aac_bus_info
*command
;
716 struct aac_bus_info_response
*bus_info
;
718 if (!(fibptr
= aac_fib_alloc(dev
)))
721 aac_fib_init(fibptr
);
722 info
= (struct aac_adapter_info
*) fib_data(fibptr
);
723 memset(info
,0,sizeof(*info
));
725 rcode
= aac_fib_send(RequestAdapterInfo
,
729 -1, 1, /* First `interrupt' command uses special wait */
734 aac_fib_complete(fibptr
);
735 aac_fib_free(fibptr
);
738 memcpy(&dev
->adapter_info
, info
, sizeof(*info
));
740 if (dev
->adapter_info
.options
& AAC_OPT_SUPPLEMENT_ADAPTER_INFO
) {
741 struct aac_supplement_adapter_info
* info
;
743 aac_fib_init(fibptr
);
745 info
= (struct aac_supplement_adapter_info
*) fib_data(fibptr
);
747 memset(info
,0,sizeof(*info
));
749 rcode
= aac_fib_send(RequestSupplementAdapterInfo
,
758 memcpy(&dev
->supplement_adapter_info
, info
, sizeof(*info
));
766 aac_fib_init(fibptr
);
768 bus_info
= (struct aac_bus_info_response
*) fib_data(fibptr
);
770 memset(bus_info
, 0, sizeof(*bus_info
));
772 command
= (struct aac_bus_info
*)bus_info
;
774 command
->Command
= cpu_to_le32(VM_Ioctl
);
775 command
->ObjType
= cpu_to_le32(FT_DRIVE
);
776 command
->MethodId
= cpu_to_le32(1);
777 command
->CtlCmd
= cpu_to_le32(GetBusInfo
);
779 rcode
= aac_fib_send(ContainerCommand
,
786 if (rcode
>= 0 && le32_to_cpu(bus_info
->Status
) == ST_OK
) {
787 dev
->maximum_num_physicals
= le32_to_cpu(bus_info
->TargetsPerBus
);
788 dev
->maximum_num_channels
= le32_to_cpu(bus_info
->BusCount
);
791 if (!dev
->in_reset
) {
792 tmp
= le32_to_cpu(dev
->adapter_info
.kernelrev
);
793 printk(KERN_INFO
"%s%d: kernel %d.%d-%d[%d] %.*s\n",
799 le32_to_cpu(dev
->adapter_info
.kernelbuild
),
800 (int)sizeof(dev
->supplement_adapter_info
.BuildDate
),
801 dev
->supplement_adapter_info
.BuildDate
);
802 tmp
= le32_to_cpu(dev
->adapter_info
.monitorrev
);
803 printk(KERN_INFO
"%s%d: monitor %d.%d-%d[%d]\n",
805 tmp
>>24,(tmp
>>16)&0xff,tmp
&0xff,
806 le32_to_cpu(dev
->adapter_info
.monitorbuild
));
807 tmp
= le32_to_cpu(dev
->adapter_info
.biosrev
);
808 printk(KERN_INFO
"%s%d: bios %d.%d-%d[%d]\n",
810 tmp
>>24,(tmp
>>16)&0xff,tmp
&0xff,
811 le32_to_cpu(dev
->adapter_info
.biosbuild
));
812 if (le32_to_cpu(dev
->adapter_info
.serial
[0]) != 0xBAD0)
813 printk(KERN_INFO
"%s%d: serial %x\n",
815 le32_to_cpu(dev
->adapter_info
.serial
[0]));
818 dev
->nondasd_support
= 0;
819 dev
->raid_scsi_mode
= 0;
820 if(dev
->adapter_info
.options
& AAC_OPT_NONDASD
){
821 dev
->nondasd_support
= 1;
825 * If the firmware supports ROMB RAID/SCSI mode and we are currently
826 * in RAID/SCSI mode, set the flag. For now if in this mode we will
827 * force nondasd support on. If we decide to allow the non-dasd flag
828 * additional changes changes will have to be made to support
829 * RAID/SCSI. the function aac_scsi_cmd in this module will have to be
830 * changed to support the new dev->raid_scsi_mode flag instead of
831 * leaching off of the dev->nondasd_support flag. Also in linit.c the
832 * function aac_detect will have to be modified where it sets up the
833 * max number of channels based on the aac->nondasd_support flag only.
835 if ((dev
->adapter_info
.options
& AAC_OPT_SCSI_MANAGED
) &&
836 (dev
->adapter_info
.options
& AAC_OPT_RAID_SCSI_MODE
)) {
837 dev
->nondasd_support
= 1;
838 dev
->raid_scsi_mode
= 1;
840 if (dev
->raid_scsi_mode
!= 0)
841 printk(KERN_INFO
"%s%d: ROMB RAID/SCSI mode enabled\n",
845 dev
->nondasd_support
= (nondasd
!=0);
847 if(dev
->nondasd_support
!= 0){
848 printk(KERN_INFO
"%s%d: Non-DASD support enabled.\n",dev
->name
, dev
->id
);
851 dev
->dac_support
= 0;
852 if( (sizeof(dma_addr_t
) > 4) && (dev
->adapter_info
.options
& AAC_OPT_SGMAP_HOST64
)){
853 printk(KERN_INFO
"%s%d: 64bit support enabled.\n", dev
->name
, dev
->id
);
854 dev
->dac_support
= 1;
858 dev
->dac_support
= (dacmode
!=0);
860 if(dev
->dac_support
!= 0) {
861 if (!pci_set_dma_mask(dev
->pdev
, DMA_64BIT_MASK
) &&
862 !pci_set_consistent_dma_mask(dev
->pdev
, DMA_64BIT_MASK
)) {
863 printk(KERN_INFO
"%s%d: 64 Bit DAC enabled\n",
865 } else if (!pci_set_dma_mask(dev
->pdev
, DMA_32BIT_MASK
) &&
866 !pci_set_consistent_dma_mask(dev
->pdev
, DMA_32BIT_MASK
)) {
867 printk(KERN_INFO
"%s%d: DMA mask set failed, 64 Bit DAC disabled\n",
869 dev
->dac_support
= 0;
871 printk(KERN_WARNING
"%s%d: No suitable DMA available.\n",
877 * 57 scatter gather elements
879 if (!(dev
->raw_io_interface
)) {
880 dev
->scsi_host_ptr
->sg_tablesize
= (dev
->max_fib_size
-
881 sizeof(struct aac_fibhdr
) -
882 sizeof(struct aac_write
) + sizeof(struct sgentry
)) /
883 sizeof(struct sgentry
);
884 if (dev
->dac_support
) {
886 * 38 scatter gather elements
888 dev
->scsi_host_ptr
->sg_tablesize
=
890 sizeof(struct aac_fibhdr
) -
891 sizeof(struct aac_write64
) +
892 sizeof(struct sgentry64
)) /
893 sizeof(struct sgentry64
);
895 dev
->scsi_host_ptr
->max_sectors
= AAC_MAX_32BIT_SGBCOUNT
;
896 if(!(dev
->adapter_info
.options
& AAC_OPT_NEW_COMM
)) {
898 * Worst case size that could cause sg overflow when
899 * we break up SG elements that are larger than 64KB.
900 * Would be nice if we could tell the SCSI layer what
901 * the maximum SG element size can be. Worst case is
902 * (sg_tablesize-1) 4KB elements with one 64KB
904 * 32bit -> 468 or 238KB 64bit -> 424 or 212KB
906 dev
->scsi_host_ptr
->max_sectors
=
907 (dev
->scsi_host_ptr
->sg_tablesize
* 8) + 112;
911 aac_fib_complete(fibptr
);
912 aac_fib_free(fibptr
);
918 static void io_callback(void *context
, struct fib
* fibptr
)
921 struct aac_read_reply
*readreply
;
922 struct scsi_cmnd
*scsicmd
;
925 scsicmd
= (struct scsi_cmnd
*) context
;
926 scsicmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
928 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
929 cid
= scmd_id(scsicmd
);
931 if (nblank(dprintk(x
))) {
933 switch (scsicmd
->cmnd
[0]) {
936 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) |
937 (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
941 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
942 ((u64
)scsicmd
->cmnd
[3] << 48) |
943 ((u64
)scsicmd
->cmnd
[4] << 40) |
944 ((u64
)scsicmd
->cmnd
[5] << 32) |
945 ((u64
)scsicmd
->cmnd
[6] << 24) |
946 (scsicmd
->cmnd
[7] << 16) |
947 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
951 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
952 (scsicmd
->cmnd
[3] << 16) |
953 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
956 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
957 (scsicmd
->cmnd
[3] << 16) |
958 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
962 "io_callback[cpu %d]: lba = %llu, t = %ld.\n",
963 smp_processor_id(), (unsigned long long)lba
, jiffies
);
966 BUG_ON(fibptr
== NULL
);
969 pci_unmap_sg(dev
->pdev
,
970 (struct scatterlist
*)scsicmd
->request_buffer
,
972 scsicmd
->sc_data_direction
);
973 else if(scsicmd
->request_bufflen
)
974 pci_unmap_single(dev
->pdev
, scsicmd
->SCp
.dma_handle
,
975 scsicmd
->request_bufflen
,
976 scsicmd
->sc_data_direction
);
977 readreply
= (struct aac_read_reply
*)fib_data(fibptr
);
978 if (le32_to_cpu(readreply
->status
) == ST_OK
)
979 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
981 #ifdef AAC_DETAILED_STATUS_INFO
982 printk(KERN_WARNING
"io_callback: io failed, status = %d\n",
983 le32_to_cpu(readreply
->status
));
985 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
986 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
988 SENCODE_INTERNAL_TARGET_FAILURE
,
989 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
991 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
992 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
993 ? sizeof(scsicmd
->sense_buffer
)
994 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
996 aac_fib_complete(fibptr
);
997 aac_fib_free(fibptr
);
999 scsicmd
->scsi_done(scsicmd
);
1002 static int aac_read(struct scsi_cmnd
* scsicmd
, int cid
)
1009 struct aac_dev
*dev
;
1010 struct fib
* cmd_fibcontext
;
1012 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1014 * Get block address and transfer length
1016 switch (scsicmd
->cmnd
[0]) {
1018 dprintk((KERN_DEBUG
"aachba: received a read(6) command on id %d.\n", cid
));
1020 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) |
1021 (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1022 count
= scsicmd
->cmnd
[4];
1028 dprintk((KERN_DEBUG
"aachba: received a read(16) command on id %d.\n", cid
));
1030 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1031 ((u64
)scsicmd
->cmnd
[3] << 48) |
1032 ((u64
)scsicmd
->cmnd
[4] << 40) |
1033 ((u64
)scsicmd
->cmnd
[5] << 32) |
1034 ((u64
)scsicmd
->cmnd
[6] << 24) |
1035 (scsicmd
->cmnd
[7] << 16) |
1036 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1037 count
= (scsicmd
->cmnd
[10] << 24) |
1038 (scsicmd
->cmnd
[11] << 16) |
1039 (scsicmd
->cmnd
[12] << 8) | scsicmd
->cmnd
[13];
1042 dprintk((KERN_DEBUG
"aachba: received a read(12) command on id %d.\n", cid
));
1044 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1045 (scsicmd
->cmnd
[3] << 16) |
1046 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1047 count
= (scsicmd
->cmnd
[6] << 24) |
1048 (scsicmd
->cmnd
[7] << 16) |
1049 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1052 dprintk((KERN_DEBUG
"aachba: received a read(10) command on id %d.\n", cid
));
1054 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1055 (scsicmd
->cmnd
[3] << 16) |
1056 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1057 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
1060 dprintk((KERN_DEBUG
"aac_read[cpu %d]: lba = %llu, t = %ld.\n",
1061 smp_processor_id(), (unsigned long long)lba
, jiffies
));
1062 if ((!(dev
->raw_io_interface
) || !(dev
->raw_io_64
)) &&
1063 (lba
& 0xffffffff00000000LL
)) {
1064 dprintk((KERN_DEBUG
"aac_read: Illegal lba\n"));
1065 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
1066 SAM_STAT_CHECK_CONDITION
;
1067 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1069 SENCODE_INTERNAL_TARGET_FAILURE
,
1070 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
1072 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1073 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1074 ? sizeof(scsicmd
->sense_buffer
)
1075 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1076 scsicmd
->scsi_done(scsicmd
);
1080 * Alocate and initialize a Fib
1082 if (!(cmd_fibcontext
= aac_fib_alloc(dev
))) {
1086 aac_fib_init(cmd_fibcontext
);
1088 if (dev
->raw_io_interface
) {
1089 struct aac_raw_io
*readcmd
;
1090 readcmd
= (struct aac_raw_io
*) fib_data(cmd_fibcontext
);
1091 readcmd
->block
[0] = cpu_to_le32((u32
)(lba
&0xffffffff));
1092 readcmd
->block
[1] = cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
1093 readcmd
->count
= cpu_to_le32(count
<<9);
1094 readcmd
->cid
= cpu_to_le16(cid
);
1095 readcmd
->flags
= cpu_to_le16(1);
1096 readcmd
->bpTotal
= 0;
1097 readcmd
->bpComplete
= 0;
1099 aac_build_sgraw(scsicmd
, &readcmd
->sg
);
1100 fibsize
= sizeof(struct aac_raw_io
) + ((le32_to_cpu(readcmd
->sg
.count
) - 1) * sizeof (struct sgentryraw
));
1101 BUG_ON(fibsize
> (dev
->max_fib_size
- sizeof(struct aac_fibhdr
)));
1103 * Now send the Fib to the adapter
1105 status
= aac_fib_send(ContainerRawIo
,
1110 (fib_callback
) io_callback
,
1112 } else if (dev
->dac_support
== 1) {
1113 struct aac_read64
*readcmd
;
1114 readcmd
= (struct aac_read64
*) fib_data(cmd_fibcontext
);
1115 readcmd
->command
= cpu_to_le32(VM_CtHostRead64
);
1116 readcmd
->cid
= cpu_to_le16(cid
);
1117 readcmd
->sector_count
= cpu_to_le16(count
);
1118 readcmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
1122 aac_build_sg64(scsicmd
, &readcmd
->sg
);
1123 fibsize
= sizeof(struct aac_read64
) +
1124 ((le32_to_cpu(readcmd
->sg
.count
) - 1) *
1125 sizeof (struct sgentry64
));
1126 BUG_ON (fibsize
> (dev
->max_fib_size
-
1127 sizeof(struct aac_fibhdr
)));
1129 * Now send the Fib to the adapter
1131 status
= aac_fib_send(ContainerCommand64
,
1136 (fib_callback
) io_callback
,
1139 struct aac_read
*readcmd
;
1140 readcmd
= (struct aac_read
*) fib_data(cmd_fibcontext
);
1141 readcmd
->command
= cpu_to_le32(VM_CtBlockRead
);
1142 readcmd
->cid
= cpu_to_le32(cid
);
1143 readcmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
1144 readcmd
->count
= cpu_to_le32(count
* 512);
1146 aac_build_sg(scsicmd
, &readcmd
->sg
);
1147 fibsize
= sizeof(struct aac_read
) +
1148 ((le32_to_cpu(readcmd
->sg
.count
) - 1) *
1149 sizeof (struct sgentry
));
1150 BUG_ON (fibsize
> (dev
->max_fib_size
-
1151 sizeof(struct aac_fibhdr
)));
1153 * Now send the Fib to the adapter
1155 status
= aac_fib_send(ContainerCommand
,
1160 (fib_callback
) io_callback
,
1167 * Check that the command queued to the controller
1169 if (status
== -EINPROGRESS
) {
1170 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1174 printk(KERN_WARNING
"aac_read: aac_fib_send failed with status: %d.\n", status
);
1176 * For some reason, the Fib didn't queue, return QUEUE_FULL
1178 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_TASK_SET_FULL
;
1179 scsicmd
->scsi_done(scsicmd
);
1180 aac_fib_complete(cmd_fibcontext
);
1181 aac_fib_free(cmd_fibcontext
);
1185 static int aac_write(struct scsi_cmnd
* scsicmd
, int cid
)
1191 struct aac_dev
*dev
;
1192 struct fib
* cmd_fibcontext
;
1194 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1196 * Get block address and transfer length
1198 if (scsicmd
->cmnd
[0] == WRITE_6
) /* 6 byte command */
1200 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) | (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1201 count
= scsicmd
->cmnd
[4];
1204 } else if (scsicmd
->cmnd
[0] == WRITE_16
) { /* 16 byte command */
1205 dprintk((KERN_DEBUG
"aachba: received a write(16) command on id %d.\n", cid
));
1207 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1208 ((u64
)scsicmd
->cmnd
[3] << 48) |
1209 ((u64
)scsicmd
->cmnd
[4] << 40) |
1210 ((u64
)scsicmd
->cmnd
[5] << 32) |
1211 ((u64
)scsicmd
->cmnd
[6] << 24) |
1212 (scsicmd
->cmnd
[7] << 16) |
1213 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1214 count
= (scsicmd
->cmnd
[10] << 24) | (scsicmd
->cmnd
[11] << 16) |
1215 (scsicmd
->cmnd
[12] << 8) | scsicmd
->cmnd
[13];
1216 } else if (scsicmd
->cmnd
[0] == WRITE_12
) { /* 12 byte command */
1217 dprintk((KERN_DEBUG
"aachba: received a write(12) command on id %d.\n", cid
));
1219 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16)
1220 | (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1221 count
= (scsicmd
->cmnd
[6] << 24) | (scsicmd
->cmnd
[7] << 16)
1222 | (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1224 dprintk((KERN_DEBUG
"aachba: received a write(10) command on id %d.\n", cid
));
1225 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16) | (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1226 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
1228 dprintk((KERN_DEBUG
"aac_write[cpu %d]: lba = %llu, t = %ld.\n",
1229 smp_processor_id(), (unsigned long long)lba
, jiffies
));
1230 if ((!(dev
->raw_io_interface
) || !(dev
->raw_io_64
))
1231 && (lba
& 0xffffffff00000000LL
)) {
1232 dprintk((KERN_DEBUG
"aac_write: Illegal lba\n"));
1233 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1234 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1236 SENCODE_INTERNAL_TARGET_FAILURE
,
1237 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
1239 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1240 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1241 ? sizeof(scsicmd
->sense_buffer
)
1242 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1243 scsicmd
->scsi_done(scsicmd
);
1247 * Allocate and initialize a Fib then setup a BlockWrite command
1249 if (!(cmd_fibcontext
= aac_fib_alloc(dev
))) {
1250 scsicmd
->result
= DID_ERROR
<< 16;
1251 scsicmd
->scsi_done(scsicmd
);
1254 aac_fib_init(cmd_fibcontext
);
1256 if (dev
->raw_io_interface
) {
1257 struct aac_raw_io
*writecmd
;
1258 writecmd
= (struct aac_raw_io
*) fib_data(cmd_fibcontext
);
1259 writecmd
->block
[0] = cpu_to_le32((u32
)(lba
&0xffffffff));
1260 writecmd
->block
[1] = cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
1261 writecmd
->count
= cpu_to_le32(count
<<9);
1262 writecmd
->cid
= cpu_to_le16(cid
);
1263 writecmd
->flags
= 0;
1264 writecmd
->bpTotal
= 0;
1265 writecmd
->bpComplete
= 0;
1267 aac_build_sgraw(scsicmd
, &writecmd
->sg
);
1268 fibsize
= sizeof(struct aac_raw_io
) + ((le32_to_cpu(writecmd
->sg
.count
) - 1) * sizeof (struct sgentryraw
));
1269 BUG_ON(fibsize
> (dev
->max_fib_size
- sizeof(struct aac_fibhdr
)));
1271 * Now send the Fib to the adapter
1273 status
= aac_fib_send(ContainerRawIo
,
1278 (fib_callback
) io_callback
,
1280 } else if (dev
->dac_support
== 1) {
1281 struct aac_write64
*writecmd
;
1282 writecmd
= (struct aac_write64
*) fib_data(cmd_fibcontext
);
1283 writecmd
->command
= cpu_to_le32(VM_CtHostWrite64
);
1284 writecmd
->cid
= cpu_to_le16(cid
);
1285 writecmd
->sector_count
= cpu_to_le16(count
);
1286 writecmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
1288 writecmd
->flags
= 0;
1290 aac_build_sg64(scsicmd
, &writecmd
->sg
);
1291 fibsize
= sizeof(struct aac_write64
) +
1292 ((le32_to_cpu(writecmd
->sg
.count
) - 1) *
1293 sizeof (struct sgentry64
));
1294 BUG_ON (fibsize
> (dev
->max_fib_size
-
1295 sizeof(struct aac_fibhdr
)));
1297 * Now send the Fib to the adapter
1299 status
= aac_fib_send(ContainerCommand64
,
1304 (fib_callback
) io_callback
,
1307 struct aac_write
*writecmd
;
1308 writecmd
= (struct aac_write
*) fib_data(cmd_fibcontext
);
1309 writecmd
->command
= cpu_to_le32(VM_CtBlockWrite
);
1310 writecmd
->cid
= cpu_to_le32(cid
);
1311 writecmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
1312 writecmd
->count
= cpu_to_le32(count
* 512);
1313 writecmd
->sg
.count
= cpu_to_le32(1);
1314 /* ->stable is not used - it did mean which type of write */
1316 aac_build_sg(scsicmd
, &writecmd
->sg
);
1317 fibsize
= sizeof(struct aac_write
) +
1318 ((le32_to_cpu(writecmd
->sg
.count
) - 1) *
1319 sizeof (struct sgentry
));
1320 BUG_ON (fibsize
> (dev
->max_fib_size
-
1321 sizeof(struct aac_fibhdr
)));
1323 * Now send the Fib to the adapter
1325 status
= aac_fib_send(ContainerCommand
,
1330 (fib_callback
) io_callback
,
1335 * Check that the command queued to the controller
1337 if (status
== -EINPROGRESS
) {
1338 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1342 printk(KERN_WARNING
"aac_write: aac_fib_send failed with status: %d\n", status
);
1344 * For some reason, the Fib didn't queue, return QUEUE_FULL
1346 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_TASK_SET_FULL
;
1347 scsicmd
->scsi_done(scsicmd
);
1349 aac_fib_complete(cmd_fibcontext
);
1350 aac_fib_free(cmd_fibcontext
);
1354 static void synchronize_callback(void *context
, struct fib
*fibptr
)
1356 struct aac_synchronize_reply
*synchronizereply
;
1357 struct scsi_cmnd
*cmd
;
1360 cmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
1362 dprintk((KERN_DEBUG
"synchronize_callback[cpu %d]: t = %ld.\n",
1363 smp_processor_id(), jiffies
));
1364 BUG_ON(fibptr
== NULL
);
1367 synchronizereply
= fib_data(fibptr
);
1368 if (le32_to_cpu(synchronizereply
->status
) == CT_OK
)
1369 cmd
->result
= DID_OK
<< 16 |
1370 COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1372 struct scsi_device
*sdev
= cmd
->device
;
1373 struct aac_dev
*dev
= (struct aac_dev
*)sdev
->host
->hostdata
;
1374 u32 cid
= sdev_id(sdev
);
1376 "synchronize_callback: synchronize failed, status = %d\n",
1377 le32_to_cpu(synchronizereply
->status
));
1378 cmd
->result
= DID_OK
<< 16 |
1379 COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1380 set_sense((u8
*)&dev
->fsa_dev
[cid
].sense_data
,
1382 SENCODE_INTERNAL_TARGET_FAILURE
,
1383 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
1385 memcpy(cmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1386 min(sizeof(dev
->fsa_dev
[cid
].sense_data
),
1387 sizeof(cmd
->sense_buffer
)));
1390 aac_fib_complete(fibptr
);
1391 aac_fib_free(fibptr
);
1392 cmd
->scsi_done(cmd
);
1395 static int aac_synchronize(struct scsi_cmnd
*scsicmd
, int cid
)
1398 struct fib
*cmd_fibcontext
;
1399 struct aac_synchronize
*synchronizecmd
;
1400 struct scsi_cmnd
*cmd
;
1401 struct scsi_device
*sdev
= scsicmd
->device
;
1403 struct aac_dev
*aac
;
1404 unsigned long flags
;
1407 * Wait for all outstanding queued commands to complete to this
1408 * specific target (block).
1410 spin_lock_irqsave(&sdev
->list_lock
, flags
);
1411 list_for_each_entry(cmd
, &sdev
->cmd_list
, list
)
1412 if (cmd
!= scsicmd
&& cmd
->SCp
.phase
== AAC_OWNER_FIRMWARE
) {
1417 spin_unlock_irqrestore(&sdev
->list_lock
, flags
);
1420 * Yield the processor (requeue for later)
1423 return SCSI_MLQUEUE_DEVICE_BUSY
;
1425 aac
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1427 return SCSI_MLQUEUE_HOST_BUSY
;
1430 * Allocate and initialize a Fib
1432 if (!(cmd_fibcontext
= aac_fib_alloc(aac
)))
1433 return SCSI_MLQUEUE_HOST_BUSY
;
1435 aac_fib_init(cmd_fibcontext
);
1437 synchronizecmd
= fib_data(cmd_fibcontext
);
1438 synchronizecmd
->command
= cpu_to_le32(VM_ContainerConfig
);
1439 synchronizecmd
->type
= cpu_to_le32(CT_FLUSH_CACHE
);
1440 synchronizecmd
->cid
= cpu_to_le32(cid
);
1441 synchronizecmd
->count
=
1442 cpu_to_le32(sizeof(((struct aac_synchronize_reply
*)NULL
)->data
));
1445 * Now send the Fib to the adapter
1447 status
= aac_fib_send(ContainerCommand
,
1449 sizeof(struct aac_synchronize
),
1452 (fib_callback
)synchronize_callback
,
1456 * Check that the command queued to the controller
1458 if (status
== -EINPROGRESS
) {
1459 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1464 "aac_synchronize: aac_fib_send failed with status: %d.\n", status
);
1465 aac_fib_complete(cmd_fibcontext
);
1466 aac_fib_free(cmd_fibcontext
);
1467 return SCSI_MLQUEUE_HOST_BUSY
;
1471 * aac_scsi_cmd() - Process SCSI command
1472 * @scsicmd: SCSI command block
1474 * Emulate a SCSI command and queue the required request for the
1478 int aac_scsi_cmd(struct scsi_cmnd
* scsicmd
)
1481 struct Scsi_Host
*host
= scsicmd
->device
->host
;
1482 struct aac_dev
*dev
= (struct aac_dev
*)host
->hostdata
;
1483 struct fsa_dev_info
*fsa_dev_ptr
= dev
->fsa_dev
;
1485 if (fsa_dev_ptr
== NULL
)
1488 * If the bus, id or lun is out of range, return fail
1489 * Test does not apply to ID 16, the pseudo id for the controller
1492 if (scmd_id(scsicmd
) != host
->this_id
) {
1493 if ((scmd_channel(scsicmd
) == CONTAINER_CHANNEL
)) {
1494 if((scmd_id(scsicmd
) >= dev
->maximum_num_containers
) ||
1495 (scsicmd
->device
->lun
!= 0)) {
1496 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1497 scsicmd
->scsi_done(scsicmd
);
1500 cid
= scmd_id(scsicmd
);
1503 * If the target container doesn't exist, it may have
1504 * been newly created
1506 if ((fsa_dev_ptr
[cid
].valid
& 1) == 0) {
1507 switch (scsicmd
->cmnd
[0]) {
1508 case SERVICE_ACTION_IN
:
1509 if (!(dev
->raw_io_interface
) ||
1510 !(dev
->raw_io_64
) ||
1511 ((scsicmd
->cmnd
[1] & 0x1f) != SAI_READ_CAPACITY_16
))
1515 case TEST_UNIT_READY
:
1518 spin_unlock_irq(host
->host_lock
);
1519 aac_probe_container(dev
, cid
);
1520 if ((fsa_dev_ptr
[cid
].valid
& 1) == 0)
1521 fsa_dev_ptr
[cid
].valid
= 0;
1522 spin_lock_irq(host
->host_lock
);
1523 if (fsa_dev_ptr
[cid
].valid
== 0) {
1524 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1525 scsicmd
->scsi_done(scsicmd
);
1533 * If the target container still doesn't exist,
1536 if (fsa_dev_ptr
[cid
].valid
== 0) {
1537 scsicmd
->result
= DID_BAD_TARGET
<< 16;
1538 scsicmd
->scsi_done(scsicmd
);
1541 } else { /* check for physical non-dasd devices */
1542 if ((dev
->nondasd_support
== 1) || expose_physicals
) {
1545 return aac_send_srb_fib(scsicmd
);
1547 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1548 scsicmd
->scsi_done(scsicmd
);
1554 * else Command for the controller itself
1556 else if ((scsicmd
->cmnd
[0] != INQUIRY
) && /* only INQUIRY & TUR cmnd supported for controller */
1557 (scsicmd
->cmnd
[0] != TEST_UNIT_READY
))
1559 dprintk((KERN_WARNING
"Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd
->cmnd
[0]));
1560 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1561 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1563 SENCODE_INVALID_COMMAND
,
1564 ASENCODE_INVALID_COMMAND
, 0, 0, 0, 0);
1565 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1566 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1567 ? sizeof(scsicmd
->sense_buffer
)
1568 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1569 scsicmd
->scsi_done(scsicmd
);
1574 /* Handle commands here that don't really require going out to the adapter */
1575 switch (scsicmd
->cmnd
[0]) {
1578 struct inquiry_data inq_data
;
1580 dprintk((KERN_DEBUG
"INQUIRY command, ID: %d.\n", scmd_id(scsicmd
)));
1581 memset(&inq_data
, 0, sizeof (struct inquiry_data
));
1583 inq_data
.inqd_ver
= 2; /* claim compliance to SCSI-2 */
1584 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 */
1585 inq_data
.inqd_len
= 31;
1586 /*Format for "pad2" is RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
1587 inq_data
.inqd_pad2
= 0x32 ; /*WBus16|Sync|CmdQue */
1589 * Set the Vendor, Product, and Revision Level
1590 * see: <vendor>.c i.e. aac.c
1592 if (scmd_id(scsicmd
) == host
->this_id
) {
1593 setinqstr(dev
, (void *) (inq_data
.inqd_vid
), ARRAY_SIZE(container_types
));
1594 inq_data
.inqd_pdt
= INQD_PDT_PROC
; /* Processor device */
1595 aac_internal_transfer(scsicmd
, &inq_data
, 0, sizeof(inq_data
));
1596 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1597 scsicmd
->scsi_done(scsicmd
);
1602 setinqstr(dev
, (void *) (inq_data
.inqd_vid
), fsa_dev_ptr
[cid
].type
);
1603 inq_data
.inqd_pdt
= INQD_PDT_DA
; /* Direct/random access device */
1604 aac_internal_transfer(scsicmd
, &inq_data
, 0, sizeof(inq_data
));
1605 return aac_get_container_name(scsicmd
, cid
);
1607 case SERVICE_ACTION_IN
:
1608 if (!(dev
->raw_io_interface
) ||
1609 !(dev
->raw_io_64
) ||
1610 ((scsicmd
->cmnd
[1] & 0x1f) != SAI_READ_CAPACITY_16
))
1616 dprintk((KERN_DEBUG
"READ CAPACITY_16 command.\n"));
1617 capacity
= fsa_dev_ptr
[cid
].size
- 1;
1618 cp
[0] = (capacity
>> 56) & 0xff;
1619 cp
[1] = (capacity
>> 48) & 0xff;
1620 cp
[2] = (capacity
>> 40) & 0xff;
1621 cp
[3] = (capacity
>> 32) & 0xff;
1622 cp
[4] = (capacity
>> 24) & 0xff;
1623 cp
[5] = (capacity
>> 16) & 0xff;
1624 cp
[6] = (capacity
>> 8) & 0xff;
1625 cp
[7] = (capacity
>> 0) & 0xff;
1631 aac_internal_transfer(scsicmd
, cp
, 0,
1632 min_t(size_t, scsicmd
->cmnd
[13], sizeof(cp
)));
1633 if (sizeof(cp
) < scsicmd
->cmnd
[13]) {
1634 unsigned int len
, offset
= sizeof(cp
);
1636 memset(cp
, 0, offset
);
1638 len
= min_t(size_t, scsicmd
->cmnd
[13] - offset
,
1640 aac_internal_transfer(scsicmd
, cp
, offset
, len
);
1641 } while ((offset
+= len
) < scsicmd
->cmnd
[13]);
1644 /* Do not cache partition table for arrays */
1645 scsicmd
->device
->removable
= 1;
1647 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1648 scsicmd
->scsi_done(scsicmd
);
1658 dprintk((KERN_DEBUG
"READ CAPACITY command.\n"));
1659 if (fsa_dev_ptr
[cid
].size
<= 0x100000000ULL
)
1660 capacity
= fsa_dev_ptr
[cid
].size
- 1;
1664 cp
[0] = (capacity
>> 24) & 0xff;
1665 cp
[1] = (capacity
>> 16) & 0xff;
1666 cp
[2] = (capacity
>> 8) & 0xff;
1667 cp
[3] = (capacity
>> 0) & 0xff;
1672 aac_internal_transfer(scsicmd
, cp
, 0, sizeof(cp
));
1673 /* Do not cache partition table for arrays */
1674 scsicmd
->device
->removable
= 1;
1676 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1677 scsicmd
->scsi_done(scsicmd
);
1686 dprintk((KERN_DEBUG
"MODE SENSE command.\n"));
1687 mode_buf
[0] = 3; /* Mode data length */
1688 mode_buf
[1] = 0; /* Medium type - default */
1689 mode_buf
[2] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */
1690 mode_buf
[3] = 0; /* Block descriptor length */
1692 aac_internal_transfer(scsicmd
, mode_buf
, 0, sizeof(mode_buf
));
1693 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1694 scsicmd
->scsi_done(scsicmd
);
1702 dprintk((KERN_DEBUG
"MODE SENSE 10 byte command.\n"));
1703 mode_buf
[0] = 0; /* Mode data length (MSB) */
1704 mode_buf
[1] = 6; /* Mode data length (LSB) */
1705 mode_buf
[2] = 0; /* Medium type - default */
1706 mode_buf
[3] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */
1707 mode_buf
[4] = 0; /* reserved */
1708 mode_buf
[5] = 0; /* reserved */
1709 mode_buf
[6] = 0; /* Block descriptor length (MSB) */
1710 mode_buf
[7] = 0; /* Block descriptor length (LSB) */
1711 aac_internal_transfer(scsicmd
, mode_buf
, 0, sizeof(mode_buf
));
1713 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1714 scsicmd
->scsi_done(scsicmd
);
1719 dprintk((KERN_DEBUG
"REQUEST SENSE command.\n"));
1720 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
, sizeof (struct sense_data
));
1721 memset(&dev
->fsa_dev
[cid
].sense_data
, 0, sizeof (struct sense_data
));
1722 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1723 scsicmd
->scsi_done(scsicmd
);
1726 case ALLOW_MEDIUM_REMOVAL
:
1727 dprintk((KERN_DEBUG
"LOCK command.\n"));
1728 if (scsicmd
->cmnd
[4])
1729 fsa_dev_ptr
[cid
].locked
= 1;
1731 fsa_dev_ptr
[cid
].locked
= 0;
1733 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1734 scsicmd
->scsi_done(scsicmd
);
1737 * These commands are all No-Ops
1739 case TEST_UNIT_READY
:
1743 case REASSIGN_BLOCKS
:
1746 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1747 scsicmd
->scsi_done(scsicmd
);
1751 switch (scsicmd
->cmnd
[0])
1760 * Hack to keep track of ordinal number of the device that
1761 * corresponds to a container. Needed to convert
1762 * containers to /dev/sd device names
1765 if (scsicmd
->request
->rq_disk
)
1766 strlcpy(fsa_dev_ptr
[cid
].devname
,
1767 scsicmd
->request
->rq_disk
->disk_name
,
1768 min(sizeof(fsa_dev_ptr
[cid
].devname
),
1769 sizeof(scsicmd
->request
->rq_disk
->disk_name
) + 1));
1771 return aac_read(scsicmd
, cid
);
1779 return aac_write(scsicmd
, cid
);
1781 case SYNCHRONIZE_CACHE
:
1782 /* Issue FIB to tell Firmware to flush it's cache */
1783 return aac_synchronize(scsicmd
, cid
);
1787 * Unhandled commands
1789 dprintk((KERN_WARNING
"Unhandled SCSI Command: 0x%x.\n", scsicmd
->cmnd
[0]));
1790 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1791 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1792 ILLEGAL_REQUEST
, SENCODE_INVALID_COMMAND
,
1793 ASENCODE_INVALID_COMMAND
, 0, 0, 0, 0);
1794 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1795 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1796 ? sizeof(scsicmd
->sense_buffer
)
1797 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1798 scsicmd
->scsi_done(scsicmd
);
1803 static int query_disk(struct aac_dev
*dev
, void __user
*arg
)
1805 struct aac_query_disk qd
;
1806 struct fsa_dev_info
*fsa_dev_ptr
;
1808 fsa_dev_ptr
= dev
->fsa_dev
;
1811 if (copy_from_user(&qd
, arg
, sizeof (struct aac_query_disk
)))
1815 else if ((qd
.bus
== -1) && (qd
.id
== -1) && (qd
.lun
== -1))
1817 if (qd
.cnum
< 0 || qd
.cnum
>= dev
->maximum_num_containers
)
1819 qd
.instance
= dev
->scsi_host_ptr
->host_no
;
1821 qd
.id
= CONTAINER_TO_ID(qd
.cnum
);
1822 qd
.lun
= CONTAINER_TO_LUN(qd
.cnum
);
1824 else return -EINVAL
;
1826 qd
.valid
= fsa_dev_ptr
[qd
.cnum
].valid
;
1827 qd
.locked
= fsa_dev_ptr
[qd
.cnum
].locked
;
1828 qd
.deleted
= fsa_dev_ptr
[qd
.cnum
].deleted
;
1830 if (fsa_dev_ptr
[qd
.cnum
].devname
[0] == '\0')
1835 strlcpy(qd
.name
, fsa_dev_ptr
[qd
.cnum
].devname
,
1836 min(sizeof(qd
.name
), sizeof(fsa_dev_ptr
[qd
.cnum
].devname
) + 1));
1838 if (copy_to_user(arg
, &qd
, sizeof (struct aac_query_disk
)))
1843 static int force_delete_disk(struct aac_dev
*dev
, void __user
*arg
)
1845 struct aac_delete_disk dd
;
1846 struct fsa_dev_info
*fsa_dev_ptr
;
1848 fsa_dev_ptr
= dev
->fsa_dev
;
1852 if (copy_from_user(&dd
, arg
, sizeof (struct aac_delete_disk
)))
1855 if (dd
.cnum
>= dev
->maximum_num_containers
)
1858 * Mark this container as being deleted.
1860 fsa_dev_ptr
[dd
.cnum
].deleted
= 1;
1862 * Mark the container as no longer valid
1864 fsa_dev_ptr
[dd
.cnum
].valid
= 0;
1868 static int delete_disk(struct aac_dev
*dev
, void __user
*arg
)
1870 struct aac_delete_disk dd
;
1871 struct fsa_dev_info
*fsa_dev_ptr
;
1873 fsa_dev_ptr
= dev
->fsa_dev
;
1877 if (copy_from_user(&dd
, arg
, sizeof (struct aac_delete_disk
)))
1880 if (dd
.cnum
>= dev
->maximum_num_containers
)
1883 * If the container is locked, it can not be deleted by the API.
1885 if (fsa_dev_ptr
[dd
.cnum
].locked
)
1889 * Mark the container as no longer being valid.
1891 fsa_dev_ptr
[dd
.cnum
].valid
= 0;
1892 fsa_dev_ptr
[dd
.cnum
].devname
[0] = '\0';
1897 int aac_dev_ioctl(struct aac_dev
*dev
, int cmd
, void __user
*arg
)
1900 case FSACTL_QUERY_DISK
:
1901 return query_disk(dev
, arg
);
1902 case FSACTL_DELETE_DISK
:
1903 return delete_disk(dev
, arg
);
1904 case FSACTL_FORCE_DELETE_DISK
:
1905 return force_delete_disk(dev
, arg
);
1906 case FSACTL_GET_CONTAINERS
:
1907 return aac_get_containers(dev
);
1916 * @context: the context set in the fib - here it is scsi cmd
1917 * @fibptr: pointer to the fib
1919 * Handles the completion of a scsi command to a non dasd device
1923 static void aac_srb_callback(void *context
, struct fib
* fibptr
)
1925 struct aac_dev
*dev
;
1926 struct aac_srb_reply
*srbreply
;
1927 struct scsi_cmnd
*scsicmd
;
1929 scsicmd
= (struct scsi_cmnd
*) context
;
1930 scsicmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
1931 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1933 BUG_ON(fibptr
== NULL
);
1935 srbreply
= (struct aac_srb_reply
*) fib_data(fibptr
);
1937 scsicmd
->sense_buffer
[0] = '\0'; /* Initialize sense valid flag to false */
1939 * Calculate resid for sg
1942 scsicmd
->resid
= scsicmd
->request_bufflen
-
1943 le32_to_cpu(srbreply
->data_xfer_length
);
1946 pci_unmap_sg(dev
->pdev
,
1947 (struct scatterlist
*)scsicmd
->request_buffer
,
1949 scsicmd
->sc_data_direction
);
1950 else if(scsicmd
->request_bufflen
)
1951 pci_unmap_single(dev
->pdev
, scsicmd
->SCp
.dma_handle
, scsicmd
->request_bufflen
,
1952 scsicmd
->sc_data_direction
);
1955 * First check the fib status
1958 if (le32_to_cpu(srbreply
->status
) != ST_OK
){
1960 printk(KERN_WARNING
"aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply
->status
));
1961 len
= (le32_to_cpu(srbreply
->sense_data_size
) >
1962 sizeof(scsicmd
->sense_buffer
)) ?
1963 sizeof(scsicmd
->sense_buffer
) :
1964 le32_to_cpu(srbreply
->sense_data_size
);
1965 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1966 memcpy(scsicmd
->sense_buffer
, srbreply
->sense_data
, len
);
1970 * Next check the srb status
1972 switch( (le32_to_cpu(srbreply
->srb_status
))&0x3f){
1973 case SRB_STATUS_ERROR_RECOVERY
:
1974 case SRB_STATUS_PENDING
:
1975 case SRB_STATUS_SUCCESS
:
1976 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
1978 case SRB_STATUS_DATA_OVERRUN
:
1979 switch(scsicmd
->cmnd
[0]){
1988 if(le32_to_cpu(srbreply
->data_xfer_length
) < scsicmd
->underflow
) {
1989 printk(KERN_WARNING
"aacraid: SCSI CMD underflow\n");
1991 printk(KERN_WARNING
"aacraid: SCSI CMD Data Overrun\n");
1993 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8;
1996 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
2000 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
2004 case SRB_STATUS_ABORTED
:
2005 scsicmd
->result
= DID_ABORT
<< 16 | ABORT
<< 8;
2007 case SRB_STATUS_ABORT_FAILED
:
2008 // Not sure about this one - but assuming the hba was trying to abort for some reason
2009 scsicmd
->result
= DID_ERROR
<< 16 | ABORT
<< 8;
2011 case SRB_STATUS_PARITY_ERROR
:
2012 scsicmd
->result
= DID_PARITY
<< 16 | MSG_PARITY_ERROR
<< 8;
2014 case SRB_STATUS_NO_DEVICE
:
2015 case SRB_STATUS_INVALID_PATH_ID
:
2016 case SRB_STATUS_INVALID_TARGET_ID
:
2017 case SRB_STATUS_INVALID_LUN
:
2018 case SRB_STATUS_SELECTION_TIMEOUT
:
2019 scsicmd
->result
= DID_NO_CONNECT
<< 16 | COMMAND_COMPLETE
<< 8;
2022 case SRB_STATUS_COMMAND_TIMEOUT
:
2023 case SRB_STATUS_TIMEOUT
:
2024 scsicmd
->result
= DID_TIME_OUT
<< 16 | COMMAND_COMPLETE
<< 8;
2027 case SRB_STATUS_BUSY
:
2028 scsicmd
->result
= DID_NO_CONNECT
<< 16 | COMMAND_COMPLETE
<< 8;
2031 case SRB_STATUS_BUS_RESET
:
2032 scsicmd
->result
= DID_RESET
<< 16 | COMMAND_COMPLETE
<< 8;
2035 case SRB_STATUS_MESSAGE_REJECTED
:
2036 scsicmd
->result
= DID_ERROR
<< 16 | MESSAGE_REJECT
<< 8;
2038 case SRB_STATUS_REQUEST_FLUSHED
:
2039 case SRB_STATUS_ERROR
:
2040 case SRB_STATUS_INVALID_REQUEST
:
2041 case SRB_STATUS_REQUEST_SENSE_FAILED
:
2042 case SRB_STATUS_NO_HBA
:
2043 case SRB_STATUS_UNEXPECTED_BUS_FREE
:
2044 case SRB_STATUS_PHASE_SEQUENCE_FAILURE
:
2045 case SRB_STATUS_BAD_SRB_BLOCK_LENGTH
:
2046 case SRB_STATUS_DELAYED_RETRY
:
2047 case SRB_STATUS_BAD_FUNCTION
:
2048 case SRB_STATUS_NOT_STARTED
:
2049 case SRB_STATUS_NOT_IN_USE
:
2050 case SRB_STATUS_FORCE_ABORT
:
2051 case SRB_STATUS_DOMAIN_VALIDATION_FAIL
:
2053 #ifdef AAC_DETAILED_STATUS_INFO
2054 printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",
2055 le32_to_cpu(srbreply
->srb_status
) & 0x3F,
2056 aac_get_status_string(
2057 le32_to_cpu(srbreply
->srb_status
) & 0x3F),
2059 le32_to_cpu(srbreply
->scsi_status
));
2061 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8;
2064 if (le32_to_cpu(srbreply
->scsi_status
) == 0x02 ){ // Check Condition
2066 scsicmd
->result
|= SAM_STAT_CHECK_CONDITION
;
2067 len
= (le32_to_cpu(srbreply
->sense_data_size
) >
2068 sizeof(scsicmd
->sense_buffer
)) ?
2069 sizeof(scsicmd
->sense_buffer
) :
2070 le32_to_cpu(srbreply
->sense_data_size
);
2071 #ifdef AAC_DETAILED_STATUS_INFO
2072 printk(KERN_WARNING
"aac_srb_callback: check condition, status = %d len=%d\n",
2073 le32_to_cpu(srbreply
->status
), len
);
2075 memcpy(scsicmd
->sense_buffer
, srbreply
->sense_data
, len
);
2079 * OR in the scsi status (already shifted up a bit)
2081 scsicmd
->result
|= le32_to_cpu(srbreply
->scsi_status
);
2083 aac_fib_complete(fibptr
);
2084 aac_fib_free(fibptr
);
2085 scsicmd
->scsi_done(scsicmd
);
2091 * @scsicmd: the scsi command block
2093 * This routine will form a FIB and fill in the aac_srb from the
2094 * scsicmd passed in.
2097 static int aac_send_srb_fib(struct scsi_cmnd
* scsicmd
)
2099 struct fib
* cmd_fibcontext
;
2100 struct aac_dev
* dev
;
2102 struct aac_srb
*srbcmd
;
2107 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2108 if (scmd_id(scsicmd
) >= dev
->maximum_num_physicals
||
2109 scsicmd
->device
->lun
> 7) {
2110 scsicmd
->result
= DID_NO_CONNECT
<< 16;
2111 scsicmd
->scsi_done(scsicmd
);
2115 switch(scsicmd
->sc_data_direction
){
2119 case DMA_BIDIRECTIONAL
:
2120 flag
= SRB_DataIn
| SRB_DataOut
;
2122 case DMA_FROM_DEVICE
:
2126 default: /* shuts up some versions of gcc */
2127 flag
= SRB_NoDataXfer
;
2133 * Allocate and initialize a Fib then setup a BlockWrite command
2135 if (!(cmd_fibcontext
= aac_fib_alloc(dev
))) {
2138 aac_fib_init(cmd_fibcontext
);
2140 srbcmd
= (struct aac_srb
*) fib_data(cmd_fibcontext
);
2141 srbcmd
->function
= cpu_to_le32(SRBF_ExecuteScsi
);
2142 srbcmd
->channel
= cpu_to_le32(aac_logical_to_phys(scmd_channel(scsicmd
)));
2143 srbcmd
->id
= cpu_to_le32(scmd_id(scsicmd
));
2144 srbcmd
->lun
= cpu_to_le32(scsicmd
->device
->lun
);
2145 srbcmd
->flags
= cpu_to_le32(flag
);
2146 timeout
= scsicmd
->timeout_per_command
/HZ
;
2150 srbcmd
->timeout
= cpu_to_le32(timeout
); // timeout in seconds
2151 srbcmd
->retry_limit
= 0; /* Obsolete parameter */
2152 srbcmd
->cdb_size
= cpu_to_le32(scsicmd
->cmd_len
);
2154 if( dev
->dac_support
== 1 ) {
2155 aac_build_sg64(scsicmd
, (struct sgmap64
*) &srbcmd
->sg
);
2156 srbcmd
->count
= cpu_to_le32(scsicmd
->request_bufflen
);
2158 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
2159 memcpy(srbcmd
->cdb
, scsicmd
->cmnd
, scsicmd
->cmd_len
);
2161 * Build Scatter/Gather list
2163 fibsize
= sizeof (struct aac_srb
) - sizeof (struct sgentry
) +
2164 ((le32_to_cpu(srbcmd
->sg
.count
) & 0xff) *
2165 sizeof (struct sgentry64
));
2166 BUG_ON (fibsize
> (dev
->max_fib_size
-
2167 sizeof(struct aac_fibhdr
)));
2170 * Now send the Fib to the adapter
2172 status
= aac_fib_send(ScsiPortCommand64
, cmd_fibcontext
,
2173 fibsize
, FsaNormal
, 0, 1,
2174 (fib_callback
) aac_srb_callback
,
2177 aac_build_sg(scsicmd
, (struct sgmap
*)&srbcmd
->sg
);
2178 srbcmd
->count
= cpu_to_le32(scsicmd
->request_bufflen
);
2180 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
2181 memcpy(srbcmd
->cdb
, scsicmd
->cmnd
, scsicmd
->cmd_len
);
2183 * Build Scatter/Gather list
2185 fibsize
= sizeof (struct aac_srb
) +
2186 (((le32_to_cpu(srbcmd
->sg
.count
) & 0xff) - 1) *
2187 sizeof (struct sgentry
));
2188 BUG_ON (fibsize
> (dev
->max_fib_size
-
2189 sizeof(struct aac_fibhdr
)));
2192 * Now send the Fib to the adapter
2194 status
= aac_fib_send(ScsiPortCommand
, cmd_fibcontext
, fibsize
, FsaNormal
, 0, 1,
2195 (fib_callback
) aac_srb_callback
, (void *) scsicmd
);
2198 * Check that the command queued to the controller
2200 if (status
== -EINPROGRESS
) {
2201 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
2205 printk(KERN_WARNING
"aac_srb: aac_fib_send failed with status: %d\n", status
);
2206 aac_fib_complete(cmd_fibcontext
);
2207 aac_fib_free(cmd_fibcontext
);
2212 static unsigned long aac_build_sg(struct scsi_cmnd
* scsicmd
, struct sgmap
* psg
)
2214 struct aac_dev
*dev
;
2215 unsigned long byte_count
= 0;
2217 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2218 // Get rid of old data
2220 psg
->sg
[0].addr
= 0;
2221 psg
->sg
[0].count
= 0;
2222 if (scsicmd
->use_sg
) {
2223 struct scatterlist
*sg
;
2226 sg
= (struct scatterlist
*) scsicmd
->request_buffer
;
2228 sg_count
= pci_map_sg(dev
->pdev
, sg
, scsicmd
->use_sg
,
2229 scsicmd
->sc_data_direction
);
2230 psg
->count
= cpu_to_le32(sg_count
);
2232 for (i
= 0; i
< sg_count
; i
++) {
2233 psg
->sg
[i
].addr
= cpu_to_le32(sg_dma_address(sg
));
2234 psg
->sg
[i
].count
= cpu_to_le32(sg_dma_len(sg
));
2235 byte_count
+= sg_dma_len(sg
);
2238 /* hba wants the size to be exact */
2239 if(byte_count
> scsicmd
->request_bufflen
){
2240 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2241 (byte_count
- scsicmd
->request_bufflen
);
2242 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2243 byte_count
= scsicmd
->request_bufflen
;
2245 /* Check for command underflow */
2246 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2247 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2248 byte_count
, scsicmd
->underflow
);
2251 else if(scsicmd
->request_bufflen
) {
2253 scsicmd
->SCp
.dma_handle
= pci_map_single(dev
->pdev
,
2254 scsicmd
->request_buffer
,
2255 scsicmd
->request_bufflen
,
2256 scsicmd
->sc_data_direction
);
2257 addr
= scsicmd
->SCp
.dma_handle
;
2258 psg
->count
= cpu_to_le32(1);
2259 psg
->sg
[0].addr
= cpu_to_le32(addr
);
2260 psg
->sg
[0].count
= cpu_to_le32(scsicmd
->request_bufflen
);
2261 byte_count
= scsicmd
->request_bufflen
;
2267 static unsigned long aac_build_sg64(struct scsi_cmnd
* scsicmd
, struct sgmap64
* psg
)
2269 struct aac_dev
*dev
;
2270 unsigned long byte_count
= 0;
2273 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2274 // Get rid of old data
2276 psg
->sg
[0].addr
[0] = 0;
2277 psg
->sg
[0].addr
[1] = 0;
2278 psg
->sg
[0].count
= 0;
2279 if (scsicmd
->use_sg
) {
2280 struct scatterlist
*sg
;
2283 sg
= (struct scatterlist
*) scsicmd
->request_buffer
;
2285 sg_count
= pci_map_sg(dev
->pdev
, sg
, scsicmd
->use_sg
,
2286 scsicmd
->sc_data_direction
);
2288 for (i
= 0; i
< sg_count
; i
++) {
2289 int count
= sg_dma_len(sg
);
2290 addr
= sg_dma_address(sg
);
2291 psg
->sg
[i
].addr
[0] = cpu_to_le32(addr
& 0xffffffff);
2292 psg
->sg
[i
].addr
[1] = cpu_to_le32(addr
>>32);
2293 psg
->sg
[i
].count
= cpu_to_le32(count
);
2294 byte_count
+= count
;
2297 psg
->count
= cpu_to_le32(sg_count
);
2298 /* hba wants the size to be exact */
2299 if(byte_count
> scsicmd
->request_bufflen
){
2300 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2301 (byte_count
- scsicmd
->request_bufflen
);
2302 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2303 byte_count
= scsicmd
->request_bufflen
;
2305 /* Check for command underflow */
2306 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2307 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2308 byte_count
, scsicmd
->underflow
);
2311 else if(scsicmd
->request_bufflen
) {
2312 scsicmd
->SCp
.dma_handle
= pci_map_single(dev
->pdev
,
2313 scsicmd
->request_buffer
,
2314 scsicmd
->request_bufflen
,
2315 scsicmd
->sc_data_direction
);
2316 addr
= scsicmd
->SCp
.dma_handle
;
2317 psg
->count
= cpu_to_le32(1);
2318 psg
->sg
[0].addr
[0] = cpu_to_le32(addr
& 0xffffffff);
2319 psg
->sg
[0].addr
[1] = cpu_to_le32(addr
>> 32);
2320 psg
->sg
[0].count
= cpu_to_le32(scsicmd
->request_bufflen
);
2321 byte_count
= scsicmd
->request_bufflen
;
2326 static unsigned long aac_build_sgraw(struct scsi_cmnd
* scsicmd
, struct sgmapraw
* psg
)
2328 struct Scsi_Host
*host
= scsicmd
->device
->host
;
2329 struct aac_dev
*dev
= (struct aac_dev
*)host
->hostdata
;
2330 unsigned long byte_count
= 0;
2332 // Get rid of old data
2334 psg
->sg
[0].next
= 0;
2335 psg
->sg
[0].prev
= 0;
2336 psg
->sg
[0].addr
[0] = 0;
2337 psg
->sg
[0].addr
[1] = 0;
2338 psg
->sg
[0].count
= 0;
2339 psg
->sg
[0].flags
= 0;
2340 if (scsicmd
->use_sg
) {
2341 struct scatterlist
*sg
;
2344 sg
= (struct scatterlist
*) scsicmd
->request_buffer
;
2346 sg_count
= pci_map_sg(dev
->pdev
, sg
, scsicmd
->use_sg
,
2347 scsicmd
->sc_data_direction
);
2349 for (i
= 0; i
< sg_count
; i
++) {
2350 int count
= sg_dma_len(sg
);
2351 u64 addr
= sg_dma_address(sg
);
2352 psg
->sg
[i
].next
= 0;
2353 psg
->sg
[i
].prev
= 0;
2354 psg
->sg
[i
].addr
[1] = cpu_to_le32((u32
)(addr
>>32));
2355 psg
->sg
[i
].addr
[0] = cpu_to_le32((u32
)(addr
& 0xffffffff));
2356 psg
->sg
[i
].count
= cpu_to_le32(count
);
2357 psg
->sg
[i
].flags
= 0;
2358 byte_count
+= count
;
2361 psg
->count
= cpu_to_le32(sg_count
);
2362 /* hba wants the size to be exact */
2363 if(byte_count
> scsicmd
->request_bufflen
){
2364 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2365 (byte_count
- scsicmd
->request_bufflen
);
2366 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2367 byte_count
= scsicmd
->request_bufflen
;
2369 /* Check for command underflow */
2370 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2371 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2372 byte_count
, scsicmd
->underflow
);
2375 else if(scsicmd
->request_bufflen
) {
2378 scsicmd
->SCp
.dma_handle
= pci_map_single(dev
->pdev
,
2379 scsicmd
->request_buffer
,
2380 scsicmd
->request_bufflen
,
2381 scsicmd
->sc_data_direction
);
2382 addr
= scsicmd
->SCp
.dma_handle
;
2383 count
= scsicmd
->request_bufflen
;
2384 psg
->count
= cpu_to_le32(1);
2385 psg
->sg
[0].next
= 0;
2386 psg
->sg
[0].prev
= 0;
2387 psg
->sg
[0].addr
[1] = cpu_to_le32((u32
)(addr
>>32));
2388 psg
->sg
[0].addr
[0] = cpu_to_le32((u32
)(addr
& 0xffffffff));
2389 psg
->sg
[0].count
= cpu_to_le32(count
);
2390 psg
->sg
[0].flags
= 0;
2391 byte_count
= scsicmd
->request_bufflen
;
2396 #ifdef AAC_DETAILED_STATUS_INFO
2398 struct aac_srb_status_info
{
2404 static struct aac_srb_status_info srb_status_info
[] = {
2405 { SRB_STATUS_PENDING
, "Pending Status"},
2406 { SRB_STATUS_SUCCESS
, "Success"},
2407 { SRB_STATUS_ABORTED
, "Aborted Command"},
2408 { SRB_STATUS_ABORT_FAILED
, "Abort Failed"},
2409 { SRB_STATUS_ERROR
, "Error Event"},
2410 { SRB_STATUS_BUSY
, "Device Busy"},
2411 { SRB_STATUS_INVALID_REQUEST
, "Invalid Request"},
2412 { SRB_STATUS_INVALID_PATH_ID
, "Invalid Path ID"},
2413 { SRB_STATUS_NO_DEVICE
, "No Device"},
2414 { SRB_STATUS_TIMEOUT
, "Timeout"},
2415 { SRB_STATUS_SELECTION_TIMEOUT
, "Selection Timeout"},
2416 { SRB_STATUS_COMMAND_TIMEOUT
, "Command Timeout"},
2417 { SRB_STATUS_MESSAGE_REJECTED
, "Message Rejected"},
2418 { SRB_STATUS_BUS_RESET
, "Bus Reset"},
2419 { SRB_STATUS_PARITY_ERROR
, "Parity Error"},
2420 { SRB_STATUS_REQUEST_SENSE_FAILED
,"Request Sense Failed"},
2421 { SRB_STATUS_NO_HBA
, "No HBA"},
2422 { SRB_STATUS_DATA_OVERRUN
, "Data Overrun/Data Underrun"},
2423 { SRB_STATUS_UNEXPECTED_BUS_FREE
,"Unexpected Bus Free"},
2424 { SRB_STATUS_PHASE_SEQUENCE_FAILURE
,"Phase Error"},
2425 { SRB_STATUS_BAD_SRB_BLOCK_LENGTH
,"Bad Srb Block Length"},
2426 { SRB_STATUS_REQUEST_FLUSHED
, "Request Flushed"},
2427 { SRB_STATUS_DELAYED_RETRY
, "Delayed Retry"},
2428 { SRB_STATUS_INVALID_LUN
, "Invalid LUN"},
2429 { SRB_STATUS_INVALID_TARGET_ID
, "Invalid TARGET ID"},
2430 { SRB_STATUS_BAD_FUNCTION
, "Bad Function"},
2431 { SRB_STATUS_ERROR_RECOVERY
, "Error Recovery"},
2432 { SRB_STATUS_NOT_STARTED
, "Not Started"},
2433 { SRB_STATUS_NOT_IN_USE
, "Not In Use"},
2434 { SRB_STATUS_FORCE_ABORT
, "Force Abort"},
2435 { SRB_STATUS_DOMAIN_VALIDATION_FAIL
,"Domain Validation Failure"},
2436 { 0xff, "Unknown Error"}
2439 char *aac_get_status_string(u32 status
)
2443 for (i
= 0; i
< ARRAY_SIZE(srb_status_info
); i
++)
2444 if (srb_status_info
[i
].status
== status
)
2445 return srb_status_info
[i
].str
;
2447 return "Bad Status Code";