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;
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);
317 "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%u\n",
318 (int)index, (int)le32_to_cpu(dresp->status),
319 (int)le32_to_cpu(dresp->mnt[0].vol),
320 (int)le32_to_cpu(dresp->mnt[0].state),
321 (unsigned)le32_to_cpu(dresp->mnt[0].capacity)));
322 if ((le32_to_cpu(dresp->status) == ST_OK) &&
323 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
324 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
325 fsa_dev_ptr[index].valid = 1;
326 fsa_dev_ptr[index].type = le32_to_cpu(dresp->mnt[0].vol);
327 fsa_dev_ptr[index].size = le32_to_cpu(dresp->mnt[0].capacity);
328 if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
329 fsa_dev_ptr[index].ro = 1;
331 fib_complete(fibptr);
333 * If there are no more containers, then stop asking.
335 if ((index + 1) >= le32_to_cpu(dresp->count)){
343 static void aac_io_done(struct scsi_cmnd * scsicmd)
345 unsigned long cpu_flags;
346 struct Scsi_Host *host = scsicmd->device->host;
347 spin_lock_irqsave(host->host_lock, cpu_flags);
348 scsicmd->scsi_done(scsicmd);
349 spin_unlock_irqrestore(host->host_lock, cpu_flags);
352 static void get_container_name_callback(void *context, struct fib * fibptr)
354 struct aac_get_name_resp * get_name_reply;
355 struct scsi_cmnd * scsicmd;
357 scsicmd = (struct scsi_cmnd *) context;
359 dprintk((KERN_DEBUG "get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies));
363 get_name_reply = (struct aac_get_name_resp *) fib_data(fibptr);
364 /* Failure is irrelevant, using default value instead */
365 if ((le32_to_cpu(get_name_reply->status) == CT_OK)
366 && (get_name_reply->data[0] != '\0')) {
369 char * sp = get_name_reply->data;
370 sp[sizeof(((struct aac_get_name_resp *)NULL)->data)-1] = '\0';
373 count = sizeof(((struct inquiry_data *)NULL)->inqd_pid);
374 dp = ((struct inquiry_data *)scsicmd->request_buffer)->inqd_pid;
376 *dp++ = (*sp) ? *sp++ : ' ';
377 } while (--count > 0);
379 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
381 fib_complete(fibptr);
383 aac_io_done(scsicmd);
387 * aac_get_container_name - get container name, none blocking.
389 static int aac_get_container_name(struct scsi_cmnd * scsicmd, int cid)
392 struct aac_get_name *dinfo;
393 struct fib * cmd_fibcontext;
394 struct aac_dev * dev;
396 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
398 if (!(cmd_fibcontext = fib_alloc(dev)))
401 fib_init(cmd_fibcontext);
402 dinfo = (struct aac_get_name *) fib_data(cmd_fibcontext);
404 dinfo->command = cpu_to_le32(VM_ContainerConfig);
405 dinfo->type = cpu_to_le32(CT_READ_NAME);
406 dinfo->cid = cpu_to_le32(cid);
407 dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data));
409 status = fib_send(ContainerCommand,
411 sizeof (struct aac_get_name),
414 (fib_callback) get_container_name_callback,
418 * Check that the command queued to the controller
420 if (status == -EINPROGRESS)
423 printk(KERN_WARNING "aac_get_container_name: fib_send failed with status: %d.\n", status);
424 fib_complete(cmd_fibcontext);
425 fib_free(cmd_fibcontext);
430 * probe_container - query a logical volume
431 * @dev: device to query
432 * @cid: container identifier
434 * Queries the controller about the given volume. The volume information
435 * is updated in the struct fsa_dev_info structure rather than returned.
438 static int probe_container(struct aac_dev *dev, int cid)
440 struct fsa_dev_info *fsa_dev_ptr;
442 struct aac_query_mount *dinfo;
443 struct aac_mount *dresp;
447 fsa_dev_ptr = dev->fsa_dev;
448 instance = dev->scsi_host_ptr->unique_id;
450 if (!(fibptr = fib_alloc(dev)))
455 dinfo = (struct aac_query_mount *)fib_data(fibptr);
457 dinfo->command = cpu_to_le32(VM_NameServe);
458 dinfo->count = cpu_to_le32(cid);
459 dinfo->type = cpu_to_le32(FT_FILESYS);
461 status = fib_send(ContainerCommand,
463 sizeof(struct aac_query_mount),
468 printk(KERN_WARNING "aacraid: probe_container query failed.\n");
472 dresp = (struct aac_mount *) fib_data(fibptr);
474 if ((le32_to_cpu(dresp->status) == ST_OK) &&
475 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
476 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
477 fsa_dev_ptr[cid].valid = 1;
478 fsa_dev_ptr[cid].type = le32_to_cpu(dresp->mnt[0].vol);
479 fsa_dev_ptr[cid].size = le32_to_cpu(dresp->mnt[0].capacity);
480 if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
481 fsa_dev_ptr[cid].ro = 1;
485 fib_complete(fibptr);
491 /* Local Structure to set SCSI inquiry data strings */
493 char vid[8]; /* Vendor ID */
494 char pid[16]; /* Product ID */
495 char prl[4]; /* Product Revision Level */
499 * InqStrCopy - string merge
500 * @a: string to copy from
501 * @b: string to copy to
503 * Copy a String from one location to another
507 static void inqstrcpy(char *a, char *b)
514 static char *container_types[] = {
535 /* Function: setinqstr
537 * Arguments: [1] pointer to void [1] int
539 * Purpose: Sets SCSI inquiry data strings for vendor, product
540 * and revision level. Allows strings to be set in platform dependant
541 * files instead of in OS dependant driver source.
544 static void setinqstr(int devtype, void *data, int tindex)
546 struct scsi_inq *str;
547 struct aac_driver_ident *mp;
549 mp = aac_get_driver_ident(devtype);
551 str = (struct scsi_inq *)(data); /* cast data to scsi inq block */
553 inqstrcpy (mp->vname, str->vid);
554 inqstrcpy (mp->model, str->pid); /* last six chars reserved for vol type */
556 if (tindex < (sizeof(container_types)/sizeof(char *))){
557 char *findit = str->pid;
559 for ( ; *findit != ' '; findit++); /* walk till we find a space */
560 /* RAID is superfluous in the context of a RAID device */
561 if (memcmp(findit-4, "RAID", 4) == 0)
562 *(findit -= 4) = ' ';
563 inqstrcpy (container_types[tindex], findit + 1);
565 inqstrcpy ("V1.0", str->prl);
568 static void set_sense(u8 *sense_buf, u8 sense_key, u8 sense_code,
569 u8 a_sense_code, u8 incorrect_length,
570 u8 bit_pointer, u16 field_pointer,
573 sense_buf[0] = 0xF0; /* Sense data valid, err code 70h (current error) */
574 sense_buf[1] = 0; /* Segment number, always zero */
576 if (incorrect_length) {
577 sense_buf[2] = sense_key | 0x20;/* Set ILI bit | sense key */
578 sense_buf[3] = BYTE3(residue);
579 sense_buf[4] = BYTE2(residue);
580 sense_buf[5] = BYTE1(residue);
581 sense_buf[6] = BYTE0(residue);
583 sense_buf[2] = sense_key; /* Sense key */
585 if (sense_key == ILLEGAL_REQUEST)
586 sense_buf[7] = 10; /* Additional sense length */
588 sense_buf[7] = 6; /* Additional sense length */
590 sense_buf[12] = sense_code; /* Additional sense code */
591 sense_buf[13] = a_sense_code; /* Additional sense code qualifier */
592 if (sense_key == ILLEGAL_REQUEST) {
595 if (sense_code == SENCODE_INVALID_PARAM_FIELD)
596 sense_buf[15] = 0x80;/* Std sense key specific field */
597 /* Illegal parameter is in the parameter block */
599 if (sense_code == SENCODE_INVALID_CDB_FIELD)
600 sense_buf[15] = 0xc0;/* Std sense key specific field */
601 /* Illegal parameter is in the CDB block */
602 sense_buf[15] |= bit_pointer;
603 sense_buf[16] = field_pointer >> 8; /* MSB */
604 sense_buf[17] = field_pointer; /* LSB */
608 int aac_get_adapter_info(struct aac_dev* dev)
613 struct aac_adapter_info * info;
615 if (!(fibptr = fib_alloc(dev)))
619 info = (struct aac_adapter_info *) fib_data(fibptr);
620 memset(info,0,sizeof(*info));
622 rcode = fib_send(RequestAdapterInfo,
631 fib_complete(fibptr);
635 memcpy(&dev->adapter_info, info, sizeof(*info));
637 if (dev->adapter_info.options & AAC_OPT_SUPPLEMENT_ADAPTER_INFO) {
638 struct aac_supplement_adapter_info * info;
642 info = (struct aac_supplement_adapter_info *) fib_data(fibptr);
644 memset(info,0,sizeof(*info));
646 rcode = fib_send(RequestSupplementAdapterInfo,
655 memcpy(&dev->supplement_adapter_info, info, sizeof(*info));
658 tmp = le32_to_cpu(dev->adapter_info.kernelrev);
659 printk(KERN_INFO "%s%d: kernel %d.%d-%d[%d] %.*s\n",
665 le32_to_cpu(dev->adapter_info.kernelbuild),
666 (int)sizeof(dev->supplement_adapter_info.BuildDate),
667 dev->supplement_adapter_info.BuildDate);
668 tmp = le32_to_cpu(dev->adapter_info.monitorrev);
669 printk(KERN_INFO "%s%d: monitor %d.%d-%d[%d]\n",
671 tmp>>24,(tmp>>16)&0xff,tmp&0xff,
672 le32_to_cpu(dev->adapter_info.monitorbuild));
673 tmp = le32_to_cpu(dev->adapter_info.biosrev);
674 printk(KERN_INFO "%s%d: bios %d.%d-%d[%d]\n",
676 tmp>>24,(tmp>>16)&0xff,tmp&0xff,
677 le32_to_cpu(dev->adapter_info.biosbuild));
678 if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0)
679 printk(KERN_INFO "%s%d: serial %x\n",
681 le32_to_cpu(dev->adapter_info.serial[0]));
683 dev->nondasd_support = 0;
684 dev->raid_scsi_mode = 0;
685 if(dev->adapter_info.options & AAC_OPT_NONDASD){
686 dev->nondasd_support = 1;
690 * If the firmware supports ROMB RAID/SCSI mode and we are currently
691 * in RAID/SCSI mode, set the flag. For now if in this mode we will
692 * force nondasd support on. If we decide to allow the non-dasd flag
693 * additional changes changes will have to be made to support
694 * RAID/SCSI. the function aac_scsi_cmd in this module will have to be
695 * changed to support the new dev->raid_scsi_mode flag instead of
696 * leaching off of the dev->nondasd_support flag. Also in linit.c the
697 * function aac_detect will have to be modified where it sets up the
698 * max number of channels based on the aac->nondasd_support flag only.
700 if ((dev->adapter_info.options & AAC_OPT_SCSI_MANAGED) &&
701 (dev->adapter_info.options & AAC_OPT_RAID_SCSI_MODE)) {
702 dev->nondasd_support = 1;
703 dev->raid_scsi_mode = 1;
705 if (dev->raid_scsi_mode != 0)
706 printk(KERN_INFO "%s%d: ROMB RAID/SCSI mode enabled\n",
710 dev->nondasd_support = (nondasd!=0);
712 if(dev->nondasd_support != 0){
713 printk(KERN_INFO "%s%d: Non-DASD support enabled.\n",dev->name, dev->id);
716 dev->dac_support = 0;
717 if( (sizeof(dma_addr_t) > 4) && (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)){
718 printk(KERN_INFO "%s%d: 64bit support enabled.\n", dev->name, dev->id);
719 dev->dac_support = 1;
723 dev->dac_support = (dacmode!=0);
725 if(dev->dac_support != 0) {
726 if (!pci_set_dma_mask(dev->pdev, 0xFFFFFFFFFFFFFFFFULL) &&
727 !pci_set_consistent_dma_mask(dev->pdev, 0xFFFFFFFFFFFFFFFFULL)) {
728 printk(KERN_INFO"%s%d: 64 Bit DAC enabled\n",
730 } else if (!pci_set_dma_mask(dev->pdev, 0xFFFFFFFFULL) &&
731 !pci_set_consistent_dma_mask(dev->pdev, 0xFFFFFFFFULL)) {
732 printk(KERN_INFO"%s%d: DMA mask set failed, 64 Bit DAC disabled\n",
734 dev->dac_support = 0;
736 printk(KERN_WARNING"%s%d: No suitable DMA available.\n",
742 * 57 scatter gather elements
744 dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size -
745 sizeof(struct aac_fibhdr) -
746 sizeof(struct aac_write) + sizeof(struct sgmap)) /
747 sizeof(struct sgmap);
748 if (dev->dac_support) {
750 * 38 scatter gather elements
752 dev->scsi_host_ptr->sg_tablesize =
754 sizeof(struct aac_fibhdr) -
755 sizeof(struct aac_write64) +
756 sizeof(struct sgmap64)) /
757 sizeof(struct sgmap64);
759 dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT;
760 if(!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) {
762 * Worst case size that could cause sg overflow when
763 * we break up SG elements that are larger than 64KB.
764 * Would be nice if we could tell the SCSI layer what
765 * the maximum SG element size can be. Worst case is
766 * (sg_tablesize-1) 4KB elements with one 64KB
768 * 32bit -> 468 or 238KB 64bit -> 424 or 212KB
770 dev->scsi_host_ptr->max_sectors =
771 (dev->scsi_host_ptr->sg_tablesize * 8) + 112;
774 fib_complete(fibptr);
781 static void read_callback(void *context, struct fib * fibptr)
784 struct aac_read_reply *readreply;
785 struct scsi_cmnd *scsicmd;
789 scsicmd = (struct scsi_cmnd *) context;
791 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
792 cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);
794 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
795 dprintk((KERN_DEBUG "read_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), lba, jiffies));
801 pci_unmap_sg(dev->pdev,
802 (struct scatterlist *)scsicmd->buffer,
804 scsicmd->sc_data_direction);
805 else if(scsicmd->request_bufflen)
806 pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle,
807 scsicmd->request_bufflen,
808 scsicmd->sc_data_direction);
809 readreply = (struct aac_read_reply *)fib_data(fibptr);
810 if (le32_to_cpu(readreply->status) == ST_OK)
811 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
813 #ifdef AAC_DETAILED_STATUS_INFO
814 printk(KERN_WARNING "read_callback: io failed, status = %d\n",
815 le32_to_cpu(readreply->status));
817 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
818 set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
820 SENCODE_INTERNAL_TARGET_FAILURE,
821 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
823 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
824 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
825 ? sizeof(scsicmd->sense_buffer)
826 : sizeof(dev->fsa_dev[cid].sense_data));
828 fib_complete(fibptr);
831 aac_io_done(scsicmd);
834 static void write_callback(void *context, struct fib * fibptr)
837 struct aac_write_reply *writereply;
838 struct scsi_cmnd *scsicmd;
842 scsicmd = (struct scsi_cmnd *) context;
843 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
844 cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);
846 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
847 dprintk((KERN_DEBUG "write_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), lba, jiffies));
852 pci_unmap_sg(dev->pdev,
853 (struct scatterlist *)scsicmd->buffer,
855 scsicmd->sc_data_direction);
856 else if(scsicmd->request_bufflen)
857 pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle,
858 scsicmd->request_bufflen,
859 scsicmd->sc_data_direction);
861 writereply = (struct aac_write_reply *) fib_data(fibptr);
862 if (le32_to_cpu(writereply->status) == ST_OK)
863 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
865 printk(KERN_WARNING "write_callback: write failed, status = %d\n", writereply->status);
866 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
867 set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
869 SENCODE_INTERNAL_TARGET_FAILURE,
870 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
872 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
873 sizeof(struct sense_data));
876 fib_complete(fibptr);
878 aac_io_done(scsicmd);
881 static int aac_read(struct scsi_cmnd * scsicmd, int cid)
889 struct fib * cmd_fibcontext;
891 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
893 * Get block address and transfer length
895 if (scsicmd->cmnd[0] == READ_6) /* 6 byte command */
897 dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", cid));
899 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
900 count = scsicmd->cmnd[4];
905 dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", cid));
907 lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
908 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
910 dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %u, t = %ld.\n",
911 smp_processor_id(), (unsigned long long)lba, jiffies));
913 * Alocate and initialize a Fib
915 if (!(cmd_fibcontext = fib_alloc(dev))) {
919 fib_init(cmd_fibcontext);
921 if (dev->dac_support == 1) {
922 struct aac_read64 *readcmd;
923 readcmd = (struct aac_read64 *) fib_data(cmd_fibcontext);
924 readcmd->command = cpu_to_le32(VM_CtHostRead64);
925 readcmd->cid = cpu_to_le16(cid);
926 readcmd->sector_count = cpu_to_le16(count);
927 readcmd->block = cpu_to_le32(lba);
931 aac_build_sg64(scsicmd, &readcmd->sg);
932 fibsize = sizeof(struct aac_read64) +
933 ((le32_to_cpu(readcmd->sg.count) - 1) *
934 sizeof (struct sgentry64));
935 BUG_ON (fibsize > (sizeof(struct hw_fib) -
936 sizeof(struct aac_fibhdr)));
938 * Now send the Fib to the adapter
940 status = fib_send(ContainerCommand64,
945 (fib_callback) read_callback,
948 struct aac_read *readcmd;
949 readcmd = (struct aac_read *) fib_data(cmd_fibcontext);
950 readcmd->command = cpu_to_le32(VM_CtBlockRead);
951 readcmd->cid = cpu_to_le32(cid);
952 readcmd->block = cpu_to_le32(lba);
953 readcmd->count = cpu_to_le32(count * 512);
955 aac_build_sg(scsicmd, &readcmd->sg);
956 fibsize = sizeof(struct aac_read) +
957 ((le32_to_cpu(readcmd->sg.count) - 1) *
958 sizeof (struct sgentry));
959 BUG_ON (fibsize > (dev->max_fib_size -
960 sizeof(struct aac_fibhdr)));
962 * Now send the Fib to the adapter
964 status = fib_send(ContainerCommand,
969 (fib_callback) read_callback,
976 * Check that the command queued to the controller
978 if (status == -EINPROGRESS)
981 printk(KERN_WARNING "aac_read: fib_send failed with status: %d.\n", status);
983 * For some reason, the Fib didn't queue, return QUEUE_FULL
985 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_TASK_SET_FULL;
986 aac_io_done(scsicmd);
987 fib_complete(cmd_fibcontext);
988 fib_free(cmd_fibcontext);
992 static int aac_write(struct scsi_cmnd * scsicmd, int cid)
999 struct fib * cmd_fibcontext;
1001 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
1003 * Get block address and transfer length
1005 if (scsicmd->cmnd[0] == WRITE_6) /* 6 byte command */
1007 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
1008 count = scsicmd->cmnd[4];
1012 dprintk((KERN_DEBUG "aachba: received a write(10) command on id %d.\n", cid));
1013 lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1014 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
1016 dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %u, t = %ld.\n",
1017 smp_processor_id(), (unsigned long long)lba, jiffies));
1019 * Allocate and initialize a Fib then setup a BlockWrite command
1021 if (!(cmd_fibcontext = fib_alloc(dev))) {
1022 scsicmd->result = DID_ERROR << 16;
1023 aac_io_done(scsicmd);
1026 fib_init(cmd_fibcontext);
1028 if(dev->dac_support == 1) {
1029 struct aac_write64 *writecmd;
1030 writecmd = (struct aac_write64 *) fib_data(cmd_fibcontext);
1031 writecmd->command = cpu_to_le32(VM_CtHostWrite64);
1032 writecmd->cid = cpu_to_le16(cid);
1033 writecmd->sector_count = cpu_to_le16(count);
1034 writecmd->block = cpu_to_le32(lba);
1036 writecmd->flags = 0;
1038 aac_build_sg64(scsicmd, &writecmd->sg);
1039 fibsize = sizeof(struct aac_write64) +
1040 ((le32_to_cpu(writecmd->sg.count) - 1) *
1041 sizeof (struct sgentry64));
1042 BUG_ON (fibsize > (dev->max_fib_size -
1043 sizeof(struct aac_fibhdr)));
1045 * Now send the Fib to the adapter
1047 status = fib_send(ContainerCommand64,
1052 (fib_callback) write_callback,
1055 struct aac_write *writecmd;
1056 writecmd = (struct aac_write *) fib_data(cmd_fibcontext);
1057 writecmd->command = cpu_to_le32(VM_CtBlockWrite);
1058 writecmd->cid = cpu_to_le32(cid);
1059 writecmd->block = cpu_to_le32(lba);
1060 writecmd->count = cpu_to_le32(count * 512);
1061 writecmd->sg.count = cpu_to_le32(1);
1062 /* ->stable is not used - it did mean which type of write */
1064 aac_build_sg(scsicmd, &writecmd->sg);
1065 fibsize = sizeof(struct aac_write) +
1066 ((le32_to_cpu(writecmd->sg.count) - 1) *
1067 sizeof (struct sgentry));
1068 BUG_ON (fibsize > (dev->max_fib_size -
1069 sizeof(struct aac_fibhdr)));
1071 * Now send the Fib to the adapter
1073 status = fib_send(ContainerCommand,
1078 (fib_callback) write_callback,
1083 * Check that the command queued to the controller
1085 if (status == -EINPROGRESS)
1090 printk(KERN_WARNING "aac_write: fib_send failed with status: %d\n", status);
1092 * For some reason, the Fib didn't queue, return QUEUE_FULL
1094 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_TASK_SET_FULL;
1095 aac_io_done(scsicmd);
1097 fib_complete(cmd_fibcontext);
1098 fib_free(cmd_fibcontext);
1102 static void synchronize_callback(void *context, struct fib *fibptr)
1104 struct aac_synchronize_reply *synchronizereply;
1105 struct scsi_cmnd *cmd;
1109 dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n",
1110 smp_processor_id(), jiffies));
1111 BUG_ON(fibptr == NULL);
1114 synchronizereply = fib_data(fibptr);
1115 if (le32_to_cpu(synchronizereply->status) == CT_OK)
1116 cmd->result = DID_OK << 16 |
1117 COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1119 struct scsi_device *sdev = cmd->device;
1120 struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;
1121 u32 cid = ID_LUN_TO_CONTAINER(sdev->id, sdev->lun);
1123 "synchronize_callback: synchronize failed, status = %d\n",
1124 le32_to_cpu(synchronizereply->status));
1125 cmd->result = DID_OK << 16 |
1126 COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
1127 set_sense((u8 *)&dev->fsa_dev[cid].sense_data,
1129 SENCODE_INTERNAL_TARGET_FAILURE,
1130 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
1132 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1133 min(sizeof(dev->fsa_dev[cid].sense_data),
1134 sizeof(cmd->sense_buffer)));
1137 fib_complete(fibptr);
1142 static int aac_synchronize(struct scsi_cmnd *scsicmd, int cid)
1145 struct fib *cmd_fibcontext;
1146 struct aac_synchronize *synchronizecmd;
1147 struct scsi_cmnd *cmd;
1148 struct scsi_device *sdev = scsicmd->device;
1150 unsigned long flags;
1153 * Wait for all commands to complete to this specific
1156 spin_lock_irqsave(&sdev->list_lock, flags);
1157 list_for_each_entry(cmd, &sdev->cmd_list, list)
1158 if (cmd != scsicmd && cmd->serial_number != 0) {
1163 spin_unlock_irqrestore(&sdev->list_lock, flags);
1166 * Yield the processor (requeue for later)
1169 return SCSI_MLQUEUE_DEVICE_BUSY;
1172 * Allocate and initialize a Fib
1174 if (!(cmd_fibcontext =
1175 fib_alloc((struct aac_dev *)scsicmd->device->host->hostdata)))
1176 return SCSI_MLQUEUE_HOST_BUSY;
1178 fib_init(cmd_fibcontext);
1180 synchronizecmd = fib_data(cmd_fibcontext);
1181 synchronizecmd->command = cpu_to_le32(VM_ContainerConfig);
1182 synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE);
1183 synchronizecmd->cid = cpu_to_le32(cid);
1184 synchronizecmd->count =
1185 cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data));
1188 * Now send the Fib to the adapter
1190 status = fib_send(ContainerCommand,
1192 sizeof(struct aac_synchronize),
1195 (fib_callback)synchronize_callback,
1199 * Check that the command queued to the controller
1201 if (status == -EINPROGRESS)
1205 "aac_synchronize: fib_send failed with status: %d.\n", status);
1206 fib_complete(cmd_fibcontext);
1207 fib_free(cmd_fibcontext);
1208 return SCSI_MLQUEUE_HOST_BUSY;
1212 * aac_scsi_cmd() - Process SCSI command
1213 * @scsicmd: SCSI command block
1215 * Emulate a SCSI command and queue the required request for the
1219 int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1222 struct Scsi_Host *host = scsicmd->device->host;
1223 struct aac_dev *dev = (struct aac_dev *)host->hostdata;
1224 struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev;
1225 int cardtype = dev->cardtype;
1229 * If the bus, id or lun is out of range, return fail
1230 * Test does not apply to ID 16, the pseudo id for the controller
1233 if (scsicmd->device->id != host->this_id) {
1234 if ((scsicmd->device->channel == 0) ){
1235 if( (scsicmd->device->id >= dev->maximum_num_containers) || (scsicmd->device->lun != 0)){
1236 scsicmd->result = DID_NO_CONNECT << 16;
1237 scsicmd->scsi_done(scsicmd);
1240 cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);
1243 * If the target container doesn't exist, it may have
1244 * been newly created
1246 if ((fsa_dev_ptr[cid].valid & 1) == 0) {
1247 switch (scsicmd->cmnd[0]) {
1250 case TEST_UNIT_READY:
1251 spin_unlock_irq(host->host_lock);
1252 probe_container(dev, cid);
1253 spin_lock_irq(host->host_lock);
1254 if (fsa_dev_ptr[cid].valid == 0) {
1255 scsicmd->result = DID_NO_CONNECT << 16;
1256 scsicmd->scsi_done(scsicmd);
1264 * If the target container still doesn't exist,
1267 if (fsa_dev_ptr[cid].valid == 0) {
1268 scsicmd->result = DID_BAD_TARGET << 16;
1269 scsicmd->scsi_done(scsicmd);
1272 } else { /* check for physical non-dasd devices */
1273 if(dev->nondasd_support == 1){
1274 return aac_send_srb_fib(scsicmd);
1276 scsicmd->result = DID_NO_CONNECT << 16;
1277 scsicmd->scsi_done(scsicmd);
1283 * else Command for the controller itself
1285 else if ((scsicmd->cmnd[0] != INQUIRY) && /* only INQUIRY & TUR cmnd supported for controller */
1286 (scsicmd->cmnd[0] != TEST_UNIT_READY))
1288 dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0]));
1289 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
1290 set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
1292 SENCODE_INVALID_COMMAND,
1293 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
1294 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1295 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
1296 ? sizeof(scsicmd->sense_buffer)
1297 : sizeof(dev->fsa_dev[cid].sense_data));
1298 scsicmd->scsi_done(scsicmd);
1303 /* Handle commands here that don't really require going out to the adapter */
1304 switch (scsicmd->cmnd[0]) {
1307 struct inquiry_data *inq_data_ptr;
1309 dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", scsicmd->device->id));
1310 inq_data_ptr = (struct inquiry_data *)scsicmd->request_buffer;
1311 memset(inq_data_ptr, 0, sizeof (struct inquiry_data));
1313 inq_data_ptr->inqd_ver = 2; /* claim compliance to SCSI-2 */
1314 inq_data_ptr->inqd_dtq = 0x80; /* set RMB bit to one indicating that the medium is removable */
1315 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 */
1316 inq_data_ptr->inqd_len = 31;
1317 /*Format for "pad2" is RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
1318 inq_data_ptr->inqd_pad2= 0x32 ; /*WBus16|Sync|CmdQue */
1320 * Set the Vendor, Product, and Revision Level
1321 * see: <vendor>.c i.e. aac.c
1323 if (scsicmd->device->id == host->this_id) {
1324 setinqstr(cardtype, (void *) (inq_data_ptr->inqd_vid), (sizeof(container_types)/sizeof(char *)));
1325 inq_data_ptr->inqd_pdt = INQD_PDT_PROC; /* Processor device */
1326 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1327 scsicmd->scsi_done(scsicmd);
1330 setinqstr(cardtype, (void *) (inq_data_ptr->inqd_vid), fsa_dev_ptr[cid].type);
1331 inq_data_ptr->inqd_pdt = INQD_PDT_DA; /* Direct/random access device */
1332 return aac_get_container_name(scsicmd, cid);
1339 dprintk((KERN_DEBUG "READ CAPACITY command.\n"));
1340 if (fsa_dev_ptr[cid].size <= 0x100000000LL)
1341 capacity = fsa_dev_ptr[cid].size - 1;
1344 cp = scsicmd->request_buffer;
1345 cp[0] = (capacity >> 24) & 0xff;
1346 cp[1] = (capacity >> 16) & 0xff;
1347 cp[2] = (capacity >> 8) & 0xff;
1348 cp[3] = (capacity >> 0) & 0xff;
1354 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1355 scsicmd->scsi_done(scsicmd);
1364 dprintk((KERN_DEBUG "MODE SENSE command.\n"));
1365 mode_buf = scsicmd->request_buffer;
1366 mode_buf[0] = 3; /* Mode data length */
1367 mode_buf[1] = 0; /* Medium type - default */
1368 mode_buf[2] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */
1369 mode_buf[3] = 0; /* Block descriptor length */
1371 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1372 scsicmd->scsi_done(scsicmd);
1380 dprintk((KERN_DEBUG "MODE SENSE 10 byte command.\n"));
1381 mode_buf = scsicmd->request_buffer;
1382 mode_buf[0] = 0; /* Mode data length (MSB) */
1383 mode_buf[1] = 6; /* Mode data length (LSB) */
1384 mode_buf[2] = 0; /* Medium type - default */
1385 mode_buf[3] = 0; /* Device-specific param, bit 8: 0/1 = write enabled/protected */
1386 mode_buf[4] = 0; /* reserved */
1387 mode_buf[5] = 0; /* reserved */
1388 mode_buf[6] = 0; /* Block descriptor length (MSB) */
1389 mode_buf[7] = 0; /* Block descriptor length (LSB) */
1391 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1392 scsicmd->scsi_done(scsicmd);
1397 dprintk((KERN_DEBUG "REQUEST SENSE command.\n"));
1398 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, sizeof (struct sense_data));
1399 memset(&dev->fsa_dev[cid].sense_data, 0, sizeof (struct sense_data));
1400 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1401 scsicmd->scsi_done(scsicmd);
1404 case ALLOW_MEDIUM_REMOVAL:
1405 dprintk((KERN_DEBUG "LOCK command.\n"));
1406 if (scsicmd->cmnd[4])
1407 fsa_dev_ptr[cid].locked = 1;
1409 fsa_dev_ptr[cid].locked = 0;
1411 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1412 scsicmd->scsi_done(scsicmd);
1415 * These commands are all No-Ops
1417 case TEST_UNIT_READY:
1421 case REASSIGN_BLOCKS:
1424 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1425 scsicmd->scsi_done(scsicmd);
1429 switch (scsicmd->cmnd[0])
1434 * Hack to keep track of ordinal number of the device that
1435 * corresponds to a container. Needed to convert
1436 * containers to /dev/sd device names
1439 spin_unlock_irq(host->host_lock);
1440 if (scsicmd->request->rq_disk)
1441 memcpy(fsa_dev_ptr[cid].devname,
1442 scsicmd->request->rq_disk->disk_name,
1445 ret = aac_read(scsicmd, cid);
1446 spin_lock_irq(host->host_lock);
1451 spin_unlock_irq(host->host_lock);
1452 ret = aac_write(scsicmd, cid);
1453 spin_lock_irq(host->host_lock);
1456 case SYNCHRONIZE_CACHE:
1457 /* Issue FIB to tell Firmware to flush it's cache */
1458 return aac_synchronize(scsicmd, cid);
1462 * Unhandled commands
1464 dprintk((KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0]));
1465 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
1466 set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
1467 ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND,
1468 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
1469 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1470 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
1471 ? sizeof(scsicmd->sense_buffer)
1472 : sizeof(dev->fsa_dev[cid].sense_data));
1473 scsicmd->scsi_done(scsicmd);
1478 static int query_disk(struct aac_dev *dev, void __user *arg)
1480 struct aac_query_disk qd;
1481 struct fsa_dev_info *fsa_dev_ptr;
1483 fsa_dev_ptr = dev->fsa_dev;
1484 if (copy_from_user(&qd, arg, sizeof (struct aac_query_disk)))
1487 qd.cnum = ID_LUN_TO_CONTAINER(qd.id, qd.lun);
1488 else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1))
1490 if (qd.cnum < 0 || qd.cnum >= dev->maximum_num_containers)
1492 qd.instance = dev->scsi_host_ptr->host_no;
1494 qd.id = CONTAINER_TO_ID(qd.cnum);
1495 qd.lun = CONTAINER_TO_LUN(qd.cnum);
1497 else return -EINVAL;
1499 qd.valid = fsa_dev_ptr[qd.cnum].valid;
1500 qd.locked = fsa_dev_ptr[qd.cnum].locked;
1501 qd.deleted = fsa_dev_ptr[qd.cnum].deleted;
1503 if (fsa_dev_ptr[qd.cnum].devname[0] == '\0')
1508 strlcpy(qd.name, fsa_dev_ptr[qd.cnum].devname,
1509 min(sizeof(qd.name), sizeof(fsa_dev_ptr[qd.cnum].devname) + 1));
1511 if (copy_to_user(arg, &qd, sizeof (struct aac_query_disk)))
1516 static int force_delete_disk(struct aac_dev *dev, void __user *arg)
1518 struct aac_delete_disk dd;
1519 struct fsa_dev_info *fsa_dev_ptr;
1521 fsa_dev_ptr = dev->fsa_dev;
1523 if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk)))
1526 if (dd.cnum >= dev->maximum_num_containers)
1529 * Mark this container as being deleted.
1531 fsa_dev_ptr[dd.cnum].deleted = 1;
1533 * Mark the container as no longer valid
1535 fsa_dev_ptr[dd.cnum].valid = 0;
1539 static int delete_disk(struct aac_dev *dev, void __user *arg)
1541 struct aac_delete_disk dd;
1542 struct fsa_dev_info *fsa_dev_ptr;
1544 fsa_dev_ptr = dev->fsa_dev;
1546 if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk)))
1549 if (dd.cnum >= dev->maximum_num_containers)
1552 * If the container is locked, it can not be deleted by the API.
1554 if (fsa_dev_ptr[dd.cnum].locked)
1558 * Mark the container as no longer being valid.
1560 fsa_dev_ptr[dd.cnum].valid = 0;
1561 fsa_dev_ptr[dd.cnum].devname[0] = '\0';
1566 int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg)
1569 case FSACTL_QUERY_DISK:
1570 return query_disk(dev, arg);
1571 case FSACTL_DELETE_DISK:
1572 return delete_disk(dev, arg);
1573 case FSACTL_FORCE_DELETE_DISK:
1574 return force_delete_disk(dev, arg);
1575 case FSACTL_GET_CONTAINERS:
1576 return aac_get_containers(dev);
1585 * @context: the context set in the fib - here it is scsi cmd
1586 * @fibptr: pointer to the fib
1588 * Handles the completion of a scsi command to a non dasd device
1592 static void aac_srb_callback(void *context, struct fib * fibptr)
1594 struct aac_dev *dev;
1595 struct aac_srb_reply *srbreply;
1596 struct scsi_cmnd *scsicmd;
1598 scsicmd = (struct scsi_cmnd *) context;
1599 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
1604 srbreply = (struct aac_srb_reply *) fib_data(fibptr);
1606 scsicmd->sense_buffer[0] = '\0'; /* Initialize sense valid flag to false */
1608 * Calculate resid for sg
1611 scsicmd->resid = scsicmd->request_bufflen -
1612 le32_to_cpu(srbreply->data_xfer_length);
1615 pci_unmap_sg(dev->pdev,
1616 (struct scatterlist *)scsicmd->buffer,
1618 scsicmd->sc_data_direction);
1619 else if(scsicmd->request_bufflen)
1620 pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle, scsicmd->request_bufflen,
1621 scsicmd->sc_data_direction);
1624 * First check the fib status
1627 if (le32_to_cpu(srbreply->status) != ST_OK){
1629 printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status));
1630 len = (le32_to_cpu(srbreply->sense_data_size) >
1631 sizeof(scsicmd->sense_buffer)) ?
1632 sizeof(scsicmd->sense_buffer) :
1633 le32_to_cpu(srbreply->sense_data_size);
1634 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
1635 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
1639 * Next check the srb status
1641 switch( (le32_to_cpu(srbreply->srb_status))&0x3f){
1642 case SRB_STATUS_ERROR_RECOVERY:
1643 case SRB_STATUS_PENDING:
1644 case SRB_STATUS_SUCCESS:
1645 if(scsicmd->cmnd[0] == INQUIRY ){
1648 /* We can't expose disk devices because we can't tell whether they
1649 * are the raw container drives or stand alone drives. If they have
1650 * the removable bit set then we should expose them though.
1652 b = (*(u8*)scsicmd->buffer)&0x1f;
1653 b1 = ((u8*)scsicmd->buffer)[1];
1654 if( b==TYPE_TAPE || b==TYPE_WORM || b==TYPE_ROM || b==TYPE_MOD|| b==TYPE_MEDIUM_CHANGER
1655 || (b==TYPE_DISK && (b1&0x80)) ){
1656 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
1658 * We will allow disk devices if in RAID/SCSI mode and
1661 } else if ((dev->raid_scsi_mode) &&
1662 (scsicmd->device->channel == 2)) {
1663 scsicmd->result = DID_OK << 16 |
1664 COMMAND_COMPLETE << 8;
1666 scsicmd->result = DID_NO_CONNECT << 16 |
1667 COMMAND_COMPLETE << 8;
1670 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
1673 case SRB_STATUS_DATA_OVERRUN:
1674 switch(scsicmd->cmnd[0]){
1681 if(le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow ) {
1682 printk(KERN_WARNING"aacraid: SCSI CMD underflow\n");
1684 printk(KERN_WARNING"aacraid: SCSI CMD Data Overrun\n");
1686 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8;
1691 /* We can't expose disk devices because we can't tell whether they
1692 * are the raw container drives or stand alone drives
1694 b = (*(u8*)scsicmd->buffer)&0x0f;
1695 b1 = ((u8*)scsicmd->buffer)[1];
1696 if( b==TYPE_TAPE || b==TYPE_WORM || b==TYPE_ROM || b==TYPE_MOD|| b==TYPE_MEDIUM_CHANGER
1697 || (b==TYPE_DISK && (b1&0x80)) ){
1698 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
1700 * We will allow disk devices if in RAID/SCSI mode and
1703 } else if ((dev->raid_scsi_mode) &&
1704 (scsicmd->device->channel == 2)) {
1705 scsicmd->result = DID_OK << 16 |
1706 COMMAND_COMPLETE << 8;
1708 scsicmd->result = DID_NO_CONNECT << 16 |
1709 COMMAND_COMPLETE << 8;
1714 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
1718 case SRB_STATUS_ABORTED:
1719 scsicmd->result = DID_ABORT << 16 | ABORT << 8;
1721 case SRB_STATUS_ABORT_FAILED:
1722 // Not sure about this one - but assuming the hba was trying to abort for some reason
1723 scsicmd->result = DID_ERROR << 16 | ABORT << 8;
1725 case SRB_STATUS_PARITY_ERROR:
1726 scsicmd->result = DID_PARITY << 16 | MSG_PARITY_ERROR << 8;
1728 case SRB_STATUS_NO_DEVICE:
1729 case SRB_STATUS_INVALID_PATH_ID:
1730 case SRB_STATUS_INVALID_TARGET_ID:
1731 case SRB_STATUS_INVALID_LUN:
1732 case SRB_STATUS_SELECTION_TIMEOUT:
1733 scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8;
1736 case SRB_STATUS_COMMAND_TIMEOUT:
1737 case SRB_STATUS_TIMEOUT:
1738 scsicmd->result = DID_TIME_OUT << 16 | COMMAND_COMPLETE << 8;
1741 case SRB_STATUS_BUSY:
1742 scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8;
1745 case SRB_STATUS_BUS_RESET:
1746 scsicmd->result = DID_RESET << 16 | COMMAND_COMPLETE << 8;
1749 case SRB_STATUS_MESSAGE_REJECTED:
1750 scsicmd->result = DID_ERROR << 16 | MESSAGE_REJECT << 8;
1752 case SRB_STATUS_REQUEST_FLUSHED:
1753 case SRB_STATUS_ERROR:
1754 case SRB_STATUS_INVALID_REQUEST:
1755 case SRB_STATUS_REQUEST_SENSE_FAILED:
1756 case SRB_STATUS_NO_HBA:
1757 case SRB_STATUS_UNEXPECTED_BUS_FREE:
1758 case SRB_STATUS_PHASE_SEQUENCE_FAILURE:
1759 case SRB_STATUS_BAD_SRB_BLOCK_LENGTH:
1760 case SRB_STATUS_DELAYED_RETRY:
1761 case SRB_STATUS_BAD_FUNCTION:
1762 case SRB_STATUS_NOT_STARTED:
1763 case SRB_STATUS_NOT_IN_USE:
1764 case SRB_STATUS_FORCE_ABORT:
1765 case SRB_STATUS_DOMAIN_VALIDATION_FAIL:
1767 #ifdef AAC_DETAILED_STATUS_INFO
1768 printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",
1769 le32_to_cpu(srbreply->srb_status) & 0x3F,
1770 aac_get_status_string(
1771 le32_to_cpu(srbreply->srb_status) & 0x3F),
1773 le32_to_cpu(srbreply->scsi_status));
1775 scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8;
1778 if (le32_to_cpu(srbreply->scsi_status) == 0x02 ){ // Check Condition
1780 scsicmd->result |= SAM_STAT_CHECK_CONDITION;
1781 len = (le32_to_cpu(srbreply->sense_data_size) >
1782 sizeof(scsicmd->sense_buffer)) ?
1783 sizeof(scsicmd->sense_buffer) :
1784 le32_to_cpu(srbreply->sense_data_size);
1785 #ifdef AAC_DETAILED_STATUS_INFO
1786 dprintk((KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n",
1787 le32_to_cpu(srbreply->status), len));
1789 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
1793 * OR in the scsi status (already shifted up a bit)
1795 scsicmd->result |= le32_to_cpu(srbreply->scsi_status);
1797 fib_complete(fibptr);
1799 aac_io_done(scsicmd);
1805 * @scsicmd: the scsi command block
1807 * This routine will form a FIB and fill in the aac_srb from the
1808 * scsicmd passed in.
1811 static int aac_send_srb_fib(struct scsi_cmnd* scsicmd)
1813 struct fib* cmd_fibcontext;
1814 struct aac_dev* dev;
1816 struct aac_srb *srbcmd;
1821 if( scsicmd->device->id > 15 || scsicmd->device->lun > 7) {
1822 scsicmd->result = DID_NO_CONNECT << 16;
1823 scsicmd->scsi_done(scsicmd);
1827 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
1828 switch(scsicmd->sc_data_direction){
1832 case DMA_BIDIRECTIONAL:
1833 flag = SRB_DataIn | SRB_DataOut;
1835 case DMA_FROM_DEVICE:
1839 default: /* shuts up some versions of gcc */
1840 flag = SRB_NoDataXfer;
1846 * Allocate and initialize a Fib then setup a BlockWrite command
1848 if (!(cmd_fibcontext = fib_alloc(dev))) {
1851 fib_init(cmd_fibcontext);
1853 srbcmd = (struct aac_srb*) fib_data(cmd_fibcontext);
1854 srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi);
1855 srbcmd->channel = cpu_to_le32(aac_logical_to_phys(scsicmd->device->channel));
1856 srbcmd->id = cpu_to_le32(scsicmd->device->id);
1857 srbcmd->lun = cpu_to_le32(scsicmd->device->lun);
1858 srbcmd->flags = cpu_to_le32(flag);
1859 timeout = (scsicmd->timeout-jiffies)/HZ;
1863 srbcmd->timeout = cpu_to_le32(timeout); // timeout in seconds
1864 srbcmd->retry_limit = 0; /* Obsolete parameter */
1865 srbcmd->cdb_size = cpu_to_le32(scsicmd->cmd_len);
1867 if( dev->dac_support == 1 ) {
1868 aac_build_sg64(scsicmd, (struct sgmap64*) &srbcmd->sg);
1869 srbcmd->count = cpu_to_le32(scsicmd->request_bufflen);
1871 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb));
1872 memcpy(srbcmd->cdb, scsicmd->cmnd, scsicmd->cmd_len);
1874 * Build Scatter/Gather list
1876 fibsize = sizeof (struct aac_srb) - sizeof (struct sgentry) +
1877 ((le32_to_cpu(srbcmd->sg.count) & 0xff) *
1878 sizeof (struct sgentry64));
1879 BUG_ON (fibsize > (dev->max_fib_size -
1880 sizeof(struct aac_fibhdr)));
1883 * Now send the Fib to the adapter
1885 status = fib_send(ScsiPortCommand64, cmd_fibcontext,
1886 fibsize, FsaNormal, 0, 1,
1887 (fib_callback) aac_srb_callback,
1890 aac_build_sg(scsicmd, (struct sgmap*)&srbcmd->sg);
1891 srbcmd->count = cpu_to_le32(scsicmd->request_bufflen);
1893 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb));
1894 memcpy(srbcmd->cdb, scsicmd->cmnd, scsicmd->cmd_len);
1896 * Build Scatter/Gather list
1898 fibsize = sizeof (struct aac_srb) +
1899 (((le32_to_cpu(srbcmd->sg.count) & 0xff) - 1) *
1900 sizeof (struct sgentry));
1901 BUG_ON (fibsize > (dev->max_fib_size -
1902 sizeof(struct aac_fibhdr)));
1905 * Now send the Fib to the adapter
1907 status = fib_send(ScsiPortCommand, cmd_fibcontext, fibsize, FsaNormal, 0, 1,
1908 (fib_callback) aac_srb_callback, (void *) scsicmd);
1911 * Check that the command queued to the controller
1913 if (status == -EINPROGRESS){
1917 printk(KERN_WARNING "aac_srb: fib_send failed with status: %d\n", status);
1918 fib_complete(cmd_fibcontext);
1919 fib_free(cmd_fibcontext);
1924 static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* psg)
1926 struct aac_dev *dev;
1927 unsigned long byte_count = 0;
1929 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
1930 // Get rid of old data
1932 psg->sg[0].addr = 0;
1933 psg->sg[0].count = 0;
1934 if (scsicmd->use_sg) {
1935 struct scatterlist *sg;
1938 sg = (struct scatterlist *) scsicmd->request_buffer;
1940 sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg,
1941 scsicmd->sc_data_direction);
1942 psg->count = cpu_to_le32(sg_count);
1946 for (i = 0; i < sg_count; i++) {
1947 psg->sg[i].addr = cpu_to_le32(sg_dma_address(sg));
1948 psg->sg[i].count = cpu_to_le32(sg_dma_len(sg));
1949 byte_count += sg_dma_len(sg);
1952 /* hba wants the size to be exact */
1953 if(byte_count > scsicmd->request_bufflen){
1954 u32 temp = le32_to_cpu(psg->sg[i-1].count) -
1955 (byte_count - scsicmd->request_bufflen);
1956 psg->sg[i-1].count = cpu_to_le32(temp);
1957 byte_count = scsicmd->request_bufflen;
1959 /* Check for command underflow */
1960 if(scsicmd->underflow && (byte_count < scsicmd->underflow)){
1961 printk(KERN_WARNING"aacraid: cmd len %08lX cmd underflow %08X\n",
1962 byte_count, scsicmd->underflow);
1965 else if(scsicmd->request_bufflen) {
1967 addr = pci_map_single(dev->pdev,
1968 scsicmd->request_buffer,
1969 scsicmd->request_bufflen,
1970 scsicmd->sc_data_direction);
1971 psg->count = cpu_to_le32(1);
1972 psg->sg[0].addr = cpu_to_le32(addr);
1973 psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen);
1974 scsicmd->SCp.dma_handle = addr;
1975 byte_count = scsicmd->request_bufflen;
1981 static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* psg)
1983 struct aac_dev *dev;
1984 unsigned long byte_count = 0;
1987 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
1988 // Get rid of old data
1990 psg->sg[0].addr[0] = 0;
1991 psg->sg[0].addr[1] = 0;
1992 psg->sg[0].count = 0;
1993 if (scsicmd->use_sg) {
1994 struct scatterlist *sg;
1997 sg = (struct scatterlist *) scsicmd->request_buffer;
1999 sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg,
2000 scsicmd->sc_data_direction);
2001 psg->count = cpu_to_le32(sg_count);
2005 for (i = 0; i < sg_count; i++) {
2006 addr = sg_dma_address(sg);
2007 psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff);
2008 psg->sg[i].addr[1] = cpu_to_le32(addr>>32);
2009 psg->sg[i].count = cpu_to_le32(sg_dma_len(sg));
2010 byte_count += sg_dma_len(sg);
2013 /* hba wants the size to be exact */
2014 if(byte_count > scsicmd->request_bufflen){
2015 u32 temp = le32_to_cpu(psg->sg[i-1].count) -
2016 (byte_count - scsicmd->request_bufflen);
2017 psg->sg[i-1].count = cpu_to_le32(temp);
2018 byte_count = scsicmd->request_bufflen;
2020 /* Check for command underflow */
2021 if(scsicmd->underflow && (byte_count < scsicmd->underflow)){
2022 printk(KERN_WARNING"aacraid: cmd len %08lX cmd underflow %08X\n",
2023 byte_count, scsicmd->underflow);
2026 else if(scsicmd->request_bufflen) {
2028 addr = pci_map_single(dev->pdev,
2029 scsicmd->request_buffer,
2030 scsicmd->request_bufflen,
2031 scsicmd->sc_data_direction);
2032 psg->count = cpu_to_le32(1);
2033 psg->sg[0].addr[0] = cpu_to_le32(addr & 0xffffffff);
2034 psg->sg[0].addr[1] = cpu_to_le32(addr >> 32);
2035 psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen);
2036 scsicmd->SCp.dma_handle = addr;
2037 byte_count = scsicmd->request_bufflen;
2042 #ifdef AAC_DETAILED_STATUS_INFO
2044 struct aac_srb_status_info {
2050 static struct aac_srb_status_info srb_status_info[] = {
2051 { SRB_STATUS_PENDING, "Pending Status"},
2052 { SRB_STATUS_SUCCESS, "Success"},
2053 { SRB_STATUS_ABORTED, "Aborted Command"},
2054 { SRB_STATUS_ABORT_FAILED, "Abort Failed"},
2055 { SRB_STATUS_ERROR, "Error Event"},
2056 { SRB_STATUS_BUSY, "Device Busy"},
2057 { SRB_STATUS_INVALID_REQUEST, "Invalid Request"},
2058 { SRB_STATUS_INVALID_PATH_ID, "Invalid Path ID"},
2059 { SRB_STATUS_NO_DEVICE, "No Device"},
2060 { SRB_STATUS_TIMEOUT, "Timeout"},
2061 { SRB_STATUS_SELECTION_TIMEOUT, "Selection Timeout"},
2062 { SRB_STATUS_COMMAND_TIMEOUT, "Command Timeout"},
2063 { SRB_STATUS_MESSAGE_REJECTED, "Message Rejected"},
2064 { SRB_STATUS_BUS_RESET, "Bus Reset"},
2065 { SRB_STATUS_PARITY_ERROR, "Parity Error"},
2066 { SRB_STATUS_REQUEST_SENSE_FAILED,"Request Sense Failed"},
2067 { SRB_STATUS_NO_HBA, "No HBA"},
2068 { SRB_STATUS_DATA_OVERRUN, "Data Overrun/Data Underrun"},
2069 { SRB_STATUS_UNEXPECTED_BUS_FREE,"Unexpected Bus Free"},
2070 { SRB_STATUS_PHASE_SEQUENCE_FAILURE,"Phase Error"},
2071 { SRB_STATUS_BAD_SRB_BLOCK_LENGTH,"Bad Srb Block Length"},
2072 { SRB_STATUS_REQUEST_FLUSHED, "Request Flushed"},
2073 { SRB_STATUS_DELAYED_RETRY, "Delayed Retry"},
2074 { SRB_STATUS_INVALID_LUN, "Invalid LUN"},
2075 { SRB_STATUS_INVALID_TARGET_ID, "Invalid TARGET ID"},
2076 { SRB_STATUS_BAD_FUNCTION, "Bad Function"},
2077 { SRB_STATUS_ERROR_RECOVERY, "Error Recovery"},
2078 { SRB_STATUS_NOT_STARTED, "Not Started"},
2079 { SRB_STATUS_NOT_IN_USE, "Not In Use"},
2080 { SRB_STATUS_FORCE_ABORT, "Force Abort"},
2081 { SRB_STATUS_DOMAIN_VALIDATION_FAIL,"Domain Validation Failure"},
2082 { 0xff, "Unknown Error"}
2085 char *aac_get_status_string(u32 status)
2089 for(i=0; i < (sizeof(srb_status_info)/sizeof(struct aac_srb_status_info)); i++ ){
2090 if(srb_status_info[i].status == status){
2091 return srb_status_info[i].str;
2095 return "Bad Status Code";