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/pci.h>
30 #include <linux/spinlock.h>
31 #include <linux/slab.h>
32 #include <linux/completion.h>
33 #include <linux/blkdev.h>
34 #include <linux/dma-mapping.h>
35 #include <asm/semaphore.h>
36 #include <asm/uaccess.h>
38 #include <scsi/scsi.h>
39 #include <scsi/scsi_cmnd.h>
40 #include <scsi/scsi_device.h>
41 #include <scsi/scsi_host.h>
45 /* values for inqd_pdt: Peripheral device type in plain English */
46 #define INQD_PDT_DA 0x00 /* Direct-access (DISK) device */
47 #define INQD_PDT_PROC 0x03 /* Processor device */
48 #define INQD_PDT_CHNGR 0x08 /* Changer (jukebox, scsi2) */
49 #define INQD_PDT_COMM 0x09 /* Communication device (scsi2) */
50 #define INQD_PDT_NOLUN2 0x1f /* Unknown Device (scsi2) */
51 #define INQD_PDT_NOLUN 0x7f /* Logical Unit Not Present */
53 #define INQD_PDT_DMASK 0x1F /* Peripheral Device Type Mask */
54 #define INQD_PDT_QMASK 0xE0 /* Peripheral Device Qualifer Mask */
60 #define SENCODE_NO_SENSE 0x00
61 #define SENCODE_END_OF_DATA 0x00
62 #define SENCODE_BECOMING_READY 0x04
63 #define SENCODE_INIT_CMD_REQUIRED 0x04
64 #define SENCODE_PARAM_LIST_LENGTH_ERROR 0x1A
65 #define SENCODE_INVALID_COMMAND 0x20
66 #define SENCODE_LBA_OUT_OF_RANGE 0x21
67 #define SENCODE_INVALID_CDB_FIELD 0x24
68 #define SENCODE_LUN_NOT_SUPPORTED 0x25
69 #define SENCODE_INVALID_PARAM_FIELD 0x26
70 #define SENCODE_PARAM_NOT_SUPPORTED 0x26
71 #define SENCODE_PARAM_VALUE_INVALID 0x26
72 #define SENCODE_RESET_OCCURRED 0x29
73 #define SENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x3E
74 #define SENCODE_INQUIRY_DATA_CHANGED 0x3F
75 #define SENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x39
76 #define SENCODE_DIAGNOSTIC_FAILURE 0x40
77 #define SENCODE_INTERNAL_TARGET_FAILURE 0x44
78 #define SENCODE_INVALID_MESSAGE_ERROR 0x49
79 #define SENCODE_LUN_FAILED_SELF_CONFIG 0x4c
80 #define SENCODE_OVERLAPPED_COMMAND 0x4E
83 * Additional sense codes
86 #define ASENCODE_NO_SENSE 0x00
87 #define ASENCODE_END_OF_DATA 0x05
88 #define ASENCODE_BECOMING_READY 0x01
89 #define ASENCODE_INIT_CMD_REQUIRED 0x02
90 #define ASENCODE_PARAM_LIST_LENGTH_ERROR 0x00
91 #define ASENCODE_INVALID_COMMAND 0x00
92 #define ASENCODE_LBA_OUT_OF_RANGE 0x00
93 #define ASENCODE_INVALID_CDB_FIELD 0x00
94 #define ASENCODE_LUN_NOT_SUPPORTED 0x00
95 #define ASENCODE_INVALID_PARAM_FIELD 0x00
96 #define ASENCODE_PARAM_NOT_SUPPORTED 0x01
97 #define ASENCODE_PARAM_VALUE_INVALID 0x02
98 #define ASENCODE_RESET_OCCURRED 0x00
99 #define ASENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x00
100 #define ASENCODE_INQUIRY_DATA_CHANGED 0x03
101 #define ASENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x00
102 #define ASENCODE_DIAGNOSTIC_FAILURE 0x80
103 #define ASENCODE_INTERNAL_TARGET_FAILURE 0x00
104 #define ASENCODE_INVALID_MESSAGE_ERROR 0x00
105 #define ASENCODE_LUN_FAILED_SELF_CONFIG 0x00
106 #define ASENCODE_OVERLAPPED_COMMAND 0x00
108 #define BYTE0(x) (unsigned char)(x)
109 #define BYTE1(x) (unsigned char)((x) >> 8)
110 #define BYTE2(x) (unsigned char)((x) >> 16)
111 #define BYTE3(x) (unsigned char)((x) >> 24)
113 /*------------------------------------------------------------------------------
114 * S T R U C T S / T Y P E D E F S
115 *----------------------------------------------------------------------------*/
116 /* SCSI inquiry data */
117 struct inquiry_data
{
118 u8 inqd_pdt
; /* Peripheral qualifier | Peripheral Device Type */
119 u8 inqd_dtq
; /* RMB | Device Type Qualifier */
120 u8 inqd_ver
; /* ISO version | ECMA version | ANSI-approved version */
121 u8 inqd_rdf
; /* AENC | TrmIOP | Response data format */
122 u8 inqd_len
; /* Additional length (n-4) */
123 u8 inqd_pad1
[2];/* Reserved - must be zero */
124 u8 inqd_pad2
; /* RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
125 u8 inqd_vid
[8]; /* Vendor ID */
126 u8 inqd_pid
[16];/* Product ID */
127 u8 inqd_prl
[4]; /* Product Revision Level */
131 * M O D U L E G L O B A L S
134 static unsigned long aac_build_sg(struct scsi_cmnd
* scsicmd
, struct sgmap
* sgmap
);
135 static unsigned long aac_build_sg64(struct scsi_cmnd
* scsicmd
, struct sgmap64
* psg
);
136 static unsigned long aac_build_sgraw(struct scsi_cmnd
* scsicmd
, struct sgmapraw
* psg
);
137 static int aac_send_srb_fib(struct scsi_cmnd
* scsicmd
);
138 #ifdef AAC_DETAILED_STATUS_INFO
139 static char *aac_get_status_string(u32 status
);
143 * Non dasd selection is handled entirely in aachba now
146 static int nondasd
= -1;
147 static int dacmode
= -1;
149 static int commit
= -1;
150 int startup_timeout
= 180;
151 int aif_timeout
= 120;
153 module_param(nondasd
, int, S_IRUGO
|S_IWUSR
);
154 MODULE_PARM_DESC(nondasd
, "Control scanning of hba for nondasd devices. 0=off, 1=on");
155 module_param(dacmode
, int, S_IRUGO
|S_IWUSR
);
156 MODULE_PARM_DESC(dacmode
, "Control whether dma addressing is using 64 bit DAC. 0=off, 1=on");
157 module_param(commit
, int, S_IRUGO
|S_IWUSR
);
158 MODULE_PARM_DESC(commit
, "Control whether a COMMIT_CONFIG is issued to the adapter for foreign arrays.\nThis is typically needed in systems that do not have a BIOS. 0=off, 1=on");
159 module_param(startup_timeout
, int, S_IRUGO
|S_IWUSR
);
160 MODULE_PARM_DESC(startup_timeout
, "The duration of time in seconds to wait for adapter to have it's kernel up and\nrunning. This is typically adjusted for large systems that do not have a BIOS.");
161 module_param(aif_timeout
, int, S_IRUGO
|S_IWUSR
);
162 MODULE_PARM_DESC(aif_timeout
, "The duration of time in seconds to wait for applications to pick up AIFs before\nderegistering them. This is typically adjusted for heavily burdened systems.");
165 module_param(numacb
, int, S_IRUGO
|S_IWUSR
);
166 MODULE_PARM_DESC(numacb
, "Request a limit to the number of adapter control blocks (FIB) allocated. Valid values are 512 and down. Default is to use suggestion from Firmware.");
169 module_param(acbsize
, int, S_IRUGO
|S_IWUSR
);
170 MODULE_PARM_DESC(acbsize
, "Request a specific adapter control block (FIB) size. Valid values are 512, 2048, 4096 and 8192. Default is to use suggestion from Firmware.");
172 int expose_physicals
= -1;
173 module_param(expose_physicals
, int, S_IRUGO
|S_IWUSR
);
174 MODULE_PARM_DESC(expose_physicals
, "Expose physical components of the arrays. -1=protect 0=off, 1=on");
176 * aac_get_config_status - check the adapter configuration
177 * @common: adapter to query
179 * Query config status, and commit the configuration if needed.
181 int aac_get_config_status(struct aac_dev
*dev
, int commit_flag
)
186 if (!(fibptr
= aac_fib_alloc(dev
)))
189 aac_fib_init(fibptr
);
191 struct aac_get_config_status
*dinfo
;
192 dinfo
= (struct aac_get_config_status
*) fib_data(fibptr
);
194 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
195 dinfo
->type
= cpu_to_le32(CT_GET_CONFIG_STATUS
);
196 dinfo
->count
= cpu_to_le32(sizeof(((struct aac_get_config_status_resp
*)NULL
)->data
));
199 status
= aac_fib_send(ContainerCommand
,
201 sizeof (struct aac_get_config_status
),
206 printk(KERN_WARNING
"aac_get_config_status: SendFIB failed.\n");
208 struct aac_get_config_status_resp
*reply
209 = (struct aac_get_config_status_resp
*) fib_data(fibptr
);
210 dprintk((KERN_WARNING
211 "aac_get_config_status: response=%d status=%d action=%d\n",
212 le32_to_cpu(reply
->response
),
213 le32_to_cpu(reply
->status
),
214 le32_to_cpu(reply
->data
.action
)));
215 if ((le32_to_cpu(reply
->response
) != ST_OK
) ||
216 (le32_to_cpu(reply
->status
) != CT_OK
) ||
217 (le32_to_cpu(reply
->data
.action
) > CFACT_PAUSE
)) {
218 printk(KERN_WARNING
"aac_get_config_status: Will not issue the Commit Configuration\n");
222 aac_fib_complete(fibptr
);
223 /* Send a CT_COMMIT_CONFIG to enable discovery of devices */
225 if ((commit
== 1) || commit_flag
) {
226 struct aac_commit_config
* dinfo
;
227 aac_fib_init(fibptr
);
228 dinfo
= (struct aac_commit_config
*) fib_data(fibptr
);
230 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
231 dinfo
->type
= cpu_to_le32(CT_COMMIT_CONFIG
);
233 status
= aac_fib_send(ContainerCommand
,
235 sizeof (struct aac_commit_config
),
239 aac_fib_complete(fibptr
);
240 } else if (commit
== 0) {
242 "aac_get_config_status: Foreign device configurations are being ignored\n");
245 aac_fib_free(fibptr
);
250 * aac_get_containers - list containers
251 * @common: adapter to probe
253 * Make a list of all containers on this controller
255 int aac_get_containers(struct aac_dev
*dev
)
257 struct fsa_dev_info
*fsa_dev_ptr
;
262 struct aac_get_container_count
*dinfo
;
263 struct aac_get_container_count_resp
*dresp
;
264 int maximum_num_containers
= MAXIMUM_NUM_CONTAINERS
;
266 instance
= dev
->scsi_host_ptr
->unique_id
;
268 if (!(fibptr
= aac_fib_alloc(dev
)))
271 aac_fib_init(fibptr
);
272 dinfo
= (struct aac_get_container_count
*) fib_data(fibptr
);
273 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
274 dinfo
->type
= cpu_to_le32(CT_GET_CONTAINER_COUNT
);
276 status
= aac_fib_send(ContainerCommand
,
278 sizeof (struct aac_get_container_count
),
283 dresp
= (struct aac_get_container_count_resp
*)fib_data(fibptr
);
284 maximum_num_containers
= le32_to_cpu(dresp
->ContainerSwitchEntries
);
285 aac_fib_complete(fibptr
);
288 if (maximum_num_containers
< MAXIMUM_NUM_CONTAINERS
)
289 maximum_num_containers
= MAXIMUM_NUM_CONTAINERS
;
290 fsa_dev_ptr
= kmalloc(
291 sizeof(*fsa_dev_ptr
) * maximum_num_containers
, GFP_KERNEL
);
293 aac_fib_free(fibptr
);
296 memset(fsa_dev_ptr
, 0, sizeof(*fsa_dev_ptr
) * maximum_num_containers
);
298 dev
->fsa_dev
= fsa_dev_ptr
;
299 dev
->maximum_num_containers
= maximum_num_containers
;
301 for (index
= 0; index
< dev
->maximum_num_containers
; index
++) {
302 struct aac_query_mount
*dinfo
;
303 struct aac_mount
*dresp
;
305 fsa_dev_ptr
[index
].devname
[0] = '\0';
307 aac_fib_init(fibptr
);
308 dinfo
= (struct aac_query_mount
*) fib_data(fibptr
);
310 dinfo
->command
= cpu_to_le32(VM_NameServe
);
311 dinfo
->count
= cpu_to_le32(index
);
312 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
314 status
= aac_fib_send(ContainerCommand
,
316 sizeof (struct aac_query_mount
),
321 printk(KERN_WARNING
"aac_get_containers: SendFIB failed.\n");
324 dresp
= (struct aac_mount
*)fib_data(fibptr
);
326 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
327 (le32_to_cpu(dresp
->mnt
[0].vol
) == CT_NONE
)) {
328 dinfo
->command
= cpu_to_le32(VM_NameServe64
);
329 dinfo
->count
= cpu_to_le32(index
);
330 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
332 if (aac_fib_send(ContainerCommand
,
334 sizeof(struct aac_query_mount
),
340 dresp
->mnt
[0].capacityhigh
= 0;
343 "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%llu\n",
344 (int)index
, (int)le32_to_cpu(dresp
->status
),
345 (int)le32_to_cpu(dresp
->mnt
[0].vol
),
346 (int)le32_to_cpu(dresp
->mnt
[0].state
),
347 ((u64
)le32_to_cpu(dresp
->mnt
[0].capacity
)) +
348 (((u64
)le32_to_cpu(dresp
->mnt
[0].capacityhigh
)) << 32)));
349 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
350 (le32_to_cpu(dresp
->mnt
[0].vol
) != CT_NONE
) &&
351 (le32_to_cpu(dresp
->mnt
[0].state
) != FSCS_HIDDEN
)) {
352 fsa_dev_ptr
[index
].valid
= 1;
353 fsa_dev_ptr
[index
].type
= le32_to_cpu(dresp
->mnt
[0].vol
);
354 fsa_dev_ptr
[index
].size
355 = ((u64
)le32_to_cpu(dresp
->mnt
[0].capacity
)) +
356 (((u64
)le32_to_cpu(dresp
->mnt
[0].capacityhigh
)) << 32);
357 if (le32_to_cpu(dresp
->mnt
[0].state
) & FSCS_READONLY
)
358 fsa_dev_ptr
[index
].ro
= 1;
360 aac_fib_complete(fibptr
);
362 * If there are no more containers, then stop asking.
364 if ((index
+ 1) >= le32_to_cpu(dresp
->count
)){
368 aac_fib_free(fibptr
);
372 static void aac_internal_transfer(struct scsi_cmnd
*scsicmd
, void *data
, unsigned int offset
, unsigned int len
)
375 unsigned int transfer_len
;
376 struct scatterlist
*sg
= scsicmd
->request_buffer
;
378 if (scsicmd
->use_sg
) {
379 buf
= kmap_atomic(sg
->page
, KM_IRQ0
) + sg
->offset
;
380 transfer_len
= min(sg
->length
, len
+ offset
);
382 buf
= scsicmd
->request_buffer
;
383 transfer_len
= min(scsicmd
->request_bufflen
, len
+ offset
);
386 memcpy(buf
+ offset
, data
, transfer_len
- offset
);
389 kunmap_atomic(buf
- sg
->offset
, KM_IRQ0
);
393 static void get_container_name_callback(void *context
, struct fib
* fibptr
)
395 struct aac_get_name_resp
* get_name_reply
;
396 struct scsi_cmnd
* scsicmd
;
398 scsicmd
= (struct scsi_cmnd
*) context
;
399 scsicmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
401 dprintk((KERN_DEBUG
"get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies
));
402 BUG_ON(fibptr
== NULL
);
404 get_name_reply
= (struct aac_get_name_resp
*) fib_data(fibptr
);
405 /* Failure is irrelevant, using default value instead */
406 if ((le32_to_cpu(get_name_reply
->status
) == CT_OK
)
407 && (get_name_reply
->data
[0] != '\0')) {
408 char *sp
= get_name_reply
->data
;
409 sp
[sizeof(((struct aac_get_name_resp
*)NULL
)->data
)-1] = '\0';
413 char d
[sizeof(((struct inquiry_data
*)NULL
)->inqd_pid
)];
414 int count
= sizeof(d
);
417 *dp
++ = (*sp
) ? *sp
++ : ' ';
418 } while (--count
> 0);
419 aac_internal_transfer(scsicmd
, d
,
420 offsetof(struct inquiry_data
, inqd_pid
), sizeof(d
));
424 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
426 aac_fib_complete(fibptr
);
427 aac_fib_free(fibptr
);
428 scsicmd
->scsi_done(scsicmd
);
432 * aac_get_container_name - get container name, none blocking.
434 static int aac_get_container_name(struct scsi_cmnd
* scsicmd
, int cid
)
437 struct aac_get_name
*dinfo
;
438 struct fib
* cmd_fibcontext
;
439 struct aac_dev
* dev
;
441 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
443 if (!(cmd_fibcontext
= aac_fib_alloc(dev
)))
446 aac_fib_init(cmd_fibcontext
);
447 dinfo
= (struct aac_get_name
*) fib_data(cmd_fibcontext
);
449 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
450 dinfo
->type
= cpu_to_le32(CT_READ_NAME
);
451 dinfo
->cid
= cpu_to_le32(cid
);
452 dinfo
->count
= cpu_to_le32(sizeof(((struct aac_get_name_resp
*)NULL
)->data
));
454 status
= aac_fib_send(ContainerCommand
,
456 sizeof (struct aac_get_name
),
459 (fib_callback
) get_container_name_callback
,
463 * Check that the command queued to the controller
465 if (status
== -EINPROGRESS
) {
466 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
470 printk(KERN_WARNING
"aac_get_container_name: aac_fib_send failed with status: %d.\n", status
);
471 aac_fib_complete(cmd_fibcontext
);
472 aac_fib_free(cmd_fibcontext
);
477 * aac_probe_container - query a logical volume
478 * @dev: device to query
479 * @cid: container identifier
481 * Queries the controller about the given volume. The volume information
482 * is updated in the struct fsa_dev_info structure rather than returned.
485 int aac_probe_container(struct aac_dev
*dev
, int cid
)
487 struct fsa_dev_info
*fsa_dev_ptr
;
489 struct aac_query_mount
*dinfo
;
490 struct aac_mount
*dresp
;
494 fsa_dev_ptr
= dev
->fsa_dev
;
497 instance
= dev
->scsi_host_ptr
->unique_id
;
499 if (!(fibptr
= aac_fib_alloc(dev
)))
502 aac_fib_init(fibptr
);
504 dinfo
= (struct aac_query_mount
*)fib_data(fibptr
);
506 dinfo
->command
= cpu_to_le32(VM_NameServe
);
507 dinfo
->count
= cpu_to_le32(cid
);
508 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
510 status
= aac_fib_send(ContainerCommand
,
512 sizeof(struct aac_query_mount
),
517 printk(KERN_WARNING
"aacraid: aac_probe_container query failed.\n");
521 dresp
= (struct aac_mount
*) fib_data(fibptr
);
523 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
524 (le32_to_cpu(dresp
->mnt
[0].vol
) == CT_NONE
)) {
525 dinfo
->command
= cpu_to_le32(VM_NameServe64
);
526 dinfo
->count
= cpu_to_le32(cid
);
527 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
529 if (aac_fib_send(ContainerCommand
,
531 sizeof(struct aac_query_mount
),
537 dresp
->mnt
[0].capacityhigh
= 0;
539 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
540 (le32_to_cpu(dresp
->mnt
[0].vol
) != CT_NONE
) &&
541 (le32_to_cpu(dresp
->mnt
[0].state
) != FSCS_HIDDEN
)) {
542 fsa_dev_ptr
[cid
].valid
= 1;
543 fsa_dev_ptr
[cid
].type
= le32_to_cpu(dresp
->mnt
[0].vol
);
544 fsa_dev_ptr
[cid
].size
545 = ((u64
)le32_to_cpu(dresp
->mnt
[0].capacity
)) +
546 (((u64
)le32_to_cpu(dresp
->mnt
[0].capacityhigh
)) << 32);
547 if (le32_to_cpu(dresp
->mnt
[0].state
) & FSCS_READONLY
)
548 fsa_dev_ptr
[cid
].ro
= 1;
552 aac_fib_complete(fibptr
);
553 aac_fib_free(fibptr
);
558 /* Local Structure to set SCSI inquiry data strings */
560 char vid
[8]; /* Vendor ID */
561 char pid
[16]; /* Product ID */
562 char prl
[4]; /* Product Revision Level */
566 * InqStrCopy - string merge
567 * @a: string to copy from
568 * @b: string to copy to
570 * Copy a String from one location to another
574 static void inqstrcpy(char *a
, char *b
)
581 static char *container_types
[] = {
607 /* Function: setinqstr
609 * Arguments: [1] pointer to void [1] int
611 * Purpose: Sets SCSI inquiry data strings for vendor, product
612 * and revision level. Allows strings to be set in platform dependant
613 * files instead of in OS dependant driver source.
616 static void setinqstr(struct aac_dev
*dev
, void *data
, int tindex
)
618 struct scsi_inq
*str
;
620 str
= (struct scsi_inq
*)(data
); /* cast data to scsi inq block */
621 memset(str
, ' ', sizeof(*str
));
623 if (dev
->supplement_adapter_info
.AdapterTypeText
[0]) {
624 char * cp
= dev
->supplement_adapter_info
.AdapterTypeText
;
625 int c
= sizeof(str
->vid
);
626 while (*cp
&& *cp
!= ' ' && --c
)
630 inqstrcpy (dev
->supplement_adapter_info
.AdapterTypeText
,
633 while (*cp
&& *cp
!= ' ')
637 /* last six chars reserved for vol type */
639 if (strlen(cp
) > sizeof(str
->pid
)) {
640 c
= cp
[sizeof(str
->pid
)];
641 cp
[sizeof(str
->pid
)] = '\0';
643 inqstrcpy (cp
, str
->pid
);
645 cp
[sizeof(str
->pid
)] = c
;
647 struct aac_driver_ident
*mp
= aac_get_driver_ident(dev
->cardtype
);
649 inqstrcpy (mp
->vname
, str
->vid
);
650 /* last six chars reserved for vol type */
651 inqstrcpy (mp
->model
, str
->pid
);
654 if (tindex
< ARRAY_SIZE(container_types
)){
655 char *findit
= str
->pid
;
657 for ( ; *findit
!= ' '; findit
++); /* walk till we find a space */
658 /* RAID is superfluous in the context of a RAID device */
659 if (memcmp(findit
-4, "RAID", 4) == 0)
660 *(findit
-= 4) = ' ';
661 if (((findit
- str
->pid
) + strlen(container_types
[tindex
]))
662 < (sizeof(str
->pid
) + sizeof(str
->prl
)))
663 inqstrcpy (container_types
[tindex
], findit
+ 1);
665 inqstrcpy ("V1.0", str
->prl
);
668 static void set_sense(u8
*sense_buf
, u8 sense_key
, u8 sense_code
,
669 u8 a_sense_code
, u8 incorrect_length
,
670 u8 bit_pointer
, u16 field_pointer
,
673 sense_buf
[0] = 0xF0; /* Sense data valid, err code 70h (current error) */
674 sense_buf
[1] = 0; /* Segment number, always zero */
676 if (incorrect_length
) {
677 sense_buf
[2] = sense_key
| 0x20;/* Set ILI bit | sense key */
678 sense_buf
[3] = BYTE3(residue
);
679 sense_buf
[4] = BYTE2(residue
);
680 sense_buf
[5] = BYTE1(residue
);
681 sense_buf
[6] = BYTE0(residue
);
683 sense_buf
[2] = sense_key
; /* Sense key */
685 if (sense_key
== ILLEGAL_REQUEST
)
686 sense_buf
[7] = 10; /* Additional sense length */
688 sense_buf
[7] = 6; /* Additional sense length */
690 sense_buf
[12] = sense_code
; /* Additional sense code */
691 sense_buf
[13] = a_sense_code
; /* Additional sense code qualifier */
692 if (sense_key
== ILLEGAL_REQUEST
) {
695 if (sense_code
== SENCODE_INVALID_PARAM_FIELD
)
696 sense_buf
[15] = 0x80;/* Std sense key specific field */
697 /* Illegal parameter is in the parameter block */
699 if (sense_code
== SENCODE_INVALID_CDB_FIELD
)
700 sense_buf
[15] = 0xc0;/* Std sense key specific field */
701 /* Illegal parameter is in the CDB block */
702 sense_buf
[15] |= bit_pointer
;
703 sense_buf
[16] = field_pointer
>> 8; /* MSB */
704 sense_buf
[17] = field_pointer
; /* LSB */
708 static int aac_bounds_32(struct aac_dev
* dev
, struct scsi_cmnd
* cmd
, u64 lba
)
710 if (lba
& 0xffffffff00000000LL
) {
711 int cid
= scmd_id(cmd
);
712 dprintk((KERN_DEBUG
"aacraid: Illegal lba\n"));
713 cmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
714 SAM_STAT_CHECK_CONDITION
;
715 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
717 SENCODE_INTERNAL_TARGET_FAILURE
,
718 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
720 memcpy(cmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
721 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(cmd
->sense_buffer
))
722 ? sizeof(cmd
->sense_buffer
)
723 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
730 static int aac_bounds_64(struct aac_dev
* dev
, struct scsi_cmnd
* cmd
, u64 lba
)
735 static void io_callback(void *context
, struct fib
* fibptr
);
737 static int aac_read_raw_io(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
740 struct aac_raw_io
*readcmd
;
742 readcmd
= (struct aac_raw_io
*) fib_data(fib
);
743 readcmd
->block
[0] = cpu_to_le32((u32
)(lba
&0xffffffff));
744 readcmd
->block
[1] = cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
745 readcmd
->count
= cpu_to_le32(count
<<9);
746 readcmd
->cid
= cpu_to_le16(scmd_id(cmd
));
747 readcmd
->flags
= cpu_to_le16(1);
748 readcmd
->bpTotal
= 0;
749 readcmd
->bpComplete
= 0;
751 aac_build_sgraw(cmd
, &readcmd
->sg
);
752 fibsize
= sizeof(struct aac_raw_io
) + ((le32_to_cpu(readcmd
->sg
.count
) - 1) * sizeof (struct sgentryraw
));
753 BUG_ON(fibsize
> (fib
->dev
->max_fib_size
- sizeof(struct aac_fibhdr
)));
755 * Now send the Fib to the adapter
757 return aac_fib_send(ContainerRawIo
,
762 (fib_callback
) io_callback
,
766 static int aac_read_block64(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
769 struct aac_read64
*readcmd
;
771 readcmd
= (struct aac_read64
*) fib_data(fib
);
772 readcmd
->command
= cpu_to_le32(VM_CtHostRead64
);
773 readcmd
->cid
= cpu_to_le16(scmd_id(cmd
));
774 readcmd
->sector_count
= cpu_to_le16(count
);
775 readcmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
779 aac_build_sg64(cmd
, &readcmd
->sg
);
780 fibsize
= sizeof(struct aac_read64
) +
781 ((le32_to_cpu(readcmd
->sg
.count
) - 1) *
782 sizeof (struct sgentry64
));
783 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
784 sizeof(struct aac_fibhdr
)));
786 * Now send the Fib to the adapter
788 return aac_fib_send(ContainerCommand64
,
793 (fib_callback
) io_callback
,
797 static int aac_read_block(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
800 struct aac_read
*readcmd
;
802 readcmd
= (struct aac_read
*) fib_data(fib
);
803 readcmd
->command
= cpu_to_le32(VM_CtBlockRead
);
804 readcmd
->cid
= cpu_to_le16(scmd_id(cmd
));
805 readcmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
806 readcmd
->count
= cpu_to_le32(count
* 512);
808 aac_build_sg(cmd
, &readcmd
->sg
);
809 fibsize
= sizeof(struct aac_read
) +
810 ((le32_to_cpu(readcmd
->sg
.count
) - 1) *
811 sizeof (struct sgentry
));
812 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
813 sizeof(struct aac_fibhdr
)));
815 * Now send the Fib to the adapter
817 return aac_fib_send(ContainerCommand
,
822 (fib_callback
) io_callback
,
826 static int aac_write_raw_io(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
829 struct aac_raw_io
*writecmd
;
831 writecmd
= (struct aac_raw_io
*) fib_data(fib
);
832 writecmd
->block
[0] = cpu_to_le32((u32
)(lba
&0xffffffff));
833 writecmd
->block
[1] = cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
834 writecmd
->count
= cpu_to_le32(count
<<9);
835 writecmd
->cid
= cpu_to_le16(scmd_id(cmd
));
837 writecmd
->bpTotal
= 0;
838 writecmd
->bpComplete
= 0;
840 aac_build_sgraw(cmd
, &writecmd
->sg
);
841 fibsize
= sizeof(struct aac_raw_io
) + ((le32_to_cpu(writecmd
->sg
.count
) - 1) * sizeof (struct sgentryraw
));
842 BUG_ON(fibsize
> (fib
->dev
->max_fib_size
- sizeof(struct aac_fibhdr
)));
844 * Now send the Fib to the adapter
846 return aac_fib_send(ContainerRawIo
,
851 (fib_callback
) io_callback
,
855 static int aac_write_block64(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
858 struct aac_write64
*writecmd
;
860 writecmd
= (struct aac_write64
*) fib_data(fib
);
861 writecmd
->command
= cpu_to_le32(VM_CtHostWrite64
);
862 writecmd
->cid
= cpu_to_le16(scmd_id(cmd
));
863 writecmd
->sector_count
= cpu_to_le16(count
);
864 writecmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
868 aac_build_sg64(cmd
, &writecmd
->sg
);
869 fibsize
= sizeof(struct aac_write64
) +
870 ((le32_to_cpu(writecmd
->sg
.count
) - 1) *
871 sizeof (struct sgentry64
));
872 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
873 sizeof(struct aac_fibhdr
)));
875 * Now send the Fib to the adapter
877 return aac_fib_send(ContainerCommand64
,
882 (fib_callback
) io_callback
,
886 static int aac_write_block(struct fib
* fib
, struct scsi_cmnd
* cmd
, u64 lba
, u32 count
)
889 struct aac_write
*writecmd
;
891 writecmd
= (struct aac_write
*) fib_data(fib
);
892 writecmd
->command
= cpu_to_le32(VM_CtBlockWrite
);
893 writecmd
->cid
= cpu_to_le16(scmd_id(cmd
));
894 writecmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
895 writecmd
->count
= cpu_to_le32(count
* 512);
896 writecmd
->sg
.count
= cpu_to_le32(1);
897 /* ->stable is not used - it did mean which type of write */
899 aac_build_sg(cmd
, &writecmd
->sg
);
900 fibsize
= sizeof(struct aac_write
) +
901 ((le32_to_cpu(writecmd
->sg
.count
) - 1) *
902 sizeof (struct sgentry
));
903 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
904 sizeof(struct aac_fibhdr
)));
906 * Now send the Fib to the adapter
908 return aac_fib_send(ContainerCommand
,
913 (fib_callback
) io_callback
,
917 static struct aac_srb
* aac_scsi_common(struct fib
* fib
, struct scsi_cmnd
* cmd
)
919 struct aac_srb
* srbcmd
;
924 switch(cmd
->sc_data_direction
){
928 case DMA_BIDIRECTIONAL
:
929 flag
= SRB_DataIn
| SRB_DataOut
;
931 case DMA_FROM_DEVICE
:
935 default: /* shuts up some versions of gcc */
936 flag
= SRB_NoDataXfer
;
940 srbcmd
= (struct aac_srb
*) fib_data(fib
);
941 srbcmd
->function
= cpu_to_le32(SRBF_ExecuteScsi
);
942 srbcmd
->channel
= cpu_to_le32(aac_logical_to_phys(scmd_channel(cmd
)));
943 srbcmd
->id
= cpu_to_le32(scmd_id(cmd
));
944 srbcmd
->lun
= cpu_to_le32(cmd
->device
->lun
);
945 srbcmd
->flags
= cpu_to_le32(flag
);
946 timeout
= cmd
->timeout_per_command
/HZ
;
949 srbcmd
->timeout
= cpu_to_le32(timeout
); // timeout in seconds
950 srbcmd
->retry_limit
= 0; /* Obsolete parameter */
951 srbcmd
->cdb_size
= cpu_to_le32(cmd
->cmd_len
);
955 static void aac_srb_callback(void *context
, struct fib
* fibptr
);
957 static int aac_scsi_64(struct fib
* fib
, struct scsi_cmnd
* cmd
)
960 struct aac_srb
* srbcmd
= aac_scsi_common(fib
, cmd
);
962 aac_build_sg64(cmd
, (struct sgmap64
*) &srbcmd
->sg
);
963 srbcmd
->count
= cpu_to_le32(cmd
->request_bufflen
);
965 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
966 memcpy(srbcmd
->cdb
, cmd
->cmnd
, cmd
->cmd_len
);
968 * Build Scatter/Gather list
970 fibsize
= sizeof (struct aac_srb
) - sizeof (struct sgentry
) +
971 ((le32_to_cpu(srbcmd
->sg
.count
) & 0xff) *
972 sizeof (struct sgentry64
));
973 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
974 sizeof(struct aac_fibhdr
)));
977 * Now send the Fib to the adapter
979 return aac_fib_send(ScsiPortCommand64
, fib
,
980 fibsize
, FsaNormal
, 0, 1,
981 (fib_callback
) aac_srb_callback
,
985 static int aac_scsi_32(struct fib
* fib
, struct scsi_cmnd
* cmd
)
988 struct aac_srb
* srbcmd
= aac_scsi_common(fib
, cmd
);
990 aac_build_sg(cmd
, (struct sgmap
*)&srbcmd
->sg
);
991 srbcmd
->count
= cpu_to_le32(cmd
->request_bufflen
);
993 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
994 memcpy(srbcmd
->cdb
, cmd
->cmnd
, cmd
->cmd_len
);
996 * Build Scatter/Gather list
998 fibsize
= sizeof (struct aac_srb
) +
999 (((le32_to_cpu(srbcmd
->sg
.count
) & 0xff) - 1) *
1000 sizeof (struct sgentry
));
1001 BUG_ON (fibsize
> (fib
->dev
->max_fib_size
-
1002 sizeof(struct aac_fibhdr
)));
1005 * Now send the Fib to the adapter
1007 return aac_fib_send(ScsiPortCommand
, fib
, fibsize
, FsaNormal
, 0, 1,
1008 (fib_callback
) aac_srb_callback
, (void *) cmd
);
1011 int aac_get_adapter_info(struct aac_dev
* dev
)
1016 struct aac_adapter_info
*info
;
1017 struct aac_bus_info
*command
;
1018 struct aac_bus_info_response
*bus_info
;
1020 if (!(fibptr
= aac_fib_alloc(dev
)))
1023 aac_fib_init(fibptr
);
1024 info
= (struct aac_adapter_info
*) fib_data(fibptr
);
1025 memset(info
,0,sizeof(*info
));
1027 rcode
= aac_fib_send(RequestAdapterInfo
,
1031 -1, 1, /* First `interrupt' command uses special wait */
1036 aac_fib_complete(fibptr
);
1037 aac_fib_free(fibptr
);
1040 memcpy(&dev
->adapter_info
, info
, sizeof(*info
));
1042 if (dev
->adapter_info
.options
& AAC_OPT_SUPPLEMENT_ADAPTER_INFO
) {
1043 struct aac_supplement_adapter_info
* info
;
1045 aac_fib_init(fibptr
);
1047 info
= (struct aac_supplement_adapter_info
*) fib_data(fibptr
);
1049 memset(info
,0,sizeof(*info
));
1051 rcode
= aac_fib_send(RequestSupplementAdapterInfo
,
1060 memcpy(&dev
->supplement_adapter_info
, info
, sizeof(*info
));
1068 aac_fib_init(fibptr
);
1070 bus_info
= (struct aac_bus_info_response
*) fib_data(fibptr
);
1072 memset(bus_info
, 0, sizeof(*bus_info
));
1074 command
= (struct aac_bus_info
*)bus_info
;
1076 command
->Command
= cpu_to_le32(VM_Ioctl
);
1077 command
->ObjType
= cpu_to_le32(FT_DRIVE
);
1078 command
->MethodId
= cpu_to_le32(1);
1079 command
->CtlCmd
= cpu_to_le32(GetBusInfo
);
1081 rcode
= aac_fib_send(ContainerCommand
,
1088 if (rcode
>= 0 && le32_to_cpu(bus_info
->Status
) == ST_OK
) {
1089 dev
->maximum_num_physicals
= le32_to_cpu(bus_info
->TargetsPerBus
);
1090 dev
->maximum_num_channels
= le32_to_cpu(bus_info
->BusCount
);
1093 if (!dev
->in_reset
) {
1094 tmp
= le32_to_cpu(dev
->adapter_info
.kernelrev
);
1095 printk(KERN_INFO
"%s%d: kernel %d.%d-%d[%d] %.*s\n",
1101 le32_to_cpu(dev
->adapter_info
.kernelbuild
),
1102 (int)sizeof(dev
->supplement_adapter_info
.BuildDate
),
1103 dev
->supplement_adapter_info
.BuildDate
);
1104 tmp
= le32_to_cpu(dev
->adapter_info
.monitorrev
);
1105 printk(KERN_INFO
"%s%d: monitor %d.%d-%d[%d]\n",
1107 tmp
>>24,(tmp
>>16)&0xff,tmp
&0xff,
1108 le32_to_cpu(dev
->adapter_info
.monitorbuild
));
1109 tmp
= le32_to_cpu(dev
->adapter_info
.biosrev
);
1110 printk(KERN_INFO
"%s%d: bios %d.%d-%d[%d]\n",
1112 tmp
>>24,(tmp
>>16)&0xff,tmp
&0xff,
1113 le32_to_cpu(dev
->adapter_info
.biosbuild
));
1114 if (le32_to_cpu(dev
->adapter_info
.serial
[0]) != 0xBAD0)
1115 printk(KERN_INFO
"%s%d: serial %x\n",
1117 le32_to_cpu(dev
->adapter_info
.serial
[0]));
1120 dev
->nondasd_support
= 0;
1121 dev
->raid_scsi_mode
= 0;
1122 if(dev
->adapter_info
.options
& AAC_OPT_NONDASD
){
1123 dev
->nondasd_support
= 1;
1127 * If the firmware supports ROMB RAID/SCSI mode and we are currently
1128 * in RAID/SCSI mode, set the flag. For now if in this mode we will
1129 * force nondasd support on. If we decide to allow the non-dasd flag
1130 * additional changes changes will have to be made to support
1131 * RAID/SCSI. the function aac_scsi_cmd in this module will have to be
1132 * changed to support the new dev->raid_scsi_mode flag instead of
1133 * leaching off of the dev->nondasd_support flag. Also in linit.c the
1134 * function aac_detect will have to be modified where it sets up the
1135 * max number of channels based on the aac->nondasd_support flag only.
1137 if ((dev
->adapter_info
.options
& AAC_OPT_SCSI_MANAGED
) &&
1138 (dev
->adapter_info
.options
& AAC_OPT_RAID_SCSI_MODE
)) {
1139 dev
->nondasd_support
= 1;
1140 dev
->raid_scsi_mode
= 1;
1142 if (dev
->raid_scsi_mode
!= 0)
1143 printk(KERN_INFO
"%s%d: ROMB RAID/SCSI mode enabled\n",
1144 dev
->name
, dev
->id
);
1147 dev
->nondasd_support
= (nondasd
!=0);
1149 if(dev
->nondasd_support
!= 0){
1150 printk(KERN_INFO
"%s%d: Non-DASD support enabled.\n",dev
->name
, dev
->id
);
1153 dev
->dac_support
= 0;
1154 if( (sizeof(dma_addr_t
) > 4) && (dev
->adapter_info
.options
& AAC_OPT_SGMAP_HOST64
)){
1155 printk(KERN_INFO
"%s%d: 64bit support enabled.\n", dev
->name
, dev
->id
);
1156 dev
->dac_support
= 1;
1160 dev
->dac_support
= (dacmode
!=0);
1162 if(dev
->dac_support
!= 0) {
1163 if (!pci_set_dma_mask(dev
->pdev
, DMA_64BIT_MASK
) &&
1164 !pci_set_consistent_dma_mask(dev
->pdev
, DMA_64BIT_MASK
)) {
1165 printk(KERN_INFO
"%s%d: 64 Bit DAC enabled\n",
1166 dev
->name
, dev
->id
);
1167 } else if (!pci_set_dma_mask(dev
->pdev
, DMA_32BIT_MASK
) &&
1168 !pci_set_consistent_dma_mask(dev
->pdev
, DMA_32BIT_MASK
)) {
1169 printk(KERN_INFO
"%s%d: DMA mask set failed, 64 Bit DAC disabled\n",
1170 dev
->name
, dev
->id
);
1171 dev
->dac_support
= 0;
1173 printk(KERN_WARNING
"%s%d: No suitable DMA available.\n",
1174 dev
->name
, dev
->id
);
1179 * Deal with configuring for the individualized limits of each packet
1182 dev
->a_ops
.adapter_scsi
= (dev
->dac_support
)
1185 if (dev
->raw_io_interface
) {
1186 dev
->a_ops
.adapter_bounds
= (dev
->raw_io_64
)
1189 dev
->a_ops
.adapter_read
= aac_read_raw_io
;
1190 dev
->a_ops
.adapter_write
= aac_write_raw_io
;
1192 dev
->a_ops
.adapter_bounds
= aac_bounds_32
;
1193 dev
->scsi_host_ptr
->sg_tablesize
= (dev
->max_fib_size
-
1194 sizeof(struct aac_fibhdr
) -
1195 sizeof(struct aac_write
) + sizeof(struct sgentry
)) /
1196 sizeof(struct sgentry
);
1197 if (dev
->dac_support
) {
1198 dev
->a_ops
.adapter_read
= aac_read_block64
;
1199 dev
->a_ops
.adapter_write
= aac_write_block64
;
1201 * 38 scatter gather elements
1203 dev
->scsi_host_ptr
->sg_tablesize
=
1204 (dev
->max_fib_size
-
1205 sizeof(struct aac_fibhdr
) -
1206 sizeof(struct aac_write64
) +
1207 sizeof(struct sgentry64
)) /
1208 sizeof(struct sgentry64
);
1210 dev
->a_ops
.adapter_read
= aac_read_block
;
1211 dev
->a_ops
.adapter_write
= aac_write_block
;
1213 dev
->scsi_host_ptr
->max_sectors
= AAC_MAX_32BIT_SGBCOUNT
;
1214 if(!(dev
->adapter_info
.options
& AAC_OPT_NEW_COMM
)) {
1216 * Worst case size that could cause sg overflow when
1217 * we break up SG elements that are larger than 64KB.
1218 * Would be nice if we could tell the SCSI layer what
1219 * the maximum SG element size can be. Worst case is
1220 * (sg_tablesize-1) 4KB elements with one 64KB
1222 * 32bit -> 468 or 238KB 64bit -> 424 or 212KB
1224 dev
->scsi_host_ptr
->max_sectors
=
1225 (dev
->scsi_host_ptr
->sg_tablesize
* 8) + 112;
1229 aac_fib_complete(fibptr
);
1230 aac_fib_free(fibptr
);
1236 static void io_callback(void *context
, struct fib
* fibptr
)
1238 struct aac_dev
*dev
;
1239 struct aac_read_reply
*readreply
;
1240 struct scsi_cmnd
*scsicmd
;
1243 scsicmd
= (struct scsi_cmnd
*) context
;
1244 scsicmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
1246 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1247 cid
= scmd_id(scsicmd
);
1249 if (nblank(dprintk(x
))) {
1251 switch (scsicmd
->cmnd
[0]) {
1254 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) |
1255 (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1259 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1260 ((u64
)scsicmd
->cmnd
[3] << 48) |
1261 ((u64
)scsicmd
->cmnd
[4] << 40) |
1262 ((u64
)scsicmd
->cmnd
[5] << 32) |
1263 ((u64
)scsicmd
->cmnd
[6] << 24) |
1264 (scsicmd
->cmnd
[7] << 16) |
1265 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1269 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1270 (scsicmd
->cmnd
[3] << 16) |
1271 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1274 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1275 (scsicmd
->cmnd
[3] << 16) |
1276 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1280 "io_callback[cpu %d]: lba = %llu, t = %ld.\n",
1281 smp_processor_id(), (unsigned long long)lba
, jiffies
);
1284 BUG_ON(fibptr
== NULL
);
1287 pci_unmap_sg(dev
->pdev
,
1288 (struct scatterlist
*)scsicmd
->request_buffer
,
1290 scsicmd
->sc_data_direction
);
1291 else if(scsicmd
->request_bufflen
)
1292 pci_unmap_single(dev
->pdev
, scsicmd
->SCp
.dma_handle
,
1293 scsicmd
->request_bufflen
,
1294 scsicmd
->sc_data_direction
);
1295 readreply
= (struct aac_read_reply
*)fib_data(fibptr
);
1296 if (le32_to_cpu(readreply
->status
) == ST_OK
)
1297 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1299 #ifdef AAC_DETAILED_STATUS_INFO
1300 printk(KERN_WARNING
"io_callback: io failed, status = %d\n",
1301 le32_to_cpu(readreply
->status
));
1303 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1304 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1306 SENCODE_INTERNAL_TARGET_FAILURE
,
1307 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
1309 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1310 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1311 ? sizeof(scsicmd
->sense_buffer
)
1312 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1314 aac_fib_complete(fibptr
);
1315 aac_fib_free(fibptr
);
1317 scsicmd
->scsi_done(scsicmd
);
1320 static int aac_read(struct scsi_cmnd
* scsicmd
, int cid
)
1325 struct aac_dev
*dev
;
1326 struct fib
* cmd_fibcontext
;
1328 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1330 * Get block address and transfer length
1332 switch (scsicmd
->cmnd
[0]) {
1334 dprintk((KERN_DEBUG
"aachba: received a read(6) command on id %d.\n", cid
));
1336 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) |
1337 (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1338 count
= scsicmd
->cmnd
[4];
1344 dprintk((KERN_DEBUG
"aachba: received a read(16) command on id %d.\n", cid
));
1346 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1347 ((u64
)scsicmd
->cmnd
[3] << 48) |
1348 ((u64
)scsicmd
->cmnd
[4] << 40) |
1349 ((u64
)scsicmd
->cmnd
[5] << 32) |
1350 ((u64
)scsicmd
->cmnd
[6] << 24) |
1351 (scsicmd
->cmnd
[7] << 16) |
1352 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1353 count
= (scsicmd
->cmnd
[10] << 24) |
1354 (scsicmd
->cmnd
[11] << 16) |
1355 (scsicmd
->cmnd
[12] << 8) | scsicmd
->cmnd
[13];
1358 dprintk((KERN_DEBUG
"aachba: received a read(12) command on id %d.\n", cid
));
1360 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1361 (scsicmd
->cmnd
[3] << 16) |
1362 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1363 count
= (scsicmd
->cmnd
[6] << 24) |
1364 (scsicmd
->cmnd
[7] << 16) |
1365 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1368 dprintk((KERN_DEBUG
"aachba: received a read(10) command on id %d.\n", cid
));
1370 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1371 (scsicmd
->cmnd
[3] << 16) |
1372 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1373 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
1376 dprintk((KERN_DEBUG
"aac_read[cpu %d]: lba = %llu, t = %ld.\n",
1377 smp_processor_id(), (unsigned long long)lba
, jiffies
));
1378 if (aac_adapter_bounds(dev
,scsicmd
,lba
))
1381 * Alocate and initialize a Fib
1383 if (!(cmd_fibcontext
= aac_fib_alloc(dev
))) {
1387 status
= aac_adapter_read(cmd_fibcontext
, scsicmd
, lba
, count
);
1390 * Check that the command queued to the controller
1392 if (status
== -EINPROGRESS
) {
1393 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1397 printk(KERN_WARNING
"aac_read: aac_fib_send failed with status: %d.\n", status
);
1399 * For some reason, the Fib didn't queue, return QUEUE_FULL
1401 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_TASK_SET_FULL
;
1402 scsicmd
->scsi_done(scsicmd
);
1403 aac_fib_complete(cmd_fibcontext
);
1404 aac_fib_free(cmd_fibcontext
);
1408 static int aac_write(struct scsi_cmnd
* scsicmd
, int cid
)
1413 struct aac_dev
*dev
;
1414 struct fib
* cmd_fibcontext
;
1416 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1418 * Get block address and transfer length
1420 if (scsicmd
->cmnd
[0] == WRITE_6
) /* 6 byte command */
1422 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) | (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1423 count
= scsicmd
->cmnd
[4];
1426 } else if (scsicmd
->cmnd
[0] == WRITE_16
) { /* 16 byte command */
1427 dprintk((KERN_DEBUG
"aachba: received a write(16) command on id %d.\n", cid
));
1429 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1430 ((u64
)scsicmd
->cmnd
[3] << 48) |
1431 ((u64
)scsicmd
->cmnd
[4] << 40) |
1432 ((u64
)scsicmd
->cmnd
[5] << 32) |
1433 ((u64
)scsicmd
->cmnd
[6] << 24) |
1434 (scsicmd
->cmnd
[7] << 16) |
1435 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1436 count
= (scsicmd
->cmnd
[10] << 24) | (scsicmd
->cmnd
[11] << 16) |
1437 (scsicmd
->cmnd
[12] << 8) | scsicmd
->cmnd
[13];
1438 } else if (scsicmd
->cmnd
[0] == WRITE_12
) { /* 12 byte command */
1439 dprintk((KERN_DEBUG
"aachba: received a write(12) command on id %d.\n", cid
));
1441 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16)
1442 | (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1443 count
= (scsicmd
->cmnd
[6] << 24) | (scsicmd
->cmnd
[7] << 16)
1444 | (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1446 dprintk((KERN_DEBUG
"aachba: received a write(10) command on id %d.\n", cid
));
1447 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16) | (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1448 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
1450 dprintk((KERN_DEBUG
"aac_write[cpu %d]: lba = %llu, t = %ld.\n",
1451 smp_processor_id(), (unsigned long long)lba
, jiffies
));
1452 if (aac_adapter_bounds(dev
,scsicmd
,lba
))
1455 * Allocate and initialize a Fib then setup a BlockWrite command
1457 if (!(cmd_fibcontext
= aac_fib_alloc(dev
))) {
1458 scsicmd
->result
= DID_ERROR
<< 16;
1459 scsicmd
->scsi_done(scsicmd
);
1463 status
= aac_adapter_write(cmd_fibcontext
, scsicmd
, lba
, count
);
1466 * Check that the command queued to the controller
1468 if (status
== -EINPROGRESS
) {
1469 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1473 printk(KERN_WARNING
"aac_write: aac_fib_send failed with status: %d\n", status
);
1475 * For some reason, the Fib didn't queue, return QUEUE_FULL
1477 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_TASK_SET_FULL
;
1478 scsicmd
->scsi_done(scsicmd
);
1480 aac_fib_complete(cmd_fibcontext
);
1481 aac_fib_free(cmd_fibcontext
);
1485 static void synchronize_callback(void *context
, struct fib
*fibptr
)
1487 struct aac_synchronize_reply
*synchronizereply
;
1488 struct scsi_cmnd
*cmd
;
1491 cmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
1493 dprintk((KERN_DEBUG
"synchronize_callback[cpu %d]: t = %ld.\n",
1494 smp_processor_id(), jiffies
));
1495 BUG_ON(fibptr
== NULL
);
1498 synchronizereply
= fib_data(fibptr
);
1499 if (le32_to_cpu(synchronizereply
->status
) == CT_OK
)
1500 cmd
->result
= DID_OK
<< 16 |
1501 COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1503 struct scsi_device
*sdev
= cmd
->device
;
1504 struct aac_dev
*dev
= (struct aac_dev
*)sdev
->host
->hostdata
;
1505 u32 cid
= sdev_id(sdev
);
1507 "synchronize_callback: synchronize failed, status = %d\n",
1508 le32_to_cpu(synchronizereply
->status
));
1509 cmd
->result
= DID_OK
<< 16 |
1510 COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1511 set_sense((u8
*)&dev
->fsa_dev
[cid
].sense_data
,
1513 SENCODE_INTERNAL_TARGET_FAILURE
,
1514 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
1516 memcpy(cmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1517 min(sizeof(dev
->fsa_dev
[cid
].sense_data
),
1518 sizeof(cmd
->sense_buffer
)));
1521 aac_fib_complete(fibptr
);
1522 aac_fib_free(fibptr
);
1523 cmd
->scsi_done(cmd
);
1526 static int aac_synchronize(struct scsi_cmnd
*scsicmd
, int cid
)
1529 struct fib
*cmd_fibcontext
;
1530 struct aac_synchronize
*synchronizecmd
;
1531 struct scsi_cmnd
*cmd
;
1532 struct scsi_device
*sdev
= scsicmd
->device
;
1534 struct aac_dev
*aac
;
1535 unsigned long flags
;
1538 * Wait for all outstanding queued commands to complete to this
1539 * specific target (block).
1541 spin_lock_irqsave(&sdev
->list_lock
, flags
);
1542 list_for_each_entry(cmd
, &sdev
->cmd_list
, list
)
1543 if (cmd
!= scsicmd
&& cmd
->SCp
.phase
== AAC_OWNER_FIRMWARE
) {
1548 spin_unlock_irqrestore(&sdev
->list_lock
, flags
);
1551 * Yield the processor (requeue for later)
1554 return SCSI_MLQUEUE_DEVICE_BUSY
;
1556 aac
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1558 return SCSI_MLQUEUE_HOST_BUSY
;
1561 * Allocate and initialize a Fib
1563 if (!(cmd_fibcontext
= aac_fib_alloc(aac
)))
1564 return SCSI_MLQUEUE_HOST_BUSY
;
1566 aac_fib_init(cmd_fibcontext
);
1568 synchronizecmd
= fib_data(cmd_fibcontext
);
1569 synchronizecmd
->command
= cpu_to_le32(VM_ContainerConfig
);
1570 synchronizecmd
->type
= cpu_to_le32(CT_FLUSH_CACHE
);
1571 synchronizecmd
->cid
= cpu_to_le32(cid
);
1572 synchronizecmd
->count
=
1573 cpu_to_le32(sizeof(((struct aac_synchronize_reply
*)NULL
)->data
));
1576 * Now send the Fib to the adapter
1578 status
= aac_fib_send(ContainerCommand
,
1580 sizeof(struct aac_synchronize
),
1583 (fib_callback
)synchronize_callback
,
1587 * Check that the command queued to the controller
1589 if (status
== -EINPROGRESS
) {
1590 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
1595 "aac_synchronize: aac_fib_send failed with status: %d.\n", status
);
1596 aac_fib_complete(cmd_fibcontext
);
1597 aac_fib_free(cmd_fibcontext
);
1598 return SCSI_MLQUEUE_HOST_BUSY
;
1602 * aac_scsi_cmd() - Process SCSI command
1603 * @scsicmd: SCSI command block
1605 * Emulate a SCSI command and queue the required request for the
1609 int aac_scsi_cmd(struct scsi_cmnd
* scsicmd
)
1612 struct Scsi_Host
*host
= scsicmd
->device
->host
;
1613 struct aac_dev
*dev
= (struct aac_dev
*)host
->hostdata
;
1614 struct fsa_dev_info
*fsa_dev_ptr
= dev
->fsa_dev
;
1616 if (fsa_dev_ptr
== NULL
)
1619 * If the bus, id or lun is out of range, return fail
1620 * Test does not apply to ID 16, the pseudo id for the controller
1623 if (scmd_id(scsicmd
) != host
->this_id
) {
1624 if ((scmd_channel(scsicmd
) == CONTAINER_CHANNEL
)) {
1625 if((scmd_id(scsicmd
) >= dev
->maximum_num_containers
) ||
1626 (scsicmd
->device
->lun
!= 0)) {
1627 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1628 scsicmd
->scsi_done(scsicmd
);
1631 cid
= scmd_id(scsicmd
);
1634 * If the target container doesn't exist, it may have
1635 * been newly created
1637 if ((fsa_dev_ptr
[cid
].valid
& 1) == 0) {
1638 switch (scsicmd
->cmnd
[0]) {
1639 case SERVICE_ACTION_IN
:
1640 if (!(dev
->raw_io_interface
) ||
1641 !(dev
->raw_io_64
) ||
1642 ((scsicmd
->cmnd
[1] & 0x1f) != SAI_READ_CAPACITY_16
))
1646 case TEST_UNIT_READY
:
1649 spin_unlock_irq(host
->host_lock
);
1650 aac_probe_container(dev
, cid
);
1651 if ((fsa_dev_ptr
[cid
].valid
& 1) == 0)
1652 fsa_dev_ptr
[cid
].valid
= 0;
1653 spin_lock_irq(host
->host_lock
);
1654 if (fsa_dev_ptr
[cid
].valid
== 0) {
1655 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1656 scsicmd
->scsi_done(scsicmd
);
1664 * If the target container still doesn't exist,
1667 if (fsa_dev_ptr
[cid
].valid
== 0) {
1668 scsicmd
->result
= DID_BAD_TARGET
<< 16;
1669 scsicmd
->scsi_done(scsicmd
);
1672 } else { /* check for physical non-dasd devices */
1673 if ((dev
->nondasd_support
== 1) || expose_physicals
) {
1676 return aac_send_srb_fib(scsicmd
);
1678 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1679 scsicmd
->scsi_done(scsicmd
);
1685 * else Command for the controller itself
1687 else if ((scsicmd
->cmnd
[0] != INQUIRY
) && /* only INQUIRY & TUR cmnd supported for controller */
1688 (scsicmd
->cmnd
[0] != TEST_UNIT_READY
))
1690 dprintk((KERN_WARNING
"Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd
->cmnd
[0]));
1691 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1692 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1694 SENCODE_INVALID_COMMAND
,
1695 ASENCODE_INVALID_COMMAND
, 0, 0, 0, 0);
1696 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1697 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1698 ? sizeof(scsicmd
->sense_buffer
)
1699 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1700 scsicmd
->scsi_done(scsicmd
);
1705 /* Handle commands here that don't really require going out to the adapter */
1706 switch (scsicmd
->cmnd
[0]) {
1709 struct inquiry_data inq_data
;
1711 dprintk((KERN_DEBUG
"INQUIRY command, ID: %d.\n", scmd_id(scsicmd
)));
1712 memset(&inq_data
, 0, sizeof (struct inquiry_data
));
1714 inq_data
.inqd_ver
= 2; /* claim compliance to SCSI-2 */
1715 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 */
1716 inq_data
.inqd_len
= 31;
1717 /*Format for "pad2" is RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
1718 inq_data
.inqd_pad2
= 0x32 ; /*WBus16|Sync|CmdQue */
1720 * Set the Vendor, Product, and Revision Level
1721 * see: <vendor>.c i.e. aac.c
1723 if (scmd_id(scsicmd
) == host
->this_id
) {
1724 setinqstr(dev
, (void *) (inq_data
.inqd_vid
), ARRAY_SIZE(container_types
));
1725 inq_data
.inqd_pdt
= INQD_PDT_PROC
; /* Processor device */
1726 aac_internal_transfer(scsicmd
, &inq_data
, 0, sizeof(inq_data
));
1727 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1728 scsicmd
->scsi_done(scsicmd
);
1733 setinqstr(dev
, (void *) (inq_data
.inqd_vid
), fsa_dev_ptr
[cid
].type
);
1734 inq_data
.inqd_pdt
= INQD_PDT_DA
; /* Direct/random access device */
1735 aac_internal_transfer(scsicmd
, &inq_data
, 0, sizeof(inq_data
));
1736 return aac_get_container_name(scsicmd
, cid
);
1738 case SERVICE_ACTION_IN
:
1739 if (!(dev
->raw_io_interface
) ||
1740 !(dev
->raw_io_64
) ||
1741 ((scsicmd
->cmnd
[1] & 0x1f) != SAI_READ_CAPACITY_16
))
1747 dprintk((KERN_DEBUG
"READ CAPACITY_16 command.\n"));
1748 capacity
= fsa_dev_ptr
[cid
].size
- 1;
1749 cp
[0] = (capacity
>> 56) & 0xff;
1750 cp
[1] = (capacity
>> 48) & 0xff;
1751 cp
[2] = (capacity
>> 40) & 0xff;
1752 cp
[3] = (capacity
>> 32) & 0xff;
1753 cp
[4] = (capacity
>> 24) & 0xff;
1754 cp
[5] = (capacity
>> 16) & 0xff;
1755 cp
[6] = (capacity
>> 8) & 0xff;
1756 cp
[7] = (capacity
>> 0) & 0xff;
1762 aac_internal_transfer(scsicmd
, cp
, 0,
1763 min_t(size_t, scsicmd
->cmnd
[13], sizeof(cp
)));
1764 if (sizeof(cp
) < scsicmd
->cmnd
[13]) {
1765 unsigned int len
, offset
= sizeof(cp
);
1767 memset(cp
, 0, offset
);
1769 len
= min_t(size_t, scsicmd
->cmnd
[13] - offset
,
1771 aac_internal_transfer(scsicmd
, cp
, offset
, len
);
1772 } while ((offset
+= len
) < scsicmd
->cmnd
[13]);
1775 /* Do not cache partition table for arrays */
1776 scsicmd
->device
->removable
= 1;
1778 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1779 scsicmd
->scsi_done(scsicmd
);
1789 dprintk((KERN_DEBUG
"READ CAPACITY command.\n"));
1790 if (fsa_dev_ptr
[cid
].size
<= 0x100000000ULL
)
1791 capacity
= fsa_dev_ptr
[cid
].size
- 1;
1795 cp
[0] = (capacity
>> 24) & 0xff;
1796 cp
[1] = (capacity
>> 16) & 0xff;
1797 cp
[2] = (capacity
>> 8) & 0xff;
1798 cp
[3] = (capacity
>> 0) & 0xff;
1803 aac_internal_transfer(scsicmd
, cp
, 0, sizeof(cp
));
1804 /* Do not cache partition table for arrays */
1805 scsicmd
->device
->removable
= 1;
1807 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1808 scsicmd
->scsi_done(scsicmd
);
1817 dprintk((KERN_DEBUG
"MODE SENSE command.\n"));
1818 mode_buf
[0] = 3; /* Mode data length */
1819 mode_buf
[1] = 0; /* Medium type - default */
1820 mode_buf
[2] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */
1821 mode_buf
[3] = 0; /* Block descriptor length */
1823 aac_internal_transfer(scsicmd
, mode_buf
, 0, sizeof(mode_buf
));
1824 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1825 scsicmd
->scsi_done(scsicmd
);
1833 dprintk((KERN_DEBUG
"MODE SENSE 10 byte command.\n"));
1834 mode_buf
[0] = 0; /* Mode data length (MSB) */
1835 mode_buf
[1] = 6; /* Mode data length (LSB) */
1836 mode_buf
[2] = 0; /* Medium type - default */
1837 mode_buf
[3] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */
1838 mode_buf
[4] = 0; /* reserved */
1839 mode_buf
[5] = 0; /* reserved */
1840 mode_buf
[6] = 0; /* Block descriptor length (MSB) */
1841 mode_buf
[7] = 0; /* Block descriptor length (LSB) */
1842 aac_internal_transfer(scsicmd
, mode_buf
, 0, sizeof(mode_buf
));
1844 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1845 scsicmd
->scsi_done(scsicmd
);
1850 dprintk((KERN_DEBUG
"REQUEST SENSE command.\n"));
1851 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
, sizeof (struct sense_data
));
1852 memset(&dev
->fsa_dev
[cid
].sense_data
, 0, sizeof (struct sense_data
));
1853 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1854 scsicmd
->scsi_done(scsicmd
);
1857 case ALLOW_MEDIUM_REMOVAL
:
1858 dprintk((KERN_DEBUG
"LOCK command.\n"));
1859 if (scsicmd
->cmnd
[4])
1860 fsa_dev_ptr
[cid
].locked
= 1;
1862 fsa_dev_ptr
[cid
].locked
= 0;
1864 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1865 scsicmd
->scsi_done(scsicmd
);
1868 * These commands are all No-Ops
1870 case TEST_UNIT_READY
:
1874 case REASSIGN_BLOCKS
:
1877 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1878 scsicmd
->scsi_done(scsicmd
);
1882 switch (scsicmd
->cmnd
[0])
1891 * Hack to keep track of ordinal number of the device that
1892 * corresponds to a container. Needed to convert
1893 * containers to /dev/sd device names
1896 if (scsicmd
->request
->rq_disk
)
1897 strlcpy(fsa_dev_ptr
[cid
].devname
,
1898 scsicmd
->request
->rq_disk
->disk_name
,
1899 min(sizeof(fsa_dev_ptr
[cid
].devname
),
1900 sizeof(scsicmd
->request
->rq_disk
->disk_name
) + 1));
1902 return aac_read(scsicmd
, cid
);
1910 return aac_write(scsicmd
, cid
);
1912 case SYNCHRONIZE_CACHE
:
1913 /* Issue FIB to tell Firmware to flush it's cache */
1914 return aac_synchronize(scsicmd
, cid
);
1918 * Unhandled commands
1920 dprintk((KERN_WARNING
"Unhandled SCSI Command: 0x%x.\n", scsicmd
->cmnd
[0]));
1921 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1922 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1923 ILLEGAL_REQUEST
, SENCODE_INVALID_COMMAND
,
1924 ASENCODE_INVALID_COMMAND
, 0, 0, 0, 0);
1925 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1926 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1927 ? sizeof(scsicmd
->sense_buffer
)
1928 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1929 scsicmd
->scsi_done(scsicmd
);
1934 static int query_disk(struct aac_dev
*dev
, void __user
*arg
)
1936 struct aac_query_disk qd
;
1937 struct fsa_dev_info
*fsa_dev_ptr
;
1939 fsa_dev_ptr
= dev
->fsa_dev
;
1942 if (copy_from_user(&qd
, arg
, sizeof (struct aac_query_disk
)))
1946 else if ((qd
.bus
== -1) && (qd
.id
== -1) && (qd
.lun
== -1))
1948 if (qd
.cnum
< 0 || qd
.cnum
>= dev
->maximum_num_containers
)
1950 qd
.instance
= dev
->scsi_host_ptr
->host_no
;
1952 qd
.id
= CONTAINER_TO_ID(qd
.cnum
);
1953 qd
.lun
= CONTAINER_TO_LUN(qd
.cnum
);
1955 else return -EINVAL
;
1957 qd
.valid
= fsa_dev_ptr
[qd
.cnum
].valid
;
1958 qd
.locked
= fsa_dev_ptr
[qd
.cnum
].locked
;
1959 qd
.deleted
= fsa_dev_ptr
[qd
.cnum
].deleted
;
1961 if (fsa_dev_ptr
[qd
.cnum
].devname
[0] == '\0')
1966 strlcpy(qd
.name
, fsa_dev_ptr
[qd
.cnum
].devname
,
1967 min(sizeof(qd
.name
), sizeof(fsa_dev_ptr
[qd
.cnum
].devname
) + 1));
1969 if (copy_to_user(arg
, &qd
, sizeof (struct aac_query_disk
)))
1974 static int force_delete_disk(struct aac_dev
*dev
, void __user
*arg
)
1976 struct aac_delete_disk dd
;
1977 struct fsa_dev_info
*fsa_dev_ptr
;
1979 fsa_dev_ptr
= dev
->fsa_dev
;
1983 if (copy_from_user(&dd
, arg
, sizeof (struct aac_delete_disk
)))
1986 if (dd
.cnum
>= dev
->maximum_num_containers
)
1989 * Mark this container as being deleted.
1991 fsa_dev_ptr
[dd
.cnum
].deleted
= 1;
1993 * Mark the container as no longer valid
1995 fsa_dev_ptr
[dd
.cnum
].valid
= 0;
1999 static int delete_disk(struct aac_dev
*dev
, void __user
*arg
)
2001 struct aac_delete_disk dd
;
2002 struct fsa_dev_info
*fsa_dev_ptr
;
2004 fsa_dev_ptr
= dev
->fsa_dev
;
2008 if (copy_from_user(&dd
, arg
, sizeof (struct aac_delete_disk
)))
2011 if (dd
.cnum
>= dev
->maximum_num_containers
)
2014 * If the container is locked, it can not be deleted by the API.
2016 if (fsa_dev_ptr
[dd
.cnum
].locked
)
2020 * Mark the container as no longer being valid.
2022 fsa_dev_ptr
[dd
.cnum
].valid
= 0;
2023 fsa_dev_ptr
[dd
.cnum
].devname
[0] = '\0';
2028 int aac_dev_ioctl(struct aac_dev
*dev
, int cmd
, void __user
*arg
)
2031 case FSACTL_QUERY_DISK
:
2032 return query_disk(dev
, arg
);
2033 case FSACTL_DELETE_DISK
:
2034 return delete_disk(dev
, arg
);
2035 case FSACTL_FORCE_DELETE_DISK
:
2036 return force_delete_disk(dev
, arg
);
2037 case FSACTL_GET_CONTAINERS
:
2038 return aac_get_containers(dev
);
2047 * @context: the context set in the fib - here it is scsi cmd
2048 * @fibptr: pointer to the fib
2050 * Handles the completion of a scsi command to a non dasd device
2054 static void aac_srb_callback(void *context
, struct fib
* fibptr
)
2056 struct aac_dev
*dev
;
2057 struct aac_srb_reply
*srbreply
;
2058 struct scsi_cmnd
*scsicmd
;
2060 scsicmd
= (struct scsi_cmnd
*) context
;
2061 scsicmd
->SCp
.phase
= AAC_OWNER_MIDLEVEL
;
2062 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2064 BUG_ON(fibptr
== NULL
);
2066 srbreply
= (struct aac_srb_reply
*) fib_data(fibptr
);
2068 scsicmd
->sense_buffer
[0] = '\0'; /* Initialize sense valid flag to false */
2070 * Calculate resid for sg
2073 scsicmd
->resid
= scsicmd
->request_bufflen
-
2074 le32_to_cpu(srbreply
->data_xfer_length
);
2077 pci_unmap_sg(dev
->pdev
,
2078 (struct scatterlist
*)scsicmd
->request_buffer
,
2080 scsicmd
->sc_data_direction
);
2081 else if(scsicmd
->request_bufflen
)
2082 pci_unmap_single(dev
->pdev
, scsicmd
->SCp
.dma_handle
, scsicmd
->request_bufflen
,
2083 scsicmd
->sc_data_direction
);
2086 * First check the fib status
2089 if (le32_to_cpu(srbreply
->status
) != ST_OK
){
2091 printk(KERN_WARNING
"aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply
->status
));
2092 len
= (le32_to_cpu(srbreply
->sense_data_size
) >
2093 sizeof(scsicmd
->sense_buffer
)) ?
2094 sizeof(scsicmd
->sense_buffer
) :
2095 le32_to_cpu(srbreply
->sense_data_size
);
2096 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
2097 memcpy(scsicmd
->sense_buffer
, srbreply
->sense_data
, len
);
2101 * Next check the srb status
2103 switch( (le32_to_cpu(srbreply
->srb_status
))&0x3f){
2104 case SRB_STATUS_ERROR_RECOVERY
:
2105 case SRB_STATUS_PENDING
:
2106 case SRB_STATUS_SUCCESS
:
2107 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
2109 case SRB_STATUS_DATA_OVERRUN
:
2110 switch(scsicmd
->cmnd
[0]){
2119 if(le32_to_cpu(srbreply
->data_xfer_length
) < scsicmd
->underflow
) {
2120 printk(KERN_WARNING
"aacraid: SCSI CMD underflow\n");
2122 printk(KERN_WARNING
"aacraid: SCSI CMD Data Overrun\n");
2124 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8;
2127 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
2131 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
2135 case SRB_STATUS_ABORTED
:
2136 scsicmd
->result
= DID_ABORT
<< 16 | ABORT
<< 8;
2138 case SRB_STATUS_ABORT_FAILED
:
2139 // Not sure about this one - but assuming the hba was trying to abort for some reason
2140 scsicmd
->result
= DID_ERROR
<< 16 | ABORT
<< 8;
2142 case SRB_STATUS_PARITY_ERROR
:
2143 scsicmd
->result
= DID_PARITY
<< 16 | MSG_PARITY_ERROR
<< 8;
2145 case SRB_STATUS_NO_DEVICE
:
2146 case SRB_STATUS_INVALID_PATH_ID
:
2147 case SRB_STATUS_INVALID_TARGET_ID
:
2148 case SRB_STATUS_INVALID_LUN
:
2149 case SRB_STATUS_SELECTION_TIMEOUT
:
2150 scsicmd
->result
= DID_NO_CONNECT
<< 16 | COMMAND_COMPLETE
<< 8;
2153 case SRB_STATUS_COMMAND_TIMEOUT
:
2154 case SRB_STATUS_TIMEOUT
:
2155 scsicmd
->result
= DID_TIME_OUT
<< 16 | COMMAND_COMPLETE
<< 8;
2158 case SRB_STATUS_BUSY
:
2159 scsicmd
->result
= DID_NO_CONNECT
<< 16 | COMMAND_COMPLETE
<< 8;
2162 case SRB_STATUS_BUS_RESET
:
2163 scsicmd
->result
= DID_RESET
<< 16 | COMMAND_COMPLETE
<< 8;
2166 case SRB_STATUS_MESSAGE_REJECTED
:
2167 scsicmd
->result
= DID_ERROR
<< 16 | MESSAGE_REJECT
<< 8;
2169 case SRB_STATUS_REQUEST_FLUSHED
:
2170 case SRB_STATUS_ERROR
:
2171 case SRB_STATUS_INVALID_REQUEST
:
2172 case SRB_STATUS_REQUEST_SENSE_FAILED
:
2173 case SRB_STATUS_NO_HBA
:
2174 case SRB_STATUS_UNEXPECTED_BUS_FREE
:
2175 case SRB_STATUS_PHASE_SEQUENCE_FAILURE
:
2176 case SRB_STATUS_BAD_SRB_BLOCK_LENGTH
:
2177 case SRB_STATUS_DELAYED_RETRY
:
2178 case SRB_STATUS_BAD_FUNCTION
:
2179 case SRB_STATUS_NOT_STARTED
:
2180 case SRB_STATUS_NOT_IN_USE
:
2181 case SRB_STATUS_FORCE_ABORT
:
2182 case SRB_STATUS_DOMAIN_VALIDATION_FAIL
:
2184 #ifdef AAC_DETAILED_STATUS_INFO
2185 printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",
2186 le32_to_cpu(srbreply
->srb_status
) & 0x3F,
2187 aac_get_status_string(
2188 le32_to_cpu(srbreply
->srb_status
) & 0x3F),
2190 le32_to_cpu(srbreply
->scsi_status
));
2192 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8;
2195 if (le32_to_cpu(srbreply
->scsi_status
) == 0x02 ){ // Check Condition
2197 scsicmd
->result
|= SAM_STAT_CHECK_CONDITION
;
2198 len
= (le32_to_cpu(srbreply
->sense_data_size
) >
2199 sizeof(scsicmd
->sense_buffer
)) ?
2200 sizeof(scsicmd
->sense_buffer
) :
2201 le32_to_cpu(srbreply
->sense_data_size
);
2202 #ifdef AAC_DETAILED_STATUS_INFO
2203 printk(KERN_WARNING
"aac_srb_callback: check condition, status = %d len=%d\n",
2204 le32_to_cpu(srbreply
->status
), len
);
2206 memcpy(scsicmd
->sense_buffer
, srbreply
->sense_data
, len
);
2210 * OR in the scsi status (already shifted up a bit)
2212 scsicmd
->result
|= le32_to_cpu(srbreply
->scsi_status
);
2214 aac_fib_complete(fibptr
);
2215 aac_fib_free(fibptr
);
2216 scsicmd
->scsi_done(scsicmd
);
2222 * @scsicmd: the scsi command block
2224 * This routine will form a FIB and fill in the aac_srb from the
2225 * scsicmd passed in.
2228 static int aac_send_srb_fib(struct scsi_cmnd
* scsicmd
)
2230 struct fib
* cmd_fibcontext
;
2231 struct aac_dev
* dev
;
2234 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2235 if (scmd_id(scsicmd
) >= dev
->maximum_num_physicals
||
2236 scsicmd
->device
->lun
> 7) {
2237 scsicmd
->result
= DID_NO_CONNECT
<< 16;
2238 scsicmd
->scsi_done(scsicmd
);
2243 * Allocate and initialize a Fib then setup a BlockWrite command
2245 if (!(cmd_fibcontext
= aac_fib_alloc(dev
))) {
2248 status
= aac_adapter_scsi(cmd_fibcontext
, scsicmd
);
2251 * Check that the command queued to the controller
2253 if (status
== -EINPROGRESS
) {
2254 scsicmd
->SCp
.phase
= AAC_OWNER_FIRMWARE
;
2258 printk(KERN_WARNING
"aac_srb: aac_fib_send failed with status: %d\n", status
);
2259 aac_fib_complete(cmd_fibcontext
);
2260 aac_fib_free(cmd_fibcontext
);
2265 static unsigned long aac_build_sg(struct scsi_cmnd
* scsicmd
, struct sgmap
* psg
)
2267 struct aac_dev
*dev
;
2268 unsigned long byte_count
= 0;
2270 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2271 // Get rid of old data
2273 psg
->sg
[0].addr
= 0;
2274 psg
->sg
[0].count
= 0;
2275 if (scsicmd
->use_sg
) {
2276 struct scatterlist
*sg
;
2279 sg
= (struct scatterlist
*) scsicmd
->request_buffer
;
2281 sg_count
= pci_map_sg(dev
->pdev
, sg
, scsicmd
->use_sg
,
2282 scsicmd
->sc_data_direction
);
2283 psg
->count
= cpu_to_le32(sg_count
);
2285 for (i
= 0; i
< sg_count
; i
++) {
2286 psg
->sg
[i
].addr
= cpu_to_le32(sg_dma_address(sg
));
2287 psg
->sg
[i
].count
= cpu_to_le32(sg_dma_len(sg
));
2288 byte_count
+= sg_dma_len(sg
);
2291 /* hba wants the size to be exact */
2292 if(byte_count
> scsicmd
->request_bufflen
){
2293 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2294 (byte_count
- scsicmd
->request_bufflen
);
2295 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2296 byte_count
= scsicmd
->request_bufflen
;
2298 /* Check for command underflow */
2299 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2300 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2301 byte_count
, scsicmd
->underflow
);
2304 else if(scsicmd
->request_bufflen
) {
2306 scsicmd
->SCp
.dma_handle
= pci_map_single(dev
->pdev
,
2307 scsicmd
->request_buffer
,
2308 scsicmd
->request_bufflen
,
2309 scsicmd
->sc_data_direction
);
2310 addr
= scsicmd
->SCp
.dma_handle
;
2311 psg
->count
= cpu_to_le32(1);
2312 psg
->sg
[0].addr
= cpu_to_le32(addr
);
2313 psg
->sg
[0].count
= cpu_to_le32(scsicmd
->request_bufflen
);
2314 byte_count
= scsicmd
->request_bufflen
;
2320 static unsigned long aac_build_sg64(struct scsi_cmnd
* scsicmd
, struct sgmap64
* psg
)
2322 struct aac_dev
*dev
;
2323 unsigned long byte_count
= 0;
2326 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2327 // Get rid of old data
2329 psg
->sg
[0].addr
[0] = 0;
2330 psg
->sg
[0].addr
[1] = 0;
2331 psg
->sg
[0].count
= 0;
2332 if (scsicmd
->use_sg
) {
2333 struct scatterlist
*sg
;
2336 sg
= (struct scatterlist
*) scsicmd
->request_buffer
;
2338 sg_count
= pci_map_sg(dev
->pdev
, sg
, scsicmd
->use_sg
,
2339 scsicmd
->sc_data_direction
);
2341 for (i
= 0; i
< sg_count
; i
++) {
2342 int count
= sg_dma_len(sg
);
2343 addr
= sg_dma_address(sg
);
2344 psg
->sg
[i
].addr
[0] = cpu_to_le32(addr
& 0xffffffff);
2345 psg
->sg
[i
].addr
[1] = cpu_to_le32(addr
>>32);
2346 psg
->sg
[i
].count
= cpu_to_le32(count
);
2347 byte_count
+= count
;
2350 psg
->count
= cpu_to_le32(sg_count
);
2351 /* hba wants the size to be exact */
2352 if(byte_count
> scsicmd
->request_bufflen
){
2353 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2354 (byte_count
- scsicmd
->request_bufflen
);
2355 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2356 byte_count
= scsicmd
->request_bufflen
;
2358 /* Check for command underflow */
2359 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2360 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2361 byte_count
, scsicmd
->underflow
);
2364 else if(scsicmd
->request_bufflen
) {
2365 scsicmd
->SCp
.dma_handle
= pci_map_single(dev
->pdev
,
2366 scsicmd
->request_buffer
,
2367 scsicmd
->request_bufflen
,
2368 scsicmd
->sc_data_direction
);
2369 addr
= scsicmd
->SCp
.dma_handle
;
2370 psg
->count
= cpu_to_le32(1);
2371 psg
->sg
[0].addr
[0] = cpu_to_le32(addr
& 0xffffffff);
2372 psg
->sg
[0].addr
[1] = cpu_to_le32(addr
>> 32);
2373 psg
->sg
[0].count
= cpu_to_le32(scsicmd
->request_bufflen
);
2374 byte_count
= scsicmd
->request_bufflen
;
2379 static unsigned long aac_build_sgraw(struct scsi_cmnd
* scsicmd
, struct sgmapraw
* psg
)
2381 struct Scsi_Host
*host
= scsicmd
->device
->host
;
2382 struct aac_dev
*dev
= (struct aac_dev
*)host
->hostdata
;
2383 unsigned long byte_count
= 0;
2385 // Get rid of old data
2387 psg
->sg
[0].next
= 0;
2388 psg
->sg
[0].prev
= 0;
2389 psg
->sg
[0].addr
[0] = 0;
2390 psg
->sg
[0].addr
[1] = 0;
2391 psg
->sg
[0].count
= 0;
2392 psg
->sg
[0].flags
= 0;
2393 if (scsicmd
->use_sg
) {
2394 struct scatterlist
*sg
;
2397 sg
= (struct scatterlist
*) scsicmd
->request_buffer
;
2399 sg_count
= pci_map_sg(dev
->pdev
, sg
, scsicmd
->use_sg
,
2400 scsicmd
->sc_data_direction
);
2402 for (i
= 0; i
< sg_count
; i
++) {
2403 int count
= sg_dma_len(sg
);
2404 u64 addr
= sg_dma_address(sg
);
2405 psg
->sg
[i
].next
= 0;
2406 psg
->sg
[i
].prev
= 0;
2407 psg
->sg
[i
].addr
[1] = cpu_to_le32((u32
)(addr
>>32));
2408 psg
->sg
[i
].addr
[0] = cpu_to_le32((u32
)(addr
& 0xffffffff));
2409 psg
->sg
[i
].count
= cpu_to_le32(count
);
2410 psg
->sg
[i
].flags
= 0;
2411 byte_count
+= count
;
2414 psg
->count
= cpu_to_le32(sg_count
);
2415 /* hba wants the size to be exact */
2416 if(byte_count
> scsicmd
->request_bufflen
){
2417 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2418 (byte_count
- scsicmd
->request_bufflen
);
2419 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2420 byte_count
= scsicmd
->request_bufflen
;
2422 /* Check for command underflow */
2423 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2424 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2425 byte_count
, scsicmd
->underflow
);
2428 else if(scsicmd
->request_bufflen
) {
2431 scsicmd
->SCp
.dma_handle
= pci_map_single(dev
->pdev
,
2432 scsicmd
->request_buffer
,
2433 scsicmd
->request_bufflen
,
2434 scsicmd
->sc_data_direction
);
2435 addr
= scsicmd
->SCp
.dma_handle
;
2436 count
= scsicmd
->request_bufflen
;
2437 psg
->count
= cpu_to_le32(1);
2438 psg
->sg
[0].next
= 0;
2439 psg
->sg
[0].prev
= 0;
2440 psg
->sg
[0].addr
[1] = cpu_to_le32((u32
)(addr
>>32));
2441 psg
->sg
[0].addr
[0] = cpu_to_le32((u32
)(addr
& 0xffffffff));
2442 psg
->sg
[0].count
= cpu_to_le32(count
);
2443 psg
->sg
[0].flags
= 0;
2444 byte_count
= scsicmd
->request_bufflen
;
2449 #ifdef AAC_DETAILED_STATUS_INFO
2451 struct aac_srb_status_info
{
2457 static struct aac_srb_status_info srb_status_info
[] = {
2458 { SRB_STATUS_PENDING
, "Pending Status"},
2459 { SRB_STATUS_SUCCESS
, "Success"},
2460 { SRB_STATUS_ABORTED
, "Aborted Command"},
2461 { SRB_STATUS_ABORT_FAILED
, "Abort Failed"},
2462 { SRB_STATUS_ERROR
, "Error Event"},
2463 { SRB_STATUS_BUSY
, "Device Busy"},
2464 { SRB_STATUS_INVALID_REQUEST
, "Invalid Request"},
2465 { SRB_STATUS_INVALID_PATH_ID
, "Invalid Path ID"},
2466 { SRB_STATUS_NO_DEVICE
, "No Device"},
2467 { SRB_STATUS_TIMEOUT
, "Timeout"},
2468 { SRB_STATUS_SELECTION_TIMEOUT
, "Selection Timeout"},
2469 { SRB_STATUS_COMMAND_TIMEOUT
, "Command Timeout"},
2470 { SRB_STATUS_MESSAGE_REJECTED
, "Message Rejected"},
2471 { SRB_STATUS_BUS_RESET
, "Bus Reset"},
2472 { SRB_STATUS_PARITY_ERROR
, "Parity Error"},
2473 { SRB_STATUS_REQUEST_SENSE_FAILED
,"Request Sense Failed"},
2474 { SRB_STATUS_NO_HBA
, "No HBA"},
2475 { SRB_STATUS_DATA_OVERRUN
, "Data Overrun/Data Underrun"},
2476 { SRB_STATUS_UNEXPECTED_BUS_FREE
,"Unexpected Bus Free"},
2477 { SRB_STATUS_PHASE_SEQUENCE_FAILURE
,"Phase Error"},
2478 { SRB_STATUS_BAD_SRB_BLOCK_LENGTH
,"Bad Srb Block Length"},
2479 { SRB_STATUS_REQUEST_FLUSHED
, "Request Flushed"},
2480 { SRB_STATUS_DELAYED_RETRY
, "Delayed Retry"},
2481 { SRB_STATUS_INVALID_LUN
, "Invalid LUN"},
2482 { SRB_STATUS_INVALID_TARGET_ID
, "Invalid TARGET ID"},
2483 { SRB_STATUS_BAD_FUNCTION
, "Bad Function"},
2484 { SRB_STATUS_ERROR_RECOVERY
, "Error Recovery"},
2485 { SRB_STATUS_NOT_STARTED
, "Not Started"},
2486 { SRB_STATUS_NOT_IN_USE
, "Not In Use"},
2487 { SRB_STATUS_FORCE_ABORT
, "Force Abort"},
2488 { SRB_STATUS_DOMAIN_VALIDATION_FAIL
,"Domain Validation Failure"},
2489 { 0xff, "Unknown Error"}
2492 char *aac_get_status_string(u32 status
)
2496 for (i
= 0; i
< ARRAY_SIZE(srb_status_info
); i
++)
2497 if (srb_status_info
[i
].status
== status
)
2498 return srb_status_info
[i
].str
;
2500 return "Bad Status Code";