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
= -1;
174 module_param(expose_physicals
, int, S_IRUGO
|S_IWUSR
);
175 MODULE_PARM_DESC(expose_physicals
, "Expose physical components of the arrays. -1=protect 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
= 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 static int aac_bounds_32(struct aac_dev
* dev
, struct scsi_cmnd
* cmd
, u64 lba
)
711 if (lba
& 0xffffffff00000000LL
) {
712 int cid
= scmd_id(cmd
);
713 dprintk((KERN_DEBUG
"aacraid: Illegal lba\n"));
714 cmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
715 SAM_STAT_CHECK_CONDITION
;
716 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
718 SENCODE_INTERNAL_TARGET_FAILURE
,
719 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
721 memcpy(cmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
722 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(cmd
->sense_buffer
))
723 ? sizeof(cmd
->sense_buffer
)
724 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
731 static int aac_bounds_64(struct aac_dev
* dev
, struct scsi_cmnd
* cmd
, u64 lba
)
736 static void io_callback(void *context
, struct fib
* fibptr
);
738 static int aac_read_raw_io(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
741 struct aac_raw_io
*readcmd
;
743 readcmd
= (struct aac_raw_io
*) fib_data(fib
);
744 readcmd
->block
[0] = cpu_to_le32((u32
)(lba
&0xffffffff));
745 readcmd
->block
[1] = cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
746 readcmd
->count
= cpu_to_le32(count
<<9);
747 readcmd
->cid
= cpu_to_le16(scmd_id(cmd
));
748 readcmd
->flags
= cpu_to_le16(1);
749 readcmd
->bpTotal
= 0;
750 readcmd
->bpComplete
= 0;
752 aac_build_sgraw(cmd
, &readcmd
->sg
);
753 fibsize
= sizeof(struct aac_raw_io
) + ((le32_to_cpu(readcmd
->sg
.count
) - 1) * sizeof (struct sgentryraw
));
754 BUG_ON(fibsize
> (fib
->dev
->max_fib_size
- sizeof(struct aac_fibhdr
)));
756 * Now send the Fib to the adapter
758 return aac_fib_send(ContainerRawIo
,
763 (fib_callback
) io_callback
,
767 static int aac_read_block64(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
770 struct aac_read64
*readcmd
;
772 readcmd
= (struct aac_read64
*) fib_data(fib
);
773 readcmd
->command
= cpu_to_le32(VM_CtHostRead64
);
774 readcmd
->cid
= cpu_to_le16(scmd_id(cmd
));
775 readcmd
->sector_count
= cpu_to_le16(count
);
776 readcmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
780 aac_build_sg64(cmd
, &readcmd
->sg
);
781 fibsize
= sizeof(struct aac_read64
) +
782 ((le32_to_cpu(readcmd
->sg
.count
) - 1) *
783 sizeof (struct sgentry64
));
784 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
785 sizeof(struct aac_fibhdr
)));
787 * Now send the Fib to the adapter
789 return aac_fib_send(ContainerCommand64
,
794 (fib_callback
) io_callback
,
798 static int aac_read_block(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
801 struct aac_read
*readcmd
;
803 readcmd
= (struct aac_read
*) fib_data(fib
);
804 readcmd
->command
= cpu_to_le32(VM_CtBlockRead
);
805 readcmd
->cid
= cpu_to_le16(scmd_id(cmd
));
806 readcmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
807 readcmd
->count
= cpu_to_le32(count
* 512);
809 aac_build_sg(cmd
, &readcmd
->sg
);
810 fibsize
= sizeof(struct aac_read
) +
811 ((le32_to_cpu(readcmd
->sg
.count
) - 1) *
812 sizeof (struct sgentry
));
813 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
814 sizeof(struct aac_fibhdr
)));
816 * Now send the Fib to the adapter
818 return aac_fib_send(ContainerCommand
,
823 (fib_callback
) io_callback
,
827 static int aac_write_raw_io(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
830 struct aac_raw_io
*writecmd
;
832 writecmd
= (struct aac_raw_io
*) fib_data(fib
);
833 writecmd
->block
[0] = cpu_to_le32((u32
)(lba
&0xffffffff));
834 writecmd
->block
[1] = cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
835 writecmd
->count
= cpu_to_le32(count
<<9);
836 writecmd
->cid
= cpu_to_le16(scmd_id(cmd
));
838 writecmd
->bpTotal
= 0;
839 writecmd
->bpComplete
= 0;
841 aac_build_sgraw(cmd
, &writecmd
->sg
);
842 fibsize
= sizeof(struct aac_raw_io
) + ((le32_to_cpu(writecmd
->sg
.count
) - 1) * sizeof (struct sgentryraw
));
843 BUG_ON(fibsize
> (fib
->dev
->max_fib_size
- sizeof(struct aac_fibhdr
)));
845 * Now send the Fib to the adapter
847 return aac_fib_send(ContainerRawIo
,
852 (fib_callback
) io_callback
,
856 static int aac_write_block64(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
859 struct aac_write64
*writecmd
;
861 writecmd
= (struct aac_write64
*) fib_data(fib
);
862 writecmd
->command
= cpu_to_le32(VM_CtHostWrite64
);
863 writecmd
->cid
= cpu_to_le16(scmd_id(cmd
));
864 writecmd
->sector_count
= cpu_to_le16(count
);
865 writecmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
869 aac_build_sg64(cmd
, &writecmd
->sg
);
870 fibsize
= sizeof(struct aac_write64
) +
871 ((le32_to_cpu(writecmd
->sg
.count
) - 1) *
872 sizeof (struct sgentry64
));
873 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
874 sizeof(struct aac_fibhdr
)));
876 * Now send the Fib to the adapter
878 return aac_fib_send(ContainerCommand64
,
883 (fib_callback
) io_callback
,
887 static int aac_write_block(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
890 struct aac_write
*writecmd
;
892 writecmd
= (struct aac_write
*) fib_data(fib
);
893 writecmd
->command
= cpu_to_le32(VM_CtBlockWrite
);
894 writecmd
->cid
= cpu_to_le16(scmd_id(cmd
));
895 writecmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
896 writecmd
->count
= cpu_to_le32(count
* 512);
897 writecmd
->sg
.count
= cpu_to_le32(1);
898 /* ->stable is not used - it did mean which type of write */
900 aac_build_sg(cmd
, &writecmd
->sg
);
901 fibsize
= sizeof(struct aac_write
) +
902 ((le32_to_cpu(writecmd
->sg
.count
) - 1) *
903 sizeof (struct sgentry
));
904 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
905 sizeof(struct aac_fibhdr
)));
907 * Now send the Fib to the adapter
909 return aac_fib_send(ContainerCommand
,
914 (fib_callback
) io_callback
,
918 static struct aac_srb
* aac_scsi_common(struct fib
* fib
, struct scsi_cmnd
* cmd
)
920 struct aac_srb
* srbcmd
;
925 switch(cmd
->sc_data_direction
){
929 case DMA_BIDIRECTIONAL
:
930 flag
= SRB_DataIn
| SRB_DataOut
;
932 case DMA_FROM_DEVICE
:
936 default: /* shuts up some versions of gcc */
937 flag
= SRB_NoDataXfer
;
941 srbcmd
= (struct aac_srb
*) fib_data(fib
);
942 srbcmd
->function
= cpu_to_le32(SRBF_ExecuteScsi
);
943 srbcmd
->channel
= cpu_to_le32(aac_logical_to_phys(scmd_channel(cmd
)));
944 srbcmd
->id
= cpu_to_le32(scmd_id(cmd
));
945 srbcmd
->lun
= cpu_to_le32(cmd
->device
->lun
);
946 srbcmd
->flags
= cpu_to_le32(flag
);
947 timeout
= cmd
->timeout_per_command
/HZ
;
950 srbcmd
->timeout
= cpu_to_le32(timeout
); // timeout in seconds
951 srbcmd
->retry_limit
= 0; /* Obsolete parameter */
952 srbcmd
->cdb_size
= cpu_to_le32(cmd
->cmd_len
);
956 static void aac_srb_callback(void *context
, struct fib
* fibptr
);
958 static int aac_scsi_64(struct fib
* fib
, struct scsi_cmnd
* cmd
)
961 struct aac_srb
* srbcmd
= aac_scsi_common(fib
, cmd
);
963 aac_build_sg64(cmd
, (struct sgmap64
*) &srbcmd
->sg
);
964 srbcmd
->count
= cpu_to_le32(cmd
->request_bufflen
);
966 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
967 memcpy(srbcmd
->cdb
, cmd
->cmnd
, cmd
->cmd_len
);
969 * Build Scatter/Gather list
971 fibsize
= sizeof (struct aac_srb
) - sizeof (struct sgentry
) +
972 ((le32_to_cpu(srbcmd
->sg
.count
) & 0xff) *
973 sizeof (struct sgentry64
));
974 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
975 sizeof(struct aac_fibhdr
)));
978 * Now send the Fib to the adapter
980 return aac_fib_send(ScsiPortCommand64
, fib
,
981 fibsize
, FsaNormal
, 0, 1,
982 (fib_callback
) aac_srb_callback
,
986 static int aac_scsi_32(struct fib
* fib
, struct scsi_cmnd
* cmd
)
989 struct aac_srb
* srbcmd
= aac_scsi_common(fib
, cmd
);
991 aac_build_sg(cmd
, (struct sgmap
*)&srbcmd
->sg
);
992 srbcmd
->count
= cpu_to_le32(cmd
->request_bufflen
);
994 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
995 memcpy(srbcmd
->cdb
, cmd
->cmnd
, cmd
->cmd_len
);
997 * Build Scatter/Gather list
999 fibsize
= sizeof (struct aac_srb
) +
1000 (((le32_to_cpu(srbcmd
->sg
.count
) & 0xff) - 1) *
1001 sizeof (struct sgentry
));
1002 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
1003 sizeof(struct aac_fibhdr
)));
1006 * Now send the Fib to the adapter
1008 return aac_fib_send(ScsiPortCommand
, fib
, fibsize
, FsaNormal
, 0, 1,
1009 (fib_callback
) aac_srb_callback
, (void *) cmd
);
1012 int aac_get_adapter_info(struct aac_dev
* dev
)
1017 struct aac_adapter_info
*info
;
1018 struct aac_bus_info
*command
;
1019 struct aac_bus_info_response
*bus_info
;
1021 if (!(fibptr
= aac_fib_alloc(dev
)))
1024 aac_fib_init(fibptr
);
1025 info
= (struct aac_adapter_info
*) fib_data(fibptr
);
1026 memset(info
,0,sizeof(*info
));
1028 rcode
= aac_fib_send(RequestAdapterInfo
,
1032 -1, 1, /* First `interrupt' command uses special wait */
1037 aac_fib_complete(fibptr
);
1038 aac_fib_free(fibptr
);
1041 memcpy(&dev
->adapter_info
, info
, sizeof(*info
));
1043 if (dev
->adapter_info
.options
& AAC_OPT_SUPPLEMENT_ADAPTER_INFO
) {
1044 struct aac_supplement_adapter_info
* info
;
1046 aac_fib_init(fibptr
);
1048 info
= (struct aac_supplement_adapter_info
*) fib_data(fibptr
);
1050 memset(info
,0,sizeof(*info
));
1052 rcode
= aac_fib_send(RequestSupplementAdapterInfo
,
1061 memcpy(&dev
->supplement_adapter_info
, info
, sizeof(*info
));
1069 aac_fib_init(fibptr
);
1071 bus_info
= (struct aac_bus_info_response
*) fib_data(fibptr
);
1073 memset(bus_info
, 0, sizeof(*bus_info
));
1075 command
= (struct aac_bus_info
*)bus_info
;
1077 command
->Command
= cpu_to_le32(VM_Ioctl
);
1078 command
->ObjType
= cpu_to_le32(FT_DRIVE
);
1079 command
->MethodId
= cpu_to_le32(1);
1080 command
->CtlCmd
= cpu_to_le32(GetBusInfo
);
1082 rcode
= aac_fib_send(ContainerCommand
,
1089 if (rcode
>= 0 && le32_to_cpu(bus_info
->Status
) == ST_OK
) {
1090 dev
->maximum_num_physicals
= le32_to_cpu(bus_info
->TargetsPerBus
);
1091 dev
->maximum_num_channels
= le32_to_cpu(bus_info
->BusCount
);
1094 if (!dev
->in_reset
) {
1095 tmp
= le32_to_cpu(dev
->adapter_info
.kernelrev
);
1096 printk(KERN_INFO
"%s%d: kernel %d.%d-%d[%d] %.*s\n",
1102 le32_to_cpu(dev
->adapter_info
.kernelbuild
),
1103 (int)sizeof(dev
->supplement_adapter_info
.BuildDate
),
1104 dev
->supplement_adapter_info
.BuildDate
);
1105 tmp
= le32_to_cpu(dev
->adapter_info
.monitorrev
);
1106 printk(KERN_INFO
"%s%d: monitor %d.%d-%d[%d]\n",
1108 tmp
>>24,(tmp
>>16)&0xff,tmp
&0xff,
1109 le32_to_cpu(dev
->adapter_info
.monitorbuild
));
1110 tmp
= le32_to_cpu(dev
->adapter_info
.biosrev
);
1111 printk(KERN_INFO
"%s%d: bios %d.%d-%d[%d]\n",
1113 tmp
>>24,(tmp
>>16)&0xff,tmp
&0xff,
1114 le32_to_cpu(dev
->adapter_info
.biosbuild
));
1115 if (le32_to_cpu(dev
->adapter_info
.serial
[0]) != 0xBAD0)
1116 printk(KERN_INFO
"%s%d: serial %x\n",
1118 le32_to_cpu(dev
->adapter_info
.serial
[0]));
1121 dev
->nondasd_support
= 0;
1122 dev
->raid_scsi_mode
= 0;
1123 if(dev
->adapter_info
.options
& AAC_OPT_NONDASD
){
1124 dev
->nondasd_support
= 1;
1128 * If the firmware supports ROMB RAID/SCSI mode and we are currently
1129 * in RAID/SCSI mode, set the flag. For now if in this mode we will
1130 * force nondasd support on. If we decide to allow the non-dasd flag
1131 * additional changes changes will have to be made to support
1132 * RAID/SCSI. the function aac_scsi_cmd in this module will have to be
1133 * changed to support the new dev->raid_scsi_mode flag instead of
1134 * leaching off of the dev->nondasd_support flag. Also in linit.c the
1135 * function aac_detect will have to be modified where it sets up the
1136 * max number of channels based on the aac->nondasd_support flag only.
1138 if ((dev
->adapter_info
.options
& AAC_OPT_SCSI_MANAGED
) &&
1139 (dev
->adapter_info
.options
& AAC_OPT_RAID_SCSI_MODE
)) {
1140 dev
->nondasd_support
= 1;
1141 dev
->raid_scsi_mode
= 1;
1143 if (dev
->raid_scsi_mode
!= 0)
1144 printk(KERN_INFO
"%s%d: ROMB RAID/SCSI mode enabled\n",
1145 dev
->name
, dev
->id
);
1148 dev
->nondasd_support
= (nondasd
!=0);
1150 if(dev
->nondasd_support
!= 0){
1151 printk(KERN_INFO
"%s%d: Non-DASD support enabled.\n",dev
->name
, dev
->id
);
1154 dev
->dac_support
= 0;
1155 if( (sizeof(dma_addr_t
) > 4) && (dev
->adapter_info
.options
& AAC_OPT_SGMAP_HOST64
)){
1156 printk(KERN_INFO
"%s%d: 64bit support enabled.\n", dev
->name
, dev
->id
);
1157 dev
->dac_support
= 1;
1161 dev
->dac_support
= (dacmode
!=0);
1163 if(dev
->dac_support
!= 0) {
1164 if (!pci_set_dma_mask(dev
->pdev
, DMA_64BIT_MASK
) &&
1165 !pci_set_consistent_dma_mask(dev
->pdev
, DMA_64BIT_MASK
)) {
1166 printk(KERN_INFO
"%s%d: 64 Bit DAC enabled\n",
1167 dev
->name
, dev
->id
);
1168 } else if (!pci_set_dma_mask(dev
->pdev
, DMA_32BIT_MASK
) &&
1169 !pci_set_consistent_dma_mask(dev
->pdev
, DMA_32BIT_MASK
)) {
1170 printk(KERN_INFO
"%s%d: DMA mask set failed, 64 Bit DAC disabled\n",
1171 dev
->name
, dev
->id
);
1172 dev
->dac_support
= 0;
1174 printk(KERN_WARNING
"%s%d: No suitable DMA available.\n",
1175 dev
->name
, dev
->id
);
1180 * Deal with configuring for the individualized limits of each packet
1183 dev
->a_ops
.adapter_scsi
= (dev
->dac_support
)
1186 if (dev
->raw_io_interface
) {
1187 dev
->a_ops
.adapter_bounds
= (dev
->raw_io_64
)
1190 dev
->a_ops
.adapter_read
= aac_read_raw_io
;
1191 dev
->a_ops
.adapter_write
= aac_write_raw_io
;
1193 dev
->a_ops
.adapter_bounds
= aac_bounds_32
;
1194 dev
->scsi_host_ptr
->sg_tablesize
= (dev
->max_fib_size
-
1195 sizeof(struct aac_fibhdr
) -
1196 sizeof(struct aac_write
) + sizeof(struct sgentry
)) /
1197 sizeof(struct sgentry
);
1198 if (dev
->dac_support
) {
1199 dev
->a_ops
.adapter_read
= aac_read_block64
;
1200 dev
->a_ops
.adapter_write
= aac_write_block64
;
1202 * 38 scatter gather elements
1204 dev
->scsi_host_ptr
->sg_tablesize
=
1205 (dev
->max_fib_size
-
1206 sizeof(struct aac_fibhdr
) -
1207 sizeof(struct aac_write64
) +
1208 sizeof(struct sgentry64
)) /
1209 sizeof(struct sgentry64
);
1211 dev
->a_ops
.adapter_read
= aac_read_block
;
1212 dev
->a_ops
.adapter_write
= aac_write_block
;
1214 dev
->scsi_host_ptr
->max_sectors
= AAC_MAX_32BIT_SGBCOUNT
;
1215 if(!(dev
->adapter_info
.options
& AAC_OPT_NEW_COMM
)) {
1217 * Worst case size that could cause sg overflow when
1218 * we break up SG elements that are larger than 64KB.
1219 * Would be nice if we could tell the SCSI layer what
1220 * the maximum SG element size can be. Worst case is
1221 * (sg_tablesize-1) 4KB elements with one 64KB
1223 * 32bit -> 468 or 238KB 64bit -> 424 or 212KB
1225 dev
->scsi_host_ptr
->max_sectors
=
1226 (dev
->scsi_host_ptr
->sg_tablesize
* 8) + 112;
1230 aac_fib_complete(fibptr
);
1231 aac_fib_free(fibptr
);
1237 static void io_callback(void *context
, struct fib
* fibptr
)
1239 struct aac_dev
*dev
;
1240 struct aac_read_reply
*readreply
;
1241 struct scsi_cmnd
*scsicmd
;
1244 scsicmd
= (struct scsi_cmnd
*) context
;
1245 scsicmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
1247 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1248 cid
= scmd_id(scsicmd
);
1250 if (nblank(dprintk(x
))) {
1252 switch (scsicmd
->cmnd
[0]) {
1255 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) |
1256 (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1260 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1261 ((u64
)scsicmd
->cmnd
[3] << 48) |
1262 ((u64
)scsicmd
->cmnd
[4] << 40) |
1263 ((u64
)scsicmd
->cmnd
[5] << 32) |
1264 ((u64
)scsicmd
->cmnd
[6] << 24) |
1265 (scsicmd
->cmnd
[7] << 16) |
1266 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1270 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1271 (scsicmd
->cmnd
[3] << 16) |
1272 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1275 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1276 (scsicmd
->cmnd
[3] << 16) |
1277 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1281 "io_callback[cpu %d]: lba = %llu, t = %ld.\n",
1282 smp_processor_id(), (unsigned long long)lba
, jiffies
);
1285 BUG_ON(fibptr
== NULL
);
1288 pci_unmap_sg(dev
->pdev
,
1289 (struct scatterlist
*)scsicmd
->request_buffer
,
1291 scsicmd
->sc_data_direction
);
1292 else if(scsicmd
->request_bufflen
)
1293 pci_unmap_single(dev
->pdev
, scsicmd
->SCp
.dma_handle
,
1294 scsicmd
->request_bufflen
,
1295 scsicmd
->sc_data_direction
);
1296 readreply
= (struct aac_read_reply
*)fib_data(fibptr
);
1297 if (le32_to_cpu(readreply
->status
) == ST_OK
)
1298 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1300 #ifdef AAC_DETAILED_STATUS_INFO
1301 printk(KERN_WARNING
"io_callback: io failed, status = %d\n",
1302 le32_to_cpu(readreply
->status
));
1304 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1305 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1307 SENCODE_INTERNAL_TARGET_FAILURE
,
1308 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
1310 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1311 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1312 ? sizeof(scsicmd
->sense_buffer
)
1313 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1315 aac_fib_complete(fibptr
);
1316 aac_fib_free(fibptr
);
1318 scsicmd
->scsi_done(scsicmd
);
1321 static int aac_read(struct scsi_cmnd
* scsicmd
, int cid
)
1326 struct aac_dev
*dev
;
1327 struct fib
* cmd_fibcontext
;
1329 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1331 * Get block address and transfer length
1333 switch (scsicmd
->cmnd
[0]) {
1335 dprintk((KERN_DEBUG
"aachba: received a read(6) command on id %d.\n", cid
));
1337 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) |
1338 (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1339 count
= scsicmd
->cmnd
[4];
1345 dprintk((KERN_DEBUG
"aachba: received a read(16) command on id %d.\n", cid
));
1347 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1348 ((u64
)scsicmd
->cmnd
[3] << 48) |
1349 ((u64
)scsicmd
->cmnd
[4] << 40) |
1350 ((u64
)scsicmd
->cmnd
[5] << 32) |
1351 ((u64
)scsicmd
->cmnd
[6] << 24) |
1352 (scsicmd
->cmnd
[7] << 16) |
1353 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1354 count
= (scsicmd
->cmnd
[10] << 24) |
1355 (scsicmd
->cmnd
[11] << 16) |
1356 (scsicmd
->cmnd
[12] << 8) | scsicmd
->cmnd
[13];
1359 dprintk((KERN_DEBUG
"aachba: received a read(12) command on id %d.\n", cid
));
1361 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1362 (scsicmd
->cmnd
[3] << 16) |
1363 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1364 count
= (scsicmd
->cmnd
[6] << 24) |
1365 (scsicmd
->cmnd
[7] << 16) |
1366 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1369 dprintk((KERN_DEBUG
"aachba: received a read(10) command on id %d.\n", cid
));
1371 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1372 (scsicmd
->cmnd
[3] << 16) |
1373 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1374 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
1377 dprintk((KERN_DEBUG
"aac_read[cpu %d]: lba = %llu, t = %ld.\n",
1378 smp_processor_id(), (unsigned long long)lba
, jiffies
));
1379 if (aac_adapter_bounds(dev
,scsicmd
,lba
))
1382 * Alocate and initialize a Fib
1384 if (!(cmd_fibcontext
= aac_fib_alloc(dev
))) {
1388 status
= aac_adapter_read(cmd_fibcontext
, scsicmd
, lba
, count
);
1391 * Check that the command queued to the controller
1393 if (status
== -EINPROGRESS
) {
1394 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1398 printk(KERN_WARNING
"aac_read: aac_fib_send failed with status: %d.\n", status
);
1400 * For some reason, the Fib didn't queue, return QUEUE_FULL
1402 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_TASK_SET_FULL
;
1403 scsicmd
->scsi_done(scsicmd
);
1404 aac_fib_complete(cmd_fibcontext
);
1405 aac_fib_free(cmd_fibcontext
);
1409 static int aac_write(struct scsi_cmnd
* scsicmd
, int cid
)
1414 struct aac_dev
*dev
;
1415 struct fib
* cmd_fibcontext
;
1417 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1419 * Get block address and transfer length
1421 if (scsicmd
->cmnd
[0] == WRITE_6
) /* 6 byte command */
1423 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) | (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1424 count
= scsicmd
->cmnd
[4];
1427 } else if (scsicmd
->cmnd
[0] == WRITE_16
) { /* 16 byte command */
1428 dprintk((KERN_DEBUG
"aachba: received a write(16) command on id %d.\n", cid
));
1430 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1431 ((u64
)scsicmd
->cmnd
[3] << 48) |
1432 ((u64
)scsicmd
->cmnd
[4] << 40) |
1433 ((u64
)scsicmd
->cmnd
[5] << 32) |
1434 ((u64
)scsicmd
->cmnd
[6] << 24) |
1435 (scsicmd
->cmnd
[7] << 16) |
1436 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1437 count
= (scsicmd
->cmnd
[10] << 24) | (scsicmd
->cmnd
[11] << 16) |
1438 (scsicmd
->cmnd
[12] << 8) | scsicmd
->cmnd
[13];
1439 } else if (scsicmd
->cmnd
[0] == WRITE_12
) { /* 12 byte command */
1440 dprintk((KERN_DEBUG
"aachba: received a write(12) command on id %d.\n", cid
));
1442 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16)
1443 | (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1444 count
= (scsicmd
->cmnd
[6] << 24) | (scsicmd
->cmnd
[7] << 16)
1445 | (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1447 dprintk((KERN_DEBUG
"aachba: received a write(10) command on id %d.\n", cid
));
1448 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16) | (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1449 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
1451 dprintk((KERN_DEBUG
"aac_write[cpu %d]: lba = %llu, t = %ld.\n",
1452 smp_processor_id(), (unsigned long long)lba
, jiffies
));
1453 if (aac_adapter_bounds(dev
,scsicmd
,lba
))
1456 * Allocate and initialize a Fib then setup a BlockWrite command
1458 if (!(cmd_fibcontext
= aac_fib_alloc(dev
))) {
1459 scsicmd
->result
= DID_ERROR
<< 16;
1460 scsicmd
->scsi_done(scsicmd
);
1464 status
= aac_adapter_write(cmd_fibcontext
, scsicmd
, lba
, count
);
1467 * Check that the command queued to the controller
1469 if (status
== -EINPROGRESS
) {
1470 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1474 printk(KERN_WARNING
"aac_write: aac_fib_send failed with status: %d\n", status
);
1476 * For some reason, the Fib didn't queue, return QUEUE_FULL
1478 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_TASK_SET_FULL
;
1479 scsicmd
->scsi_done(scsicmd
);
1481 aac_fib_complete(cmd_fibcontext
);
1482 aac_fib_free(cmd_fibcontext
);
1486 static void synchronize_callback(void *context
, struct fib
*fibptr
)
1488 struct aac_synchronize_reply
*synchronizereply
;
1489 struct scsi_cmnd
*cmd
;
1492 cmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
1494 dprintk((KERN_DEBUG
"synchronize_callback[cpu %d]: t = %ld.\n",
1495 smp_processor_id(), jiffies
));
1496 BUG_ON(fibptr
== NULL
);
1499 synchronizereply
= fib_data(fibptr
);
1500 if (le32_to_cpu(synchronizereply
->status
) == CT_OK
)
1501 cmd
->result
= DID_OK
<< 16 |
1502 COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1504 struct scsi_device
*sdev
= cmd
->device
;
1505 struct aac_dev
*dev
= (struct aac_dev
*)sdev
->host
->hostdata
;
1506 u32 cid
= sdev_id(sdev
);
1508 "synchronize_callback: synchronize failed, status = %d\n",
1509 le32_to_cpu(synchronizereply
->status
));
1510 cmd
->result
= DID_OK
<< 16 |
1511 COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1512 set_sense((u8
*)&dev
->fsa_dev
[cid
].sense_data
,
1514 SENCODE_INTERNAL_TARGET_FAILURE
,
1515 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
1517 memcpy(cmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1518 min(sizeof(dev
->fsa_dev
[cid
].sense_data
),
1519 sizeof(cmd
->sense_buffer
)));
1522 aac_fib_complete(fibptr
);
1523 aac_fib_free(fibptr
);
1524 cmd
->scsi_done(cmd
);
1527 static int aac_synchronize(struct scsi_cmnd
*scsicmd
, int cid
)
1530 struct fib
*cmd_fibcontext
;
1531 struct aac_synchronize
*synchronizecmd
;
1532 struct scsi_cmnd
*cmd
;
1533 struct scsi_device
*sdev
= scsicmd
->device
;
1535 struct aac_dev
*aac
;
1536 unsigned long flags
;
1539 * Wait for all outstanding queued commands to complete to this
1540 * specific target (block).
1542 spin_lock_irqsave(&sdev
->list_lock
, flags
);
1543 list_for_each_entry(cmd
, &sdev
->cmd_list
, list
)
1544 if (cmd
!= scsicmd
&& cmd
->SCp
.phase
== AAC_OWNER_FIRMWARE
) {
1549 spin_unlock_irqrestore(&sdev
->list_lock
, flags
);
1552 * Yield the processor (requeue for later)
1555 return SCSI_MLQUEUE_DEVICE_BUSY
;
1557 aac
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1559 return SCSI_MLQUEUE_HOST_BUSY
;
1562 * Allocate and initialize a Fib
1564 if (!(cmd_fibcontext
= aac_fib_alloc(aac
)))
1565 return SCSI_MLQUEUE_HOST_BUSY
;
1567 aac_fib_init(cmd_fibcontext
);
1569 synchronizecmd
= fib_data(cmd_fibcontext
);
1570 synchronizecmd
->command
= cpu_to_le32(VM_ContainerConfig
);
1571 synchronizecmd
->type
= cpu_to_le32(CT_FLUSH_CACHE
);
1572 synchronizecmd
->cid
= cpu_to_le32(cid
);
1573 synchronizecmd
->count
=
1574 cpu_to_le32(sizeof(((struct aac_synchronize_reply
*)NULL
)->data
));
1577 * Now send the Fib to the adapter
1579 status
= aac_fib_send(ContainerCommand
,
1581 sizeof(struct aac_synchronize
),
1584 (fib_callback
)synchronize_callback
,
1588 * Check that the command queued to the controller
1590 if (status
== -EINPROGRESS
) {
1591 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1596 "aac_synchronize: aac_fib_send failed with status: %d.\n", status
);
1597 aac_fib_complete(cmd_fibcontext
);
1598 aac_fib_free(cmd_fibcontext
);
1599 return SCSI_MLQUEUE_HOST_BUSY
;
1603 * aac_scsi_cmd() - Process SCSI command
1604 * @scsicmd: SCSI command block
1606 * Emulate a SCSI command and queue the required request for the
1610 int aac_scsi_cmd(struct scsi_cmnd
* scsicmd
)
1613 struct Scsi_Host
*host
= scsicmd
->device
->host
;
1614 struct aac_dev
*dev
= (struct aac_dev
*)host
->hostdata
;
1615 struct fsa_dev_info
*fsa_dev_ptr
= dev
->fsa_dev
;
1617 if (fsa_dev_ptr
== NULL
)
1620 * If the bus, id or lun is out of range, return fail
1621 * Test does not apply to ID 16, the pseudo id for the controller
1624 if (scmd_id(scsicmd
) != host
->this_id
) {
1625 if ((scmd_channel(scsicmd
) == CONTAINER_CHANNEL
)) {
1626 if((scmd_id(scsicmd
) >= dev
->maximum_num_containers
) ||
1627 (scsicmd
->device
->lun
!= 0)) {
1628 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1629 scsicmd
->scsi_done(scsicmd
);
1632 cid
= scmd_id(scsicmd
);
1635 * If the target container doesn't exist, it may have
1636 * been newly created
1638 if ((fsa_dev_ptr
[cid
].valid
& 1) == 0) {
1639 switch (scsicmd
->cmnd
[0]) {
1640 case SERVICE_ACTION_IN
:
1641 if (!(dev
->raw_io_interface
) ||
1642 !(dev
->raw_io_64
) ||
1643 ((scsicmd
->cmnd
[1] & 0x1f) != SAI_READ_CAPACITY_16
))
1647 case TEST_UNIT_READY
:
1650 spin_unlock_irq(host
->host_lock
);
1651 aac_probe_container(dev
, cid
);
1652 if ((fsa_dev_ptr
[cid
].valid
& 1) == 0)
1653 fsa_dev_ptr
[cid
].valid
= 0;
1654 spin_lock_irq(host
->host_lock
);
1655 if (fsa_dev_ptr
[cid
].valid
== 0) {
1656 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1657 scsicmd
->scsi_done(scsicmd
);
1665 * If the target container still doesn't exist,
1668 if (fsa_dev_ptr
[cid
].valid
== 0) {
1669 scsicmd
->result
= DID_BAD_TARGET
<< 16;
1670 scsicmd
->scsi_done(scsicmd
);
1673 } else { /* check for physical non-dasd devices */
1674 if ((dev
->nondasd_support
== 1) || expose_physicals
) {
1677 return aac_send_srb_fib(scsicmd
);
1679 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1680 scsicmd
->scsi_done(scsicmd
);
1686 * else Command for the controller itself
1688 else if ((scsicmd
->cmnd
[0] != INQUIRY
) && /* only INQUIRY & TUR cmnd supported for controller */
1689 (scsicmd
->cmnd
[0] != TEST_UNIT_READY
))
1691 dprintk((KERN_WARNING
"Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd
->cmnd
[0]));
1692 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1693 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1695 SENCODE_INVALID_COMMAND
,
1696 ASENCODE_INVALID_COMMAND
, 0, 0, 0, 0);
1697 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1698 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1699 ? sizeof(scsicmd
->sense_buffer
)
1700 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1701 scsicmd
->scsi_done(scsicmd
);
1706 /* Handle commands here that don't really require going out to the adapter */
1707 switch (scsicmd
->cmnd
[0]) {
1710 struct inquiry_data inq_data
;
1712 dprintk((KERN_DEBUG
"INQUIRY command, ID: %d.\n", scmd_id(scsicmd
)));
1713 memset(&inq_data
, 0, sizeof (struct inquiry_data
));
1715 inq_data
.inqd_ver
= 2; /* claim compliance to SCSI-2 */
1716 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 */
1717 inq_data
.inqd_len
= 31;
1718 /*Format for "pad2" is RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
1719 inq_data
.inqd_pad2
= 0x32 ; /*WBus16|Sync|CmdQue */
1721 * Set the Vendor, Product, and Revision Level
1722 * see: <vendor>.c i.e. aac.c
1724 if (scmd_id(scsicmd
) == host
->this_id
) {
1725 setinqstr(dev
, (void *) (inq_data
.inqd_vid
), ARRAY_SIZE(container_types
));
1726 inq_data
.inqd_pdt
= INQD_PDT_PROC
; /* Processor device */
1727 aac_internal_transfer(scsicmd
, &inq_data
, 0, sizeof(inq_data
));
1728 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1729 scsicmd
->scsi_done(scsicmd
);
1734 setinqstr(dev
, (void *) (inq_data
.inqd_vid
), fsa_dev_ptr
[cid
].type
);
1735 inq_data
.inqd_pdt
= INQD_PDT_DA
; /* Direct/random access device */
1736 aac_internal_transfer(scsicmd
, &inq_data
, 0, sizeof(inq_data
));
1737 return aac_get_container_name(scsicmd
, cid
);
1739 case SERVICE_ACTION_IN
:
1740 if (!(dev
->raw_io_interface
) ||
1741 !(dev
->raw_io_64
) ||
1742 ((scsicmd
->cmnd
[1] & 0x1f) != SAI_READ_CAPACITY_16
))
1748 dprintk((KERN_DEBUG
"READ CAPACITY_16 command.\n"));
1749 capacity
= fsa_dev_ptr
[cid
].size
- 1;
1750 cp
[0] = (capacity
>> 56) & 0xff;
1751 cp
[1] = (capacity
>> 48) & 0xff;
1752 cp
[2] = (capacity
>> 40) & 0xff;
1753 cp
[3] = (capacity
>> 32) & 0xff;
1754 cp
[4] = (capacity
>> 24) & 0xff;
1755 cp
[5] = (capacity
>> 16) & 0xff;
1756 cp
[6] = (capacity
>> 8) & 0xff;
1757 cp
[7] = (capacity
>> 0) & 0xff;
1763 aac_internal_transfer(scsicmd
, cp
, 0,
1764 min_t(size_t, scsicmd
->cmnd
[13], sizeof(cp
)));
1765 if (sizeof(cp
) < scsicmd
->cmnd
[13]) {
1766 unsigned int len
, offset
= sizeof(cp
);
1768 memset(cp
, 0, offset
);
1770 len
= min_t(size_t, scsicmd
->cmnd
[13] - offset
,
1772 aac_internal_transfer(scsicmd
, cp
, offset
, len
);
1773 } while ((offset
+= len
) < scsicmd
->cmnd
[13]);
1776 /* Do not cache partition table for arrays */
1777 scsicmd
->device
->removable
= 1;
1779 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1780 scsicmd
->scsi_done(scsicmd
);
1790 dprintk((KERN_DEBUG
"READ CAPACITY command.\n"));
1791 if (fsa_dev_ptr
[cid
].size
<= 0x100000000ULL
)
1792 capacity
= fsa_dev_ptr
[cid
].size
- 1;
1796 cp
[0] = (capacity
>> 24) & 0xff;
1797 cp
[1] = (capacity
>> 16) & 0xff;
1798 cp
[2] = (capacity
>> 8) & 0xff;
1799 cp
[3] = (capacity
>> 0) & 0xff;
1804 aac_internal_transfer(scsicmd
, cp
, 0, sizeof(cp
));
1805 /* Do not cache partition table for arrays */
1806 scsicmd
->device
->removable
= 1;
1808 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1809 scsicmd
->scsi_done(scsicmd
);
1818 dprintk((KERN_DEBUG
"MODE SENSE command.\n"));
1819 mode_buf
[0] = 3; /* Mode data length */
1820 mode_buf
[1] = 0; /* Medium type - default */
1821 mode_buf
[2] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */
1822 mode_buf
[3] = 0; /* Block descriptor length */
1824 aac_internal_transfer(scsicmd
, mode_buf
, 0, sizeof(mode_buf
));
1825 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1826 scsicmd
->scsi_done(scsicmd
);
1834 dprintk((KERN_DEBUG
"MODE SENSE 10 byte command.\n"));
1835 mode_buf
[0] = 0; /* Mode data length (MSB) */
1836 mode_buf
[1] = 6; /* Mode data length (LSB) */
1837 mode_buf
[2] = 0; /* Medium type - default */
1838 mode_buf
[3] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */
1839 mode_buf
[4] = 0; /* reserved */
1840 mode_buf
[5] = 0; /* reserved */
1841 mode_buf
[6] = 0; /* Block descriptor length (MSB) */
1842 mode_buf
[7] = 0; /* Block descriptor length (LSB) */
1843 aac_internal_transfer(scsicmd
, mode_buf
, 0, sizeof(mode_buf
));
1845 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1846 scsicmd
->scsi_done(scsicmd
);
1851 dprintk((KERN_DEBUG
"REQUEST SENSE command.\n"));
1852 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
, sizeof (struct sense_data
));
1853 memset(&dev
->fsa_dev
[cid
].sense_data
, 0, sizeof (struct sense_data
));
1854 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1855 scsicmd
->scsi_done(scsicmd
);
1858 case ALLOW_MEDIUM_REMOVAL
:
1859 dprintk((KERN_DEBUG
"LOCK command.\n"));
1860 if (scsicmd
->cmnd
[4])
1861 fsa_dev_ptr
[cid
].locked
= 1;
1863 fsa_dev_ptr
[cid
].locked
= 0;
1865 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1866 scsicmd
->scsi_done(scsicmd
);
1869 * These commands are all No-Ops
1871 case TEST_UNIT_READY
:
1875 case REASSIGN_BLOCKS
:
1878 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1879 scsicmd
->scsi_done(scsicmd
);
1883 switch (scsicmd
->cmnd
[0])
1892 * Hack to keep track of ordinal number of the device that
1893 * corresponds to a container. Needed to convert
1894 * containers to /dev/sd device names
1897 if (scsicmd
->request
->rq_disk
)
1898 strlcpy(fsa_dev_ptr
[cid
].devname
,
1899 scsicmd
->request
->rq_disk
->disk_name
,
1900 min(sizeof(fsa_dev_ptr
[cid
].devname
),
1901 sizeof(scsicmd
->request
->rq_disk
->disk_name
) + 1));
1903 return aac_read(scsicmd
, cid
);
1911 return aac_write(scsicmd
, cid
);
1913 case SYNCHRONIZE_CACHE
:
1914 /* Issue FIB to tell Firmware to flush it's cache */
1915 return aac_synchronize(scsicmd
, cid
);
1919 * Unhandled commands
1921 dprintk((KERN_WARNING
"Unhandled SCSI Command: 0x%x.\n", scsicmd
->cmnd
[0]));
1922 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1923 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1924 ILLEGAL_REQUEST
, SENCODE_INVALID_COMMAND
,
1925 ASENCODE_INVALID_COMMAND
, 0, 0, 0, 0);
1926 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1927 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1928 ? sizeof(scsicmd
->sense_buffer
)
1929 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1930 scsicmd
->scsi_done(scsicmd
);
1935 static int query_disk(struct aac_dev
*dev
, void __user
*arg
)
1937 struct aac_query_disk qd
;
1938 struct fsa_dev_info
*fsa_dev_ptr
;
1940 fsa_dev_ptr
= dev
->fsa_dev
;
1943 if (copy_from_user(&qd
, arg
, sizeof (struct aac_query_disk
)))
1947 else if ((qd
.bus
== -1) && (qd
.id
== -1) && (qd
.lun
== -1))
1949 if (qd
.cnum
< 0 || qd
.cnum
>= dev
->maximum_num_containers
)
1951 qd
.instance
= dev
->scsi_host_ptr
->host_no
;
1953 qd
.id
= CONTAINER_TO_ID(qd
.cnum
);
1954 qd
.lun
= CONTAINER_TO_LUN(qd
.cnum
);
1956 else return -EINVAL
;
1958 qd
.valid
= fsa_dev_ptr
[qd
.cnum
].valid
;
1959 qd
.locked
= fsa_dev_ptr
[qd
.cnum
].locked
;
1960 qd
.deleted
= fsa_dev_ptr
[qd
.cnum
].deleted
;
1962 if (fsa_dev_ptr
[qd
.cnum
].devname
[0] == '\0')
1967 strlcpy(qd
.name
, fsa_dev_ptr
[qd
.cnum
].devname
,
1968 min(sizeof(qd
.name
), sizeof(fsa_dev_ptr
[qd
.cnum
].devname
) + 1));
1970 if (copy_to_user(arg
, &qd
, sizeof (struct aac_query_disk
)))
1975 static int force_delete_disk(struct aac_dev
*dev
, void __user
*arg
)
1977 struct aac_delete_disk dd
;
1978 struct fsa_dev_info
*fsa_dev_ptr
;
1980 fsa_dev_ptr
= dev
->fsa_dev
;
1984 if (copy_from_user(&dd
, arg
, sizeof (struct aac_delete_disk
)))
1987 if (dd
.cnum
>= dev
->maximum_num_containers
)
1990 * Mark this container as being deleted.
1992 fsa_dev_ptr
[dd
.cnum
].deleted
= 1;
1994 * Mark the container as no longer valid
1996 fsa_dev_ptr
[dd
.cnum
].valid
= 0;
2000 static int delete_disk(struct aac_dev
*dev
, void __user
*arg
)
2002 struct aac_delete_disk dd
;
2003 struct fsa_dev_info
*fsa_dev_ptr
;
2005 fsa_dev_ptr
= dev
->fsa_dev
;
2009 if (copy_from_user(&dd
, arg
, sizeof (struct aac_delete_disk
)))
2012 if (dd
.cnum
>= dev
->maximum_num_containers
)
2015 * If the container is locked, it can not be deleted by the API.
2017 if (fsa_dev_ptr
[dd
.cnum
].locked
)
2021 * Mark the container as no longer being valid.
2023 fsa_dev_ptr
[dd
.cnum
].valid
= 0;
2024 fsa_dev_ptr
[dd
.cnum
].devname
[0] = '\0';
2029 int aac_dev_ioctl(struct aac_dev
*dev
, int cmd
, void __user
*arg
)
2032 case FSACTL_QUERY_DISK
:
2033 return query_disk(dev
, arg
);
2034 case FSACTL_DELETE_DISK
:
2035 return delete_disk(dev
, arg
);
2036 case FSACTL_FORCE_DELETE_DISK
:
2037 return force_delete_disk(dev
, arg
);
2038 case FSACTL_GET_CONTAINERS
:
2039 return aac_get_containers(dev
);
2048 * @context: the context set in the fib - here it is scsi cmd
2049 * @fibptr: pointer to the fib
2051 * Handles the completion of a scsi command to a non dasd device
2055 static void aac_srb_callback(void *context
, struct fib
* fibptr
)
2057 struct aac_dev
*dev
;
2058 struct aac_srb_reply
*srbreply
;
2059 struct scsi_cmnd
*scsicmd
;
2061 scsicmd
= (struct scsi_cmnd
*) context
;
2062 scsicmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
2063 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2065 BUG_ON(fibptr
== NULL
);
2067 srbreply
= (struct aac_srb_reply
*) fib_data(fibptr
);
2069 scsicmd
->sense_buffer
[0] = '\0'; /* Initialize sense valid flag to false */
2071 * Calculate resid for sg
2074 scsicmd
->resid
= scsicmd
->request_bufflen
-
2075 le32_to_cpu(srbreply
->data_xfer_length
);
2078 pci_unmap_sg(dev
->pdev
,
2079 (struct scatterlist
*)scsicmd
->request_buffer
,
2081 scsicmd
->sc_data_direction
);
2082 else if(scsicmd
->request_bufflen
)
2083 pci_unmap_single(dev
->pdev
, scsicmd
->SCp
.dma_handle
, scsicmd
->request_bufflen
,
2084 scsicmd
->sc_data_direction
);
2087 * First check the fib status
2090 if (le32_to_cpu(srbreply
->status
) != ST_OK
){
2092 printk(KERN_WARNING
"aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply
->status
));
2093 len
= (le32_to_cpu(srbreply
->sense_data_size
) >
2094 sizeof(scsicmd
->sense_buffer
)) ?
2095 sizeof(scsicmd
->sense_buffer
) :
2096 le32_to_cpu(srbreply
->sense_data_size
);
2097 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
2098 memcpy(scsicmd
->sense_buffer
, srbreply
->sense_data
, len
);
2102 * Next check the srb status
2104 switch( (le32_to_cpu(srbreply
->srb_status
))&0x3f){
2105 case SRB_STATUS_ERROR_RECOVERY
:
2106 case SRB_STATUS_PENDING
:
2107 case SRB_STATUS_SUCCESS
:
2108 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
2110 case SRB_STATUS_DATA_OVERRUN
:
2111 switch(scsicmd
->cmnd
[0]){
2120 if(le32_to_cpu(srbreply
->data_xfer_length
) < scsicmd
->underflow
) {
2121 printk(KERN_WARNING
"aacraid: SCSI CMD underflow\n");
2123 printk(KERN_WARNING
"aacraid: SCSI CMD Data Overrun\n");
2125 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8;
2128 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
2132 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
2136 case SRB_STATUS_ABORTED
:
2137 scsicmd
->result
= DID_ABORT
<< 16 | ABORT
<< 8;
2139 case SRB_STATUS_ABORT_FAILED
:
2140 // Not sure about this one - but assuming the hba was trying to abort for some reason
2141 scsicmd
->result
= DID_ERROR
<< 16 | ABORT
<< 8;
2143 case SRB_STATUS_PARITY_ERROR
:
2144 scsicmd
->result
= DID_PARITY
<< 16 | MSG_PARITY_ERROR
<< 8;
2146 case SRB_STATUS_NO_DEVICE
:
2147 case SRB_STATUS_INVALID_PATH_ID
:
2148 case SRB_STATUS_INVALID_TARGET_ID
:
2149 case SRB_STATUS_INVALID_LUN
:
2150 case SRB_STATUS_SELECTION_TIMEOUT
:
2151 scsicmd
->result
= DID_NO_CONNECT
<< 16 | COMMAND_COMPLETE
<< 8;
2154 case SRB_STATUS_COMMAND_TIMEOUT
:
2155 case SRB_STATUS_TIMEOUT
:
2156 scsicmd
->result
= DID_TIME_OUT
<< 16 | COMMAND_COMPLETE
<< 8;
2159 case SRB_STATUS_BUSY
:
2160 scsicmd
->result
= DID_NO_CONNECT
<< 16 | COMMAND_COMPLETE
<< 8;
2163 case SRB_STATUS_BUS_RESET
:
2164 scsicmd
->result
= DID_RESET
<< 16 | COMMAND_COMPLETE
<< 8;
2167 case SRB_STATUS_MESSAGE_REJECTED
:
2168 scsicmd
->result
= DID_ERROR
<< 16 | MESSAGE_REJECT
<< 8;
2170 case SRB_STATUS_REQUEST_FLUSHED
:
2171 case SRB_STATUS_ERROR
:
2172 case SRB_STATUS_INVALID_REQUEST
:
2173 case SRB_STATUS_REQUEST_SENSE_FAILED
:
2174 case SRB_STATUS_NO_HBA
:
2175 case SRB_STATUS_UNEXPECTED_BUS_FREE
:
2176 case SRB_STATUS_PHASE_SEQUENCE_FAILURE
:
2177 case SRB_STATUS_BAD_SRB_BLOCK_LENGTH
:
2178 case SRB_STATUS_DELAYED_RETRY
:
2179 case SRB_STATUS_BAD_FUNCTION
:
2180 case SRB_STATUS_NOT_STARTED
:
2181 case SRB_STATUS_NOT_IN_USE
:
2182 case SRB_STATUS_FORCE_ABORT
:
2183 case SRB_STATUS_DOMAIN_VALIDATION_FAIL
:
2185 #ifdef AAC_DETAILED_STATUS_INFO
2186 printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",
2187 le32_to_cpu(srbreply
->srb_status
) & 0x3F,
2188 aac_get_status_string(
2189 le32_to_cpu(srbreply
->srb_status
) & 0x3F),
2191 le32_to_cpu(srbreply
->scsi_status
));
2193 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8;
2196 if (le32_to_cpu(srbreply
->scsi_status
) == 0x02 ){ // Check Condition
2198 scsicmd
->result
|= SAM_STAT_CHECK_CONDITION
;
2199 len
= (le32_to_cpu(srbreply
->sense_data_size
) >
2200 sizeof(scsicmd
->sense_buffer
)) ?
2201 sizeof(scsicmd
->sense_buffer
) :
2202 le32_to_cpu(srbreply
->sense_data_size
);
2203 #ifdef AAC_DETAILED_STATUS_INFO
2204 printk(KERN_WARNING
"aac_srb_callback: check condition, status = %d len=%d\n",
2205 le32_to_cpu(srbreply
->status
), len
);
2207 memcpy(scsicmd
->sense_buffer
, srbreply
->sense_data
, len
);
2211 * OR in the scsi status (already shifted up a bit)
2213 scsicmd
->result
|= le32_to_cpu(srbreply
->scsi_status
);
2215 aac_fib_complete(fibptr
);
2216 aac_fib_free(fibptr
);
2217 scsicmd
->scsi_done(scsicmd
);
2223 * @scsicmd: the scsi command block
2225 * This routine will form a FIB and fill in the aac_srb from the
2226 * scsicmd passed in.
2229 static int aac_send_srb_fib(struct scsi_cmnd
* scsicmd
)
2231 struct fib
* cmd_fibcontext
;
2232 struct aac_dev
* dev
;
2235 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2236 if (scmd_id(scsicmd
) >= dev
->maximum_num_physicals
||
2237 scsicmd
->device
->lun
> 7) {
2238 scsicmd
->result
= DID_NO_CONNECT
<< 16;
2239 scsicmd
->scsi_done(scsicmd
);
2244 * Allocate and initialize a Fib then setup a BlockWrite command
2246 if (!(cmd_fibcontext
= aac_fib_alloc(dev
))) {
2249 status
= aac_adapter_scsi(cmd_fibcontext
, scsicmd
);
2252 * Check that the command queued to the controller
2254 if (status
== -EINPROGRESS
) {
2255 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
2259 printk(KERN_WARNING
"aac_srb: aac_fib_send failed with status: %d\n", status
);
2260 aac_fib_complete(cmd_fibcontext
);
2261 aac_fib_free(cmd_fibcontext
);
2266 static unsigned long aac_build_sg(struct scsi_cmnd
* scsicmd
, struct sgmap
* psg
)
2268 struct aac_dev
*dev
;
2269 unsigned long byte_count
= 0;
2271 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2272 // Get rid of old data
2274 psg
->sg
[0].addr
= 0;
2275 psg
->sg
[0].count
= 0;
2276 if (scsicmd
->use_sg
) {
2277 struct scatterlist
*sg
;
2280 sg
= (struct scatterlist
*) scsicmd
->request_buffer
;
2282 sg_count
= pci_map_sg(dev
->pdev
, sg
, scsicmd
->use_sg
,
2283 scsicmd
->sc_data_direction
);
2284 psg
->count
= cpu_to_le32(sg_count
);
2286 for (i
= 0; i
< sg_count
; i
++) {
2287 psg
->sg
[i
].addr
= cpu_to_le32(sg_dma_address(sg
));
2288 psg
->sg
[i
].count
= cpu_to_le32(sg_dma_len(sg
));
2289 byte_count
+= sg_dma_len(sg
);
2292 /* hba wants the size to be exact */
2293 if(byte_count
> scsicmd
->request_bufflen
){
2294 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2295 (byte_count
- scsicmd
->request_bufflen
);
2296 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2297 byte_count
= scsicmd
->request_bufflen
;
2299 /* Check for command underflow */
2300 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2301 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2302 byte_count
, scsicmd
->underflow
);
2305 else if(scsicmd
->request_bufflen
) {
2307 scsicmd
->SCp
.dma_handle
= pci_map_single(dev
->pdev
,
2308 scsicmd
->request_buffer
,
2309 scsicmd
->request_bufflen
,
2310 scsicmd
->sc_data_direction
);
2311 addr
= scsicmd
->SCp
.dma_handle
;
2312 psg
->count
= cpu_to_le32(1);
2313 psg
->sg
[0].addr
= cpu_to_le32(addr
);
2314 psg
->sg
[0].count
= cpu_to_le32(scsicmd
->request_bufflen
);
2315 byte_count
= scsicmd
->request_bufflen
;
2321 static unsigned long aac_build_sg64(struct scsi_cmnd
* scsicmd
, struct sgmap64
* psg
)
2323 struct aac_dev
*dev
;
2324 unsigned long byte_count
= 0;
2327 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2328 // Get rid of old data
2330 psg
->sg
[0].addr
[0] = 0;
2331 psg
->sg
[0].addr
[1] = 0;
2332 psg
->sg
[0].count
= 0;
2333 if (scsicmd
->use_sg
) {
2334 struct scatterlist
*sg
;
2337 sg
= (struct scatterlist
*) scsicmd
->request_buffer
;
2339 sg_count
= pci_map_sg(dev
->pdev
, sg
, scsicmd
->use_sg
,
2340 scsicmd
->sc_data_direction
);
2342 for (i
= 0; i
< sg_count
; i
++) {
2343 int count
= sg_dma_len(sg
);
2344 addr
= sg_dma_address(sg
);
2345 psg
->sg
[i
].addr
[0] = cpu_to_le32(addr
& 0xffffffff);
2346 psg
->sg
[i
].addr
[1] = cpu_to_le32(addr
>>32);
2347 psg
->sg
[i
].count
= cpu_to_le32(count
);
2348 byte_count
+= count
;
2351 psg
->count
= cpu_to_le32(sg_count
);
2352 /* hba wants the size to be exact */
2353 if(byte_count
> scsicmd
->request_bufflen
){
2354 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2355 (byte_count
- scsicmd
->request_bufflen
);
2356 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2357 byte_count
= scsicmd
->request_bufflen
;
2359 /* Check for command underflow */
2360 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2361 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2362 byte_count
, scsicmd
->underflow
);
2365 else if(scsicmd
->request_bufflen
) {
2366 scsicmd
->SCp
.dma_handle
= pci_map_single(dev
->pdev
,
2367 scsicmd
->request_buffer
,
2368 scsicmd
->request_bufflen
,
2369 scsicmd
->sc_data_direction
);
2370 addr
= scsicmd
->SCp
.dma_handle
;
2371 psg
->count
= cpu_to_le32(1);
2372 psg
->sg
[0].addr
[0] = cpu_to_le32(addr
& 0xffffffff);
2373 psg
->sg
[0].addr
[1] = cpu_to_le32(addr
>> 32);
2374 psg
->sg
[0].count
= cpu_to_le32(scsicmd
->request_bufflen
);
2375 byte_count
= scsicmd
->request_bufflen
;
2380 static unsigned long aac_build_sgraw(struct scsi_cmnd
* scsicmd
, struct sgmapraw
* psg
)
2382 struct Scsi_Host
*host
= scsicmd
->device
->host
;
2383 struct aac_dev
*dev
= (struct aac_dev
*)host
->hostdata
;
2384 unsigned long byte_count
= 0;
2386 // Get rid of old data
2388 psg
->sg
[0].next
= 0;
2389 psg
->sg
[0].prev
= 0;
2390 psg
->sg
[0].addr
[0] = 0;
2391 psg
->sg
[0].addr
[1] = 0;
2392 psg
->sg
[0].count
= 0;
2393 psg
->sg
[0].flags
= 0;
2394 if (scsicmd
->use_sg
) {
2395 struct scatterlist
*sg
;
2398 sg
= (struct scatterlist
*) scsicmd
->request_buffer
;
2400 sg_count
= pci_map_sg(dev
->pdev
, sg
, scsicmd
->use_sg
,
2401 scsicmd
->sc_data_direction
);
2403 for (i
= 0; i
< sg_count
; i
++) {
2404 int count
= sg_dma_len(sg
);
2405 u64 addr
= sg_dma_address(sg
);
2406 psg
->sg
[i
].next
= 0;
2407 psg
->sg
[i
].prev
= 0;
2408 psg
->sg
[i
].addr
[1] = cpu_to_le32((u32
)(addr
>>32));
2409 psg
->sg
[i
].addr
[0] = cpu_to_le32((u32
)(addr
& 0xffffffff));
2410 psg
->sg
[i
].count
= cpu_to_le32(count
);
2411 psg
->sg
[i
].flags
= 0;
2412 byte_count
+= count
;
2415 psg
->count
= cpu_to_le32(sg_count
);
2416 /* hba wants the size to be exact */
2417 if(byte_count
> scsicmd
->request_bufflen
){
2418 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2419 (byte_count
- scsicmd
->request_bufflen
);
2420 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2421 byte_count
= scsicmd
->request_bufflen
;
2423 /* Check for command underflow */
2424 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2425 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2426 byte_count
, scsicmd
->underflow
);
2429 else if(scsicmd
->request_bufflen
) {
2432 scsicmd
->SCp
.dma_handle
= pci_map_single(dev
->pdev
,
2433 scsicmd
->request_buffer
,
2434 scsicmd
->request_bufflen
,
2435 scsicmd
->sc_data_direction
);
2436 addr
= scsicmd
->SCp
.dma_handle
;
2437 count
= scsicmd
->request_bufflen
;
2438 psg
->count
= cpu_to_le32(1);
2439 psg
->sg
[0].next
= 0;
2440 psg
->sg
[0].prev
= 0;
2441 psg
->sg
[0].addr
[1] = cpu_to_le32((u32
)(addr
>>32));
2442 psg
->sg
[0].addr
[0] = cpu_to_le32((u32
)(addr
& 0xffffffff));
2443 psg
->sg
[0].count
= cpu_to_le32(count
);
2444 psg
->sg
[0].flags
= 0;
2445 byte_count
= scsicmd
->request_bufflen
;
2450 #ifdef AAC_DETAILED_STATUS_INFO
2452 struct aac_srb_status_info
{
2458 static struct aac_srb_status_info srb_status_info
[] = {
2459 { SRB_STATUS_PENDING
, "Pending Status"},
2460 { SRB_STATUS_SUCCESS
, "Success"},
2461 { SRB_STATUS_ABORTED
, "Aborted Command"},
2462 { SRB_STATUS_ABORT_FAILED
, "Abort Failed"},
2463 { SRB_STATUS_ERROR
, "Error Event"},
2464 { SRB_STATUS_BUSY
, "Device Busy"},
2465 { SRB_STATUS_INVALID_REQUEST
, "Invalid Request"},
2466 { SRB_STATUS_INVALID_PATH_ID
, "Invalid Path ID"},
2467 { SRB_STATUS_NO_DEVICE
, "No Device"},
2468 { SRB_STATUS_TIMEOUT
, "Timeout"},
2469 { SRB_STATUS_SELECTION_TIMEOUT
, "Selection Timeout"},
2470 { SRB_STATUS_COMMAND_TIMEOUT
, "Command Timeout"},
2471 { SRB_STATUS_MESSAGE_REJECTED
, "Message Rejected"},
2472 { SRB_STATUS_BUS_RESET
, "Bus Reset"},
2473 { SRB_STATUS_PARITY_ERROR
, "Parity Error"},
2474 { SRB_STATUS_REQUEST_SENSE_FAILED
,"Request Sense Failed"},
2475 { SRB_STATUS_NO_HBA
, "No HBA"},
2476 { SRB_STATUS_DATA_OVERRUN
, "Data Overrun/Data Underrun"},
2477 { SRB_STATUS_UNEXPECTED_BUS_FREE
,"Unexpected Bus Free"},
2478 { SRB_STATUS_PHASE_SEQUENCE_FAILURE
,"Phase Error"},
2479 { SRB_STATUS_BAD_SRB_BLOCK_LENGTH
,"Bad Srb Block Length"},
2480 { SRB_STATUS_REQUEST_FLUSHED
, "Request Flushed"},
2481 { SRB_STATUS_DELAYED_RETRY
, "Delayed Retry"},
2482 { SRB_STATUS_INVALID_LUN
, "Invalid LUN"},
2483 { SRB_STATUS_INVALID_TARGET_ID
, "Invalid TARGET ID"},
2484 { SRB_STATUS_BAD_FUNCTION
, "Bad Function"},
2485 { SRB_STATUS_ERROR_RECOVERY
, "Error Recovery"},
2486 { SRB_STATUS_NOT_STARTED
, "Not Started"},
2487 { SRB_STATUS_NOT_IN_USE
, "Not In Use"},
2488 { SRB_STATUS_FORCE_ABORT
, "Force Abort"},
2489 { SRB_STATUS_DOMAIN_VALIDATION_FAIL
,"Domain Validation Failure"},
2490 { 0xff, "Unknown Error"}
2493 char *aac_get_status_string(u32 status
)
2497 for (i
= 0; i
< ARRAY_SIZE(srb_status_info
); i
++)
2498 if (srb_status_info
[i
].status
== status
)
2499 return srb_status_info
[i
].str
;
2501 return "Bad Status Code";