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 int aac_send_srb_fib(struct scsi_cmnd* scsicmd);
137 #ifdef AAC_DETAILED_STATUS_INFO
138 static char *aac_get_status_string(u32 status);
142 * Non dasd selection is handled entirely in aachba now
145 static int nondasd = -1;
146 static int dacmode = -1;
148 static int commit = -1;
150 module_param(nondasd, int, 0);
151 MODULE_PARM_DESC(nondasd, "Control scanning of hba for nondasd devices. 0=off, 1=on");
152 module_param(dacmode, int, 0);
153 MODULE_PARM_DESC(dacmode, "Control whether dma addressing is using 64 bit DAC. 0=off, 1=on");
154 module_param(commit, int, 0);
155 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");
158 module_param(numacb, int, S_IRUGO|S_IWUSR);
159 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.");
162 module_param(acbsize, int, S_IRUGO|S_IWUSR);
163 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.");
165 * aac_get_config_status - check the adapter configuration
166 * @common: adapter to query
168 * Query config status, and commit the configuration if needed.
170 int aac_get_config_status(struct aac_dev *dev)
175 if (!(fibptr = fib_alloc(dev)))
180 struct aac_get_config_status *dinfo;
181 dinfo = (struct aac_get_config_status *) fib_data(fibptr);
183 dinfo->command = cpu_to_le32(VM_ContainerConfig);
184 dinfo->type = cpu_to_le32(CT_GET_CONFIG_STATUS);
185 dinfo->count = cpu_to_le32(sizeof(((struct aac_get_config_status_resp *)NULL)->data));
188 status = fib_send(ContainerCommand,
190 sizeof (struct aac_get_config_status),
195 printk(KERN_WARNING "aac_get_config_status: SendFIB failed.\n");
197 struct aac_get_config_status_resp *reply
198 = (struct aac_get_config_status_resp *) fib_data(fibptr);
199 dprintk((KERN_WARNING
200 "aac_get_config_status: response=%d status=%d action=%d\n",
201 le32_to_cpu(reply->response),
202 le32_to_cpu(reply->status),
203 le32_to_cpu(reply->data.action)));
204 if ((le32_to_cpu(reply->response) != ST_OK) ||
205 (le32_to_cpu(reply->status) != CT_OK) ||
206 (le32_to_cpu(reply->data.action) > CFACT_PAUSE)) {
207 printk(KERN_WARNING "aac_get_config_status: Will not issue the Commit Configuration\n");
211 fib_complete(fibptr);
212 /* Send a CT_COMMIT_CONFIG to enable discovery of devices */
215 struct aac_commit_config * dinfo;
217 dinfo = (struct aac_commit_config *) fib_data(fibptr);
219 dinfo->command = cpu_to_le32(VM_ContainerConfig);
220 dinfo->type = cpu_to_le32(CT_COMMIT_CONFIG);
222 status = fib_send(ContainerCommand,
224 sizeof (struct aac_commit_config),
228 fib_complete(fibptr);
229 } else if (commit == 0) {
231 "aac_get_config_status: Foreign device configurations are being ignored\n");
239 * aac_get_containers - list containers
240 * @common: adapter to probe
242 * Make a list of all containers on this controller
244 int aac_get_containers(struct aac_dev *dev)
246 struct fsa_dev_info *fsa_dev_ptr;
251 struct aac_get_container_count *dinfo;
252 struct aac_get_container_count_resp *dresp;
253 int maximum_num_containers = MAXIMUM_NUM_CONTAINERS;
255 instance = dev->scsi_host_ptr->unique_id;
257 if (!(fibptr = fib_alloc(dev)))
261 dinfo = (struct aac_get_container_count *) fib_data(fibptr);
262 dinfo->command = cpu_to_le32(VM_ContainerConfig);
263 dinfo->type = cpu_to_le32(CT_GET_CONTAINER_COUNT);
265 status = fib_send(ContainerCommand,
267 sizeof (struct aac_get_container_count),
272 dresp = (struct aac_get_container_count_resp *)fib_data(fibptr);
273 maximum_num_containers = le32_to_cpu(dresp->ContainerSwitchEntries);
274 fib_complete(fibptr);
277 if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS)
278 maximum_num_containers = MAXIMUM_NUM_CONTAINERS;
279 fsa_dev_ptr = (struct fsa_dev_info *) kmalloc(
280 sizeof(*fsa_dev_ptr) * maximum_num_containers, GFP_KERNEL);
285 memset(fsa_dev_ptr, 0, sizeof(*fsa_dev_ptr) * maximum_num_containers);
287 dev->fsa_dev = fsa_dev_ptr;
288 dev->maximum_num_containers = maximum_num_containers;
290 for (index = 0; index < dev->maximum_num_containers; index++) {
291 struct aac_query_mount *dinfo;
292 struct aac_mount *dresp;
294 fsa_dev_ptr[index].devname[0] = '\0';
297 dinfo = (struct aac_query_mount *) fib_data(fibptr);
299 dinfo->command = cpu_to_le32(VM_NameServe);
300 dinfo->count = cpu_to_le32(index);
301 dinfo->type = cpu_to_le32(FT_FILESYS);
303 status = fib_send(ContainerCommand,
305 sizeof (struct aac_query_mount),
310 printk(KERN_WARNING "aac_get_containers: SendFIB failed.\n");
313 dresp = (struct aac_mount *)fib_data(fibptr);
316 "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%u\n",
317 (int)index, (int)le32_to_cpu(dresp->status),
318 (int)le32_to_cpu(dresp->mnt[0].vol),
319 (int)le32_to_cpu(dresp->mnt[0].state),
320 (unsigned)le32_to_cpu(dresp->mnt[0].capacity)));
321 if ((le32_to_cpu(dresp->status) == ST_OK) &&
322 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
323 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
324 fsa_dev_ptr[index].valid = 1;
325 fsa_dev_ptr[index].type = le32_to_cpu(dresp->mnt[0].vol);
326 fsa_dev_ptr[index].size = le32_to_cpu(dresp->mnt[0].capacity);
327 if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
328 fsa_dev_ptr[index].ro = 1;
330 fib_complete(fibptr);
332 * If there are no more containers, then stop asking.
334 if ((index + 1) >= le32_to_cpu(dresp->count)){
342 static void aac_io_done(struct scsi_cmnd * scsicmd)
344 unsigned long cpu_flags;
345 struct Scsi_Host *host = scsicmd->device->host;
346 spin_lock_irqsave(host->host_lock, cpu_flags);
347 scsicmd->scsi_done(scsicmd);
348 spin_unlock_irqrestore(host->host_lock, cpu_flags);
351 static void get_container_name_callback(void *context, struct fib * fibptr)
353 struct aac_get_name_resp * get_name_reply;
354 struct scsi_cmnd * scsicmd;
356 scsicmd = (struct scsi_cmnd *) context;
358 dprintk((KERN_DEBUG "get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies));
362 get_name_reply = (struct aac_get_name_resp *) fib_data(fibptr);
363 /* Failure is irrelevant, using default value instead */
364 if ((le32_to_cpu(get_name_reply->status) == CT_OK)
365 && (get_name_reply->data[0] != '\0')) {
368 char * sp = get_name_reply->data;
369 sp[sizeof(((struct aac_get_name_resp *)NULL)->data)-1] = '\0';
372 count = sizeof(((struct inquiry_data *)NULL)->inqd_pid);
373 dp = ((struct inquiry_data *)scsicmd->request_buffer)->inqd_pid;
375 *dp++ = (*sp) ? *sp++ : ' ';
376 } while (--count > 0);
378 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
380 fib_complete(fibptr);
382 aac_io_done(scsicmd);
386 * aac_get_container_name - get container name, none blocking.
388 static int aac_get_container_name(struct scsi_cmnd * scsicmd, int cid)
391 struct aac_get_name *dinfo;
392 struct fib * cmd_fibcontext;
393 struct aac_dev * dev;
395 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
397 if (!(cmd_fibcontext = fib_alloc(dev)))
400 fib_init(cmd_fibcontext);
401 dinfo = (struct aac_get_name *) fib_data(cmd_fibcontext);
403 dinfo->command = cpu_to_le32(VM_ContainerConfig);
404 dinfo->type = cpu_to_le32(CT_READ_NAME);
405 dinfo->cid = cpu_to_le32(cid);
406 dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data));
408 status = fib_send(ContainerCommand,
410 sizeof (struct aac_get_name),
413 (fib_callback) get_container_name_callback,
417 * Check that the command queued to the controller
419 if (status == -EINPROGRESS)
422 printk(KERN_WARNING "aac_get_container_name: fib_send failed with status: %d.\n", status);
423 fib_complete(cmd_fibcontext);
424 fib_free(cmd_fibcontext);
429 * probe_container - query a logical volume
430 * @dev: device to query
431 * @cid: container identifier
433 * Queries the controller about the given volume. The volume information
434 * is updated in the struct fsa_dev_info structure rather than returned.
437 static int probe_container(struct aac_dev *dev, int cid)
439 struct fsa_dev_info *fsa_dev_ptr;
441 struct aac_query_mount *dinfo;
442 struct aac_mount *dresp;
446 fsa_dev_ptr = dev->fsa_dev;
447 instance = dev->scsi_host_ptr->unique_id;
449 if (!(fibptr = fib_alloc(dev)))
454 dinfo = (struct aac_query_mount *)fib_data(fibptr);
456 dinfo->command = cpu_to_le32(VM_NameServe);
457 dinfo->count = cpu_to_le32(cid);
458 dinfo->type = cpu_to_le32(FT_FILESYS);
460 status = fib_send(ContainerCommand,
462 sizeof(struct aac_query_mount),
467 printk(KERN_WARNING "aacraid: probe_container query failed.\n");
471 dresp = (struct aac_mount *) fib_data(fibptr);
473 if ((le32_to_cpu(dresp->status) == ST_OK) &&
474 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
475 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
476 fsa_dev_ptr[cid].valid = 1;
477 fsa_dev_ptr[cid].type = le32_to_cpu(dresp->mnt[0].vol);
478 fsa_dev_ptr[cid].size = le32_to_cpu(dresp->mnt[0].capacity);
479 if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
480 fsa_dev_ptr[cid].ro = 1;
484 fib_complete(fibptr);
490 /* Local Structure to set SCSI inquiry data strings */
492 char vid[8]; /* Vendor ID */
493 char pid[16]; /* Product ID */
494 char prl[4]; /* Product Revision Level */
498 * InqStrCopy - string merge
499 * @a: string to copy from
500 * @b: string to copy to
502 * Copy a String from one location to another
506 static void inqstrcpy(char *a, char *b)
513 static char *container_types[] = {
539 /* Function: setinqstr
541 * Arguments: [1] pointer to void [1] int
543 * Purpose: Sets SCSI inquiry data strings for vendor, product
544 * and revision level. Allows strings to be set in platform dependant
545 * files instead of in OS dependant driver source.
548 static void setinqstr(int devtype, void *data, int tindex)
550 struct scsi_inq *str;
551 struct aac_driver_ident *mp;
553 mp = aac_get_driver_ident(devtype);
555 str = (struct scsi_inq *)(data); /* cast data to scsi inq block */
557 inqstrcpy (mp->vname, str->vid);
558 inqstrcpy (mp->model, str->pid); /* last six chars reserved for vol type */
560 if (tindex < (sizeof(container_types)/sizeof(char *))){
561 char *findit = str->pid;
563 for ( ; *findit != ' '; findit++); /* walk till we find a space */
564 /* RAID is superfluous in the context of a RAID device */
565 if (memcmp(findit-4, "RAID", 4) == 0)
566 *(findit -= 4) = ' ';
567 inqstrcpy (container_types[tindex], findit + 1);
569 inqstrcpy ("V1.0", str->prl);
572 static void set_sense(u8 *sense_buf, u8 sense_key, u8 sense_code,
573 u8 a_sense_code, u8 incorrect_length,
574 u8 bit_pointer, u16 field_pointer,
577 sense_buf[0] = 0xF0; /* Sense data valid, err code 70h (current error) */
578 sense_buf[1] = 0; /* Segment number, always zero */
580 if (incorrect_length) {
581 sense_buf[2] = sense_key | 0x20;/* Set ILI bit | sense key */
582 sense_buf[3] = BYTE3(residue);
583 sense_buf[4] = BYTE2(residue);
584 sense_buf[5] = BYTE1(residue);
585 sense_buf[6] = BYTE0(residue);
587 sense_buf[2] = sense_key; /* Sense key */
589 if (sense_key == ILLEGAL_REQUEST)
590 sense_buf[7] = 10; /* Additional sense length */
592 sense_buf[7] = 6; /* Additional sense length */
594 sense_buf[12] = sense_code; /* Additional sense code */
595 sense_buf[13] = a_sense_code; /* Additional sense code qualifier */
596 if (sense_key == ILLEGAL_REQUEST) {
599 if (sense_code == SENCODE_INVALID_PARAM_FIELD)
600 sense_buf[15] = 0x80;/* Std sense key specific field */
601 /* Illegal parameter is in the parameter block */
603 if (sense_code == SENCODE_INVALID_CDB_FIELD)
604 sense_buf[15] = 0xc0;/* Std sense key specific field */
605 /* Illegal parameter is in the CDB block */
606 sense_buf[15] |= bit_pointer;
607 sense_buf[16] = field_pointer >> 8; /* MSB */
608 sense_buf[17] = field_pointer; /* LSB */
612 int aac_get_adapter_info(struct aac_dev* dev)
617 struct aac_adapter_info *info;
618 struct aac_bus_info *command;
619 struct aac_bus_info_response *bus_info;
621 if (!(fibptr = fib_alloc(dev)))
625 info = (struct aac_adapter_info *) fib_data(fibptr);
626 memset(info,0,sizeof(*info));
628 rcode = fib_send(RequestAdapterInfo,
637 fib_complete(fibptr);
641 memcpy(&dev->adapter_info, info, sizeof(*info));
643 if (dev->adapter_info.options & AAC_OPT_SUPPLEMENT_ADAPTER_INFO) {
644 struct aac_supplement_adapter_info * info;
648 info = (struct aac_supplement_adapter_info *) fib_data(fibptr);
650 memset(info,0,sizeof(*info));
652 rcode = fib_send(RequestSupplementAdapterInfo,
661 memcpy(&dev->supplement_adapter_info, info, sizeof(*info));
671 bus_info = (struct aac_bus_info_response *) fib_data(fibptr);
673 memset(bus_info, 0, sizeof(*bus_info));
675 command = (struct aac_bus_info *)bus_info;
677 command->Command = cpu_to_le32(VM_Ioctl);
678 command->ObjType = cpu_to_le32(FT_DRIVE);
679 command->MethodId = cpu_to_le32(1);
680 command->CtlCmd = cpu_to_le32(GetBusInfo);
682 rcode = fib_send(ContainerCommand,
689 if (rcode >= 0 && le32_to_cpu(bus_info->Status) == ST_OK) {
690 dev->maximum_num_physicals = le32_to_cpu(bus_info->TargetsPerBus);
691 dev->maximum_num_channels = le32_to_cpu(bus_info->BusCount);
694 tmp = le32_to_cpu(dev->adapter_info.kernelrev);
695 printk(KERN_INFO "%s%d: kernel %d.%d-%d[%d] %.*s\n",
701 le32_to_cpu(dev->adapter_info.kernelbuild),
702 (int)sizeof(dev->supplement_adapter_info.BuildDate),
703 dev->supplement_adapter_info.BuildDate);
704 tmp = le32_to_cpu(dev->adapter_info.monitorrev);
705 printk(KERN_INFO "%s%d: monitor %d.%d-%d[%d]\n",
707 tmp>>24,(tmp>>16)&0xff,tmp&0xff,
708 le32_to_cpu(dev->adapter_info.monitorbuild));
709 tmp = le32_to_cpu(dev->adapter_info.biosrev);
710 printk(KERN_INFO "%s%d: bios %d.%d-%d[%d]\n",
712 tmp>>24,(tmp>>16)&0xff,tmp&0xff,
713 le32_to_cpu(dev->adapter_info.biosbuild));
714 if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0)
715 printk(KERN_INFO "%s%d: serial %x\n",
717 le32_to_cpu(dev->adapter_info.serial[0]));
719 dev->nondasd_support = 0;
720 dev->raid_scsi_mode = 0;
721 if(dev->adapter_info.options & AAC_OPT_NONDASD){
722 dev->nondasd_support = 1;
726 * If the firmware supports ROMB RAID/SCSI mode and we are currently
727 * in RAID/SCSI mode, set the flag. For now if in this mode we will
728 * force nondasd support on. If we decide to allow the non-dasd flag
729 * additional changes changes will have to be made to support
730 * RAID/SCSI. the function aac_scsi_cmd in this module will have to be
731 * changed to support the new dev->raid_scsi_mode flag instead of
732 * leaching off of the dev->nondasd_support flag. Also in linit.c the
733 * function aac_detect will have to be modified where it sets up the
734 * max number of channels based on the aac->nondasd_support flag only.
736 if ((dev->adapter_info.options & AAC_OPT_SCSI_MANAGED) &&
737 (dev->adapter_info.options & AAC_OPT_RAID_SCSI_MODE)) {
738 dev->nondasd_support = 1;
739 dev->raid_scsi_mode = 1;
741 if (dev->raid_scsi_mode != 0)
742 printk(KERN_INFO "%s%d: ROMB RAID/SCSI mode enabled\n",
746 dev->nondasd_support = (nondasd!=0);
748 if(dev->nondasd_support != 0){
749 printk(KERN_INFO "%s%d: Non-DASD support enabled.\n",dev->name, dev->id);
752 dev->dac_support = 0;
753 if( (sizeof(dma_addr_t) > 4) && (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)){
754 printk(KERN_INFO "%s%d: 64bit support enabled.\n", dev->name, dev->id);
755 dev->dac_support = 1;
759 dev->dac_support = (dacmode!=0);
761 if(dev->dac_support != 0) {
762 if (!pci_set_dma_mask(dev->pdev, 0xFFFFFFFFFFFFFFFFULL) &&
763 !pci_set_consistent_dma_mask(dev->pdev, 0xFFFFFFFFFFFFFFFFULL)) {
764 printk(KERN_INFO"%s%d: 64 Bit DAC enabled\n",
766 } else if (!pci_set_dma_mask(dev->pdev, 0xFFFFFFFFULL) &&
767 !pci_set_consistent_dma_mask(dev->pdev, 0xFFFFFFFFULL)) {
768 printk(KERN_INFO"%s%d: DMA mask set failed, 64 Bit DAC disabled\n",
770 dev->dac_support = 0;
772 printk(KERN_WARNING"%s%d: No suitable DMA available.\n",
778 * 57 scatter gather elements
780 dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size -
781 sizeof(struct aac_fibhdr) -
782 sizeof(struct aac_write) + sizeof(struct sgmap)) /
783 sizeof(struct sgmap);
784 if (dev->dac_support) {
786 * 38 scatter gather elements
788 dev->scsi_host_ptr->sg_tablesize =
790 sizeof(struct aac_fibhdr) -
791 sizeof(struct aac_write64) +
792 sizeof(struct sgmap64)) /
793 sizeof(struct sgmap64);
795 dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT;
796 if(!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) {
798 * Worst case size that could cause sg overflow when
799 * we break up SG elements that are larger than 64KB.
800 * Would be nice if we could tell the SCSI layer what
801 * the maximum SG element size can be. Worst case is
802 * (sg_tablesize-1) 4KB elements with one 64KB
804 * 32bit -> 468 or 238KB 64bit -> 424 or 212KB
806 dev->scsi_host_ptr->max_sectors =
807 (dev->scsi_host_ptr->sg_tablesize * 8) + 112;
810 fib_complete(fibptr);
817 static void io_callback(void *context, struct fib * fibptr)
820 struct aac_read_reply *readreply;
821 struct scsi_cmnd *scsicmd;
824 scsicmd = (struct scsi_cmnd *) context;
826 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
827 cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);
829 dprintk((KERN_DEBUG "io_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3], jiffies));
835 pci_unmap_sg(dev->pdev,
836 (struct scatterlist *)scsicmd->buffer,
838 scsicmd->sc_data_direction);
839 else if(scsicmd->request_bufflen)
840 pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle,
841 scsicmd->request_bufflen,
842 scsicmd->sc_data_direction);
843 readreply = (struct aac_read_reply *)fib_data(fibptr);
844 if (le32_to_cpu(readreply->status) == ST_OK)
845 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
847 #ifdef AAC_DETAILED_STATUS_INFO
848 printk(KERN_WARNING "io_callback: io failed, status = %d\n",
849 le32_to_cpu(readreply->status));
851 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
852 set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
854 SENCODE_INTERNAL_TARGET_FAILURE,
855 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
857 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
858 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
859 ? sizeof(scsicmd->sense_buffer)
860 : sizeof(dev->fsa_dev[cid].sense_data));
862 fib_complete(fibptr);
865 aac_io_done(scsicmd);
868 static int aac_read(struct scsi_cmnd * scsicmd, int cid)
876 struct fib * cmd_fibcontext;
878 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
880 * Get block address and transfer length
882 if (scsicmd->cmnd[0] == READ_6) /* 6 byte command */
884 dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", cid));
886 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
887 count = scsicmd->cmnd[4];
892 dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", cid));
894 lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
895 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
897 dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %u, t = %ld.\n",
898 smp_processor_id(), (unsigned long long)lba, jiffies));
900 * Alocate and initialize a Fib
902 if (!(cmd_fibcontext = fib_alloc(dev))) {
906 fib_init(cmd_fibcontext);
908 if (dev->dac_support == 1) {
909 struct aac_read64 *readcmd;
910 readcmd = (struct aac_read64 *) fib_data(cmd_fibcontext);
911 readcmd->command = cpu_to_le32(VM_CtHostRead64);
912 readcmd->cid = cpu_to_le16(cid);
913 readcmd->sector_count = cpu_to_le16(count);
914 readcmd->block = cpu_to_le32(lba);
918 aac_build_sg64(scsicmd, &readcmd->sg);
919 fibsize = sizeof(struct aac_read64) +
920 ((le32_to_cpu(readcmd->sg.count) - 1) *
921 sizeof (struct sgentry64));
922 BUG_ON (fibsize > (sizeof(struct hw_fib) -
923 sizeof(struct aac_fibhdr)));
925 * Now send the Fib to the adapter
927 status = fib_send(ContainerCommand64,
932 (fib_callback) io_callback,
935 struct aac_read *readcmd;
936 readcmd = (struct aac_read *) fib_data(cmd_fibcontext);
937 readcmd->command = cpu_to_le32(VM_CtBlockRead);
938 readcmd->cid = cpu_to_le32(cid);
939 readcmd->block = cpu_to_le32(lba);
940 readcmd->count = cpu_to_le32(count * 512);
942 aac_build_sg(scsicmd, &readcmd->sg);
943 fibsize = sizeof(struct aac_read) +
944 ((le32_to_cpu(readcmd->sg.count) - 1) *
945 sizeof (struct sgentry));
946 BUG_ON (fibsize > (dev->max_fib_size -
947 sizeof(struct aac_fibhdr)));
949 * Now send the Fib to the adapter
951 status = fib_send(ContainerCommand,
956 (fib_callback) io_callback,
963 * Check that the command queued to the controller
965 if (status == -EINPROGRESS)
968 printk(KERN_WARNING "aac_read: fib_send failed with status: %d.\n", status);
970 * For some reason, the Fib didn't queue, return QUEUE_FULL
972 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_TASK_SET_FULL;
973 aac_io_done(scsicmd);
974 fib_complete(cmd_fibcontext);
975 fib_free(cmd_fibcontext);
979 static int aac_write(struct scsi_cmnd * scsicmd, int cid)
986 struct fib * cmd_fibcontext;
988 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
990 * Get block address and transfer length
992 if (scsicmd->cmnd[0] == WRITE_6) /* 6 byte command */
994 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
995 count = scsicmd->cmnd[4];
999 dprintk((KERN_DEBUG "aachba: received a write(10) command on id %d.\n", cid));
1000 lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1001 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
1003 dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %u, t = %ld.\n",
1004 smp_processor_id(), (unsigned long long)lba, jiffies));
1006 * Allocate and initialize a Fib then setup a BlockWrite command
1008 if (!(cmd_fibcontext = fib_alloc(dev))) {
1009 scsicmd->result = DID_ERROR << 16;
1010 aac_io_done(scsicmd);
1013 fib_init(cmd_fibcontext);
1015 if(dev->dac_support == 1) {
1016 struct aac_write64 *writecmd;
1017 writecmd = (struct aac_write64 *) fib_data(cmd_fibcontext);
1018 writecmd->command = cpu_to_le32(VM_CtHostWrite64);
1019 writecmd->cid = cpu_to_le16(cid);
1020 writecmd->sector_count = cpu_to_le16(count);
1021 writecmd->block = cpu_to_le32(lba);
1023 writecmd->flags = 0;
1025 aac_build_sg64(scsicmd, &writecmd->sg);
1026 fibsize = sizeof(struct aac_write64) +
1027 ((le32_to_cpu(writecmd->sg.count) - 1) *
1028 sizeof (struct sgentry64));
1029 BUG_ON (fibsize > (dev->max_fib_size -
1030 sizeof(struct aac_fibhdr)));
1032 * Now send the Fib to the adapter
1034 status = fib_send(ContainerCommand64,
1039 (fib_callback) io_callback,
1042 struct aac_write *writecmd;
1043 writecmd = (struct aac_write *) fib_data(cmd_fibcontext);
1044 writecmd->command = cpu_to_le32(VM_CtBlockWrite);
1045 writecmd->cid = cpu_to_le32(cid);
1046 writecmd->block = cpu_to_le32(lba);
1047 writecmd->count = cpu_to_le32(count * 512);
1048 writecmd->sg.count = cpu_to_le32(1);
1049 /* ->stable is not used - it did mean which type of write */
1051 aac_build_sg(scsicmd, &writecmd->sg);
1052 fibsize = sizeof(struct aac_write) +
1053 ((le32_to_cpu(writecmd->sg.count) - 1) *
1054 sizeof (struct sgentry));
1055 BUG_ON (fibsize > (dev->max_fib_size -
1056 sizeof(struct aac_fibhdr)));
1058 * Now send the Fib to the adapter
1060 status = fib_send(ContainerCommand,
1065 (fib_callback) io_callback,
1070 * Check that the command queued to the controller
1072 if (status == -EINPROGRESS)
1077 printk(KERN_WARNING "aac_write: fib_send failed with status: %d\n", status);
1079 * For some reason, the Fib didn't queue, return QUEUE_FULL
1081 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_TASK_SET_FULL;
1082 aac_io_done(scsicmd);
1084 fib_complete(cmd_fibcontext);
1085 fib_free(cmd_fibcontext);
1089 static void synchronize_callback(void *context, struct fib *fibptr)
1091 struct aac_synchronize_reply *synchronizereply;
1092 struct scsi_cmnd *cmd;
1096 dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n",
1097 smp_processor_id(), jiffies));
1098 BUG_ON(fibptr == NULL);
1101 synchronizereply = fib_data(fibptr);
1102 if (le32_to_cpu(synchronizereply->status) == CT_OK)
1103 cmd->result = DID_OK << 16 |
1104 COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1106 struct scsi_device *sdev = cmd->device;
1107 struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;
1108 u32 cid = ID_LUN_TO_CONTAINER(sdev->id, sdev->lun);
1110 "synchronize_callback: synchronize failed, status = %d\n",
1111 le32_to_cpu(synchronizereply->status));
1112 cmd->result = DID_OK << 16 |
1113 COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
1114 set_sense((u8 *)&dev->fsa_dev[cid].sense_data,
1116 SENCODE_INTERNAL_TARGET_FAILURE,
1117 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
1119 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1120 min(sizeof(dev->fsa_dev[cid].sense_data),
1121 sizeof(cmd->sense_buffer)));
1124 fib_complete(fibptr);
1129 static int aac_synchronize(struct scsi_cmnd *scsicmd, int cid)
1132 struct fib *cmd_fibcontext;
1133 struct aac_synchronize *synchronizecmd;
1134 struct scsi_cmnd *cmd;
1135 struct scsi_device *sdev = scsicmd->device;
1137 unsigned long flags;
1140 * Wait for all commands to complete to this specific
1143 spin_lock_irqsave(&sdev->list_lock, flags);
1144 list_for_each_entry(cmd, &sdev->cmd_list, list)
1145 if (cmd != scsicmd && cmd->serial_number != 0) {
1150 spin_unlock_irqrestore(&sdev->list_lock, flags);
1153 * Yield the processor (requeue for later)
1156 return SCSI_MLQUEUE_DEVICE_BUSY;
1159 * Allocate and initialize a Fib
1161 if (!(cmd_fibcontext =
1162 fib_alloc((struct aac_dev *)scsicmd->device->host->hostdata)))
1163 return SCSI_MLQUEUE_HOST_BUSY;
1165 fib_init(cmd_fibcontext);
1167 synchronizecmd = fib_data(cmd_fibcontext);
1168 synchronizecmd->command = cpu_to_le32(VM_ContainerConfig);
1169 synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE);
1170 synchronizecmd->cid = cpu_to_le32(cid);
1171 synchronizecmd->count =
1172 cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data));
1175 * Now send the Fib to the adapter
1177 status = fib_send(ContainerCommand,
1179 sizeof(struct aac_synchronize),
1182 (fib_callback)synchronize_callback,
1186 * Check that the command queued to the controller
1188 if (status == -EINPROGRESS)
1192 "aac_synchronize: fib_send failed with status: %d.\n", status);
1193 fib_complete(cmd_fibcontext);
1194 fib_free(cmd_fibcontext);
1195 return SCSI_MLQUEUE_HOST_BUSY;
1199 * aac_scsi_cmd() - Process SCSI command
1200 * @scsicmd: SCSI command block
1202 * Emulate a SCSI command and queue the required request for the
1206 int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1209 struct Scsi_Host *host = scsicmd->device->host;
1210 struct aac_dev *dev = (struct aac_dev *)host->hostdata;
1211 struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev;
1212 int cardtype = dev->cardtype;
1216 * If the bus, id or lun is out of range, return fail
1217 * Test does not apply to ID 16, the pseudo id for the controller
1220 if (scsicmd->device->id != host->this_id) {
1221 if ((scsicmd->device->channel == 0) ){
1222 if( (scsicmd->device->id >= dev->maximum_num_containers) || (scsicmd->device->lun != 0)){
1223 scsicmd->result = DID_NO_CONNECT << 16;
1224 scsicmd->scsi_done(scsicmd);
1227 cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);
1230 * If the target container doesn't exist, it may have
1231 * been newly created
1233 if ((fsa_dev_ptr[cid].valid & 1) == 0) {
1234 switch (scsicmd->cmnd[0]) {
1237 case TEST_UNIT_READY:
1238 spin_unlock_irq(host->host_lock);
1239 probe_container(dev, cid);
1240 spin_lock_irq(host->host_lock);
1241 if (fsa_dev_ptr[cid].valid == 0) {
1242 scsicmd->result = DID_NO_CONNECT << 16;
1243 scsicmd->scsi_done(scsicmd);
1251 * If the target container still doesn't exist,
1254 if (fsa_dev_ptr[cid].valid == 0) {
1255 scsicmd->result = DID_BAD_TARGET << 16;
1256 scsicmd->scsi_done(scsicmd);
1259 } else { /* check for physical non-dasd devices */
1260 if(dev->nondasd_support == 1){
1261 return aac_send_srb_fib(scsicmd);
1263 scsicmd->result = DID_NO_CONNECT << 16;
1264 scsicmd->scsi_done(scsicmd);
1270 * else Command for the controller itself
1272 else if ((scsicmd->cmnd[0] != INQUIRY) && /* only INQUIRY & TUR cmnd supported for controller */
1273 (scsicmd->cmnd[0] != TEST_UNIT_READY))
1275 dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0]));
1276 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
1277 set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
1279 SENCODE_INVALID_COMMAND,
1280 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
1281 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1282 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
1283 ? sizeof(scsicmd->sense_buffer)
1284 : sizeof(dev->fsa_dev[cid].sense_data));
1285 scsicmd->scsi_done(scsicmd);
1290 /* Handle commands here that don't really require going out to the adapter */
1291 switch (scsicmd->cmnd[0]) {
1294 struct inquiry_data *inq_data_ptr;
1296 dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", scsicmd->device->id));
1297 inq_data_ptr = (struct inquiry_data *)scsicmd->request_buffer;
1298 memset(inq_data_ptr, 0, sizeof (struct inquiry_data));
1300 inq_data_ptr->inqd_ver = 2; /* claim compliance to SCSI-2 */
1301 inq_data_ptr->inqd_dtq = 0x80; /* set RMB bit to one indicating that the medium is removable */
1302 inq_data_ptr->inqd_rdf = 2; /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */
1303 inq_data_ptr->inqd_len = 31;
1304 /*Format for "pad2" is RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
1305 inq_data_ptr->inqd_pad2= 0x32 ; /*WBus16|Sync|CmdQue */
1307 * Set the Vendor, Product, and Revision Level
1308 * see: <vendor>.c i.e. aac.c
1310 if (scsicmd->device->id == host->this_id) {
1311 setinqstr(cardtype, (void *) (inq_data_ptr->inqd_vid), (sizeof(container_types)/sizeof(char *)));
1312 inq_data_ptr->inqd_pdt = INQD_PDT_PROC; /* Processor device */
1313 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1314 scsicmd->scsi_done(scsicmd);
1317 setinqstr(cardtype, (void *) (inq_data_ptr->inqd_vid), fsa_dev_ptr[cid].type);
1318 inq_data_ptr->inqd_pdt = INQD_PDT_DA; /* Direct/random access device */
1319 return aac_get_container_name(scsicmd, cid);
1326 dprintk((KERN_DEBUG "READ CAPACITY command.\n"));
1327 if (fsa_dev_ptr[cid].size <= 0x100000000LL)
1328 capacity = fsa_dev_ptr[cid].size - 1;
1331 cp = scsicmd->request_buffer;
1332 cp[0] = (capacity >> 24) & 0xff;
1333 cp[1] = (capacity >> 16) & 0xff;
1334 cp[2] = (capacity >> 8) & 0xff;
1335 cp[3] = (capacity >> 0) & 0xff;
1341 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1342 scsicmd->scsi_done(scsicmd);
1351 dprintk((KERN_DEBUG "MODE SENSE command.\n"));
1352 mode_buf = scsicmd->request_buffer;
1353 mode_buf[0] = 3; /* Mode data length */
1354 mode_buf[1] = 0; /* Medium type - default */
1355 mode_buf[2] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */
1356 mode_buf[3] = 0; /* Block descriptor length */
1358 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1359 scsicmd->scsi_done(scsicmd);
1367 dprintk((KERN_DEBUG "MODE SENSE 10 byte command.\n"));
1368 mode_buf = scsicmd->request_buffer;
1369 mode_buf[0] = 0; /* Mode data length (MSB) */
1370 mode_buf[1] = 6; /* Mode data length (LSB) */
1371 mode_buf[2] = 0; /* Medium type - default */
1372 mode_buf[3] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */
1373 mode_buf[4] = 0; /* reserved */
1374 mode_buf[5] = 0; /* reserved */
1375 mode_buf[6] = 0; /* Block descriptor length (MSB) */
1376 mode_buf[7] = 0; /* Block descriptor length (LSB) */
1378 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1379 scsicmd->scsi_done(scsicmd);
1384 dprintk((KERN_DEBUG "REQUEST SENSE command.\n"));
1385 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, sizeof (struct sense_data));
1386 memset(&dev->fsa_dev[cid].sense_data, 0, sizeof (struct sense_data));
1387 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1388 scsicmd->scsi_done(scsicmd);
1391 case ALLOW_MEDIUM_REMOVAL:
1392 dprintk((KERN_DEBUG "LOCK command.\n"));
1393 if (scsicmd->cmnd[4])
1394 fsa_dev_ptr[cid].locked = 1;
1396 fsa_dev_ptr[cid].locked = 0;
1398 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1399 scsicmd->scsi_done(scsicmd);
1402 * These commands are all No-Ops
1404 case TEST_UNIT_READY:
1408 case REASSIGN_BLOCKS:
1411 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1412 scsicmd->scsi_done(scsicmd);
1416 switch (scsicmd->cmnd[0])
1421 * Hack to keep track of ordinal number of the device that
1422 * corresponds to a container. Needed to convert
1423 * containers to /dev/sd device names
1426 spin_unlock_irq(host->host_lock);
1427 if (scsicmd->request->rq_disk)
1428 memcpy(fsa_dev_ptr[cid].devname,
1429 scsicmd->request->rq_disk->disk_name,
1432 ret = aac_read(scsicmd, cid);
1433 spin_lock_irq(host->host_lock);
1438 spin_unlock_irq(host->host_lock);
1439 ret = aac_write(scsicmd, cid);
1440 spin_lock_irq(host->host_lock);
1443 case SYNCHRONIZE_CACHE:
1444 /* Issue FIB to tell Firmware to flush it's cache */
1445 return aac_synchronize(scsicmd, cid);
1449 * Unhandled commands
1451 dprintk((KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0]));
1452 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
1453 set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
1454 ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND,
1455 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
1456 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1457 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
1458 ? sizeof(scsicmd->sense_buffer)
1459 : sizeof(dev->fsa_dev[cid].sense_data));
1460 scsicmd->scsi_done(scsicmd);
1465 static int query_disk(struct aac_dev *dev, void __user *arg)
1467 struct aac_query_disk qd;
1468 struct fsa_dev_info *fsa_dev_ptr;
1470 fsa_dev_ptr = dev->fsa_dev;
1471 if (copy_from_user(&qd, arg, sizeof (struct aac_query_disk)))
1474 qd.cnum = ID_LUN_TO_CONTAINER(qd.id, qd.lun);
1475 else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1))
1477 if (qd.cnum < 0 || qd.cnum >= dev->maximum_num_containers)
1479 qd.instance = dev->scsi_host_ptr->host_no;
1481 qd.id = CONTAINER_TO_ID(qd.cnum);
1482 qd.lun = CONTAINER_TO_LUN(qd.cnum);
1484 else return -EINVAL;
1486 qd.valid = fsa_dev_ptr[qd.cnum].valid;
1487 qd.locked = fsa_dev_ptr[qd.cnum].locked;
1488 qd.deleted = fsa_dev_ptr[qd.cnum].deleted;
1490 if (fsa_dev_ptr[qd.cnum].devname[0] == '\0')
1495 strlcpy(qd.name, fsa_dev_ptr[qd.cnum].devname,
1496 min(sizeof(qd.name), sizeof(fsa_dev_ptr[qd.cnum].devname) + 1));
1498 if (copy_to_user(arg, &qd, sizeof (struct aac_query_disk)))
1503 static int force_delete_disk(struct aac_dev *dev, void __user *arg)
1505 struct aac_delete_disk dd;
1506 struct fsa_dev_info *fsa_dev_ptr;
1508 fsa_dev_ptr = dev->fsa_dev;
1510 if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk)))
1513 if (dd.cnum >= dev->maximum_num_containers)
1516 * Mark this container as being deleted.
1518 fsa_dev_ptr[dd.cnum].deleted = 1;
1520 * Mark the container as no longer valid
1522 fsa_dev_ptr[dd.cnum].valid = 0;
1526 static int delete_disk(struct aac_dev *dev, void __user *arg)
1528 struct aac_delete_disk dd;
1529 struct fsa_dev_info *fsa_dev_ptr;
1531 fsa_dev_ptr = dev->fsa_dev;
1533 if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk)))
1536 if (dd.cnum >= dev->maximum_num_containers)
1539 * If the container is locked, it can not be deleted by the API.
1541 if (fsa_dev_ptr[dd.cnum].locked)
1545 * Mark the container as no longer being valid.
1547 fsa_dev_ptr[dd.cnum].valid = 0;
1548 fsa_dev_ptr[dd.cnum].devname[0] = '\0';
1553 int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg)
1556 case FSACTL_QUERY_DISK:
1557 return query_disk(dev, arg);
1558 case FSACTL_DELETE_DISK:
1559 return delete_disk(dev, arg);
1560 case FSACTL_FORCE_DELETE_DISK:
1561 return force_delete_disk(dev, arg);
1562 case FSACTL_GET_CONTAINERS:
1563 return aac_get_containers(dev);
1572 * @context: the context set in the fib - here it is scsi cmd
1573 * @fibptr: pointer to the fib
1575 * Handles the completion of a scsi command to a non dasd device
1579 static void aac_srb_callback(void *context, struct fib * fibptr)
1581 struct aac_dev *dev;
1582 struct aac_srb_reply *srbreply;
1583 struct scsi_cmnd *scsicmd;
1585 scsicmd = (struct scsi_cmnd *) context;
1586 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
1591 srbreply = (struct aac_srb_reply *) fib_data(fibptr);
1593 scsicmd->sense_buffer[0] = '\0'; /* Initialize sense valid flag to false */
1595 * Calculate resid for sg
1598 scsicmd->resid = scsicmd->request_bufflen -
1599 le32_to_cpu(srbreply->data_xfer_length);
1602 pci_unmap_sg(dev->pdev,
1603 (struct scatterlist *)scsicmd->buffer,
1605 scsicmd->sc_data_direction);
1606 else if(scsicmd->request_bufflen)
1607 pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle, scsicmd->request_bufflen,
1608 scsicmd->sc_data_direction);
1611 * First check the fib status
1614 if (le32_to_cpu(srbreply->status) != ST_OK){
1616 printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status));
1617 len = (le32_to_cpu(srbreply->sense_data_size) >
1618 sizeof(scsicmd->sense_buffer)) ?
1619 sizeof(scsicmd->sense_buffer) :
1620 le32_to_cpu(srbreply->sense_data_size);
1621 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
1622 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
1626 * Next check the srb status
1628 switch( (le32_to_cpu(srbreply->srb_status))&0x3f){
1629 case SRB_STATUS_ERROR_RECOVERY:
1630 case SRB_STATUS_PENDING:
1631 case SRB_STATUS_SUCCESS:
1632 if(scsicmd->cmnd[0] == INQUIRY ){
1635 /* We can't expose disk devices because we can't tell whether they
1636 * are the raw container drives or stand alone drives. If they have
1637 * the removable bit set then we should expose them though.
1639 b = (*(u8*)scsicmd->buffer)&0x1f;
1640 b1 = ((u8*)scsicmd->buffer)[1];
1641 if( b==TYPE_TAPE || b==TYPE_WORM || b==TYPE_ROM || b==TYPE_MOD|| b==TYPE_MEDIUM_CHANGER
1642 || (b==TYPE_DISK && (b1&0x80)) ){
1643 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
1645 * We will allow disk devices if in RAID/SCSI mode and
1648 } else if ((dev->raid_scsi_mode) &&
1649 (scsicmd->device->channel == 2)) {
1650 scsicmd->result = DID_OK << 16 |
1651 COMMAND_COMPLETE << 8;
1653 scsicmd->result = DID_NO_CONNECT << 16 |
1654 COMMAND_COMPLETE << 8;
1657 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
1660 case SRB_STATUS_DATA_OVERRUN:
1661 switch(scsicmd->cmnd[0]){
1668 if(le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow ) {
1669 printk(KERN_WARNING"aacraid: SCSI CMD underflow\n");
1671 printk(KERN_WARNING"aacraid: SCSI CMD Data Overrun\n");
1673 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8;
1678 /* We can't expose disk devices because we can't tell whether they
1679 * are the raw container drives or stand alone drives
1681 b = (*(u8*)scsicmd->buffer)&0x0f;
1682 b1 = ((u8*)scsicmd->buffer)[1];
1683 if( b==TYPE_TAPE || b==TYPE_WORM || b==TYPE_ROM || b==TYPE_MOD|| b==TYPE_MEDIUM_CHANGER
1684 || (b==TYPE_DISK && (b1&0x80)) ){
1685 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
1687 * We will allow disk devices if in RAID/SCSI mode and
1690 } else if ((dev->raid_scsi_mode) &&
1691 (scsicmd->device->channel == 2)) {
1692 scsicmd->result = DID_OK << 16 |
1693 COMMAND_COMPLETE << 8;
1695 scsicmd->result = DID_NO_CONNECT << 16 |
1696 COMMAND_COMPLETE << 8;
1701 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
1705 case SRB_STATUS_ABORTED:
1706 scsicmd->result = DID_ABORT << 16 | ABORT << 8;
1708 case SRB_STATUS_ABORT_FAILED:
1709 // Not sure about this one - but assuming the hba was trying to abort for some reason
1710 scsicmd->result = DID_ERROR << 16 | ABORT << 8;
1712 case SRB_STATUS_PARITY_ERROR:
1713 scsicmd->result = DID_PARITY << 16 | MSG_PARITY_ERROR << 8;
1715 case SRB_STATUS_NO_DEVICE:
1716 case SRB_STATUS_INVALID_PATH_ID:
1717 case SRB_STATUS_INVALID_TARGET_ID:
1718 case SRB_STATUS_INVALID_LUN:
1719 case SRB_STATUS_SELECTION_TIMEOUT:
1720 scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8;
1723 case SRB_STATUS_COMMAND_TIMEOUT:
1724 case SRB_STATUS_TIMEOUT:
1725 scsicmd->result = DID_TIME_OUT << 16 | COMMAND_COMPLETE << 8;
1728 case SRB_STATUS_BUSY:
1729 scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8;
1732 case SRB_STATUS_BUS_RESET:
1733 scsicmd->result = DID_RESET << 16 | COMMAND_COMPLETE << 8;
1736 case SRB_STATUS_MESSAGE_REJECTED:
1737 scsicmd->result = DID_ERROR << 16 | MESSAGE_REJECT << 8;
1739 case SRB_STATUS_REQUEST_FLUSHED:
1740 case SRB_STATUS_ERROR:
1741 case SRB_STATUS_INVALID_REQUEST:
1742 case SRB_STATUS_REQUEST_SENSE_FAILED:
1743 case SRB_STATUS_NO_HBA:
1744 case SRB_STATUS_UNEXPECTED_BUS_FREE:
1745 case SRB_STATUS_PHASE_SEQUENCE_FAILURE:
1746 case SRB_STATUS_BAD_SRB_BLOCK_LENGTH:
1747 case SRB_STATUS_DELAYED_RETRY:
1748 case SRB_STATUS_BAD_FUNCTION:
1749 case SRB_STATUS_NOT_STARTED:
1750 case SRB_STATUS_NOT_IN_USE:
1751 case SRB_STATUS_FORCE_ABORT:
1752 case SRB_STATUS_DOMAIN_VALIDATION_FAIL:
1754 #ifdef AAC_DETAILED_STATUS_INFO
1755 printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",
1756 le32_to_cpu(srbreply->srb_status) & 0x3F,
1757 aac_get_status_string(
1758 le32_to_cpu(srbreply->srb_status) & 0x3F),
1760 le32_to_cpu(srbreply->scsi_status));
1762 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8;
1765 if (le32_to_cpu(srbreply->scsi_status) == 0x02 ){ // Check Condition
1767 scsicmd->result |= SAM_STAT_CHECK_CONDITION;
1768 len = (le32_to_cpu(srbreply->sense_data_size) >
1769 sizeof(scsicmd->sense_buffer)) ?
1770 sizeof(scsicmd->sense_buffer) :
1771 le32_to_cpu(srbreply->sense_data_size);
1772 #ifdef AAC_DETAILED_STATUS_INFO
1773 dprintk((KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n",
1774 le32_to_cpu(srbreply->status), len));
1776 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
1780 * OR in the scsi status (already shifted up a bit)
1782 scsicmd->result |= le32_to_cpu(srbreply->scsi_status);
1784 fib_complete(fibptr);
1786 aac_io_done(scsicmd);
1792 * @scsicmd: the scsi command block
1794 * This routine will form a FIB and fill in the aac_srb from the
1795 * scsicmd passed in.
1798 static int aac_send_srb_fib(struct scsi_cmnd* scsicmd)
1800 struct fib* cmd_fibcontext;
1801 struct aac_dev* dev;
1803 struct aac_srb *srbcmd;
1808 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
1809 if (scsicmd->device->id >= dev->maximum_num_physicals ||
1810 scsicmd->device->lun > 7) {
1811 scsicmd->result = DID_NO_CONNECT << 16;
1812 scsicmd->scsi_done(scsicmd);
1816 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
1817 switch(scsicmd->sc_data_direction){
1821 case DMA_BIDIRECTIONAL:
1822 flag = SRB_DataIn | SRB_DataOut;
1824 case DMA_FROM_DEVICE:
1828 default: /* shuts up some versions of gcc */
1829 flag = SRB_NoDataXfer;
1835 * Allocate and initialize a Fib then setup a BlockWrite command
1837 if (!(cmd_fibcontext = fib_alloc(dev))) {
1840 fib_init(cmd_fibcontext);
1842 srbcmd = (struct aac_srb*) fib_data(cmd_fibcontext);
1843 srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi);
1844 srbcmd->channel = cpu_to_le32(aac_logical_to_phys(scsicmd->device->channel));
1845 srbcmd->id = cpu_to_le32(scsicmd->device->id);
1846 srbcmd->lun = cpu_to_le32(scsicmd->device->lun);
1847 srbcmd->flags = cpu_to_le32(flag);
1848 timeout = (scsicmd->timeout-jiffies)/HZ;
1852 srbcmd->timeout = cpu_to_le32(timeout); // timeout in seconds
1853 srbcmd->retry_limit = 0; /* Obsolete parameter */
1854 srbcmd->cdb_size = cpu_to_le32(scsicmd->cmd_len);
1856 if( dev->dac_support == 1 ) {
1857 aac_build_sg64(scsicmd, (struct sgmap64*) &srbcmd->sg);
1858 srbcmd->count = cpu_to_le32(scsicmd->request_bufflen);
1860 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb));
1861 memcpy(srbcmd->cdb, scsicmd->cmnd, scsicmd->cmd_len);
1863 * Build Scatter/Gather list
1865 fibsize = sizeof (struct aac_srb) - sizeof (struct sgentry) +
1866 ((le32_to_cpu(srbcmd->sg.count) & 0xff) *
1867 sizeof (struct sgentry64));
1868 BUG_ON (fibsize > (dev->max_fib_size -
1869 sizeof(struct aac_fibhdr)));
1872 * Now send the Fib to the adapter
1874 status = fib_send(ScsiPortCommand64, cmd_fibcontext,
1875 fibsize, FsaNormal, 0, 1,
1876 (fib_callback) aac_srb_callback,
1879 aac_build_sg(scsicmd, (struct sgmap*)&srbcmd->sg);
1880 srbcmd->count = cpu_to_le32(scsicmd->request_bufflen);
1882 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb));
1883 memcpy(srbcmd->cdb, scsicmd->cmnd, scsicmd->cmd_len);
1885 * Build Scatter/Gather list
1887 fibsize = sizeof (struct aac_srb) +
1888 (((le32_to_cpu(srbcmd->sg.count) & 0xff) - 1) *
1889 sizeof (struct sgentry));
1890 BUG_ON (fibsize > (dev->max_fib_size -
1891 sizeof(struct aac_fibhdr)));
1894 * Now send the Fib to the adapter
1896 status = fib_send(ScsiPortCommand, cmd_fibcontext, fibsize, FsaNormal, 0, 1,
1897 (fib_callback) aac_srb_callback, (void *) scsicmd);
1900 * Check that the command queued to the controller
1902 if (status == -EINPROGRESS){
1906 printk(KERN_WARNING "aac_srb: fib_send failed with status: %d\n", status);
1907 fib_complete(cmd_fibcontext);
1908 fib_free(cmd_fibcontext);
1913 static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* psg)
1915 struct aac_dev *dev;
1916 unsigned long byte_count = 0;
1918 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
1919 // Get rid of old data
1921 psg->sg[0].addr = 0;
1922 psg->sg[0].count = 0;
1923 if (scsicmd->use_sg) {
1924 struct scatterlist *sg;
1927 sg = (struct scatterlist *) scsicmd->request_buffer;
1929 sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg,
1930 scsicmd->sc_data_direction);
1931 psg->count = cpu_to_le32(sg_count);
1935 for (i = 0; i < sg_count; i++) {
1936 psg->sg[i].addr = cpu_to_le32(sg_dma_address(sg));
1937 psg->sg[i].count = cpu_to_le32(sg_dma_len(sg));
1938 byte_count += sg_dma_len(sg);
1941 /* hba wants the size to be exact */
1942 if(byte_count > scsicmd->request_bufflen){
1943 u32 temp = le32_to_cpu(psg->sg[i-1].count) -
1944 (byte_count - scsicmd->request_bufflen);
1945 psg->sg[i-1].count = cpu_to_le32(temp);
1946 byte_count = scsicmd->request_bufflen;
1948 /* Check for command underflow */
1949 if(scsicmd->underflow && (byte_count < scsicmd->underflow)){
1950 printk(KERN_WARNING"aacraid: cmd len %08lX cmd underflow %08X\n",
1951 byte_count, scsicmd->underflow);
1954 else if(scsicmd->request_bufflen) {
1956 addr = pci_map_single(dev->pdev,
1957 scsicmd->request_buffer,
1958 scsicmd->request_bufflen,
1959 scsicmd->sc_data_direction);
1960 psg->count = cpu_to_le32(1);
1961 psg->sg[0].addr = cpu_to_le32(addr);
1962 psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen);
1963 scsicmd->SCp.dma_handle = addr;
1964 byte_count = scsicmd->request_bufflen;
1970 static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* psg)
1972 struct aac_dev *dev;
1973 unsigned long byte_count = 0;
1976 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
1977 // Get rid of old data
1979 psg->sg[0].addr[0] = 0;
1980 psg->sg[0].addr[1] = 0;
1981 psg->sg[0].count = 0;
1982 if (scsicmd->use_sg) {
1983 struct scatterlist *sg;
1986 sg = (struct scatterlist *) scsicmd->request_buffer;
1988 sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg,
1989 scsicmd->sc_data_direction);
1990 psg->count = cpu_to_le32(sg_count);
1994 for (i = 0; i < sg_count; i++) {
1995 addr = sg_dma_address(sg);
1996 psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff);
1997 psg->sg[i].addr[1] = cpu_to_le32(addr>>32);
1998 psg->sg[i].count = cpu_to_le32(sg_dma_len(sg));
1999 byte_count += sg_dma_len(sg);
2002 /* hba wants the size to be exact */
2003 if(byte_count > scsicmd->request_bufflen){
2004 u32 temp = le32_to_cpu(psg->sg[i-1].count) -
2005 (byte_count - scsicmd->request_bufflen);
2006 psg->sg[i-1].count = cpu_to_le32(temp);
2007 byte_count = scsicmd->request_bufflen;
2009 /* Check for command underflow */
2010 if(scsicmd->underflow && (byte_count < scsicmd->underflow)){
2011 printk(KERN_WARNING"aacraid: cmd len %08lX cmd underflow %08X\n",
2012 byte_count, scsicmd->underflow);
2015 else if(scsicmd->request_bufflen) {
2017 addr = pci_map_single(dev->pdev,
2018 scsicmd->request_buffer,
2019 scsicmd->request_bufflen,
2020 scsicmd->sc_data_direction);
2021 psg->count = cpu_to_le32(1);
2022 psg->sg[0].addr[0] = cpu_to_le32(addr & 0xffffffff);
2023 psg->sg[0].addr[1] = cpu_to_le32(addr >> 32);
2024 psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen);
2025 scsicmd->SCp.dma_handle = addr;
2026 byte_count = scsicmd->request_bufflen;
2031 #ifdef AAC_DETAILED_STATUS_INFO
2033 struct aac_srb_status_info {
2039 static struct aac_srb_status_info srb_status_info[] = {
2040 { SRB_STATUS_PENDING, "Pending Status"},
2041 { SRB_STATUS_SUCCESS, "Success"},
2042 { SRB_STATUS_ABORTED, "Aborted Command"},
2043 { SRB_STATUS_ABORT_FAILED, "Abort Failed"},
2044 { SRB_STATUS_ERROR, "Error Event"},
2045 { SRB_STATUS_BUSY, "Device Busy"},
2046 { SRB_STATUS_INVALID_REQUEST, "Invalid Request"},
2047 { SRB_STATUS_INVALID_PATH_ID, "Invalid Path ID"},
2048 { SRB_STATUS_NO_DEVICE, "No Device"},
2049 { SRB_STATUS_TIMEOUT, "Timeout"},
2050 { SRB_STATUS_SELECTION_TIMEOUT, "Selection Timeout"},
2051 { SRB_STATUS_COMMAND_TIMEOUT, "Command Timeout"},
2052 { SRB_STATUS_MESSAGE_REJECTED, "Message Rejected"},
2053 { SRB_STATUS_BUS_RESET, "Bus Reset"},
2054 { SRB_STATUS_PARITY_ERROR, "Parity Error"},
2055 { SRB_STATUS_REQUEST_SENSE_FAILED,"Request Sense Failed"},
2056 { SRB_STATUS_NO_HBA, "No HBA"},
2057 { SRB_STATUS_DATA_OVERRUN, "Data Overrun/Data Underrun"},
2058 { SRB_STATUS_UNEXPECTED_BUS_FREE,"Unexpected Bus Free"},
2059 { SRB_STATUS_PHASE_SEQUENCE_FAILURE,"Phase Error"},
2060 { SRB_STATUS_BAD_SRB_BLOCK_LENGTH,"Bad Srb Block Length"},
2061 { SRB_STATUS_REQUEST_FLUSHED, "Request Flushed"},
2062 { SRB_STATUS_DELAYED_RETRY, "Delayed Retry"},
2063 { SRB_STATUS_INVALID_LUN, "Invalid LUN"},
2064 { SRB_STATUS_INVALID_TARGET_ID, "Invalid TARGET ID"},
2065 { SRB_STATUS_BAD_FUNCTION, "Bad Function"},
2066 { SRB_STATUS_ERROR_RECOVERY, "Error Recovery"},
2067 { SRB_STATUS_NOT_STARTED, "Not Started"},
2068 { SRB_STATUS_NOT_IN_USE, "Not In Use"},
2069 { SRB_STATUS_FORCE_ABORT, "Force Abort"},
2070 { SRB_STATUS_DOMAIN_VALIDATION_FAIL,"Domain Validation Failure"},
2071 { 0xff, "Unknown Error"}
2074 char *aac_get_status_string(u32 status)
2078 for(i=0; i < (sizeof(srb_status_info)/sizeof(struct aac_srb_status_info)); i++ ){
2079 if(srb_status_info[i].status == status){
2080 return srb_status_info[i].str;
2084 return "Bad Status Code";