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 <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;
151 module_param(nondasd
, int, 0);
152 MODULE_PARM_DESC(nondasd
, "Control scanning of hba for nondasd devices. 0=off, 1=on");
153 module_param(dacmode
, int, 0);
154 MODULE_PARM_DESC(dacmode
, "Control whether dma addressing is using 64 bit DAC. 0=off, 1=on");
155 module_param(commit
, int, 0);
156 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(numacb
, int, S_IRUGO
|S_IWUSR
);
160 MODULE_PARM_DESC(numacb
, "Request a limit to the number of adapter control blocks (FIB) allocated. Valid\nvalues are 512 and down. Default is to use suggestion from Firmware.");
163 module_param(acbsize
, int, S_IRUGO
|S_IWUSR
);
164 MODULE_PARM_DESC(acbsize
, "Request a specific adapter control block (FIB) size. Valid values are 512,\n2048, 4096 and 8192. Default is to use suggestion from Firmware.");
166 * aac_get_config_status - check the adapter configuration
167 * @common: adapter to query
169 * Query config status, and commit the configuration if needed.
171 int aac_get_config_status(struct aac_dev
*dev
)
176 if (!(fibptr
= fib_alloc(dev
)))
181 struct aac_get_config_status
*dinfo
;
182 dinfo
= (struct aac_get_config_status
*) fib_data(fibptr
);
184 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
185 dinfo
->type
= cpu_to_le32(CT_GET_CONFIG_STATUS
);
186 dinfo
->count
= cpu_to_le32(sizeof(((struct aac_get_config_status_resp
*)NULL
)->data
));
189 status
= fib_send(ContainerCommand
,
191 sizeof (struct aac_get_config_status
),
196 printk(KERN_WARNING
"aac_get_config_status: SendFIB failed.\n");
198 struct aac_get_config_status_resp
*reply
199 = (struct aac_get_config_status_resp
*) fib_data(fibptr
);
200 dprintk((KERN_WARNING
201 "aac_get_config_status: response=%d status=%d action=%d\n",
202 le32_to_cpu(reply
->response
),
203 le32_to_cpu(reply
->status
),
204 le32_to_cpu(reply
->data
.action
)));
205 if ((le32_to_cpu(reply
->response
) != ST_OK
) ||
206 (le32_to_cpu(reply
->status
) != CT_OK
) ||
207 (le32_to_cpu(reply
->data
.action
) > CFACT_PAUSE
)) {
208 printk(KERN_WARNING
"aac_get_config_status: Will not issue the Commit Configuration\n");
212 fib_complete(fibptr
);
213 /* Send a CT_COMMIT_CONFIG to enable discovery of devices */
216 struct aac_commit_config
* dinfo
;
218 dinfo
= (struct aac_commit_config
*) fib_data(fibptr
);
220 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
221 dinfo
->type
= cpu_to_le32(CT_COMMIT_CONFIG
);
223 status
= fib_send(ContainerCommand
,
225 sizeof (struct aac_commit_config
),
229 fib_complete(fibptr
);
230 } else if (commit
== 0) {
232 "aac_get_config_status: Foreign device configurations are being ignored\n");
240 * aac_get_containers - list containers
241 * @common: adapter to probe
243 * Make a list of all containers on this controller
245 int aac_get_containers(struct aac_dev
*dev
)
247 struct fsa_dev_info
*fsa_dev_ptr
;
252 struct aac_get_container_count
*dinfo
;
253 struct aac_get_container_count_resp
*dresp
;
254 int maximum_num_containers
= MAXIMUM_NUM_CONTAINERS
;
256 instance
= dev
->scsi_host_ptr
->unique_id
;
258 if (!(fibptr
= fib_alloc(dev
)))
262 dinfo
= (struct aac_get_container_count
*) fib_data(fibptr
);
263 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
264 dinfo
->type
= cpu_to_le32(CT_GET_CONTAINER_COUNT
);
266 status
= fib_send(ContainerCommand
,
268 sizeof (struct aac_get_container_count
),
273 dresp
= (struct aac_get_container_count_resp
*)fib_data(fibptr
);
274 maximum_num_containers
= le32_to_cpu(dresp
->ContainerSwitchEntries
);
275 fib_complete(fibptr
);
278 if (maximum_num_containers
< MAXIMUM_NUM_CONTAINERS
)
279 maximum_num_containers
= MAXIMUM_NUM_CONTAINERS
;
280 fsa_dev_ptr
= (struct fsa_dev_info
*) kmalloc(
281 sizeof(*fsa_dev_ptr
) * maximum_num_containers
, GFP_KERNEL
);
286 memset(fsa_dev_ptr
, 0, sizeof(*fsa_dev_ptr
) * maximum_num_containers
);
288 dev
->fsa_dev
= fsa_dev_ptr
;
289 dev
->maximum_num_containers
= maximum_num_containers
;
291 for (index
= 0; index
< dev
->maximum_num_containers
; index
++) {
292 struct aac_query_mount
*dinfo
;
293 struct aac_mount
*dresp
;
295 fsa_dev_ptr
[index
].devname
[0] = '\0';
298 dinfo
= (struct aac_query_mount
*) fib_data(fibptr
);
300 dinfo
->command
= cpu_to_le32(VM_NameServe
);
301 dinfo
->count
= cpu_to_le32(index
);
302 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
304 status
= fib_send(ContainerCommand
,
306 sizeof (struct aac_query_mount
),
311 printk(KERN_WARNING
"aac_get_containers: SendFIB failed.\n");
314 dresp
= (struct aac_mount
*)fib_data(fibptr
);
316 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
317 (le32_to_cpu(dresp
->mnt
[0].vol
) == CT_NONE
)) {
318 dinfo
->command
= cpu_to_le32(VM_NameServe64
);
319 dinfo
->count
= cpu_to_le32(index
);
320 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
322 if (fib_send(ContainerCommand
,
324 sizeof(struct aac_query_mount
),
330 dresp
->mnt
[0].capacityhigh
= 0;
333 "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%llu\n",
334 (int)index
, (int)le32_to_cpu(dresp
->status
),
335 (int)le32_to_cpu(dresp
->mnt
[0].vol
),
336 (int)le32_to_cpu(dresp
->mnt
[0].state
),
337 ((u64
)le32_to_cpu(dresp
->mnt
[0].capacity
)) +
338 (((u64
)le32_to_cpu(dresp
->mnt
[0].capacityhigh
)) << 32)));
339 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
340 (le32_to_cpu(dresp
->mnt
[0].vol
) != CT_NONE
) &&
341 (le32_to_cpu(dresp
->mnt
[0].state
) != FSCS_HIDDEN
)) {
342 fsa_dev_ptr
[index
].valid
= 1;
343 fsa_dev_ptr
[index
].type
= le32_to_cpu(dresp
->mnt
[0].vol
);
344 fsa_dev_ptr
[index
].size
345 = ((u64
)le32_to_cpu(dresp
->mnt
[0].capacity
)) +
346 (((u64
)le32_to_cpu(dresp
->mnt
[0].capacityhigh
)) << 32);
347 if (le32_to_cpu(dresp
->mnt
[0].state
) & FSCS_READONLY
)
348 fsa_dev_ptr
[index
].ro
= 1;
350 fib_complete(fibptr
);
352 * If there are no more containers, then stop asking.
354 if ((index
+ 1) >= le32_to_cpu(dresp
->count
)){
362 static void aac_internal_transfer(struct scsi_cmnd
*scsicmd
, void *data
, unsigned int offset
, unsigned int len
)
365 unsigned int transfer_len
;
366 struct scatterlist
*sg
= scsicmd
->request_buffer
;
368 if (scsicmd
->use_sg
) {
369 buf
= kmap_atomic(sg
->page
, KM_IRQ0
) + sg
->offset
;
370 transfer_len
= min(sg
->length
, len
+ offset
);
372 buf
= scsicmd
->request_buffer
;
373 transfer_len
= min(scsicmd
->request_bufflen
, len
+ offset
);
376 memcpy(buf
+ offset
, data
, transfer_len
- offset
);
379 kunmap_atomic(buf
- sg
->offset
, KM_IRQ0
);
383 static void get_container_name_callback(void *context
, struct fib
* fibptr
)
385 struct aac_get_name_resp
* get_name_reply
;
386 struct scsi_cmnd
* scsicmd
;
388 scsicmd
= (struct scsi_cmnd
*) context
;
390 dprintk((KERN_DEBUG
"get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies
));
394 get_name_reply
= (struct aac_get_name_resp
*) fib_data(fibptr
);
395 /* Failure is irrelevant, using default value instead */
396 if ((le32_to_cpu(get_name_reply
->status
) == CT_OK
)
397 && (get_name_reply
->data
[0] != '\0')) {
398 char *sp
= get_name_reply
->data
;
399 sp
[sizeof(((struct aac_get_name_resp
*)NULL
)->data
)-1] = '\0';
403 char d
[sizeof(((struct inquiry_data
*)NULL
)->inqd_pid
)];
404 int count
= sizeof(d
);
407 *dp
++ = (*sp
) ? *sp
++ : ' ';
408 } while (--count
> 0);
409 aac_internal_transfer(scsicmd
, d
,
410 offsetof(struct inquiry_data
, inqd_pid
), sizeof(d
));
414 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
416 fib_complete(fibptr
);
418 scsicmd
->scsi_done(scsicmd
);
422 * aac_get_container_name - get container name, none blocking.
424 static int aac_get_container_name(struct scsi_cmnd
* scsicmd
, int cid
)
427 struct aac_get_name
*dinfo
;
428 struct fib
* cmd_fibcontext
;
429 struct aac_dev
* dev
;
431 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
433 if (!(cmd_fibcontext
= fib_alloc(dev
)))
436 fib_init(cmd_fibcontext
);
437 dinfo
= (struct aac_get_name
*) fib_data(cmd_fibcontext
);
439 dinfo
->command
= cpu_to_le32(VM_ContainerConfig
);
440 dinfo
->type
= cpu_to_le32(CT_READ_NAME
);
441 dinfo
->cid
= cpu_to_le32(cid
);
442 dinfo
->count
= cpu_to_le32(sizeof(((struct aac_get_name_resp
*)NULL
)->data
));
444 status
= fib_send(ContainerCommand
,
446 sizeof (struct aac_get_name
),
449 (fib_callback
) get_container_name_callback
,
453 * Check that the command queued to the controller
455 if (status
== -EINPROGRESS
)
458 printk(KERN_WARNING
"aac_get_container_name: fib_send failed with status: %d.\n", status
);
459 fib_complete(cmd_fibcontext
);
460 fib_free(cmd_fibcontext
);
465 * probe_container - query a logical volume
466 * @dev: device to query
467 * @cid: container identifier
469 * Queries the controller about the given volume. The volume information
470 * is updated in the struct fsa_dev_info structure rather than returned.
473 int probe_container(struct aac_dev
*dev
, int cid
)
475 struct fsa_dev_info
*fsa_dev_ptr
;
477 struct aac_query_mount
*dinfo
;
478 struct aac_mount
*dresp
;
482 fsa_dev_ptr
= dev
->fsa_dev
;
483 instance
= dev
->scsi_host_ptr
->unique_id
;
485 if (!(fibptr
= fib_alloc(dev
)))
490 dinfo
= (struct aac_query_mount
*)fib_data(fibptr
);
492 dinfo
->command
= cpu_to_le32(VM_NameServe
);
493 dinfo
->count
= cpu_to_le32(cid
);
494 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
496 status
= fib_send(ContainerCommand
,
498 sizeof(struct aac_query_mount
),
503 printk(KERN_WARNING
"aacraid: probe_container query failed.\n");
507 dresp
= (struct aac_mount
*) fib_data(fibptr
);
509 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
510 (le32_to_cpu(dresp
->mnt
[0].vol
) == CT_NONE
)) {
511 dinfo
->command
= cpu_to_le32(VM_NameServe64
);
512 dinfo
->count
= cpu_to_le32(cid
);
513 dinfo
->type
= cpu_to_le32(FT_FILESYS
);
515 if (fib_send(ContainerCommand
,
517 sizeof(struct aac_query_mount
),
523 dresp
->mnt
[0].capacityhigh
= 0;
525 if ((le32_to_cpu(dresp
->status
) == ST_OK
) &&
526 (le32_to_cpu(dresp
->mnt
[0].vol
) != CT_NONE
) &&
527 (le32_to_cpu(dresp
->mnt
[0].state
) != FSCS_HIDDEN
)) {
528 fsa_dev_ptr
[cid
].valid
= 1;
529 fsa_dev_ptr
[cid
].type
= le32_to_cpu(dresp
->mnt
[0].vol
);
530 fsa_dev_ptr
[cid
].size
531 = ((u64
)le32_to_cpu(dresp
->mnt
[0].capacity
)) +
532 (((u64
)le32_to_cpu(dresp
->mnt
[0].capacityhigh
)) << 32);
533 if (le32_to_cpu(dresp
->mnt
[0].state
) & FSCS_READONLY
)
534 fsa_dev_ptr
[cid
].ro
= 1;
538 fib_complete(fibptr
);
544 /* Local Structure to set SCSI inquiry data strings */
546 char vid
[8]; /* Vendor ID */
547 char pid
[16]; /* Product ID */
548 char prl
[4]; /* Product Revision Level */
552 * InqStrCopy - string merge
553 * @a: string to copy from
554 * @b: string to copy to
556 * Copy a String from one location to another
560 static void inqstrcpy(char *a
, char *b
)
567 static char *container_types
[] = {
593 /* Function: setinqstr
595 * Arguments: [1] pointer to void [1] int
597 * Purpose: Sets SCSI inquiry data strings for vendor, product
598 * and revision level. Allows strings to be set in platform dependant
599 * files instead of in OS dependant driver source.
602 static void setinqstr(struct aac_dev
*dev
, void *data
, int tindex
)
604 struct scsi_inq
*str
;
606 str
= (struct scsi_inq
*)(data
); /* cast data to scsi inq block */
607 memset(str
, ' ', sizeof(*str
));
609 if (dev
->supplement_adapter_info
.AdapterTypeText
[0]) {
610 char * cp
= dev
->supplement_adapter_info
.AdapterTypeText
;
611 int c
= sizeof(str
->vid
);
612 while (*cp
&& *cp
!= ' ' && --c
)
616 inqstrcpy (dev
->supplement_adapter_info
.AdapterTypeText
,
619 while (*cp
&& *cp
!= ' ')
623 /* last six chars reserved for vol type */
625 if (strlen(cp
) > sizeof(str
->pid
)) {
626 c
= cp
[sizeof(str
->pid
)];
627 cp
[sizeof(str
->pid
)] = '\0';
629 inqstrcpy (cp
, str
->pid
);
631 cp
[sizeof(str
->pid
)] = c
;
633 struct aac_driver_ident
*mp
= aac_get_driver_ident(dev
->cardtype
);
635 inqstrcpy (mp
->vname
, str
->vid
);
636 /* last six chars reserved for vol type */
637 inqstrcpy (mp
->model
, str
->pid
);
640 if (tindex
< (sizeof(container_types
)/sizeof(char *))){
641 char *findit
= str
->pid
;
643 for ( ; *findit
!= ' '; findit
++); /* walk till we find a space */
644 /* RAID is superfluous in the context of a RAID device */
645 if (memcmp(findit
-4, "RAID", 4) == 0)
646 *(findit
-= 4) = ' ';
647 if (((findit
- str
->pid
) + strlen(container_types
[tindex
]))
648 < (sizeof(str
->pid
) + sizeof(str
->prl
)))
649 inqstrcpy (container_types
[tindex
], findit
+ 1);
651 inqstrcpy ("V1.0", str
->prl
);
654 static void set_sense(u8
*sense_buf
, u8 sense_key
, u8 sense_code
,
655 u8 a_sense_code
, u8 incorrect_length
,
656 u8 bit_pointer
, u16 field_pointer
,
659 sense_buf
[0] = 0xF0; /* Sense data valid, err code 70h (current error) */
660 sense_buf
[1] = 0; /* Segment number, always zero */
662 if (incorrect_length
) {
663 sense_buf
[2] = sense_key
| 0x20;/* Set ILI bit | sense key */
664 sense_buf
[3] = BYTE3(residue
);
665 sense_buf
[4] = BYTE2(residue
);
666 sense_buf
[5] = BYTE1(residue
);
667 sense_buf
[6] = BYTE0(residue
);
669 sense_buf
[2] = sense_key
; /* Sense key */
671 if (sense_key
== ILLEGAL_REQUEST
)
672 sense_buf
[7] = 10; /* Additional sense length */
674 sense_buf
[7] = 6; /* Additional sense length */
676 sense_buf
[12] = sense_code
; /* Additional sense code */
677 sense_buf
[13] = a_sense_code
; /* Additional sense code qualifier */
678 if (sense_key
== ILLEGAL_REQUEST
) {
681 if (sense_code
== SENCODE_INVALID_PARAM_FIELD
)
682 sense_buf
[15] = 0x80;/* Std sense key specific field */
683 /* Illegal parameter is in the parameter block */
685 if (sense_code
== SENCODE_INVALID_CDB_FIELD
)
686 sense_buf
[15] = 0xc0;/* Std sense key specific field */
687 /* Illegal parameter is in the CDB block */
688 sense_buf
[15] |= bit_pointer
;
689 sense_buf
[16] = field_pointer
>> 8; /* MSB */
690 sense_buf
[17] = field_pointer
; /* LSB */
694 int aac_get_adapter_info(struct aac_dev
* dev
)
699 struct aac_adapter_info
*info
;
700 struct aac_bus_info
*command
;
701 struct aac_bus_info_response
*bus_info
;
703 if (!(fibptr
= fib_alloc(dev
)))
707 info
= (struct aac_adapter_info
*) fib_data(fibptr
);
708 memset(info
,0,sizeof(*info
));
710 rcode
= fib_send(RequestAdapterInfo
,
714 -1, 1, /* First `interrupt' command uses special wait */
719 fib_complete(fibptr
);
723 memcpy(&dev
->adapter_info
, info
, sizeof(*info
));
725 if (dev
->adapter_info
.options
& AAC_OPT_SUPPLEMENT_ADAPTER_INFO
) {
726 struct aac_supplement_adapter_info
* info
;
730 info
= (struct aac_supplement_adapter_info
*) fib_data(fibptr
);
732 memset(info
,0,sizeof(*info
));
734 rcode
= fib_send(RequestSupplementAdapterInfo
,
743 memcpy(&dev
->supplement_adapter_info
, info
, sizeof(*info
));
753 bus_info
= (struct aac_bus_info_response
*) fib_data(fibptr
);
755 memset(bus_info
, 0, sizeof(*bus_info
));
757 command
= (struct aac_bus_info
*)bus_info
;
759 command
->Command
= cpu_to_le32(VM_Ioctl
);
760 command
->ObjType
= cpu_to_le32(FT_DRIVE
);
761 command
->MethodId
= cpu_to_le32(1);
762 command
->CtlCmd
= cpu_to_le32(GetBusInfo
);
764 rcode
= fib_send(ContainerCommand
,
771 if (rcode
>= 0 && le32_to_cpu(bus_info
->Status
) == ST_OK
) {
772 dev
->maximum_num_physicals
= le32_to_cpu(bus_info
->TargetsPerBus
);
773 dev
->maximum_num_channels
= le32_to_cpu(bus_info
->BusCount
);
776 tmp
= le32_to_cpu(dev
->adapter_info
.kernelrev
);
777 printk(KERN_INFO
"%s%d: kernel %d.%d-%d[%d] %.*s\n",
783 le32_to_cpu(dev
->adapter_info
.kernelbuild
),
784 (int)sizeof(dev
->supplement_adapter_info
.BuildDate
),
785 dev
->supplement_adapter_info
.BuildDate
);
786 tmp
= le32_to_cpu(dev
->adapter_info
.monitorrev
);
787 printk(KERN_INFO
"%s%d: monitor %d.%d-%d[%d]\n",
789 tmp
>>24,(tmp
>>16)&0xff,tmp
&0xff,
790 le32_to_cpu(dev
->adapter_info
.monitorbuild
));
791 tmp
= le32_to_cpu(dev
->adapter_info
.biosrev
);
792 printk(KERN_INFO
"%s%d: bios %d.%d-%d[%d]\n",
794 tmp
>>24,(tmp
>>16)&0xff,tmp
&0xff,
795 le32_to_cpu(dev
->adapter_info
.biosbuild
));
796 if (le32_to_cpu(dev
->adapter_info
.serial
[0]) != 0xBAD0)
797 printk(KERN_INFO
"%s%d: serial %x\n",
799 le32_to_cpu(dev
->adapter_info
.serial
[0]));
801 dev
->nondasd_support
= 0;
802 dev
->raid_scsi_mode
= 0;
803 if(dev
->adapter_info
.options
& AAC_OPT_NONDASD
){
804 dev
->nondasd_support
= 1;
808 * If the firmware supports ROMB RAID/SCSI mode and we are currently
809 * in RAID/SCSI mode, set the flag. For now if in this mode we will
810 * force nondasd support on. If we decide to allow the non-dasd flag
811 * additional changes changes will have to be made to support
812 * RAID/SCSI. the function aac_scsi_cmd in this module will have to be
813 * changed to support the new dev->raid_scsi_mode flag instead of
814 * leaching off of the dev->nondasd_support flag. Also in linit.c the
815 * function aac_detect will have to be modified where it sets up the
816 * max number of channels based on the aac->nondasd_support flag only.
818 if ((dev
->adapter_info
.options
& AAC_OPT_SCSI_MANAGED
) &&
819 (dev
->adapter_info
.options
& AAC_OPT_RAID_SCSI_MODE
)) {
820 dev
->nondasd_support
= 1;
821 dev
->raid_scsi_mode
= 1;
823 if (dev
->raid_scsi_mode
!= 0)
824 printk(KERN_INFO
"%s%d: ROMB RAID/SCSI mode enabled\n",
828 dev
->nondasd_support
= (nondasd
!=0);
830 if(dev
->nondasd_support
!= 0){
831 printk(KERN_INFO
"%s%d: Non-DASD support enabled.\n",dev
->name
, dev
->id
);
834 dev
->dac_support
= 0;
835 if( (sizeof(dma_addr_t
) > 4) && (dev
->adapter_info
.options
& AAC_OPT_SGMAP_HOST64
)){
836 printk(KERN_INFO
"%s%d: 64bit support enabled.\n", dev
->name
, dev
->id
);
837 dev
->dac_support
= 1;
841 dev
->dac_support
= (dacmode
!=0);
843 if(dev
->dac_support
!= 0) {
844 if (!pci_set_dma_mask(dev
->pdev
, DMA_64BIT_MASK
) &&
845 !pci_set_consistent_dma_mask(dev
->pdev
, DMA_64BIT_MASK
)) {
846 printk(KERN_INFO
"%s%d: 64 Bit DAC enabled\n",
848 } else if (!pci_set_dma_mask(dev
->pdev
, DMA_32BIT_MASK
) &&
849 !pci_set_consistent_dma_mask(dev
->pdev
, DMA_32BIT_MASK
)) {
850 printk(KERN_INFO
"%s%d: DMA mask set failed, 64 Bit DAC disabled\n",
852 dev
->dac_support
= 0;
854 printk(KERN_WARNING
"%s%d: No suitable DMA available.\n",
860 * 57 scatter gather elements
862 if (!(dev
->raw_io_interface
)) {
863 dev
->scsi_host_ptr
->sg_tablesize
= (dev
->max_fib_size
-
864 sizeof(struct aac_fibhdr
) -
865 sizeof(struct aac_write
) + sizeof(struct sgentry
)) /
866 sizeof(struct sgentry
);
867 if (dev
->dac_support
) {
869 * 38 scatter gather elements
871 dev
->scsi_host_ptr
->sg_tablesize
=
873 sizeof(struct aac_fibhdr
) -
874 sizeof(struct aac_write64
) +
875 sizeof(struct sgentry64
)) /
876 sizeof(struct sgentry64
);
878 dev
->scsi_host_ptr
->max_sectors
= AAC_MAX_32BIT_SGBCOUNT
;
879 if(!(dev
->adapter_info
.options
& AAC_OPT_NEW_COMM
)) {
881 * Worst case size that could cause sg overflow when
882 * we break up SG elements that are larger than 64KB.
883 * Would be nice if we could tell the SCSI layer what
884 * the maximum SG element size can be. Worst case is
885 * (sg_tablesize-1) 4KB elements with one 64KB
887 * 32bit -> 468 or 238KB 64bit -> 424 or 212KB
889 dev
->scsi_host_ptr
->max_sectors
=
890 (dev
->scsi_host_ptr
->sg_tablesize
* 8) + 112;
894 fib_complete(fibptr
);
901 static void io_callback(void *context
, struct fib
* fibptr
)
904 struct aac_read_reply
*readreply
;
905 struct scsi_cmnd
*scsicmd
;
908 scsicmd
= (struct scsi_cmnd
*) context
;
910 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
911 cid
= ID_LUN_TO_CONTAINER(scsicmd
->device
->id
, scsicmd
->device
->lun
);
913 if (nblank(dprintk(x
))) {
915 switch (scsicmd
->cmnd
[0]) {
918 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) |
919 (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
923 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
924 ((u64
)scsicmd
->cmnd
[3] << 48) |
925 ((u64
)scsicmd
->cmnd
[4] << 40) |
926 ((u64
)scsicmd
->cmnd
[5] << 32) |
927 ((u64
)scsicmd
->cmnd
[6] << 24) |
928 (scsicmd
->cmnd
[7] << 16) |
929 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
933 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
934 (scsicmd
->cmnd
[3] << 16) |
935 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
938 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
939 (scsicmd
->cmnd
[3] << 16) |
940 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
944 "io_callback[cpu %d]: lba = %llu, t = %ld.\n",
945 smp_processor_id(), (unsigned long long)lba
, jiffies
);
952 pci_unmap_sg(dev
->pdev
,
953 (struct scatterlist
*)scsicmd
->buffer
,
955 scsicmd
->sc_data_direction
);
956 else if(scsicmd
->request_bufflen
)
957 pci_unmap_single(dev
->pdev
, scsicmd
->SCp
.dma_handle
,
958 scsicmd
->request_bufflen
,
959 scsicmd
->sc_data_direction
);
960 readreply
= (struct aac_read_reply
*)fib_data(fibptr
);
961 if (le32_to_cpu(readreply
->status
) == ST_OK
)
962 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
964 #ifdef AAC_DETAILED_STATUS_INFO
965 printk(KERN_WARNING
"io_callback: io failed, status = %d\n",
966 le32_to_cpu(readreply
->status
));
968 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
969 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
971 SENCODE_INTERNAL_TARGET_FAILURE
,
972 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
974 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
975 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
976 ? sizeof(scsicmd
->sense_buffer
)
977 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
979 fib_complete(fibptr
);
982 scsicmd
->scsi_done(scsicmd
);
985 static int aac_read(struct scsi_cmnd
* scsicmd
, int cid
)
993 struct fib
* cmd_fibcontext
;
995 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
997 * Get block address and transfer length
999 switch (scsicmd
->cmnd
[0]) {
1001 dprintk((KERN_DEBUG
"aachba: received a read(6) command on id %d.\n", cid
));
1003 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) |
1004 (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1005 count
= scsicmd
->cmnd
[4];
1011 dprintk((KERN_DEBUG
"aachba: received a read(16) command on id %d.\n", cid
));
1013 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1014 ((u64
)scsicmd
->cmnd
[3] << 48) |
1015 ((u64
)scsicmd
->cmnd
[4] << 40) |
1016 ((u64
)scsicmd
->cmnd
[5] << 32) |
1017 ((u64
)scsicmd
->cmnd
[6] << 24) |
1018 (scsicmd
->cmnd
[7] << 16) |
1019 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1020 count
= (scsicmd
->cmnd
[10] << 24) |
1021 (scsicmd
->cmnd
[11] << 16) |
1022 (scsicmd
->cmnd
[12] << 8) | scsicmd
->cmnd
[13];
1025 dprintk((KERN_DEBUG
"aachba: received a read(12) command on id %d.\n", cid
));
1027 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1028 (scsicmd
->cmnd
[3] << 16) |
1029 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1030 count
= (scsicmd
->cmnd
[6] << 24) |
1031 (scsicmd
->cmnd
[7] << 16) |
1032 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1035 dprintk((KERN_DEBUG
"aachba: received a read(10) command on id %d.\n", cid
));
1037 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) |
1038 (scsicmd
->cmnd
[3] << 16) |
1039 (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1040 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
1043 dprintk((KERN_DEBUG
"aac_read[cpu %d]: lba = %llu, t = %ld.\n",
1044 smp_processor_id(), (unsigned long long)lba
, jiffies
));
1045 if ((!(dev
->raw_io_interface
) || !(dev
->raw_io_64
)) &&
1046 (lba
& 0xffffffff00000000LL
)) {
1047 dprintk((KERN_DEBUG
"aac_read: Illegal lba\n"));
1048 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 |
1049 SAM_STAT_CHECK_CONDITION
;
1050 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1052 SENCODE_INTERNAL_TARGET_FAILURE
,
1053 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
1055 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1056 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1057 ? sizeof(scsicmd
->sense_buffer
)
1058 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1059 scsicmd
->scsi_done(scsicmd
);
1063 * Alocate and initialize a Fib
1065 if (!(cmd_fibcontext
= fib_alloc(dev
))) {
1069 fib_init(cmd_fibcontext
);
1071 if (dev
->raw_io_interface
) {
1072 struct aac_raw_io
*readcmd
;
1073 readcmd
= (struct aac_raw_io
*) fib_data(cmd_fibcontext
);
1074 readcmd
->block
[0] = cpu_to_le32((u32
)(lba
&0xffffffff));
1075 readcmd
->block
[1] = cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
1076 readcmd
->count
= cpu_to_le32(count
<<9);
1077 readcmd
->cid
= cpu_to_le16(cid
);
1078 readcmd
->flags
= cpu_to_le16(1);
1079 readcmd
->bpTotal
= 0;
1080 readcmd
->bpComplete
= 0;
1082 aac_build_sgraw(scsicmd
, &readcmd
->sg
);
1083 fibsize
= sizeof(struct aac_raw_io
) + ((le32_to_cpu(readcmd
->sg
.count
) - 1) * sizeof (struct sgentryraw
));
1084 if (fibsize
> (dev
->max_fib_size
- sizeof(struct aac_fibhdr
)))
1087 * Now send the Fib to the adapter
1089 status
= fib_send(ContainerRawIo
,
1094 (fib_callback
) io_callback
,
1096 } else if (dev
->dac_support
== 1) {
1097 struct aac_read64
*readcmd
;
1098 readcmd
= (struct aac_read64
*) fib_data(cmd_fibcontext
);
1099 readcmd
->command
= cpu_to_le32(VM_CtHostRead64
);
1100 readcmd
->cid
= cpu_to_le16(cid
);
1101 readcmd
->sector_count
= cpu_to_le16(count
);
1102 readcmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
1106 aac_build_sg64(scsicmd
, &readcmd
->sg
);
1107 fibsize
= sizeof(struct aac_read64
) +
1108 ((le32_to_cpu(readcmd
->sg
.count
) - 1) *
1109 sizeof (struct sgentry64
));
1110 BUG_ON (fibsize
> (dev
->max_fib_size
-
1111 sizeof(struct aac_fibhdr
)));
1113 * Now send the Fib to the adapter
1115 status
= fib_send(ContainerCommand64
,
1120 (fib_callback
) io_callback
,
1123 struct aac_read
*readcmd
;
1124 readcmd
= (struct aac_read
*) fib_data(cmd_fibcontext
);
1125 readcmd
->command
= cpu_to_le32(VM_CtBlockRead
);
1126 readcmd
->cid
= cpu_to_le32(cid
);
1127 readcmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
1128 readcmd
->count
= cpu_to_le32(count
* 512);
1130 aac_build_sg(scsicmd
, &readcmd
->sg
);
1131 fibsize
= sizeof(struct aac_read
) +
1132 ((le32_to_cpu(readcmd
->sg
.count
) - 1) *
1133 sizeof (struct sgentry
));
1134 BUG_ON (fibsize
> (dev
->max_fib_size
-
1135 sizeof(struct aac_fibhdr
)));
1137 * Now send the Fib to the adapter
1139 status
= fib_send(ContainerCommand
,
1144 (fib_callback
) io_callback
,
1151 * Check that the command queued to the controller
1153 if (status
== -EINPROGRESS
)
1156 printk(KERN_WARNING
"aac_read: fib_send failed with status: %d.\n", status
);
1158 * For some reason, the Fib didn't queue, return QUEUE_FULL
1160 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_TASK_SET_FULL
;
1161 scsicmd
->scsi_done(scsicmd
);
1162 fib_complete(cmd_fibcontext
);
1163 fib_free(cmd_fibcontext
);
1167 static int aac_write(struct scsi_cmnd
* scsicmd
, int cid
)
1173 struct aac_dev
*dev
;
1174 struct fib
* cmd_fibcontext
;
1176 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1178 * Get block address and transfer length
1180 if (scsicmd
->cmnd
[0] == WRITE_6
) /* 6 byte command */
1182 lba
= ((scsicmd
->cmnd
[1] & 0x1F) << 16) | (scsicmd
->cmnd
[2] << 8) | scsicmd
->cmnd
[3];
1183 count
= scsicmd
->cmnd
[4];
1186 } else if (scsicmd
->cmnd
[0] == WRITE_16
) { /* 16 byte command */
1187 dprintk((KERN_DEBUG
"aachba: received a write(16) command on id %d.\n", cid
));
1189 lba
= ((u64
)scsicmd
->cmnd
[2] << 56) |
1190 ((u64
)scsicmd
->cmnd
[3] << 48) |
1191 ((u64
)scsicmd
->cmnd
[4] << 40) |
1192 ((u64
)scsicmd
->cmnd
[5] << 32) |
1193 ((u64
)scsicmd
->cmnd
[6] << 24) |
1194 (scsicmd
->cmnd
[7] << 16) |
1195 (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1196 count
= (scsicmd
->cmnd
[10] << 24) | (scsicmd
->cmnd
[11] << 16) |
1197 (scsicmd
->cmnd
[12] << 8) | scsicmd
->cmnd
[13];
1198 } else if (scsicmd
->cmnd
[0] == WRITE_12
) { /* 12 byte command */
1199 dprintk((KERN_DEBUG
"aachba: received a write(12) command on id %d.\n", cid
));
1201 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16)
1202 | (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1203 count
= (scsicmd
->cmnd
[6] << 24) | (scsicmd
->cmnd
[7] << 16)
1204 | (scsicmd
->cmnd
[8] << 8) | scsicmd
->cmnd
[9];
1206 dprintk((KERN_DEBUG
"aachba: received a write(10) command on id %d.\n", cid
));
1207 lba
= ((u64
)scsicmd
->cmnd
[2] << 24) | (scsicmd
->cmnd
[3] << 16) | (scsicmd
->cmnd
[4] << 8) | scsicmd
->cmnd
[5];
1208 count
= (scsicmd
->cmnd
[7] << 8) | scsicmd
->cmnd
[8];
1210 dprintk((KERN_DEBUG
"aac_write[cpu %d]: lba = %llu, t = %ld.\n",
1211 smp_processor_id(), (unsigned long long)lba
, jiffies
));
1212 if ((!(dev
->raw_io_interface
) || !(dev
->raw_io_64
))
1213 && (lba
& 0xffffffff00000000LL
)) {
1214 dprintk((KERN_DEBUG
"aac_write: Illegal lba\n"));
1215 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1216 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1218 SENCODE_INTERNAL_TARGET_FAILURE
,
1219 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
1221 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1222 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1223 ? sizeof(scsicmd
->sense_buffer
)
1224 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1225 scsicmd
->scsi_done(scsicmd
);
1229 * Allocate and initialize a Fib then setup a BlockWrite command
1231 if (!(cmd_fibcontext
= fib_alloc(dev
))) {
1232 scsicmd
->result
= DID_ERROR
<< 16;
1233 scsicmd
->scsi_done(scsicmd
);
1236 fib_init(cmd_fibcontext
);
1238 if (dev
->raw_io_interface
) {
1239 struct aac_raw_io
*writecmd
;
1240 writecmd
= (struct aac_raw_io
*) fib_data(cmd_fibcontext
);
1241 writecmd
->block
[0] = cpu_to_le32((u32
)(lba
&0xffffffff));
1242 writecmd
->block
[1] = cpu_to_le32((u32
)((lba
&0xffffffff00000000LL
)>>32));
1243 writecmd
->count
= cpu_to_le32(count
<<9);
1244 writecmd
->cid
= cpu_to_le16(cid
);
1245 writecmd
->flags
= 0;
1246 writecmd
->bpTotal
= 0;
1247 writecmd
->bpComplete
= 0;
1249 aac_build_sgraw(scsicmd
, &writecmd
->sg
);
1250 fibsize
= sizeof(struct aac_raw_io
) + ((le32_to_cpu(writecmd
->sg
.count
) - 1) * sizeof (struct sgentryraw
));
1251 if (fibsize
> (dev
->max_fib_size
- sizeof(struct aac_fibhdr
)))
1254 * Now send the Fib to the adapter
1256 status
= fib_send(ContainerRawIo
,
1261 (fib_callback
) io_callback
,
1263 } else if (dev
->dac_support
== 1) {
1264 struct aac_write64
*writecmd
;
1265 writecmd
= (struct aac_write64
*) fib_data(cmd_fibcontext
);
1266 writecmd
->command
= cpu_to_le32(VM_CtHostWrite64
);
1267 writecmd
->cid
= cpu_to_le16(cid
);
1268 writecmd
->sector_count
= cpu_to_le16(count
);
1269 writecmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
1271 writecmd
->flags
= 0;
1273 aac_build_sg64(scsicmd
, &writecmd
->sg
);
1274 fibsize
= sizeof(struct aac_write64
) +
1275 ((le32_to_cpu(writecmd
->sg
.count
) - 1) *
1276 sizeof (struct sgentry64
));
1277 BUG_ON (fibsize
> (dev
->max_fib_size
-
1278 sizeof(struct aac_fibhdr
)));
1280 * Now send the Fib to the adapter
1282 status
= fib_send(ContainerCommand64
,
1287 (fib_callback
) io_callback
,
1290 struct aac_write
*writecmd
;
1291 writecmd
= (struct aac_write
*) fib_data(cmd_fibcontext
);
1292 writecmd
->command
= cpu_to_le32(VM_CtBlockWrite
);
1293 writecmd
->cid
= cpu_to_le32(cid
);
1294 writecmd
->block
= cpu_to_le32((u32
)(lba
&0xffffffff));
1295 writecmd
->count
= cpu_to_le32(count
* 512);
1296 writecmd
->sg
.count
= cpu_to_le32(1);
1297 /* ->stable is not used - it did mean which type of write */
1299 aac_build_sg(scsicmd
, &writecmd
->sg
);
1300 fibsize
= sizeof(struct aac_write
) +
1301 ((le32_to_cpu(writecmd
->sg
.count
) - 1) *
1302 sizeof (struct sgentry
));
1303 BUG_ON (fibsize
> (dev
->max_fib_size
-
1304 sizeof(struct aac_fibhdr
)));
1306 * Now send the Fib to the adapter
1308 status
= fib_send(ContainerCommand
,
1313 (fib_callback
) io_callback
,
1318 * Check that the command queued to the controller
1320 if (status
== -EINPROGRESS
)
1325 printk(KERN_WARNING
"aac_write: fib_send failed with status: %d\n", status
);
1327 * For some reason, the Fib didn't queue, return QUEUE_FULL
1329 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_TASK_SET_FULL
;
1330 scsicmd
->scsi_done(scsicmd
);
1332 fib_complete(cmd_fibcontext
);
1333 fib_free(cmd_fibcontext
);
1337 static void synchronize_callback(void *context
, struct fib
*fibptr
)
1339 struct aac_synchronize_reply
*synchronizereply
;
1340 struct scsi_cmnd
*cmd
;
1344 dprintk((KERN_DEBUG
"synchronize_callback[cpu %d]: t = %ld.\n",
1345 smp_processor_id(), jiffies
));
1346 BUG_ON(fibptr
== NULL
);
1349 synchronizereply
= fib_data(fibptr
);
1350 if (le32_to_cpu(synchronizereply
->status
) == CT_OK
)
1351 cmd
->result
= DID_OK
<< 16 |
1352 COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1354 struct scsi_device
*sdev
= cmd
->device
;
1355 struct aac_dev
*dev
= (struct aac_dev
*)sdev
->host
->hostdata
;
1356 u32 cid
= ID_LUN_TO_CONTAINER(sdev
->id
, sdev
->lun
);
1358 "synchronize_callback: synchronize failed, status = %d\n",
1359 le32_to_cpu(synchronizereply
->status
));
1360 cmd
->result
= DID_OK
<< 16 |
1361 COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1362 set_sense((u8
*)&dev
->fsa_dev
[cid
].sense_data
,
1364 SENCODE_INTERNAL_TARGET_FAILURE
,
1365 ASENCODE_INTERNAL_TARGET_FAILURE
, 0, 0,
1367 memcpy(cmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1368 min(sizeof(dev
->fsa_dev
[cid
].sense_data
),
1369 sizeof(cmd
->sense_buffer
)));
1372 fib_complete(fibptr
);
1374 cmd
->scsi_done(cmd
);
1377 static int aac_synchronize(struct scsi_cmnd
*scsicmd
, int cid
)
1380 struct fib
*cmd_fibcontext
;
1381 struct aac_synchronize
*synchronizecmd
;
1382 struct scsi_cmnd
*cmd
;
1383 struct scsi_device
*sdev
= scsicmd
->device
;
1385 unsigned long flags
;
1388 * Wait for all commands to complete to this specific
1391 spin_lock_irqsave(&sdev
->list_lock
, flags
);
1392 list_for_each_entry(cmd
, &sdev
->cmd_list
, list
)
1393 if (cmd
!= scsicmd
&& cmd
->serial_number
!= 0) {
1398 spin_unlock_irqrestore(&sdev
->list_lock
, flags
);
1401 * Yield the processor (requeue for later)
1404 return SCSI_MLQUEUE_DEVICE_BUSY
;
1407 * Allocate and initialize a Fib
1409 if (!(cmd_fibcontext
=
1410 fib_alloc((struct aac_dev
*)scsicmd
->device
->host
->hostdata
)))
1411 return SCSI_MLQUEUE_HOST_BUSY
;
1413 fib_init(cmd_fibcontext
);
1415 synchronizecmd
= fib_data(cmd_fibcontext
);
1416 synchronizecmd
->command
= cpu_to_le32(VM_ContainerConfig
);
1417 synchronizecmd
->type
= cpu_to_le32(CT_FLUSH_CACHE
);
1418 synchronizecmd
->cid
= cpu_to_le32(cid
);
1419 synchronizecmd
->count
=
1420 cpu_to_le32(sizeof(((struct aac_synchronize_reply
*)NULL
)->data
));
1423 * Now send the Fib to the adapter
1425 status
= fib_send(ContainerCommand
,
1427 sizeof(struct aac_synchronize
),
1430 (fib_callback
)synchronize_callback
,
1434 * Check that the command queued to the controller
1436 if (status
== -EINPROGRESS
)
1440 "aac_synchronize: fib_send failed with status: %d.\n", status
);
1441 fib_complete(cmd_fibcontext
);
1442 fib_free(cmd_fibcontext
);
1443 return SCSI_MLQUEUE_HOST_BUSY
;
1447 * aac_scsi_cmd() - Process SCSI command
1448 * @scsicmd: SCSI command block
1450 * Emulate a SCSI command and queue the required request for the
1454 int aac_scsi_cmd(struct scsi_cmnd
* scsicmd
)
1457 struct Scsi_Host
*host
= scsicmd
->device
->host
;
1458 struct aac_dev
*dev
= (struct aac_dev
*)host
->hostdata
;
1459 struct fsa_dev_info
*fsa_dev_ptr
= dev
->fsa_dev
;
1463 * If the bus, id or lun is out of range, return fail
1464 * Test does not apply to ID 16, the pseudo id for the controller
1467 if (scmd_id(scsicmd
) != host
->this_id
) {
1468 if ((scsicmd
->device
->channel
== 0) ){
1469 if( (scsicmd
->device
->id
>= dev
->maximum_num_containers
) || (scsicmd
->device
->lun
!= 0)){
1470 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1471 scsicmd
->scsi_done(scsicmd
);
1474 cid
= ID_LUN_TO_CONTAINER(scsicmd
->device
->id
, scsicmd
->device
->lun
);
1477 * If the target container doesn't exist, it may have
1478 * been newly created
1480 if ((fsa_dev_ptr
[cid
].valid
& 1) == 0) {
1481 switch (scsicmd
->cmnd
[0]) {
1482 case SERVICE_ACTION_IN
:
1483 if (!(dev
->raw_io_interface
) ||
1484 !(dev
->raw_io_64
) ||
1485 ((scsicmd
->cmnd
[1] & 0x1f) != SAI_READ_CAPACITY_16
))
1489 case TEST_UNIT_READY
:
1490 spin_unlock_irq(host
->host_lock
);
1491 probe_container(dev
, cid
);
1492 if ((fsa_dev_ptr
[cid
].valid
& 1) == 0)
1493 fsa_dev_ptr
[cid
].valid
= 0;
1494 spin_lock_irq(host
->host_lock
);
1495 if (fsa_dev_ptr
[cid
].valid
== 0) {
1496 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1497 scsicmd
->scsi_done(scsicmd
);
1505 * If the target container still doesn't exist,
1508 if (fsa_dev_ptr
[cid
].valid
== 0) {
1509 scsicmd
->result
= DID_BAD_TARGET
<< 16;
1510 scsicmd
->scsi_done(scsicmd
);
1513 } else { /* check for physical non-dasd devices */
1514 if(dev
->nondasd_support
== 1){
1515 return aac_send_srb_fib(scsicmd
);
1517 scsicmd
->result
= DID_NO_CONNECT
<< 16;
1518 scsicmd
->scsi_done(scsicmd
);
1524 * else Command for the controller itself
1526 else if ((scsicmd
->cmnd
[0] != INQUIRY
) && /* only INQUIRY & TUR cmnd supported for controller */
1527 (scsicmd
->cmnd
[0] != TEST_UNIT_READY
))
1529 dprintk((KERN_WARNING
"Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd
->cmnd
[0]));
1530 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1531 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1533 SENCODE_INVALID_COMMAND
,
1534 ASENCODE_INVALID_COMMAND
, 0, 0, 0, 0);
1535 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1536 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1537 ? sizeof(scsicmd
->sense_buffer
)
1538 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1539 scsicmd
->scsi_done(scsicmd
);
1544 /* Handle commands here that don't really require going out to the adapter */
1545 switch (scsicmd
->cmnd
[0]) {
1548 struct inquiry_data inq_data
;
1550 dprintk((KERN_DEBUG
"INQUIRY command, ID: %d.\n", scsicmd
->device
->id
));
1551 memset(&inq_data
, 0, sizeof (struct inquiry_data
));
1553 inq_data
.inqd_ver
= 2; /* claim compliance to SCSI-2 */
1554 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 */
1555 inq_data
.inqd_len
= 31;
1556 /*Format for "pad2" is RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
1557 inq_data
.inqd_pad2
= 0x32 ; /*WBus16|Sync|CmdQue */
1559 * Set the Vendor, Product, and Revision Level
1560 * see: <vendor>.c i.e. aac.c
1562 if (scmd_id(scsicmd
) == host
->this_id
) {
1563 setinqstr(dev
, (void *) (inq_data
.inqd_vid
), (sizeof(container_types
)/sizeof(char *)));
1564 inq_data
.inqd_pdt
= INQD_PDT_PROC
; /* Processor device */
1565 aac_internal_transfer(scsicmd
, &inq_data
, 0, sizeof(inq_data
));
1566 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1567 scsicmd
->scsi_done(scsicmd
);
1570 setinqstr(dev
, (void *) (inq_data
.inqd_vid
), fsa_dev_ptr
[cid
].type
);
1571 inq_data
.inqd_pdt
= INQD_PDT_DA
; /* Direct/random access device */
1572 aac_internal_transfer(scsicmd
, &inq_data
, 0, sizeof(inq_data
));
1573 return aac_get_container_name(scsicmd
, cid
);
1575 case SERVICE_ACTION_IN
:
1576 if (!(dev
->raw_io_interface
) ||
1577 !(dev
->raw_io_64
) ||
1578 ((scsicmd
->cmnd
[1] & 0x1f) != SAI_READ_CAPACITY_16
))
1583 unsigned int offset
= 0;
1585 dprintk((KERN_DEBUG
"READ CAPACITY_16 command.\n"));
1586 capacity
= fsa_dev_ptr
[cid
].size
- 1;
1587 if (scsicmd
->cmnd
[13] > 12) {
1588 offset
= scsicmd
->cmnd
[13] - 12;
1589 if (offset
> sizeof(cp
))
1591 memset(cp
, 0, offset
);
1592 aac_internal_transfer(scsicmd
, cp
, 0, offset
);
1594 cp
[0] = (capacity
>> 56) & 0xff;
1595 cp
[1] = (capacity
>> 48) & 0xff;
1596 cp
[2] = (capacity
>> 40) & 0xff;
1597 cp
[3] = (capacity
>> 32) & 0xff;
1598 cp
[4] = (capacity
>> 24) & 0xff;
1599 cp
[5] = (capacity
>> 16) & 0xff;
1600 cp
[6] = (capacity
>> 8) & 0xff;
1601 cp
[7] = (capacity
>> 0) & 0xff;
1606 aac_internal_transfer(scsicmd
, cp
, offset
, sizeof(cp
));
1608 /* Do not cache partition table for arrays */
1609 scsicmd
->device
->removable
= 1;
1611 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1612 scsicmd
->scsi_done(scsicmd
);
1622 dprintk((KERN_DEBUG
"READ CAPACITY command.\n"));
1623 if (fsa_dev_ptr
[cid
].size
<= 0x100000000ULL
)
1624 capacity
= fsa_dev_ptr
[cid
].size
- 1;
1628 cp
[0] = (capacity
>> 24) & 0xff;
1629 cp
[1] = (capacity
>> 16) & 0xff;
1630 cp
[2] = (capacity
>> 8) & 0xff;
1631 cp
[3] = (capacity
>> 0) & 0xff;
1636 aac_internal_transfer(scsicmd
, cp
, 0, sizeof(cp
));
1637 /* Do not cache partition table for arrays */
1638 scsicmd
->device
->removable
= 1;
1640 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1641 scsicmd
->scsi_done(scsicmd
);
1650 dprintk((KERN_DEBUG
"MODE SENSE command.\n"));
1651 mode_buf
[0] = 3; /* Mode data length */
1652 mode_buf
[1] = 0; /* Medium type - default */
1653 mode_buf
[2] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */
1654 mode_buf
[3] = 0; /* Block descriptor length */
1656 aac_internal_transfer(scsicmd
, mode_buf
, 0, sizeof(mode_buf
));
1657 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1658 scsicmd
->scsi_done(scsicmd
);
1666 dprintk((KERN_DEBUG
"MODE SENSE 10 byte command.\n"));
1667 mode_buf
[0] = 0; /* Mode data length (MSB) */
1668 mode_buf
[1] = 6; /* Mode data length (LSB) */
1669 mode_buf
[2] = 0; /* Medium type - default */
1670 mode_buf
[3] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */
1671 mode_buf
[4] = 0; /* reserved */
1672 mode_buf
[5] = 0; /* reserved */
1673 mode_buf
[6] = 0; /* Block descriptor length (MSB) */
1674 mode_buf
[7] = 0; /* Block descriptor length (LSB) */
1675 aac_internal_transfer(scsicmd
, mode_buf
, 0, sizeof(mode_buf
));
1677 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1678 scsicmd
->scsi_done(scsicmd
);
1683 dprintk((KERN_DEBUG
"REQUEST SENSE command.\n"));
1684 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
, sizeof (struct sense_data
));
1685 memset(&dev
->fsa_dev
[cid
].sense_data
, 0, sizeof (struct sense_data
));
1686 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1687 scsicmd
->scsi_done(scsicmd
);
1690 case ALLOW_MEDIUM_REMOVAL
:
1691 dprintk((KERN_DEBUG
"LOCK command.\n"));
1692 if (scsicmd
->cmnd
[4])
1693 fsa_dev_ptr
[cid
].locked
= 1;
1695 fsa_dev_ptr
[cid
].locked
= 0;
1697 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1698 scsicmd
->scsi_done(scsicmd
);
1701 * These commands are all No-Ops
1703 case TEST_UNIT_READY
:
1707 case REASSIGN_BLOCKS
:
1710 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_GOOD
;
1711 scsicmd
->scsi_done(scsicmd
);
1715 switch (scsicmd
->cmnd
[0])
1722 * Hack to keep track of ordinal number of the device that
1723 * corresponds to a container. Needed to convert
1724 * containers to /dev/sd device names
1727 spin_unlock_irq(host
->host_lock
);
1728 if (scsicmd
->request
->rq_disk
)
1729 strlcpy(fsa_dev_ptr
[cid
].devname
,
1730 scsicmd
->request
->rq_disk
->disk_name
,
1731 min(sizeof(fsa_dev_ptr
[cid
].devname
),
1732 sizeof(scsicmd
->request
->rq_disk
->disk_name
) + 1));
1733 ret
= aac_read(scsicmd
, cid
);
1734 spin_lock_irq(host
->host_lock
);
1741 spin_unlock_irq(host
->host_lock
);
1742 ret
= aac_write(scsicmd
, cid
);
1743 spin_lock_irq(host
->host_lock
);
1746 case SYNCHRONIZE_CACHE
:
1747 /* Issue FIB to tell Firmware to flush it's cache */
1748 return aac_synchronize(scsicmd
, cid
);
1752 * Unhandled commands
1754 dprintk((KERN_WARNING
"Unhandled SCSI Command: 0x%x.\n", scsicmd
->cmnd
[0]));
1755 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1756 set_sense((u8
*) &dev
->fsa_dev
[cid
].sense_data
,
1757 ILLEGAL_REQUEST
, SENCODE_INVALID_COMMAND
,
1758 ASENCODE_INVALID_COMMAND
, 0, 0, 0, 0);
1759 memcpy(scsicmd
->sense_buffer
, &dev
->fsa_dev
[cid
].sense_data
,
1760 (sizeof(dev
->fsa_dev
[cid
].sense_data
) > sizeof(scsicmd
->sense_buffer
))
1761 ? sizeof(scsicmd
->sense_buffer
)
1762 : sizeof(dev
->fsa_dev
[cid
].sense_data
));
1763 scsicmd
->scsi_done(scsicmd
);
1768 static int query_disk(struct aac_dev
*dev
, void __user
*arg
)
1770 struct aac_query_disk qd
;
1771 struct fsa_dev_info
*fsa_dev_ptr
;
1773 fsa_dev_ptr
= dev
->fsa_dev
;
1774 if (copy_from_user(&qd
, arg
, sizeof (struct aac_query_disk
)))
1777 qd
.cnum
= ID_LUN_TO_CONTAINER(qd
.id
, qd
.lun
);
1778 else if ((qd
.bus
== -1) && (qd
.id
== -1) && (qd
.lun
== -1))
1780 if (qd
.cnum
< 0 || qd
.cnum
>= dev
->maximum_num_containers
)
1782 qd
.instance
= dev
->scsi_host_ptr
->host_no
;
1784 qd
.id
= CONTAINER_TO_ID(qd
.cnum
);
1785 qd
.lun
= CONTAINER_TO_LUN(qd
.cnum
);
1787 else return -EINVAL
;
1789 qd
.valid
= fsa_dev_ptr
[qd
.cnum
].valid
;
1790 qd
.locked
= fsa_dev_ptr
[qd
.cnum
].locked
;
1791 qd
.deleted
= fsa_dev_ptr
[qd
.cnum
].deleted
;
1793 if (fsa_dev_ptr
[qd
.cnum
].devname
[0] == '\0')
1798 strlcpy(qd
.name
, fsa_dev_ptr
[qd
.cnum
].devname
,
1799 min(sizeof(qd
.name
), sizeof(fsa_dev_ptr
[qd
.cnum
].devname
) + 1));
1801 if (copy_to_user(arg
, &qd
, sizeof (struct aac_query_disk
)))
1806 static int force_delete_disk(struct aac_dev
*dev
, void __user
*arg
)
1808 struct aac_delete_disk dd
;
1809 struct fsa_dev_info
*fsa_dev_ptr
;
1811 fsa_dev_ptr
= dev
->fsa_dev
;
1813 if (copy_from_user(&dd
, arg
, sizeof (struct aac_delete_disk
)))
1816 if (dd
.cnum
>= dev
->maximum_num_containers
)
1819 * Mark this container as being deleted.
1821 fsa_dev_ptr
[dd
.cnum
].deleted
= 1;
1823 * Mark the container as no longer valid
1825 fsa_dev_ptr
[dd
.cnum
].valid
= 0;
1829 static int delete_disk(struct aac_dev
*dev
, void __user
*arg
)
1831 struct aac_delete_disk dd
;
1832 struct fsa_dev_info
*fsa_dev_ptr
;
1834 fsa_dev_ptr
= dev
->fsa_dev
;
1836 if (copy_from_user(&dd
, arg
, sizeof (struct aac_delete_disk
)))
1839 if (dd
.cnum
>= dev
->maximum_num_containers
)
1842 * If the container is locked, it can not be deleted by the API.
1844 if (fsa_dev_ptr
[dd
.cnum
].locked
)
1848 * Mark the container as no longer being valid.
1850 fsa_dev_ptr
[dd
.cnum
].valid
= 0;
1851 fsa_dev_ptr
[dd
.cnum
].devname
[0] = '\0';
1856 int aac_dev_ioctl(struct aac_dev
*dev
, int cmd
, void __user
*arg
)
1859 case FSACTL_QUERY_DISK
:
1860 return query_disk(dev
, arg
);
1861 case FSACTL_DELETE_DISK
:
1862 return delete_disk(dev
, arg
);
1863 case FSACTL_FORCE_DELETE_DISK
:
1864 return force_delete_disk(dev
, arg
);
1865 case FSACTL_GET_CONTAINERS
:
1866 return aac_get_containers(dev
);
1875 * @context: the context set in the fib - here it is scsi cmd
1876 * @fibptr: pointer to the fib
1878 * Handles the completion of a scsi command to a non dasd device
1882 static void aac_srb_callback(void *context
, struct fib
* fibptr
)
1884 struct aac_dev
*dev
;
1885 struct aac_srb_reply
*srbreply
;
1886 struct scsi_cmnd
*scsicmd
;
1888 scsicmd
= (struct scsi_cmnd
*) context
;
1889 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
1894 srbreply
= (struct aac_srb_reply
*) fib_data(fibptr
);
1896 scsicmd
->sense_buffer
[0] = '\0'; /* Initialize sense valid flag to false */
1898 * Calculate resid for sg
1901 scsicmd
->resid
= scsicmd
->request_bufflen
-
1902 le32_to_cpu(srbreply
->data_xfer_length
);
1905 pci_unmap_sg(dev
->pdev
,
1906 (struct scatterlist
*)scsicmd
->buffer
,
1908 scsicmd
->sc_data_direction
);
1909 else if(scsicmd
->request_bufflen
)
1910 pci_unmap_single(dev
->pdev
, scsicmd
->SCp
.dma_handle
, scsicmd
->request_bufflen
,
1911 scsicmd
->sc_data_direction
);
1914 * First check the fib status
1917 if (le32_to_cpu(srbreply
->status
) != ST_OK
){
1919 printk(KERN_WARNING
"aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply
->status
));
1920 len
= (le32_to_cpu(srbreply
->sense_data_size
) >
1921 sizeof(scsicmd
->sense_buffer
)) ?
1922 sizeof(scsicmd
->sense_buffer
) :
1923 le32_to_cpu(srbreply
->sense_data_size
);
1924 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8 | SAM_STAT_CHECK_CONDITION
;
1925 memcpy(scsicmd
->sense_buffer
, srbreply
->sense_data
, len
);
1929 * Next check the srb status
1931 switch( (le32_to_cpu(srbreply
->srb_status
))&0x3f){
1932 case SRB_STATUS_ERROR_RECOVERY
:
1933 case SRB_STATUS_PENDING
:
1934 case SRB_STATUS_SUCCESS
:
1935 if(scsicmd
->cmnd
[0] == INQUIRY
){
1938 /* We can't expose disk devices because we can't tell whether they
1939 * are the raw container drives or stand alone drives. If they have
1940 * the removable bit set then we should expose them though.
1942 b
= (*(u8
*)scsicmd
->buffer
)&0x1f;
1943 b1
= ((u8
*)scsicmd
->buffer
)[1];
1944 if( b
==TYPE_TAPE
|| b
==TYPE_WORM
|| b
==TYPE_ROM
|| b
==TYPE_MOD
|| b
==TYPE_MEDIUM_CHANGER
1945 || (b
==TYPE_DISK
&& (b1
&0x80)) ){
1946 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
1948 * We will allow disk devices if in RAID/SCSI mode and
1951 } else if ((dev
->raid_scsi_mode
) &&
1952 (scmd_channel(scsicmd
) == 2)) {
1953 scsicmd
->result
= DID_OK
<< 16 |
1954 COMMAND_COMPLETE
<< 8;
1956 scsicmd
->result
= DID_NO_CONNECT
<< 16 |
1957 COMMAND_COMPLETE
<< 8;
1960 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
1963 case SRB_STATUS_DATA_OVERRUN
:
1964 switch(scsicmd
->cmnd
[0]){
1973 if(le32_to_cpu(srbreply
->data_xfer_length
) < scsicmd
->underflow
) {
1974 printk(KERN_WARNING
"aacraid: SCSI CMD underflow\n");
1976 printk(KERN_WARNING
"aacraid: SCSI CMD Data Overrun\n");
1978 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8;
1983 /* We can't expose disk devices because we can't tell whether they
1984 * are the raw container drives or stand alone drives
1986 b
= (*(u8
*)scsicmd
->buffer
)&0x0f;
1987 b1
= ((u8
*)scsicmd
->buffer
)[1];
1988 if( b
==TYPE_TAPE
|| b
==TYPE_WORM
|| b
==TYPE_ROM
|| b
==TYPE_MOD
|| b
==TYPE_MEDIUM_CHANGER
1989 || (b
==TYPE_DISK
&& (b1
&0x80)) ){
1990 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
1992 * We will allow disk devices if in RAID/SCSI mode and
1995 } else if ((dev
->raid_scsi_mode
) &&
1996 (scmd_channel(scsicmd
) == 2)) {
1997 scsicmd
->result
= DID_OK
<< 16 |
1998 COMMAND_COMPLETE
<< 8;
2000 scsicmd
->result
= DID_NO_CONNECT
<< 16 |
2001 COMMAND_COMPLETE
<< 8;
2006 scsicmd
->result
= DID_OK
<< 16 | COMMAND_COMPLETE
<< 8;
2010 case SRB_STATUS_ABORTED
:
2011 scsicmd
->result
= DID_ABORT
<< 16 | ABORT
<< 8;
2013 case SRB_STATUS_ABORT_FAILED
:
2014 // Not sure about this one - but assuming the hba was trying to abort for some reason
2015 scsicmd
->result
= DID_ERROR
<< 16 | ABORT
<< 8;
2017 case SRB_STATUS_PARITY_ERROR
:
2018 scsicmd
->result
= DID_PARITY
<< 16 | MSG_PARITY_ERROR
<< 8;
2020 case SRB_STATUS_NO_DEVICE
:
2021 case SRB_STATUS_INVALID_PATH_ID
:
2022 case SRB_STATUS_INVALID_TARGET_ID
:
2023 case SRB_STATUS_INVALID_LUN
:
2024 case SRB_STATUS_SELECTION_TIMEOUT
:
2025 scsicmd
->result
= DID_NO_CONNECT
<< 16 | COMMAND_COMPLETE
<< 8;
2028 case SRB_STATUS_COMMAND_TIMEOUT
:
2029 case SRB_STATUS_TIMEOUT
:
2030 scsicmd
->result
= DID_TIME_OUT
<< 16 | COMMAND_COMPLETE
<< 8;
2033 case SRB_STATUS_BUSY
:
2034 scsicmd
->result
= DID_NO_CONNECT
<< 16 | COMMAND_COMPLETE
<< 8;
2037 case SRB_STATUS_BUS_RESET
:
2038 scsicmd
->result
= DID_RESET
<< 16 | COMMAND_COMPLETE
<< 8;
2041 case SRB_STATUS_MESSAGE_REJECTED
:
2042 scsicmd
->result
= DID_ERROR
<< 16 | MESSAGE_REJECT
<< 8;
2044 case SRB_STATUS_REQUEST_FLUSHED
:
2045 case SRB_STATUS_ERROR
:
2046 case SRB_STATUS_INVALID_REQUEST
:
2047 case SRB_STATUS_REQUEST_SENSE_FAILED
:
2048 case SRB_STATUS_NO_HBA
:
2049 case SRB_STATUS_UNEXPECTED_BUS_FREE
:
2050 case SRB_STATUS_PHASE_SEQUENCE_FAILURE
:
2051 case SRB_STATUS_BAD_SRB_BLOCK_LENGTH
:
2052 case SRB_STATUS_DELAYED_RETRY
:
2053 case SRB_STATUS_BAD_FUNCTION
:
2054 case SRB_STATUS_NOT_STARTED
:
2055 case SRB_STATUS_NOT_IN_USE
:
2056 case SRB_STATUS_FORCE_ABORT
:
2057 case SRB_STATUS_DOMAIN_VALIDATION_FAIL
:
2059 #ifdef AAC_DETAILED_STATUS_INFO
2060 printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",
2061 le32_to_cpu(srbreply
->srb_status
) & 0x3F,
2062 aac_get_status_string(
2063 le32_to_cpu(srbreply
->srb_status
) & 0x3F),
2065 le32_to_cpu(srbreply
->scsi_status
));
2067 scsicmd
->result
= DID_ERROR
<< 16 | COMMAND_COMPLETE
<< 8;
2070 if (le32_to_cpu(srbreply
->scsi_status
) == 0x02 ){ // Check Condition
2072 scsicmd
->result
|= SAM_STAT_CHECK_CONDITION
;
2073 len
= (le32_to_cpu(srbreply
->sense_data_size
) >
2074 sizeof(scsicmd
->sense_buffer
)) ?
2075 sizeof(scsicmd
->sense_buffer
) :
2076 le32_to_cpu(srbreply
->sense_data_size
);
2077 #ifdef AAC_DETAILED_STATUS_INFO
2078 printk(KERN_WARNING
"aac_srb_callback: check condition, status = %d len=%d\n",
2079 le32_to_cpu(srbreply
->status
), len
);
2081 memcpy(scsicmd
->sense_buffer
, srbreply
->sense_data
, len
);
2085 * OR in the scsi status (already shifted up a bit)
2087 scsicmd
->result
|= le32_to_cpu(srbreply
->scsi_status
);
2089 fib_complete(fibptr
);
2091 scsicmd
->scsi_done(scsicmd
);
2097 * @scsicmd: the scsi command block
2099 * This routine will form a FIB and fill in the aac_srb from the
2100 * scsicmd passed in.
2103 static int aac_send_srb_fib(struct scsi_cmnd
* scsicmd
)
2105 struct fib
* cmd_fibcontext
;
2106 struct aac_dev
* dev
;
2108 struct aac_srb
*srbcmd
;
2113 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2114 if (scsicmd
->device
->id
>= dev
->maximum_num_physicals
||
2115 scsicmd
->device
->lun
> 7) {
2116 scsicmd
->result
= DID_NO_CONNECT
<< 16;
2117 scsicmd
->scsi_done(scsicmd
);
2121 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2122 switch(scsicmd
->sc_data_direction
){
2126 case DMA_BIDIRECTIONAL
:
2127 flag
= SRB_DataIn
| SRB_DataOut
;
2129 case DMA_FROM_DEVICE
:
2133 default: /* shuts up some versions of gcc */
2134 flag
= SRB_NoDataXfer
;
2140 * Allocate and initialize a Fib then setup a BlockWrite command
2142 if (!(cmd_fibcontext
= fib_alloc(dev
))) {
2145 fib_init(cmd_fibcontext
);
2147 srbcmd
= (struct aac_srb
*) fib_data(cmd_fibcontext
);
2148 srbcmd
->function
= cpu_to_le32(SRBF_ExecuteScsi
);
2149 srbcmd
->channel
= cpu_to_le32(aac_logical_to_phys(scsicmd
->device
->channel
));
2150 srbcmd
->id
= cpu_to_le32(scsicmd
->device
->id
);
2151 srbcmd
->lun
= cpu_to_le32(scsicmd
->device
->lun
);
2152 srbcmd
->flags
= cpu_to_le32(flag
);
2153 timeout
= scsicmd
->timeout_per_command
/HZ
;
2157 srbcmd
->timeout
= cpu_to_le32(timeout
); // timeout in seconds
2158 srbcmd
->retry_limit
= 0; /* Obsolete parameter */
2159 srbcmd
->cdb_size
= cpu_to_le32(scsicmd
->cmd_len
);
2161 if( dev
->dac_support
== 1 ) {
2162 aac_build_sg64(scsicmd
, (struct sgmap64
*) &srbcmd
->sg
);
2163 srbcmd
->count
= cpu_to_le32(scsicmd
->request_bufflen
);
2165 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
2166 memcpy(srbcmd
->cdb
, scsicmd
->cmnd
, scsicmd
->cmd_len
);
2168 * Build Scatter/Gather list
2170 fibsize
= sizeof (struct aac_srb
) - sizeof (struct sgentry
) +
2171 ((le32_to_cpu(srbcmd
->sg
.count
) & 0xff) *
2172 sizeof (struct sgentry64
));
2173 BUG_ON (fibsize
> (dev
->max_fib_size
-
2174 sizeof(struct aac_fibhdr
)));
2177 * Now send the Fib to the adapter
2179 status
= fib_send(ScsiPortCommand64
, cmd_fibcontext
,
2180 fibsize
, FsaNormal
, 0, 1,
2181 (fib_callback
) aac_srb_callback
,
2184 aac_build_sg(scsicmd
, (struct sgmap
*)&srbcmd
->sg
);
2185 srbcmd
->count
= cpu_to_le32(scsicmd
->request_bufflen
);
2187 memset(srbcmd
->cdb
, 0, sizeof(srbcmd
->cdb
));
2188 memcpy(srbcmd
->cdb
, scsicmd
->cmnd
, scsicmd
->cmd_len
);
2190 * Build Scatter/Gather list
2192 fibsize
= sizeof (struct aac_srb
) +
2193 (((le32_to_cpu(srbcmd
->sg
.count
) & 0xff) - 1) *
2194 sizeof (struct sgentry
));
2195 BUG_ON (fibsize
> (dev
->max_fib_size
-
2196 sizeof(struct aac_fibhdr
)));
2199 * Now send the Fib to the adapter
2201 status
= fib_send(ScsiPortCommand
, cmd_fibcontext
, fibsize
, FsaNormal
, 0, 1,
2202 (fib_callback
) aac_srb_callback
, (void *) scsicmd
);
2205 * Check that the command queued to the controller
2207 if (status
== -EINPROGRESS
){
2211 printk(KERN_WARNING
"aac_srb: fib_send failed with status: %d\n", status
);
2212 fib_complete(cmd_fibcontext
);
2213 fib_free(cmd_fibcontext
);
2218 static unsigned long aac_build_sg(struct scsi_cmnd
* scsicmd
, struct sgmap
* psg
)
2220 struct aac_dev
*dev
;
2221 unsigned long byte_count
= 0;
2223 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2224 // Get rid of old data
2226 psg
->sg
[0].addr
= 0;
2227 psg
->sg
[0].count
= 0;
2228 if (scsicmd
->use_sg
) {
2229 struct scatterlist
*sg
;
2232 sg
= (struct scatterlist
*) scsicmd
->request_buffer
;
2234 sg_count
= pci_map_sg(dev
->pdev
, sg
, scsicmd
->use_sg
,
2235 scsicmd
->sc_data_direction
);
2236 psg
->count
= cpu_to_le32(sg_count
);
2240 for (i
= 0; i
< sg_count
; i
++) {
2241 psg
->sg
[i
].addr
= cpu_to_le32(sg_dma_address(sg
));
2242 psg
->sg
[i
].count
= cpu_to_le32(sg_dma_len(sg
));
2243 byte_count
+= sg_dma_len(sg
);
2246 /* hba wants the size to be exact */
2247 if(byte_count
> scsicmd
->request_bufflen
){
2248 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2249 (byte_count
- scsicmd
->request_bufflen
);
2250 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2251 byte_count
= scsicmd
->request_bufflen
;
2253 /* Check for command underflow */
2254 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2255 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2256 byte_count
, scsicmd
->underflow
);
2259 else if(scsicmd
->request_bufflen
) {
2261 addr
= pci_map_single(dev
->pdev
,
2262 scsicmd
->request_buffer
,
2263 scsicmd
->request_bufflen
,
2264 scsicmd
->sc_data_direction
);
2265 psg
->count
= cpu_to_le32(1);
2266 psg
->sg
[0].addr
= cpu_to_le32(addr
);
2267 psg
->sg
[0].count
= cpu_to_le32(scsicmd
->request_bufflen
);
2268 scsicmd
->SCp
.dma_handle
= addr
;
2269 byte_count
= scsicmd
->request_bufflen
;
2275 static unsigned long aac_build_sg64(struct scsi_cmnd
* scsicmd
, struct sgmap64
* psg
)
2277 struct aac_dev
*dev
;
2278 unsigned long byte_count
= 0;
2281 dev
= (struct aac_dev
*)scsicmd
->device
->host
->hostdata
;
2282 // Get rid of old data
2284 psg
->sg
[0].addr
[0] = 0;
2285 psg
->sg
[0].addr
[1] = 0;
2286 psg
->sg
[0].count
= 0;
2287 if (scsicmd
->use_sg
) {
2288 struct scatterlist
*sg
;
2291 sg
= (struct scatterlist
*) scsicmd
->request_buffer
;
2293 sg_count
= pci_map_sg(dev
->pdev
, sg
, scsicmd
->use_sg
,
2294 scsicmd
->sc_data_direction
);
2295 psg
->count
= cpu_to_le32(sg_count
);
2299 for (i
= 0; i
< sg_count
; i
++) {
2300 addr
= sg_dma_address(sg
);
2301 psg
->sg
[i
].addr
[0] = cpu_to_le32(addr
& 0xffffffff);
2302 psg
->sg
[i
].addr
[1] = cpu_to_le32(addr
>>32);
2303 psg
->sg
[i
].count
= cpu_to_le32(sg_dma_len(sg
));
2304 byte_count
+= sg_dma_len(sg
);
2307 /* hba wants the size to be exact */
2308 if(byte_count
> scsicmd
->request_bufflen
){
2309 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2310 (byte_count
- scsicmd
->request_bufflen
);
2311 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2312 byte_count
= scsicmd
->request_bufflen
;
2314 /* Check for command underflow */
2315 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2316 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2317 byte_count
, scsicmd
->underflow
);
2320 else if(scsicmd
->request_bufflen
) {
2322 addr
= pci_map_single(dev
->pdev
,
2323 scsicmd
->request_buffer
,
2324 scsicmd
->request_bufflen
,
2325 scsicmd
->sc_data_direction
);
2326 psg
->count
= cpu_to_le32(1);
2327 psg
->sg
[0].addr
[0] = cpu_to_le32(addr
& 0xffffffff);
2328 psg
->sg
[0].addr
[1] = cpu_to_le32(addr
>> 32);
2329 psg
->sg
[0].count
= cpu_to_le32(scsicmd
->request_bufflen
);
2330 scsicmd
->SCp
.dma_handle
= addr
;
2331 byte_count
= scsicmd
->request_bufflen
;
2336 static unsigned long aac_build_sgraw(struct scsi_cmnd
* scsicmd
, struct sgmapraw
* psg
)
2338 struct Scsi_Host
*host
= scsicmd
->device
->host
;
2339 struct aac_dev
*dev
= (struct aac_dev
*)host
->hostdata
;
2340 unsigned long byte_count
= 0;
2342 // Get rid of old data
2344 psg
->sg
[0].next
= 0;
2345 psg
->sg
[0].prev
= 0;
2346 psg
->sg
[0].addr
[0] = 0;
2347 psg
->sg
[0].addr
[1] = 0;
2348 psg
->sg
[0].count
= 0;
2349 psg
->sg
[0].flags
= 0;
2350 if (scsicmd
->use_sg
) {
2351 struct scatterlist
*sg
;
2354 sg
= (struct scatterlist
*) scsicmd
->request_buffer
;
2356 sg_count
= pci_map_sg(dev
->pdev
, sg
, scsicmd
->use_sg
,
2357 scsicmd
->sc_data_direction
);
2359 for (i
= 0; i
< sg_count
; i
++) {
2360 int count
= sg_dma_len(sg
);
2361 u64 addr
= sg_dma_address(sg
);
2362 psg
->sg
[i
].next
= 0;
2363 psg
->sg
[i
].prev
= 0;
2364 psg
->sg
[i
].addr
[1] = cpu_to_le32((u32
)(addr
>>32));
2365 psg
->sg
[i
].addr
[0] = cpu_to_le32((u32
)(addr
& 0xffffffff));
2366 psg
->sg
[i
].count
= cpu_to_le32(count
);
2367 psg
->sg
[i
].flags
= 0;
2368 byte_count
+= count
;
2371 psg
->count
= cpu_to_le32(sg_count
);
2372 /* hba wants the size to be exact */
2373 if(byte_count
> scsicmd
->request_bufflen
){
2374 u32 temp
= le32_to_cpu(psg
->sg
[i
-1].count
) -
2375 (byte_count
- scsicmd
->request_bufflen
);
2376 psg
->sg
[i
-1].count
= cpu_to_le32(temp
);
2377 byte_count
= scsicmd
->request_bufflen
;
2379 /* Check for command underflow */
2380 if(scsicmd
->underflow
&& (byte_count
< scsicmd
->underflow
)){
2381 printk(KERN_WARNING
"aacraid: cmd len %08lX cmd underflow %08X\n",
2382 byte_count
, scsicmd
->underflow
);
2385 else if(scsicmd
->request_bufflen
) {
2388 scsicmd
->SCp
.dma_handle
= pci_map_single(dev
->pdev
,
2389 scsicmd
->request_buffer
,
2390 scsicmd
->request_bufflen
,
2391 scsicmd
->sc_data_direction
);
2392 addr
= scsicmd
->SCp
.dma_handle
;
2393 count
= scsicmd
->request_bufflen
;
2394 psg
->count
= cpu_to_le32(1);
2395 psg
->sg
[0].next
= 0;
2396 psg
->sg
[0].prev
= 0;
2397 psg
->sg
[0].addr
[1] = cpu_to_le32((u32
)(addr
>>32));
2398 psg
->sg
[0].addr
[0] = cpu_to_le32((u32
)(addr
& 0xffffffff));
2399 psg
->sg
[0].count
= cpu_to_le32(count
);
2400 psg
->sg
[0].flags
= 0;
2401 byte_count
= scsicmd
->request_bufflen
;
2406 #ifdef AAC_DETAILED_STATUS_INFO
2408 struct aac_srb_status_info
{
2414 static struct aac_srb_status_info srb_status_info
[] = {
2415 { SRB_STATUS_PENDING
, "Pending Status"},
2416 { SRB_STATUS_SUCCESS
, "Success"},
2417 { SRB_STATUS_ABORTED
, "Aborted Command"},
2418 { SRB_STATUS_ABORT_FAILED
, "Abort Failed"},
2419 { SRB_STATUS_ERROR
, "Error Event"},
2420 { SRB_STATUS_BUSY
, "Device Busy"},
2421 { SRB_STATUS_INVALID_REQUEST
, "Invalid Request"},
2422 { SRB_STATUS_INVALID_PATH_ID
, "Invalid Path ID"},
2423 { SRB_STATUS_NO_DEVICE
, "No Device"},
2424 { SRB_STATUS_TIMEOUT
, "Timeout"},
2425 { SRB_STATUS_SELECTION_TIMEOUT
, "Selection Timeout"},
2426 { SRB_STATUS_COMMAND_TIMEOUT
, "Command Timeout"},
2427 { SRB_STATUS_MESSAGE_REJECTED
, "Message Rejected"},
2428 { SRB_STATUS_BUS_RESET
, "Bus Reset"},
2429 { SRB_STATUS_PARITY_ERROR
, "Parity Error"},
2430 { SRB_STATUS_REQUEST_SENSE_FAILED
,"Request Sense Failed"},
2431 { SRB_STATUS_NO_HBA
, "No HBA"},
2432 { SRB_STATUS_DATA_OVERRUN
, "Data Overrun/Data Underrun"},
2433 { SRB_STATUS_UNEXPECTED_BUS_FREE
,"Unexpected Bus Free"},
2434 { SRB_STATUS_PHASE_SEQUENCE_FAILURE
,"Phase Error"},
2435 { SRB_STATUS_BAD_SRB_BLOCK_LENGTH
,"Bad Srb Block Length"},
2436 { SRB_STATUS_REQUEST_FLUSHED
, "Request Flushed"},
2437 { SRB_STATUS_DELAYED_RETRY
, "Delayed Retry"},
2438 { SRB_STATUS_INVALID_LUN
, "Invalid LUN"},
2439 { SRB_STATUS_INVALID_TARGET_ID
, "Invalid TARGET ID"},
2440 { SRB_STATUS_BAD_FUNCTION
, "Bad Function"},
2441 { SRB_STATUS_ERROR_RECOVERY
, "Error Recovery"},
2442 { SRB_STATUS_NOT_STARTED
, "Not Started"},
2443 { SRB_STATUS_NOT_IN_USE
, "Not In Use"},
2444 { SRB_STATUS_FORCE_ABORT
, "Force Abort"},
2445 { SRB_STATUS_DOMAIN_VALIDATION_FAIL
,"Domain Validation Failure"},
2446 { 0xff, "Unknown Error"}
2449 char *aac_get_status_string(u32 status
)
2453 for(i
=0; i
< (sizeof(srb_status_info
)/sizeof(struct aac_srb_status_info
)); i
++ ){
2454 if(srb_status_info
[i
].status
== status
){
2455 return srb_status_info
[i
].str
;
2459 return "Bad Status Code";