Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Adaptec AAC series RAID controller driver |
Alan Cox | fa195af | 2008-10-27 15:16:36 +0000 | [diff] [blame] | 3 | * (c) Copyright 2001 Red Hat Inc. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
| 5 | * based on the old aacraid driver that is.. |
| 6 | * Adaptec aacraid device driver for Linux. |
| 7 | * |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 8 | * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * |
| 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) |
| 13 | * any later version. |
| 14 | * |
| 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. |
| 19 | * |
| 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. |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #include <linux/kernel.h> |
| 27 | #include <linux/init.h> |
| 28 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <linux/pci.h> |
| 30 | #include <linux/spinlock.h> |
| 31 | #include <linux/slab.h> |
| 32 | #include <linux/completion.h> |
| 33 | #include <linux/blkdev.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <asm/uaccess.h> |
Salyzyn, Mark | 3a0086a8 | 2008-01-11 11:46:44 -0800 | [diff] [blame] | 35 | #include <linux/highmem.h> /* For flush_kernel_dcache_page */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
| 37 | #include <scsi/scsi.h> |
| 38 | #include <scsi/scsi_cmnd.h> |
| 39 | #include <scsi/scsi_device.h> |
| 40 | #include <scsi/scsi_host.h> |
| 41 | |
| 42 | #include "aacraid.h" |
| 43 | |
| 44 | /* values for inqd_pdt: Peripheral device type in plain English */ |
| 45 | #define INQD_PDT_DA 0x00 /* Direct-access (DISK) device */ |
| 46 | #define INQD_PDT_PROC 0x03 /* Processor device */ |
| 47 | #define INQD_PDT_CHNGR 0x08 /* Changer (jukebox, scsi2) */ |
| 48 | #define INQD_PDT_COMM 0x09 /* Communication device (scsi2) */ |
| 49 | #define INQD_PDT_NOLUN2 0x1f /* Unknown Device (scsi2) */ |
| 50 | #define INQD_PDT_NOLUN 0x7f /* Logical Unit Not Present */ |
| 51 | |
| 52 | #define INQD_PDT_DMASK 0x1F /* Peripheral Device Type Mask */ |
| 53 | #define INQD_PDT_QMASK 0xE0 /* Peripheral Device Qualifer Mask */ |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | /* |
| 56 | * Sense codes |
| 57 | */ |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 58 | |
| 59 | #define SENCODE_NO_SENSE 0x00 |
| 60 | #define SENCODE_END_OF_DATA 0x00 |
| 61 | #define SENCODE_BECOMING_READY 0x04 |
| 62 | #define SENCODE_INIT_CMD_REQUIRED 0x04 |
| 63 | #define SENCODE_PARAM_LIST_LENGTH_ERROR 0x1A |
| 64 | #define SENCODE_INVALID_COMMAND 0x20 |
| 65 | #define SENCODE_LBA_OUT_OF_RANGE 0x21 |
| 66 | #define SENCODE_INVALID_CDB_FIELD 0x24 |
| 67 | #define SENCODE_LUN_NOT_SUPPORTED 0x25 |
| 68 | #define SENCODE_INVALID_PARAM_FIELD 0x26 |
| 69 | #define SENCODE_PARAM_NOT_SUPPORTED 0x26 |
| 70 | #define SENCODE_PARAM_VALUE_INVALID 0x26 |
| 71 | #define SENCODE_RESET_OCCURRED 0x29 |
| 72 | #define SENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x3E |
| 73 | #define SENCODE_INQUIRY_DATA_CHANGED 0x3F |
| 74 | #define SENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x39 |
| 75 | #define SENCODE_DIAGNOSTIC_FAILURE 0x40 |
| 76 | #define SENCODE_INTERNAL_TARGET_FAILURE 0x44 |
| 77 | #define SENCODE_INVALID_MESSAGE_ERROR 0x49 |
| 78 | #define SENCODE_LUN_FAILED_SELF_CONFIG 0x4c |
| 79 | #define SENCODE_OVERLAPPED_COMMAND 0x4E |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
| 81 | /* |
| 82 | * Additional sense codes |
| 83 | */ |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 84 | |
| 85 | #define ASENCODE_NO_SENSE 0x00 |
| 86 | #define ASENCODE_END_OF_DATA 0x05 |
| 87 | #define ASENCODE_BECOMING_READY 0x01 |
| 88 | #define ASENCODE_INIT_CMD_REQUIRED 0x02 |
| 89 | #define ASENCODE_PARAM_LIST_LENGTH_ERROR 0x00 |
| 90 | #define ASENCODE_INVALID_COMMAND 0x00 |
| 91 | #define ASENCODE_LBA_OUT_OF_RANGE 0x00 |
| 92 | #define ASENCODE_INVALID_CDB_FIELD 0x00 |
| 93 | #define ASENCODE_LUN_NOT_SUPPORTED 0x00 |
| 94 | #define ASENCODE_INVALID_PARAM_FIELD 0x00 |
| 95 | #define ASENCODE_PARAM_NOT_SUPPORTED 0x01 |
| 96 | #define ASENCODE_PARAM_VALUE_INVALID 0x02 |
| 97 | #define ASENCODE_RESET_OCCURRED 0x00 |
| 98 | #define ASENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x00 |
| 99 | #define ASENCODE_INQUIRY_DATA_CHANGED 0x03 |
| 100 | #define ASENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x00 |
| 101 | #define ASENCODE_DIAGNOSTIC_FAILURE 0x80 |
| 102 | #define ASENCODE_INTERNAL_TARGET_FAILURE 0x00 |
| 103 | #define ASENCODE_INVALID_MESSAGE_ERROR 0x00 |
| 104 | #define ASENCODE_LUN_FAILED_SELF_CONFIG 0x00 |
| 105 | #define ASENCODE_OVERLAPPED_COMMAND 0x00 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | |
| 107 | #define BYTE0(x) (unsigned char)(x) |
| 108 | #define BYTE1(x) (unsigned char)((x) >> 8) |
| 109 | #define BYTE2(x) (unsigned char)((x) >> 16) |
| 110 | #define BYTE3(x) (unsigned char)((x) >> 24) |
| 111 | |
| 112 | /*------------------------------------------------------------------------------ |
| 113 | * S T R U C T S / T Y P E D E F S |
| 114 | *----------------------------------------------------------------------------*/ |
| 115 | /* SCSI inquiry data */ |
| 116 | struct inquiry_data { |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 117 | u8 inqd_pdt; /* Peripheral qualifier | Peripheral Device Type */ |
| 118 | u8 inqd_dtq; /* RMB | Device Type Qualifier */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | u8 inqd_ver; /* ISO version | ECMA version | ANSI-approved version */ |
| 120 | u8 inqd_rdf; /* AENC | TrmIOP | Response data format */ |
| 121 | u8 inqd_len; /* Additional length (n-4) */ |
| 122 | u8 inqd_pad1[2];/* Reserved - must be zero */ |
| 123 | u8 inqd_pad2; /* RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */ |
| 124 | u8 inqd_vid[8]; /* Vendor ID */ |
| 125 | u8 inqd_pid[16];/* Product ID */ |
| 126 | u8 inqd_prl[4]; /* Product Revision Level */ |
| 127 | }; |
| 128 | |
| 129 | /* |
| 130 | * M O D U L E G L O B A L S |
| 131 | */ |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 132 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* sgmap); |
| 134 | static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* psg); |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 135 | static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw* psg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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); |
| 139 | #endif |
| 140 | |
| 141 | /* |
| 142 | * Non dasd selection is handled entirely in aachba now |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 143 | */ |
| 144 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | static int nondasd = -1; |
Leubner, Achim | d8e96507 | 2009-04-01 07:16:08 -0700 | [diff] [blame] | 146 | static int aac_cache = 2; /* WCE=0 to avoid performance problems */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | static int dacmode = -1; |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 148 | int aac_msi; |
Salyzyn, Mark | 1208bab | 2007-05-22 09:32:29 -0400 | [diff] [blame] | 149 | int aac_commit = -1; |
Mark Haverkamp | 404d9a9 | 2006-05-10 09:12:48 -0700 | [diff] [blame] | 150 | int startup_timeout = 180; |
| 151 | int aif_timeout = 120; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
Mark Haverkamp | 9a72f97 | 2006-03-27 09:44:37 -0800 | [diff] [blame] | 153 | module_param(nondasd, int, S_IRUGO|S_IWUSR); |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 154 | MODULE_PARM_DESC(nondasd, "Control scanning of hba for nondasd devices." |
| 155 | " 0=off, 1=on"); |
Salyzyn, Mark | 95e852e | 2008-01-08 12:01:07 -0800 | [diff] [blame] | 156 | module_param_named(cache, aac_cache, int, S_IRUGO|S_IWUSR); |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 157 | MODULE_PARM_DESC(cache, "Disable Queue Flush commands:\n" |
| 158 | "\tbit 0 - Disable FUA in WRITE SCSI commands\n" |
| 159 | "\tbit 1 - Disable SYNCHRONIZE_CACHE SCSI command\n" |
Leubner, Achim | d8e96507 | 2009-04-01 07:16:08 -0700 | [diff] [blame] | 160 | "\tbit 2 - Disable only if Battery is protecting Cache"); |
Mark Haverkamp | 9a72f97 | 2006-03-27 09:44:37 -0800 | [diff] [blame] | 161 | module_param(dacmode, int, S_IRUGO|S_IWUSR); |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 162 | MODULE_PARM_DESC(dacmode, "Control whether dma addressing is using 64 bit DAC." |
| 163 | " 0=off, 1=on"); |
Salyzyn, Mark | 1208bab | 2007-05-22 09:32:29 -0400 | [diff] [blame] | 164 | module_param_named(commit, aac_commit, int, S_IRUGO|S_IWUSR); |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 165 | MODULE_PARM_DESC(commit, "Control whether a COMMIT_CONFIG is issued to the" |
| 166 | " adapter for foreign arrays.\n" |
| 167 | "This is typically needed in systems that do not have a BIOS." |
| 168 | " 0=off, 1=on"); |
| 169 | module_param_named(msi, aac_msi, int, S_IRUGO|S_IWUSR); |
| 170 | MODULE_PARM_DESC(msi, "IRQ handling." |
| 171 | " 0=PIC(default), 1=MSI, 2=MSI-X(unsupported, uses MSI)"); |
Mark Haverkamp | 404d9a9 | 2006-05-10 09:12:48 -0700 | [diff] [blame] | 172 | module_param(startup_timeout, int, S_IRUGO|S_IWUSR); |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 173 | MODULE_PARM_DESC(startup_timeout, "The duration of time in seconds to wait for" |
| 174 | " adapter to have it's kernel up and\n" |
| 175 | "running. This is typically adjusted for large systems that do not" |
| 176 | " have a BIOS."); |
Mark Haverkamp | 404d9a9 | 2006-05-10 09:12:48 -0700 | [diff] [blame] | 177 | module_param(aif_timeout, int, S_IRUGO|S_IWUSR); |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 178 | MODULE_PARM_DESC(aif_timeout, "The duration of time in seconds to wait for" |
| 179 | " applications to pick up AIFs before\n" |
| 180 | "deregistering them. This is typically adjusted for heavily burdened" |
| 181 | " systems."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 183 | int numacb = -1; |
| 184 | module_param(numacb, int, S_IRUGO|S_IWUSR); |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 185 | MODULE_PARM_DESC(numacb, "Request a limit to the number of adapter control" |
| 186 | " blocks (FIB) allocated. Valid values are 512 and down. Default is" |
| 187 | " to use suggestion from Firmware."); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 188 | |
| 189 | int acbsize = -1; |
| 190 | module_param(acbsize, int, S_IRUGO|S_IWUSR); |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 191 | MODULE_PARM_DESC(acbsize, "Request a specific adapter control block (FIB)" |
| 192 | " size. Valid values are 512, 2048, 4096 and 8192. Default is to use" |
| 193 | " suggestion from Firmware."); |
Mark Haverkamp | 653ba58 | 2006-09-19 08:59:43 -0700 | [diff] [blame] | 194 | |
Salyzyn, Mark | 29c9768 | 2007-06-12 09:33:54 -0400 | [diff] [blame] | 195 | int update_interval = 30 * 60; |
| 196 | module_param(update_interval, int, S_IRUGO|S_IWUSR); |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 197 | MODULE_PARM_DESC(update_interval, "Interval in seconds between time sync" |
| 198 | " updates issued to adapter."); |
Salyzyn, Mark | 29c9768 | 2007-06-12 09:33:54 -0400 | [diff] [blame] | 199 | |
| 200 | int check_interval = 24 * 60 * 60; |
| 201 | module_param(check_interval, int, S_IRUGO|S_IWUSR); |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 202 | MODULE_PARM_DESC(check_interval, "Interval in seconds between adapter health" |
| 203 | " checks."); |
Salyzyn, Mark | 29c9768 | 2007-06-12 09:33:54 -0400 | [diff] [blame] | 204 | |
Andrew Morton | 87f3bda | 2007-08-10 14:50:30 -0700 | [diff] [blame] | 205 | int aac_check_reset = 1; |
| 206 | module_param_named(check_reset, aac_check_reset, int, S_IRUGO|S_IWUSR); |
Paul Bolle | 95e7a8e | 2008-04-16 14:43:00 +0200 | [diff] [blame] | 207 | MODULE_PARM_DESC(check_reset, "If adapter fails health check, reset the" |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 208 | " adapter. a value of -1 forces the reset to adapters programmed to" |
| 209 | " ignore it."); |
Salyzyn, Mark | 29c9768 | 2007-06-12 09:33:54 -0400 | [diff] [blame] | 210 | |
Mark Haverkamp | e37ee4b | 2007-01-26 09:23:32 -0800 | [diff] [blame] | 211 | int expose_physicals = -1; |
Mark Haverkamp | 653ba58 | 2006-09-19 08:59:43 -0700 | [diff] [blame] | 212 | module_param(expose_physicals, int, S_IRUGO|S_IWUSR); |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 213 | MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays." |
| 214 | " -1=protect 0=off, 1=on"); |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 215 | |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 216 | int aac_reset_devices; |
Salyzyn, Mark | 1208bab | 2007-05-22 09:32:29 -0400 | [diff] [blame] | 217 | module_param_named(reset_devices, aac_reset_devices, int, S_IRUGO|S_IWUSR); |
| 218 | MODULE_PARM_DESC(reset_devices, "Force an adapter reset at initialization."); |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 219 | |
Leubner, Achim | d8e96507 | 2009-04-01 07:16:08 -0700 | [diff] [blame] | 220 | int aac_wwn = 1; |
| 221 | module_param_named(wwn, aac_wwn, int, S_IRUGO|S_IWUSR); |
| 222 | MODULE_PARM_DESC(wwn, "Select a WWN type for the arrays:\n" |
| 223 | "\t0 - Disable\n" |
| 224 | "\t1 - Array Meta Data Signature (default)\n" |
| 225 | "\t2 - Adapter Serial Number"); |
| 226 | |
| 227 | |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 228 | static inline int aac_valid_context(struct scsi_cmnd *scsicmd, |
| 229 | struct fib *fibptr) { |
| 230 | struct scsi_device *device; |
| 231 | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 232 | if (unlikely(!scsicmd || !scsicmd->scsi_done)) { |
Salyzyn, Mark | c835e37 | 2007-07-26 14:20:02 -0400 | [diff] [blame] | 233 | dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n")); |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 234 | aac_fib_complete(fibptr); |
| 235 | aac_fib_free(fibptr); |
| 236 | return 0; |
| 237 | } |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 238 | scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL; |
| 239 | device = scsicmd->device; |
| 240 | if (unlikely(!device || !scsi_device_online(device))) { |
| 241 | dprintk((KERN_WARNING "aac_valid_context: scsi device corrupt\n")); |
| 242 | aac_fib_complete(fibptr); |
| 243 | aac_fib_free(fibptr); |
| 244 | return 0; |
| 245 | } |
| 246 | return 1; |
| 247 | } |
| 248 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | /** |
| 250 | * aac_get_config_status - check the adapter configuration |
| 251 | * @common: adapter to query |
| 252 | * |
| 253 | * Query config status, and commit the configuration if needed. |
| 254 | */ |
Mark Haverkamp | 8c867b2 | 2006-08-03 08:03:30 -0700 | [diff] [blame] | 255 | int aac_get_config_status(struct aac_dev *dev, int commit_flag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | { |
| 257 | int status = 0; |
| 258 | struct fib * fibptr; |
| 259 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 260 | if (!(fibptr = aac_fib_alloc(dev))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | return -ENOMEM; |
| 262 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 263 | aac_fib_init(fibptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | { |
| 265 | struct aac_get_config_status *dinfo; |
| 266 | dinfo = (struct aac_get_config_status *) fib_data(fibptr); |
| 267 | |
| 268 | dinfo->command = cpu_to_le32(VM_ContainerConfig); |
| 269 | dinfo->type = cpu_to_le32(CT_GET_CONFIG_STATUS); |
| 270 | dinfo->count = cpu_to_le32(sizeof(((struct aac_get_config_status_resp *)NULL)->data)); |
| 271 | } |
| 272 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 273 | status = aac_fib_send(ContainerCommand, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | fibptr, |
| 275 | sizeof (struct aac_get_config_status), |
| 276 | FsaNormal, |
| 277 | 1, 1, |
| 278 | NULL, NULL); |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 279 | if (status < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | printk(KERN_WARNING "aac_get_config_status: SendFIB failed.\n"); |
| 281 | } else { |
| 282 | struct aac_get_config_status_resp *reply |
| 283 | = (struct aac_get_config_status_resp *) fib_data(fibptr); |
| 284 | dprintk((KERN_WARNING |
| 285 | "aac_get_config_status: response=%d status=%d action=%d\n", |
| 286 | le32_to_cpu(reply->response), |
| 287 | le32_to_cpu(reply->status), |
| 288 | le32_to_cpu(reply->data.action))); |
| 289 | if ((le32_to_cpu(reply->response) != ST_OK) || |
| 290 | (le32_to_cpu(reply->status) != CT_OK) || |
| 291 | (le32_to_cpu(reply->data.action) > CFACT_PAUSE)) { |
| 292 | printk(KERN_WARNING "aac_get_config_status: Will not issue the Commit Configuration\n"); |
| 293 | status = -EINVAL; |
| 294 | } |
| 295 | } |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 296 | aac_fib_complete(fibptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | /* Send a CT_COMMIT_CONFIG to enable discovery of devices */ |
| 298 | if (status >= 0) { |
Salyzyn, Mark | 1208bab | 2007-05-22 09:32:29 -0400 | [diff] [blame] | 299 | if ((aac_commit == 1) || commit_flag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | struct aac_commit_config * dinfo; |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 301 | aac_fib_init(fibptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | dinfo = (struct aac_commit_config *) fib_data(fibptr); |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 303 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | dinfo->command = cpu_to_le32(VM_ContainerConfig); |
| 305 | dinfo->type = cpu_to_le32(CT_COMMIT_CONFIG); |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 306 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 307 | status = aac_fib_send(ContainerCommand, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | fibptr, |
| 309 | sizeof (struct aac_commit_config), |
| 310 | FsaNormal, |
| 311 | 1, 1, |
| 312 | NULL, NULL); |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 313 | aac_fib_complete(fibptr); |
Salyzyn, Mark | 1208bab | 2007-05-22 09:32:29 -0400 | [diff] [blame] | 314 | } else if (aac_commit == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | printk(KERN_WARNING |
| 316 | "aac_get_config_status: Foreign device configurations are being ignored\n"); |
| 317 | } |
| 318 | } |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 319 | aac_fib_free(fibptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | return status; |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * aac_get_containers - list containers |
| 325 | * @common: adapter to probe |
| 326 | * |
| 327 | * Make a list of all containers on this controller |
| 328 | */ |
| 329 | int aac_get_containers(struct aac_dev *dev) |
| 330 | { |
| 331 | struct fsa_dev_info *fsa_dev_ptr; |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 332 | u32 index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | int status = 0; |
| 334 | struct fib * fibptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | struct aac_get_container_count *dinfo; |
| 336 | struct aac_get_container_count_resp *dresp; |
| 337 | int maximum_num_containers = MAXIMUM_NUM_CONTAINERS; |
| 338 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 339 | if (!(fibptr = aac_fib_alloc(dev))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | return -ENOMEM; |
| 341 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 342 | aac_fib_init(fibptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | dinfo = (struct aac_get_container_count *) fib_data(fibptr); |
| 344 | dinfo->command = cpu_to_le32(VM_ContainerConfig); |
| 345 | dinfo->type = cpu_to_le32(CT_GET_CONTAINER_COUNT); |
| 346 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 347 | status = aac_fib_send(ContainerCommand, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | fibptr, |
| 349 | sizeof (struct aac_get_container_count), |
| 350 | FsaNormal, |
| 351 | 1, 1, |
| 352 | NULL, NULL); |
| 353 | if (status >= 0) { |
| 354 | dresp = (struct aac_get_container_count_resp *)fib_data(fibptr); |
| 355 | maximum_num_containers = le32_to_cpu(dresp->ContainerSwitchEntries); |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 356 | aac_fib_complete(fibptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | } |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 358 | aac_fib_free(fibptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | |
| 360 | if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS) |
| 361 | maximum_num_containers = MAXIMUM_NUM_CONTAINERS; |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 362 | fsa_dev_ptr = kzalloc(sizeof(*fsa_dev_ptr) * maximum_num_containers, |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 363 | GFP_KERNEL); |
| 364 | if (!fsa_dev_ptr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
| 367 | dev->fsa_dev = fsa_dev_ptr; |
| 368 | dev->maximum_num_containers = maximum_num_containers; |
| 369 | |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 370 | for (index = 0; index < dev->maximum_num_containers; ) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | fsa_dev_ptr[index].devname[0] = '\0'; |
| 372 | |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 373 | status = aac_probe_container(dev, index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 375 | if (status < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | printk(KERN_WARNING "aac_get_containers: SendFIB failed.\n"); |
| 377 | break; |
| 378 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | /* |
| 381 | * If there are no more containers, then stop asking. |
| 382 | */ |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 383 | if (++index >= status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | return status; |
| 387 | } |
| 388 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | static void get_container_name_callback(void *context, struct fib * fibptr) |
| 390 | { |
| 391 | struct aac_get_name_resp * get_name_reply; |
| 392 | struct scsi_cmnd * scsicmd; |
| 393 | |
| 394 | scsicmd = (struct scsi_cmnd *) context; |
| 395 | |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 396 | if (!aac_valid_context(scsicmd, fibptr)) |
| 397 | return; |
| 398 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | dprintk((KERN_DEBUG "get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies)); |
Eric Sesterhenn | 125e187 | 2006-06-23 02:06:06 -0700 | [diff] [blame] | 400 | BUG_ON(fibptr == NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | |
| 402 | get_name_reply = (struct aac_get_name_resp *) fib_data(fibptr); |
| 403 | /* Failure is irrelevant, using default value instead */ |
| 404 | if ((le32_to_cpu(get_name_reply->status) == CT_OK) |
| 405 | && (get_name_reply->data[0] != '\0')) { |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 406 | char *sp = get_name_reply->data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | sp[sizeof(((struct aac_get_name_resp *)NULL)->data)-1] = '\0'; |
| 408 | while (*sp == ' ') |
| 409 | ++sp; |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 410 | if (*sp) { |
FUJITA Tomonori | d434502 | 2008-03-09 13:44:34 +0900 | [diff] [blame] | 411 | struct inquiry_data inq; |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 412 | char d[sizeof(((struct inquiry_data *)NULL)->inqd_pid)]; |
| 413 | int count = sizeof(d); |
| 414 | char *dp = d; |
| 415 | do { |
| 416 | *dp++ = (*sp) ? *sp++ : ' '; |
| 417 | } while (--count > 0); |
FUJITA Tomonori | d434502 | 2008-03-09 13:44:34 +0900 | [diff] [blame] | 418 | |
| 419 | scsi_sg_copy_to_buffer(scsicmd, &inq, sizeof(inq)); |
| 420 | memcpy(inq.inqd_pid, d, sizeof(d)); |
| 421 | scsi_sg_copy_from_buffer(scsicmd, &inq, sizeof(inq)); |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 422 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | } |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 424 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 426 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 427 | aac_fib_complete(fibptr); |
| 428 | aac_fib_free(fibptr); |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 429 | scsicmd->scsi_done(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | /** |
| 433 | * aac_get_container_name - get container name, none blocking. |
| 434 | */ |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 435 | static int aac_get_container_name(struct scsi_cmnd * scsicmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | { |
| 437 | int status; |
| 438 | struct aac_get_name *dinfo; |
| 439 | struct fib * cmd_fibcontext; |
| 440 | struct aac_dev * dev; |
| 441 | |
| 442 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
| 443 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 444 | if (!(cmd_fibcontext = aac_fib_alloc(dev))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | return -ENOMEM; |
| 446 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 447 | aac_fib_init(cmd_fibcontext); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | dinfo = (struct aac_get_name *) fib_data(cmd_fibcontext); |
| 449 | |
| 450 | dinfo->command = cpu_to_le32(VM_ContainerConfig); |
| 451 | dinfo->type = cpu_to_le32(CT_READ_NAME); |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 452 | dinfo->cid = cpu_to_le32(scmd_id(scsicmd)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data)); |
| 454 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 455 | status = aac_fib_send(ContainerCommand, |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 456 | cmd_fibcontext, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | sizeof (struct aac_get_name), |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 458 | FsaNormal, |
| 459 | 0, 1, |
| 460 | (fib_callback)get_container_name_callback, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | (void *) scsicmd); |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 462 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | /* |
| 464 | * Check that the command queued to the controller |
| 465 | */ |
Mark Haverkamp | 77d644d | 2006-03-27 09:43:40 -0800 | [diff] [blame] | 466 | if (status == -EINPROGRESS) { |
| 467 | scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | return 0; |
Mark Haverkamp | 77d644d | 2006-03-27 09:43:40 -0800 | [diff] [blame] | 469 | } |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 470 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 471 | printk(KERN_WARNING "aac_get_container_name: aac_fib_send failed with status: %d.\n", status); |
| 472 | aac_fib_complete(cmd_fibcontext); |
| 473 | aac_fib_free(cmd_fibcontext); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | return -1; |
| 475 | } |
| 476 | |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 477 | static int aac_probe_container_callback2(struct scsi_cmnd * scsicmd) |
| 478 | { |
| 479 | struct fsa_dev_info *fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev; |
| 480 | |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 481 | if ((fsa_dev_ptr[scmd_id(scsicmd)].valid & 1)) |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 482 | return aac_scsi_cmd(scsicmd); |
| 483 | |
| 484 | scsicmd->result = DID_NO_CONNECT << 16; |
| 485 | scsicmd->scsi_done(scsicmd); |
| 486 | return 0; |
| 487 | } |
| 488 | |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 489 | static void _aac_probe_container2(void * context, struct fib * fibptr) |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 490 | { |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 491 | struct fsa_dev_info *fsa_dev_ptr; |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 492 | int (*callback)(struct scsi_cmnd *); |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 493 | struct scsi_cmnd * scsicmd = (struct scsi_cmnd *)context; |
| 494 | |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 495 | |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 496 | if (!aac_valid_context(scsicmd, fibptr)) |
| 497 | return; |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 498 | |
| 499 | scsicmd->SCp.Status = 0; |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 500 | fsa_dev_ptr = fibptr->dev->fsa_dev; |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 501 | if (fsa_dev_ptr) { |
| 502 | struct aac_mount * dresp = (struct aac_mount *) fib_data(fibptr); |
| 503 | fsa_dev_ptr += scmd_id(scsicmd); |
| 504 | |
| 505 | if ((le32_to_cpu(dresp->status) == ST_OK) && |
| 506 | (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) && |
| 507 | (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) { |
| 508 | fsa_dev_ptr->valid = 1; |
Mark Salyzyn | 655d722 | 2008-04-30 16:03:42 -0400 | [diff] [blame] | 509 | /* sense_key holds the current state of the spin-up */ |
| 510 | if (dresp->mnt[0].state & cpu_to_le32(FSCS_NOT_READY)) |
| 511 | fsa_dev_ptr->sense_data.sense_key = NOT_READY; |
| 512 | else if (fsa_dev_ptr->sense_data.sense_key == NOT_READY) |
| 513 | fsa_dev_ptr->sense_data.sense_key = NO_SENSE; |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 514 | fsa_dev_ptr->type = le32_to_cpu(dresp->mnt[0].vol); |
| 515 | fsa_dev_ptr->size |
| 516 | = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) + |
| 517 | (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32); |
| 518 | fsa_dev_ptr->ro = ((le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY) != 0); |
| 519 | } |
| 520 | if ((fsa_dev_ptr->valid & 1) == 0) |
| 521 | fsa_dev_ptr->valid = 0; |
| 522 | scsicmd->SCp.Status = le32_to_cpu(dresp->count); |
| 523 | } |
| 524 | aac_fib_complete(fibptr); |
| 525 | aac_fib_free(fibptr); |
| 526 | callback = (int (*)(struct scsi_cmnd *))(scsicmd->SCp.ptr); |
| 527 | scsicmd->SCp.ptr = NULL; |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 528 | (*callback)(scsicmd); |
| 529 | return; |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 530 | } |
| 531 | |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 532 | static void _aac_probe_container1(void * context, struct fib * fibptr) |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 533 | { |
| 534 | struct scsi_cmnd * scsicmd; |
| 535 | struct aac_mount * dresp; |
| 536 | struct aac_query_mount *dinfo; |
| 537 | int status; |
| 538 | |
| 539 | dresp = (struct aac_mount *) fib_data(fibptr); |
| 540 | dresp->mnt[0].capacityhigh = 0; |
| 541 | if ((le32_to_cpu(dresp->status) != ST_OK) || |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 542 | (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE)) { |
| 543 | _aac_probe_container2(context, fibptr); |
| 544 | return; |
| 545 | } |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 546 | scsicmd = (struct scsi_cmnd *) context; |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 547 | |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 548 | if (!aac_valid_context(scsicmd, fibptr)) |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 549 | return; |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 550 | |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 551 | aac_fib_init(fibptr); |
| 552 | |
| 553 | dinfo = (struct aac_query_mount *)fib_data(fibptr); |
| 554 | |
| 555 | dinfo->command = cpu_to_le32(VM_NameServe64); |
| 556 | dinfo->count = cpu_to_le32(scmd_id(scsicmd)); |
| 557 | dinfo->type = cpu_to_le32(FT_FILESYS); |
| 558 | |
| 559 | status = aac_fib_send(ContainerCommand, |
| 560 | fibptr, |
| 561 | sizeof(struct aac_query_mount), |
| 562 | FsaNormal, |
| 563 | 0, 1, |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 564 | _aac_probe_container2, |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 565 | (void *) scsicmd); |
| 566 | /* |
| 567 | * Check that the command queued to the controller |
| 568 | */ |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 569 | if (status == -EINPROGRESS) |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 570 | scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 571 | else if (status < 0) { |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 572 | /* Inherit results from VM_NameServe, if any */ |
| 573 | dresp->status = cpu_to_le32(ST_OK); |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 574 | _aac_probe_container2(context, fibptr); |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 575 | } |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 576 | } |
| 577 | |
| 578 | static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(struct scsi_cmnd *)) |
| 579 | { |
| 580 | struct fib * fibptr; |
| 581 | int status = -ENOMEM; |
| 582 | |
| 583 | if ((fibptr = aac_fib_alloc((struct aac_dev *)scsicmd->device->host->hostdata))) { |
| 584 | struct aac_query_mount *dinfo; |
| 585 | |
| 586 | aac_fib_init(fibptr); |
| 587 | |
| 588 | dinfo = (struct aac_query_mount *)fib_data(fibptr); |
| 589 | |
| 590 | dinfo->command = cpu_to_le32(VM_NameServe); |
| 591 | dinfo->count = cpu_to_le32(scmd_id(scsicmd)); |
| 592 | dinfo->type = cpu_to_le32(FT_FILESYS); |
| 593 | scsicmd->SCp.ptr = (char *)callback; |
| 594 | |
| 595 | status = aac_fib_send(ContainerCommand, |
| 596 | fibptr, |
| 597 | sizeof(struct aac_query_mount), |
| 598 | FsaNormal, |
| 599 | 0, 1, |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 600 | _aac_probe_container1, |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 601 | (void *) scsicmd); |
| 602 | /* |
| 603 | * Check that the command queued to the controller |
| 604 | */ |
| 605 | if (status == -EINPROGRESS) { |
| 606 | scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; |
| 607 | return 0; |
| 608 | } |
| 609 | if (status < 0) { |
| 610 | scsicmd->SCp.ptr = NULL; |
| 611 | aac_fib_complete(fibptr); |
| 612 | aac_fib_free(fibptr); |
| 613 | } |
| 614 | } |
| 615 | if (status < 0) { |
| 616 | struct fsa_dev_info *fsa_dev_ptr = ((struct aac_dev *)(scsicmd->device->host->hostdata))->fsa_dev; |
| 617 | if (fsa_dev_ptr) { |
| 618 | fsa_dev_ptr += scmd_id(scsicmd); |
| 619 | if ((fsa_dev_ptr->valid & 1) == 0) { |
| 620 | fsa_dev_ptr->valid = 0; |
| 621 | return (*callback)(scsicmd); |
| 622 | } |
| 623 | } |
| 624 | } |
| 625 | return status; |
| 626 | } |
| 627 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | /** |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 629 | * aac_probe_container - query a logical volume |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | * @dev: device to query |
| 631 | * @cid: container identifier |
| 632 | * |
| 633 | * Queries the controller about the given volume. The volume information |
| 634 | * is updated in the struct fsa_dev_info structure rather than returned. |
| 635 | */ |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 636 | static int aac_probe_container_callback1(struct scsi_cmnd * scsicmd) |
| 637 | { |
| 638 | scsicmd->device = NULL; |
| 639 | return 0; |
| 640 | } |
| 641 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 642 | int aac_probe_container(struct aac_dev *dev, int cid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | { |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 644 | struct scsi_cmnd *scsicmd = kmalloc(sizeof(*scsicmd), GFP_KERNEL); |
| 645 | struct scsi_device *scsidev = kmalloc(sizeof(*scsidev), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 648 | if (!scsicmd || !scsidev) { |
| 649 | kfree(scsicmd); |
| 650 | kfree(scsidev); |
Mark Haverkamp | 90ee346 | 2006-08-03 08:03:07 -0700 | [diff] [blame] | 651 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | } |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 653 | scsicmd->list.next = NULL; |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 654 | scsicmd->scsi_done = (void (*)(struct scsi_cmnd*))aac_probe_container_callback1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 656 | scsicmd->device = scsidev; |
| 657 | scsidev->sdev_state = 0; |
| 658 | scsidev->id = cid; |
| 659 | scsidev->host = dev->scsi_host_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 661 | if (_aac_probe_container(scsicmd, aac_probe_container_callback1) == 0) |
| 662 | while (scsicmd->device == scsidev) |
| 663 | schedule(); |
Salyzyn, Mark | 802ae2f | 2007-03-21 13:49:47 -0400 | [diff] [blame] | 664 | kfree(scsidev); |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 665 | status = scsicmd->SCp.Status; |
| 666 | kfree(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | return status; |
| 668 | } |
| 669 | |
| 670 | /* Local Structure to set SCSI inquiry data strings */ |
| 671 | struct scsi_inq { |
| 672 | char vid[8]; /* Vendor ID */ |
| 673 | char pid[16]; /* Product ID */ |
| 674 | char prl[4]; /* Product Revision Level */ |
| 675 | }; |
| 676 | |
| 677 | /** |
| 678 | * InqStrCopy - string merge |
| 679 | * @a: string to copy from |
| 680 | * @b: string to copy to |
| 681 | * |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 682 | * Copy a String from one location to another |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | * without copying \0 |
| 684 | */ |
| 685 | |
| 686 | static void inqstrcpy(char *a, char *b) |
| 687 | { |
| 688 | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 689 | while (*a != (char)0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | *b++ = *a++; |
| 691 | } |
| 692 | |
| 693 | static char *container_types[] = { |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 694 | "None", |
| 695 | "Volume", |
| 696 | "Mirror", |
| 697 | "Stripe", |
| 698 | "RAID5", |
| 699 | "SSRW", |
| 700 | "SSRO", |
| 701 | "Morph", |
| 702 | "Legacy", |
| 703 | "RAID4", |
| 704 | "RAID10", |
| 705 | "RAID00", |
| 706 | "V-MIRRORS", |
| 707 | "PSEUDO R4", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | "RAID50", |
Mark Haverkamp | 8497173 | 2005-06-20 11:55:24 -0700 | [diff] [blame] | 709 | "RAID5D", |
| 710 | "RAID5D0", |
| 711 | "RAID1E", |
| 712 | "RAID6", |
| 713 | "RAID60", |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 714 | "Unknown" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | }; |
| 716 | |
Salyzyn, Mark | 17eaace | 2008-01-08 12:23:49 -0800 | [diff] [blame] | 717 | char * get_container_type(unsigned tindex) |
| 718 | { |
| 719 | if (tindex >= ARRAY_SIZE(container_types)) |
| 720 | tindex = ARRAY_SIZE(container_types) - 1; |
| 721 | return container_types[tindex]; |
| 722 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | |
| 724 | /* Function: setinqstr |
| 725 | * |
| 726 | * Arguments: [1] pointer to void [1] int |
| 727 | * |
| 728 | * Purpose: Sets SCSI inquiry data strings for vendor, product |
| 729 | * and revision level. Allows strings to be set in platform dependant |
| 730 | * files instead of in OS dependant driver source. |
| 731 | */ |
| 732 | |
Mark Haverkamp | 794d060 | 2005-10-24 10:51:53 -0700 | [diff] [blame] | 733 | static void setinqstr(struct aac_dev *dev, void *data, int tindex) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | { |
| 735 | struct scsi_inq *str; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | str = (struct scsi_inq *)(data); /* cast data to scsi inq block */ |
Mark Haverkamp | 794d060 | 2005-10-24 10:51:53 -0700 | [diff] [blame] | 738 | memset(str, ' ', sizeof(*str)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | |
Mark Haverkamp | 794d060 | 2005-10-24 10:51:53 -0700 | [diff] [blame] | 740 | if (dev->supplement_adapter_info.AdapterTypeText[0]) { |
| 741 | char * cp = dev->supplement_adapter_info.AdapterTypeText; |
Salyzyn, Mark | 3bc8070 | 2008-01-11 13:46:24 -0800 | [diff] [blame] | 742 | int c; |
| 743 | if ((cp[0] == 'A') && (cp[1] == 'O') && (cp[2] == 'C')) |
| 744 | inqstrcpy("SMC", str->vid); |
| 745 | else { |
| 746 | c = sizeof(str->vid); |
| 747 | while (*cp && *cp != ' ' && --c) |
| 748 | ++cp; |
| 749 | c = *cp; |
| 750 | *cp = '\0'; |
| 751 | inqstrcpy (dev->supplement_adapter_info.AdapterTypeText, |
| 752 | str->vid); |
| 753 | *cp = c; |
| 754 | while (*cp && *cp != ' ') |
| 755 | ++cp; |
| 756 | } |
Mark Haverkamp | 794d060 | 2005-10-24 10:51:53 -0700 | [diff] [blame] | 757 | while (*cp == ' ') |
| 758 | ++cp; |
| 759 | /* last six chars reserved for vol type */ |
| 760 | c = 0; |
| 761 | if (strlen(cp) > sizeof(str->pid)) { |
| 762 | c = cp[sizeof(str->pid)]; |
| 763 | cp[sizeof(str->pid)] = '\0'; |
| 764 | } |
| 765 | inqstrcpy (cp, str->pid); |
| 766 | if (c) |
| 767 | cp[sizeof(str->pid)] = c; |
| 768 | } else { |
| 769 | struct aac_driver_ident *mp = aac_get_driver_ident(dev->cardtype); |
Tobias Klauser | 6391a11 | 2006-06-08 22:23:48 -0700 | [diff] [blame] | 770 | |
| 771 | inqstrcpy (mp->vname, str->vid); |
Mark Haverkamp | 794d060 | 2005-10-24 10:51:53 -0700 | [diff] [blame] | 772 | /* last six chars reserved for vol type */ |
| 773 | inqstrcpy (mp->model, str->pid); |
| 774 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | |
Tobias Klauser | 6391a11 | 2006-06-08 22:23:48 -0700 | [diff] [blame] | 776 | if (tindex < ARRAY_SIZE(container_types)){ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | char *findit = str->pid; |
| 778 | |
| 779 | for ( ; *findit != ' '; findit++); /* walk till we find a space */ |
| 780 | /* RAID is superfluous in the context of a RAID device */ |
| 781 | if (memcmp(findit-4, "RAID", 4) == 0) |
| 782 | *(findit -= 4) = ' '; |
Mark Haverkamp | 794d060 | 2005-10-24 10:51:53 -0700 | [diff] [blame] | 783 | if (((findit - str->pid) + strlen(container_types[tindex])) |
| 784 | < (sizeof(str->pid) + sizeof(str->prl))) |
| 785 | inqstrcpy (container_types[tindex], findit + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | } |
| 787 | inqstrcpy ("V1.0", str->prl); |
| 788 | } |
| 789 | |
Salyzyn, Mark | 88e2f98 | 2007-07-17 14:01:28 -0400 | [diff] [blame] | 790 | static void get_container_serial_callback(void *context, struct fib * fibptr) |
| 791 | { |
| 792 | struct aac_get_serial_resp * get_serial_reply; |
| 793 | struct scsi_cmnd * scsicmd; |
| 794 | |
| 795 | BUG_ON(fibptr == NULL); |
| 796 | |
| 797 | scsicmd = (struct scsi_cmnd *) context; |
| 798 | if (!aac_valid_context(scsicmd, fibptr)) |
| 799 | return; |
| 800 | |
| 801 | get_serial_reply = (struct aac_get_serial_resp *) fib_data(fibptr); |
| 802 | /* Failure is irrelevant, using default value instead */ |
| 803 | if (le32_to_cpu(get_serial_reply->status) == CT_OK) { |
| 804 | char sp[13]; |
| 805 | /* EVPD bit set */ |
| 806 | sp[0] = INQD_PDT_DA; |
| 807 | sp[1] = scsicmd->cmnd[2]; |
| 808 | sp[2] = 0; |
| 809 | sp[3] = snprintf(sp+4, sizeof(sp)-4, "%08X", |
| 810 | le32_to_cpu(get_serial_reply->uid)); |
FUJITA Tomonori | d434502 | 2008-03-09 13:44:34 +0900 | [diff] [blame] | 811 | scsi_sg_copy_from_buffer(scsicmd, sp, sizeof(sp)); |
Salyzyn, Mark | 88e2f98 | 2007-07-17 14:01:28 -0400 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 815 | |
| 816 | aac_fib_complete(fibptr); |
| 817 | aac_fib_free(fibptr); |
| 818 | scsicmd->scsi_done(scsicmd); |
| 819 | } |
| 820 | |
| 821 | /** |
| 822 | * aac_get_container_serial - get container serial, none blocking. |
| 823 | */ |
| 824 | static int aac_get_container_serial(struct scsi_cmnd * scsicmd) |
| 825 | { |
| 826 | int status; |
| 827 | struct aac_get_serial *dinfo; |
| 828 | struct fib * cmd_fibcontext; |
| 829 | struct aac_dev * dev; |
| 830 | |
| 831 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
| 832 | |
| 833 | if (!(cmd_fibcontext = aac_fib_alloc(dev))) |
| 834 | return -ENOMEM; |
| 835 | |
| 836 | aac_fib_init(cmd_fibcontext); |
| 837 | dinfo = (struct aac_get_serial *) fib_data(cmd_fibcontext); |
| 838 | |
| 839 | dinfo->command = cpu_to_le32(VM_ContainerConfig); |
| 840 | dinfo->type = cpu_to_le32(CT_CID_TO_32BITS_UID); |
| 841 | dinfo->cid = cpu_to_le32(scmd_id(scsicmd)); |
| 842 | |
| 843 | status = aac_fib_send(ContainerCommand, |
| 844 | cmd_fibcontext, |
| 845 | sizeof (struct aac_get_serial), |
| 846 | FsaNormal, |
| 847 | 0, 1, |
| 848 | (fib_callback) get_container_serial_callback, |
| 849 | (void *) scsicmd); |
| 850 | |
| 851 | /* |
| 852 | * Check that the command queued to the controller |
| 853 | */ |
| 854 | if (status == -EINPROGRESS) { |
| 855 | scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; |
| 856 | return 0; |
| 857 | } |
| 858 | |
| 859 | printk(KERN_WARNING "aac_get_container_serial: aac_fib_send failed with status: %d.\n", status); |
| 860 | aac_fib_complete(cmd_fibcontext); |
| 861 | aac_fib_free(cmd_fibcontext); |
| 862 | return -1; |
| 863 | } |
| 864 | |
| 865 | /* Function: setinqserial |
| 866 | * |
| 867 | * Arguments: [1] pointer to void [1] int |
| 868 | * |
| 869 | * Purpose: Sets SCSI Unit Serial number. |
| 870 | * This is a fake. We should read a proper |
| 871 | * serial number from the container. <SuSE>But |
| 872 | * without docs it's quite hard to do it :-) |
| 873 | * So this will have to do in the meantime.</SuSE> |
| 874 | */ |
| 875 | |
| 876 | static int setinqserial(struct aac_dev *dev, void *data, int cid) |
| 877 | { |
| 878 | /* |
| 879 | * This breaks array migration. |
| 880 | */ |
| 881 | return snprintf((char *)(data), sizeof(struct scsi_inq) - 4, "%08X%02X", |
| 882 | le32_to_cpu(dev->adapter_info.serial[0]), cid); |
| 883 | } |
| 884 | |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 885 | static inline void set_sense(struct sense_data *sense_data, u8 sense_key, |
| 886 | u8 sense_code, u8 a_sense_code, u8 bit_pointer, u16 field_pointer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | { |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 888 | u8 *sense_buf = (u8 *)sense_data; |
| 889 | /* Sense data valid, err code 70h */ |
| 890 | sense_buf[0] = 0x70; /* No info field */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 891 | sense_buf[1] = 0; /* Segment number, always zero */ |
| 892 | |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 893 | sense_buf[2] = sense_key; /* Sense key */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | |
| 895 | sense_buf[12] = sense_code; /* Additional sense code */ |
| 896 | sense_buf[13] = a_sense_code; /* Additional sense code qualifier */ |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 897 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | if (sense_key == ILLEGAL_REQUEST) { |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 899 | sense_buf[7] = 10; /* Additional sense length */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 900 | |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 901 | sense_buf[15] = bit_pointer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | /* Illegal parameter is in the parameter block */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | if (sense_code == SENCODE_INVALID_CDB_FIELD) |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 904 | sense_buf[15] |= 0xc0;/* Std sense key specific field */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | /* Illegal parameter is in the CDB block */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | sense_buf[16] = field_pointer >> 8; /* MSB */ |
| 907 | sense_buf[17] = field_pointer; /* LSB */ |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 908 | } else |
| 909 | sense_buf[7] = 6; /* Additional sense length */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | } |
| 911 | |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 912 | static int aac_bounds_32(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba) |
| 913 | { |
| 914 | if (lba & 0xffffffff00000000LL) { |
| 915 | int cid = scmd_id(cmd); |
| 916 | dprintk((KERN_DEBUG "aacraid: Illegal lba\n")); |
| 917 | cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | |
| 918 | SAM_STAT_CHECK_CONDITION; |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 919 | set_sense(&dev->fsa_dev[cid].sense_data, |
| 920 | HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, |
| 921 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 922 | memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, |
Salyzyn, Mark | 3ace426 | 2008-01-14 07:25:33 -0800 | [diff] [blame] | 923 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), |
| 924 | SCSI_SENSE_BUFFERSIZE)); |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 925 | cmd->scsi_done(cmd); |
| 926 | return 1; |
| 927 | } |
| 928 | return 0; |
| 929 | } |
| 930 | |
| 931 | static int aac_bounds_64(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba) |
| 932 | { |
| 933 | return 0; |
| 934 | } |
| 935 | |
| 936 | static void io_callback(void *context, struct fib * fibptr); |
| 937 | |
| 938 | static int aac_read_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count) |
| 939 | { |
| 940 | u16 fibsize; |
| 941 | struct aac_raw_io *readcmd; |
| 942 | aac_fib_init(fib); |
| 943 | readcmd = (struct aac_raw_io *) fib_data(fib); |
| 944 | readcmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff)); |
| 945 | readcmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32)); |
| 946 | readcmd->count = cpu_to_le32(count<<9); |
| 947 | readcmd->cid = cpu_to_le16(scmd_id(cmd)); |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 948 | readcmd->flags = cpu_to_le16(IO_TYPE_READ); |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 949 | readcmd->bpTotal = 0; |
| 950 | readcmd->bpComplete = 0; |
| 951 | |
| 952 | aac_build_sgraw(cmd, &readcmd->sg); |
| 953 | fibsize = sizeof(struct aac_raw_io) + ((le32_to_cpu(readcmd->sg.count) - 1) * sizeof (struct sgentryraw)); |
| 954 | BUG_ON(fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); |
| 955 | /* |
| 956 | * Now send the Fib to the adapter |
| 957 | */ |
| 958 | return aac_fib_send(ContainerRawIo, |
| 959 | fib, |
| 960 | fibsize, |
| 961 | FsaNormal, |
| 962 | 0, 1, |
| 963 | (fib_callback) io_callback, |
| 964 | (void *) cmd); |
| 965 | } |
| 966 | |
| 967 | static int aac_read_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count) |
| 968 | { |
| 969 | u16 fibsize; |
| 970 | struct aac_read64 *readcmd; |
| 971 | aac_fib_init(fib); |
| 972 | readcmd = (struct aac_read64 *) fib_data(fib); |
| 973 | readcmd->command = cpu_to_le32(VM_CtHostRead64); |
| 974 | readcmd->cid = cpu_to_le16(scmd_id(cmd)); |
| 975 | readcmd->sector_count = cpu_to_le16(count); |
| 976 | readcmd->block = cpu_to_le32((u32)(lba&0xffffffff)); |
| 977 | readcmd->pad = 0; |
| 978 | readcmd->flags = 0; |
| 979 | |
| 980 | aac_build_sg64(cmd, &readcmd->sg); |
| 981 | fibsize = sizeof(struct aac_read64) + |
| 982 | ((le32_to_cpu(readcmd->sg.count) - 1) * |
| 983 | sizeof (struct sgentry64)); |
| 984 | BUG_ON (fibsize > (fib->dev->max_fib_size - |
| 985 | sizeof(struct aac_fibhdr))); |
| 986 | /* |
| 987 | * Now send the Fib to the adapter |
| 988 | */ |
| 989 | return aac_fib_send(ContainerCommand64, |
| 990 | fib, |
| 991 | fibsize, |
| 992 | FsaNormal, |
| 993 | 0, 1, |
| 994 | (fib_callback) io_callback, |
| 995 | (void *) cmd); |
| 996 | } |
| 997 | |
| 998 | static int aac_read_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count) |
| 999 | { |
| 1000 | u16 fibsize; |
| 1001 | struct aac_read *readcmd; |
| 1002 | aac_fib_init(fib); |
| 1003 | readcmd = (struct aac_read *) fib_data(fib); |
| 1004 | readcmd->command = cpu_to_le32(VM_CtBlockRead); |
Christoph Hellwig | f3307f7 | 2007-11-08 17:27:47 +0000 | [diff] [blame] | 1005 | readcmd->cid = cpu_to_le32(scmd_id(cmd)); |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1006 | readcmd->block = cpu_to_le32((u32)(lba&0xffffffff)); |
| 1007 | readcmd->count = cpu_to_le32(count * 512); |
| 1008 | |
| 1009 | aac_build_sg(cmd, &readcmd->sg); |
| 1010 | fibsize = sizeof(struct aac_read) + |
| 1011 | ((le32_to_cpu(readcmd->sg.count) - 1) * |
| 1012 | sizeof (struct sgentry)); |
| 1013 | BUG_ON (fibsize > (fib->dev->max_fib_size - |
| 1014 | sizeof(struct aac_fibhdr))); |
| 1015 | /* |
| 1016 | * Now send the Fib to the adapter |
| 1017 | */ |
| 1018 | return aac_fib_send(ContainerCommand, |
| 1019 | fib, |
| 1020 | fibsize, |
| 1021 | FsaNormal, |
| 1022 | 0, 1, |
| 1023 | (fib_callback) io_callback, |
| 1024 | (void *) cmd); |
| 1025 | } |
| 1026 | |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 1027 | static int aac_write_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua) |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1028 | { |
| 1029 | u16 fibsize; |
| 1030 | struct aac_raw_io *writecmd; |
| 1031 | aac_fib_init(fib); |
| 1032 | writecmd = (struct aac_raw_io *) fib_data(fib); |
| 1033 | writecmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff)); |
| 1034 | writecmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32)); |
| 1035 | writecmd->count = cpu_to_le32(count<<9); |
| 1036 | writecmd->cid = cpu_to_le16(scmd_id(cmd)); |
Salyzyn, Mark | 95e852e | 2008-01-08 12:01:07 -0800 | [diff] [blame] | 1037 | writecmd->flags = (fua && ((aac_cache & 5) != 1) && |
| 1038 | (((aac_cache & 5) != 5) || !fib->dev->cache_protected)) ? |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 1039 | cpu_to_le16(IO_TYPE_WRITE|IO_SUREWRITE) : |
| 1040 | cpu_to_le16(IO_TYPE_WRITE); |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1041 | writecmd->bpTotal = 0; |
| 1042 | writecmd->bpComplete = 0; |
| 1043 | |
| 1044 | aac_build_sgraw(cmd, &writecmd->sg); |
| 1045 | fibsize = sizeof(struct aac_raw_io) + ((le32_to_cpu(writecmd->sg.count) - 1) * sizeof (struct sgentryraw)); |
| 1046 | BUG_ON(fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); |
| 1047 | /* |
| 1048 | * Now send the Fib to the adapter |
| 1049 | */ |
| 1050 | return aac_fib_send(ContainerRawIo, |
| 1051 | fib, |
| 1052 | fibsize, |
| 1053 | FsaNormal, |
| 1054 | 0, 1, |
| 1055 | (fib_callback) io_callback, |
| 1056 | (void *) cmd); |
| 1057 | } |
| 1058 | |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 1059 | static int aac_write_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua) |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1060 | { |
| 1061 | u16 fibsize; |
| 1062 | struct aac_write64 *writecmd; |
| 1063 | aac_fib_init(fib); |
| 1064 | writecmd = (struct aac_write64 *) fib_data(fib); |
| 1065 | writecmd->command = cpu_to_le32(VM_CtHostWrite64); |
| 1066 | writecmd->cid = cpu_to_le16(scmd_id(cmd)); |
| 1067 | writecmd->sector_count = cpu_to_le16(count); |
| 1068 | writecmd->block = cpu_to_le32((u32)(lba&0xffffffff)); |
| 1069 | writecmd->pad = 0; |
| 1070 | writecmd->flags = 0; |
| 1071 | |
| 1072 | aac_build_sg64(cmd, &writecmd->sg); |
| 1073 | fibsize = sizeof(struct aac_write64) + |
| 1074 | ((le32_to_cpu(writecmd->sg.count) - 1) * |
| 1075 | sizeof (struct sgentry64)); |
| 1076 | BUG_ON (fibsize > (fib->dev->max_fib_size - |
| 1077 | sizeof(struct aac_fibhdr))); |
| 1078 | /* |
| 1079 | * Now send the Fib to the adapter |
| 1080 | */ |
| 1081 | return aac_fib_send(ContainerCommand64, |
| 1082 | fib, |
| 1083 | fibsize, |
| 1084 | FsaNormal, |
| 1085 | 0, 1, |
| 1086 | (fib_callback) io_callback, |
| 1087 | (void *) cmd); |
| 1088 | } |
| 1089 | |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 1090 | static int aac_write_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua) |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1091 | { |
| 1092 | u16 fibsize; |
| 1093 | struct aac_write *writecmd; |
| 1094 | aac_fib_init(fib); |
| 1095 | writecmd = (struct aac_write *) fib_data(fib); |
| 1096 | writecmd->command = cpu_to_le32(VM_CtBlockWrite); |
Christoph Hellwig | f3307f7 | 2007-11-08 17:27:47 +0000 | [diff] [blame] | 1097 | writecmd->cid = cpu_to_le32(scmd_id(cmd)); |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1098 | writecmd->block = cpu_to_le32((u32)(lba&0xffffffff)); |
| 1099 | writecmd->count = cpu_to_le32(count * 512); |
| 1100 | writecmd->sg.count = cpu_to_le32(1); |
| 1101 | /* ->stable is not used - it did mean which type of write */ |
| 1102 | |
| 1103 | aac_build_sg(cmd, &writecmd->sg); |
| 1104 | fibsize = sizeof(struct aac_write) + |
| 1105 | ((le32_to_cpu(writecmd->sg.count) - 1) * |
| 1106 | sizeof (struct sgentry)); |
| 1107 | BUG_ON (fibsize > (fib->dev->max_fib_size - |
| 1108 | sizeof(struct aac_fibhdr))); |
| 1109 | /* |
| 1110 | * Now send the Fib to the adapter |
| 1111 | */ |
| 1112 | return aac_fib_send(ContainerCommand, |
| 1113 | fib, |
| 1114 | fibsize, |
| 1115 | FsaNormal, |
| 1116 | 0, 1, |
| 1117 | (fib_callback) io_callback, |
| 1118 | (void *) cmd); |
| 1119 | } |
| 1120 | |
| 1121 | static struct aac_srb * aac_scsi_common(struct fib * fib, struct scsi_cmnd * cmd) |
| 1122 | { |
| 1123 | struct aac_srb * srbcmd; |
| 1124 | u32 flag; |
| 1125 | u32 timeout; |
| 1126 | |
| 1127 | aac_fib_init(fib); |
| 1128 | switch(cmd->sc_data_direction){ |
| 1129 | case DMA_TO_DEVICE: |
| 1130 | flag = SRB_DataOut; |
| 1131 | break; |
| 1132 | case DMA_BIDIRECTIONAL: |
| 1133 | flag = SRB_DataIn | SRB_DataOut; |
| 1134 | break; |
| 1135 | case DMA_FROM_DEVICE: |
| 1136 | flag = SRB_DataIn; |
| 1137 | break; |
| 1138 | case DMA_NONE: |
| 1139 | default: /* shuts up some versions of gcc */ |
| 1140 | flag = SRB_NoDataXfer; |
| 1141 | break; |
| 1142 | } |
| 1143 | |
| 1144 | srbcmd = (struct aac_srb*) fib_data(fib); |
| 1145 | srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); |
| 1146 | srbcmd->channel = cpu_to_le32(aac_logical_to_phys(scmd_channel(cmd))); |
| 1147 | srbcmd->id = cpu_to_le32(scmd_id(cmd)); |
| 1148 | srbcmd->lun = cpu_to_le32(cmd->device->lun); |
| 1149 | srbcmd->flags = cpu_to_le32(flag); |
Jens Axboe | 242f9dc | 2008-09-14 05:55:09 -0700 | [diff] [blame] | 1150 | timeout = cmd->request->timeout/HZ; |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1151 | if (timeout == 0) |
| 1152 | timeout = 1; |
| 1153 | srbcmd->timeout = cpu_to_le32(timeout); // timeout in seconds |
| 1154 | srbcmd->retry_limit = 0; /* Obsolete parameter */ |
| 1155 | srbcmd->cdb_size = cpu_to_le32(cmd->cmd_len); |
| 1156 | return srbcmd; |
| 1157 | } |
| 1158 | |
| 1159 | static void aac_srb_callback(void *context, struct fib * fibptr); |
| 1160 | |
| 1161 | static int aac_scsi_64(struct fib * fib, struct scsi_cmnd * cmd) |
| 1162 | { |
| 1163 | u16 fibsize; |
| 1164 | struct aac_srb * srbcmd = aac_scsi_common(fib, cmd); |
| 1165 | |
| 1166 | aac_build_sg64(cmd, (struct sgmap64*) &srbcmd->sg); |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 1167 | srbcmd->count = cpu_to_le32(scsi_bufflen(cmd)); |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1168 | |
| 1169 | memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); |
| 1170 | memcpy(srbcmd->cdb, cmd->cmnd, cmd->cmd_len); |
| 1171 | /* |
| 1172 | * Build Scatter/Gather list |
| 1173 | */ |
| 1174 | fibsize = sizeof (struct aac_srb) - sizeof (struct sgentry) + |
| 1175 | ((le32_to_cpu(srbcmd->sg.count) & 0xff) * |
| 1176 | sizeof (struct sgentry64)); |
| 1177 | BUG_ON (fibsize > (fib->dev->max_fib_size - |
| 1178 | sizeof(struct aac_fibhdr))); |
| 1179 | |
| 1180 | /* |
| 1181 | * Now send the Fib to the adapter |
| 1182 | */ |
| 1183 | return aac_fib_send(ScsiPortCommand64, fib, |
| 1184 | fibsize, FsaNormal, 0, 1, |
| 1185 | (fib_callback) aac_srb_callback, |
| 1186 | (void *) cmd); |
| 1187 | } |
| 1188 | |
| 1189 | static int aac_scsi_32(struct fib * fib, struct scsi_cmnd * cmd) |
| 1190 | { |
| 1191 | u16 fibsize; |
| 1192 | struct aac_srb * srbcmd = aac_scsi_common(fib, cmd); |
| 1193 | |
| 1194 | aac_build_sg(cmd, (struct sgmap*)&srbcmd->sg); |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 1195 | srbcmd->count = cpu_to_le32(scsi_bufflen(cmd)); |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1196 | |
| 1197 | memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); |
| 1198 | memcpy(srbcmd->cdb, cmd->cmnd, cmd->cmd_len); |
| 1199 | /* |
| 1200 | * Build Scatter/Gather list |
| 1201 | */ |
| 1202 | fibsize = sizeof (struct aac_srb) + |
| 1203 | (((le32_to_cpu(srbcmd->sg.count) & 0xff) - 1) * |
| 1204 | sizeof (struct sgentry)); |
| 1205 | BUG_ON (fibsize > (fib->dev->max_fib_size - |
| 1206 | sizeof(struct aac_fibhdr))); |
| 1207 | |
| 1208 | /* |
| 1209 | * Now send the Fib to the adapter |
| 1210 | */ |
| 1211 | return aac_fib_send(ScsiPortCommand, fib, fibsize, FsaNormal, 0, 1, |
| 1212 | (fib_callback) aac_srb_callback, (void *) cmd); |
| 1213 | } |
| 1214 | |
Salyzyn, Mark | 94cf6ba | 2007-12-13 16:14:18 -0800 | [diff] [blame] | 1215 | static int aac_scsi_32_64(struct fib * fib, struct scsi_cmnd * cmd) |
| 1216 | { |
Leubner, Achim | d8e96507 | 2009-04-01 07:16:08 -0700 | [diff] [blame] | 1217 | if ((sizeof(dma_addr_t) > 4) && fib->dev->needs_dac && |
| 1218 | (fib->dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)) |
Salyzyn, Mark | 94cf6ba | 2007-12-13 16:14:18 -0800 | [diff] [blame] | 1219 | return FAILED; |
| 1220 | return aac_scsi_32(fib, cmd); |
| 1221 | } |
| 1222 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1223 | int aac_get_adapter_info(struct aac_dev* dev) |
| 1224 | { |
| 1225 | struct fib* fibptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1226 | int rcode; |
| 1227 | u32 tmp; |
Mark Haverkamp | 8497173 | 2005-06-20 11:55:24 -0700 | [diff] [blame] | 1228 | struct aac_adapter_info *info; |
| 1229 | struct aac_bus_info *command; |
| 1230 | struct aac_bus_info_response *bus_info; |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1231 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1232 | if (!(fibptr = aac_fib_alloc(dev))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1233 | return -ENOMEM; |
| 1234 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1235 | aac_fib_init(fibptr); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1236 | info = (struct aac_adapter_info *) fib_data(fibptr); |
| 1237 | memset(info,0,sizeof(*info)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1238 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1239 | rcode = aac_fib_send(RequestAdapterInfo, |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1240 | fibptr, |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1241 | sizeof(*info), |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1242 | FsaNormal, |
Mark Haverkamp | 9203344 | 2005-09-20 12:56:50 -0700 | [diff] [blame] | 1243 | -1, 1, /* First `interrupt' command uses special wait */ |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1244 | NULL, |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1245 | NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1246 | |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1247 | if (rcode < 0) { |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1248 | aac_fib_complete(fibptr); |
| 1249 | aac_fib_free(fibptr); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1250 | return rcode; |
| 1251 | } |
| 1252 | memcpy(&dev->adapter_info, info, sizeof(*info)); |
| 1253 | |
| 1254 | if (dev->adapter_info.options & AAC_OPT_SUPPLEMENT_ADAPTER_INFO) { |
Salyzyn, Mark | 06a43d1 | 2008-01-08 12:32:00 -0800 | [diff] [blame] | 1255 | struct aac_supplement_adapter_info * sinfo; |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1256 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1257 | aac_fib_init(fibptr); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1258 | |
Salyzyn, Mark | 06a43d1 | 2008-01-08 12:32:00 -0800 | [diff] [blame] | 1259 | sinfo = (struct aac_supplement_adapter_info *) fib_data(fibptr); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1260 | |
Salyzyn, Mark | 06a43d1 | 2008-01-08 12:32:00 -0800 | [diff] [blame] | 1261 | memset(sinfo,0,sizeof(*sinfo)); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1262 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1263 | rcode = aac_fib_send(RequestSupplementAdapterInfo, |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1264 | fibptr, |
Salyzyn, Mark | 06a43d1 | 2008-01-08 12:32:00 -0800 | [diff] [blame] | 1265 | sizeof(*sinfo), |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1266 | FsaNormal, |
| 1267 | 1, 1, |
| 1268 | NULL, |
| 1269 | NULL); |
| 1270 | |
| 1271 | if (rcode >= 0) |
Salyzyn, Mark | 06a43d1 | 2008-01-08 12:32:00 -0800 | [diff] [blame] | 1272 | memcpy(&dev->supplement_adapter_info, sinfo, sizeof(*sinfo)); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1273 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | |
Mark Haverkamp | 8497173 | 2005-06-20 11:55:24 -0700 | [diff] [blame] | 1275 | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1276 | /* |
| 1277 | * GetBusInfo |
Mark Haverkamp | 8497173 | 2005-06-20 11:55:24 -0700 | [diff] [blame] | 1278 | */ |
| 1279 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1280 | aac_fib_init(fibptr); |
Mark Haverkamp | 8497173 | 2005-06-20 11:55:24 -0700 | [diff] [blame] | 1281 | |
| 1282 | bus_info = (struct aac_bus_info_response *) fib_data(fibptr); |
| 1283 | |
| 1284 | memset(bus_info, 0, sizeof(*bus_info)); |
| 1285 | |
| 1286 | command = (struct aac_bus_info *)bus_info; |
| 1287 | |
| 1288 | command->Command = cpu_to_le32(VM_Ioctl); |
| 1289 | command->ObjType = cpu_to_le32(FT_DRIVE); |
| 1290 | command->MethodId = cpu_to_le32(1); |
| 1291 | command->CtlCmd = cpu_to_le32(GetBusInfo); |
| 1292 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1293 | rcode = aac_fib_send(ContainerCommand, |
Mark Haverkamp | 8497173 | 2005-06-20 11:55:24 -0700 | [diff] [blame] | 1294 | fibptr, |
| 1295 | sizeof (*bus_info), |
| 1296 | FsaNormal, |
| 1297 | 1, 1, |
| 1298 | NULL, NULL); |
| 1299 | |
Salyzyn, Mark | 94cf6ba | 2007-12-13 16:14:18 -0800 | [diff] [blame] | 1300 | /* reasoned default */ |
| 1301 | dev->maximum_num_physicals = 16; |
Mark Haverkamp | 8497173 | 2005-06-20 11:55:24 -0700 | [diff] [blame] | 1302 | if (rcode >= 0 && le32_to_cpu(bus_info->Status) == ST_OK) { |
| 1303 | dev->maximum_num_physicals = le32_to_cpu(bus_info->TargetsPerBus); |
| 1304 | dev->maximum_num_channels = le32_to_cpu(bus_info->BusCount); |
| 1305 | } |
| 1306 | |
Mark Haverkamp | 8c867b2 | 2006-08-03 08:03:30 -0700 | [diff] [blame] | 1307 | if (!dev->in_reset) { |
Salyzyn, Mark | 24f02e1 | 2007-06-19 16:29:24 -0400 | [diff] [blame] | 1308 | char buffer[16]; |
Mark Haverkamp | 8c867b2 | 2006-08-03 08:03:30 -0700 | [diff] [blame] | 1309 | tmp = le32_to_cpu(dev->adapter_info.kernelrev); |
| 1310 | printk(KERN_INFO "%s%d: kernel %d.%d-%d[%d] %.*s\n", |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1311 | dev->name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | dev->id, |
| 1313 | tmp>>24, |
| 1314 | (tmp>>16)&0xff, |
| 1315 | tmp&0xff, |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1316 | le32_to_cpu(dev->adapter_info.kernelbuild), |
| 1317 | (int)sizeof(dev->supplement_adapter_info.BuildDate), |
| 1318 | dev->supplement_adapter_info.BuildDate); |
Mark Haverkamp | 8c867b2 | 2006-08-03 08:03:30 -0700 | [diff] [blame] | 1319 | tmp = le32_to_cpu(dev->adapter_info.monitorrev); |
| 1320 | printk(KERN_INFO "%s%d: monitor %d.%d-%d[%d]\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1321 | dev->name, dev->id, |
| 1322 | tmp>>24,(tmp>>16)&0xff,tmp&0xff, |
| 1323 | le32_to_cpu(dev->adapter_info.monitorbuild)); |
Mark Haverkamp | 8c867b2 | 2006-08-03 08:03:30 -0700 | [diff] [blame] | 1324 | tmp = le32_to_cpu(dev->adapter_info.biosrev); |
| 1325 | printk(KERN_INFO "%s%d: bios %d.%d-%d[%d]\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1326 | dev->name, dev->id, |
| 1327 | tmp>>24,(tmp>>16)&0xff,tmp&0xff, |
| 1328 | le32_to_cpu(dev->adapter_info.biosbuild)); |
Salyzyn, Mark | 24f02e1 | 2007-06-19 16:29:24 -0400 | [diff] [blame] | 1329 | buffer[0] = '\0'; |
Tony Jones | ee959b0 | 2008-02-22 00:13:36 +0100 | [diff] [blame] | 1330 | if (aac_get_serial_number( |
Salyzyn, Mark | 24f02e1 | 2007-06-19 16:29:24 -0400 | [diff] [blame] | 1331 | shost_to_class(dev->scsi_host_ptr), buffer)) |
| 1332 | printk(KERN_INFO "%s%d: serial %s", |
| 1333 | dev->name, dev->id, buffer); |
Salyzyn, Mark | a45c863 | 2007-03-28 13:44:54 -0400 | [diff] [blame] | 1334 | if (dev->supplement_adapter_info.VpdInfo.Tsid[0]) { |
| 1335 | printk(KERN_INFO "%s%d: TSID %.*s\n", |
| 1336 | dev->name, dev->id, |
| 1337 | (int)sizeof(dev->supplement_adapter_info.VpdInfo.Tsid), |
| 1338 | dev->supplement_adapter_info.VpdInfo.Tsid); |
| 1339 | } |
Salyzyn, Mark | 2f7ecc5 | 2008-02-08 08:36:23 -0800 | [diff] [blame] | 1340 | if (!aac_check_reset || ((aac_check_reset == 1) && |
Salyzyn, Mark | a3940da | 2008-01-08 12:48:25 -0800 | [diff] [blame] | 1341 | (dev->supplement_adapter_info.SupportedOptions2 & |
| 1342 | AAC_OPTION_IGNORE_RESET))) { |
Salyzyn, Mark | 29c9768 | 2007-06-12 09:33:54 -0400 | [diff] [blame] | 1343 | printk(KERN_INFO "%s%d: Reset Adapter Ignored\n", |
| 1344 | dev->name, dev->id); |
| 1345 | } |
Mark Haverkamp | 8c867b2 | 2006-08-03 08:03:30 -0700 | [diff] [blame] | 1346 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | |
Salyzyn, Mark | 95e852e | 2008-01-08 12:01:07 -0800 | [diff] [blame] | 1348 | dev->cache_protected = 0; |
Salyzyn, Mark | cb1042f | 2008-01-17 09:25:07 -0800 | [diff] [blame] | 1349 | dev->jbod = ((dev->supplement_adapter_info.FeatureBits & |
| 1350 | AAC_FEATURE_JBOD) != 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1351 | dev->nondasd_support = 0; |
| 1352 | dev->raid_scsi_mode = 0; |
Salyzyn, Mark | 95e852e | 2008-01-08 12:01:07 -0800 | [diff] [blame] | 1353 | if(dev->adapter_info.options & AAC_OPT_NONDASD) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1354 | dev->nondasd_support = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1355 | |
| 1356 | /* |
| 1357 | * If the firmware supports ROMB RAID/SCSI mode and we are currently |
| 1358 | * in RAID/SCSI mode, set the flag. For now if in this mode we will |
| 1359 | * force nondasd support on. If we decide to allow the non-dasd flag |
| 1360 | * additional changes changes will have to be made to support |
| 1361 | * RAID/SCSI. the function aac_scsi_cmd in this module will have to be |
| 1362 | * changed to support the new dev->raid_scsi_mode flag instead of |
| 1363 | * leaching off of the dev->nondasd_support flag. Also in linit.c the |
| 1364 | * function aac_detect will have to be modified where it sets up the |
| 1365 | * max number of channels based on the aac->nondasd_support flag only. |
| 1366 | */ |
| 1367 | if ((dev->adapter_info.options & AAC_OPT_SCSI_MANAGED) && |
| 1368 | (dev->adapter_info.options & AAC_OPT_RAID_SCSI_MODE)) { |
| 1369 | dev->nondasd_support = 1; |
| 1370 | dev->raid_scsi_mode = 1; |
| 1371 | } |
| 1372 | if (dev->raid_scsi_mode != 0) |
| 1373 | printk(KERN_INFO "%s%d: ROMB RAID/SCSI mode enabled\n", |
| 1374 | dev->name, dev->id); |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1375 | |
Salyzyn, Mark | 95e852e | 2008-01-08 12:01:07 -0800 | [diff] [blame] | 1376 | if (nondasd != -1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1377 | dev->nondasd_support = (nondasd!=0); |
Salyzyn, Mark | 2f7ecc5 | 2008-02-08 08:36:23 -0800 | [diff] [blame] | 1378 | if (dev->nondasd_support && !dev->in_reset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1379 | printk(KERN_INFO "%s%d: Non-DASD support enabled.\n",dev->name, dev->id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1380 | |
Leubner, Achim | d8e96507 | 2009-04-01 07:16:08 -0700 | [diff] [blame] | 1381 | if (dma_get_required_mask(&dev->pdev->dev) > DMA_32BIT_MASK) |
| 1382 | dev->needs_dac = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1383 | dev->dac_support = 0; |
Leubner, Achim | d8e96507 | 2009-04-01 07:16:08 -0700 | [diff] [blame] | 1384 | if ((sizeof(dma_addr_t) > 4) && dev->needs_dac && |
| 1385 | (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)) { |
Salyzyn, Mark | 2f7ecc5 | 2008-02-08 08:36:23 -0800 | [diff] [blame] | 1386 | if (!dev->in_reset) |
| 1387 | printk(KERN_INFO "%s%d: 64bit support enabled.\n", |
| 1388 | dev->name, dev->id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1389 | dev->dac_support = 1; |
| 1390 | } |
| 1391 | |
| 1392 | if(dacmode != -1) { |
| 1393 | dev->dac_support = (dacmode!=0); |
| 1394 | } |
Leubner, Achim | d8e96507 | 2009-04-01 07:16:08 -0700 | [diff] [blame] | 1395 | |
| 1396 | /* avoid problems with AAC_QUIRK_SCSI_32 controllers */ |
| 1397 | if (dev->dac_support && (aac_get_driver_ident(dev->cardtype)->quirks |
| 1398 | & AAC_QUIRK_SCSI_32)) { |
| 1399 | dev->nondasd_support = 0; |
| 1400 | dev->jbod = 0; |
| 1401 | expose_physicals = 0; |
| 1402 | } |
| 1403 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | if(dev->dac_support != 0) { |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1405 | if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(64)) && |
| 1406 | !pci_set_consistent_dma_mask(dev->pdev, DMA_BIT_MASK(64))) { |
Salyzyn, Mark | 2f7ecc5 | 2008-02-08 08:36:23 -0800 | [diff] [blame] | 1407 | if (!dev->in_reset) |
| 1408 | printk(KERN_INFO"%s%d: 64 Bit DAC enabled\n", |
| 1409 | dev->name, dev->id); |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame^] | 1410 | } else if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(32)) && |
| 1411 | !pci_set_consistent_dma_mask(dev->pdev, DMA_BIT_MASK(32))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1412 | printk(KERN_INFO"%s%d: DMA mask set failed, 64 Bit DAC disabled\n", |
| 1413 | dev->name, dev->id); |
| 1414 | dev->dac_support = 0; |
| 1415 | } else { |
| 1416 | printk(KERN_WARNING"%s%d: No suitable DMA available.\n", |
| 1417 | dev->name, dev->id); |
| 1418 | rcode = -ENOMEM; |
| 1419 | } |
| 1420 | } |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1421 | /* |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1422 | * Deal with configuring for the individualized limits of each packet |
| 1423 | * interface. |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1424 | */ |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1425 | dev->a_ops.adapter_scsi = (dev->dac_support) |
Salyzyn, Mark | 94cf6ba | 2007-12-13 16:14:18 -0800 | [diff] [blame] | 1426 | ? ((aac_get_driver_ident(dev->cardtype)->quirks & AAC_QUIRK_SCSI_32) |
| 1427 | ? aac_scsi_32_64 |
| 1428 | : aac_scsi_64) |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1429 | : aac_scsi_32; |
| 1430 | if (dev->raw_io_interface) { |
| 1431 | dev->a_ops.adapter_bounds = (dev->raw_io_64) |
| 1432 | ? aac_bounds_64 |
| 1433 | : aac_bounds_32; |
| 1434 | dev->a_ops.adapter_read = aac_read_raw_io; |
| 1435 | dev->a_ops.adapter_write = aac_write_raw_io; |
| 1436 | } else { |
| 1437 | dev->a_ops.adapter_bounds = aac_bounds_32; |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 1438 | dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size - |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1439 | sizeof(struct aac_fibhdr) - |
Mark Haverkamp | 63a70ee | 2005-09-20 12:57:04 -0700 | [diff] [blame] | 1440 | sizeof(struct aac_write) + sizeof(struct sgentry)) / |
| 1441 | sizeof(struct sgentry); |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 1442 | if (dev->dac_support) { |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1443 | dev->a_ops.adapter_read = aac_read_block64; |
| 1444 | dev->a_ops.adapter_write = aac_write_block64; |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1445 | /* |
| 1446 | * 38 scatter gather elements |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 1447 | */ |
| 1448 | dev->scsi_host_ptr->sg_tablesize = |
| 1449 | (dev->max_fib_size - |
| 1450 | sizeof(struct aac_fibhdr) - |
| 1451 | sizeof(struct aac_write64) + |
Mark Haverkamp | 63a70ee | 2005-09-20 12:57:04 -0700 | [diff] [blame] | 1452 | sizeof(struct sgentry64)) / |
| 1453 | sizeof(struct sgentry64); |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1454 | } else { |
| 1455 | dev->a_ops.adapter_read = aac_read_block; |
| 1456 | dev->a_ops.adapter_write = aac_write_block; |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 1457 | } |
| 1458 | dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT; |
| 1459 | if(!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) { |
| 1460 | /* |
| 1461 | * Worst case size that could cause sg overflow when |
| 1462 | * we break up SG elements that are larger than 64KB. |
| 1463 | * Would be nice if we could tell the SCSI layer what |
| 1464 | * the maximum SG element size can be. Worst case is |
| 1465 | * (sg_tablesize-1) 4KB elements with one 64KB |
| 1466 | * element. |
| 1467 | * 32bit -> 468 or 238KB 64bit -> 424 or 212KB |
| 1468 | */ |
| 1469 | dev->scsi_host_ptr->max_sectors = |
| 1470 | (dev->scsi_host_ptr->sg_tablesize * 8) + 112; |
| 1471 | } |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1472 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1474 | aac_fib_complete(fibptr); |
| 1475 | aac_fib_free(fibptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | |
| 1477 | return rcode; |
| 1478 | } |
| 1479 | |
| 1480 | |
Mark Haverkamp | e53cb35 | 2005-08-03 15:39:09 -0700 | [diff] [blame] | 1481 | static void io_callback(void *context, struct fib * fibptr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1482 | { |
| 1483 | struct aac_dev *dev; |
| 1484 | struct aac_read_reply *readreply; |
| 1485 | struct scsi_cmnd *scsicmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | u32 cid; |
| 1487 | |
| 1488 | scsicmd = (struct scsi_cmnd *) context; |
| 1489 | |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 1490 | if (!aac_valid_context(scsicmd, fibptr)) |
| 1491 | return; |
| 1492 | |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 1493 | dev = fibptr->dev; |
Mark Haverkamp | e571877 | 2006-03-27 09:43:25 -0800 | [diff] [blame] | 1494 | cid = scmd_id(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1495 | |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1496 | if (nblank(dprintk(x))) { |
| 1497 | u64 lba; |
| 1498 | switch (scsicmd->cmnd[0]) { |
| 1499 | case WRITE_6: |
| 1500 | case READ_6: |
| 1501 | lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | |
| 1502 | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; |
| 1503 | break; |
| 1504 | case WRITE_16: |
| 1505 | case READ_16: |
| 1506 | lba = ((u64)scsicmd->cmnd[2] << 56) | |
| 1507 | ((u64)scsicmd->cmnd[3] << 48) | |
| 1508 | ((u64)scsicmd->cmnd[4] << 40) | |
| 1509 | ((u64)scsicmd->cmnd[5] << 32) | |
| 1510 | ((u64)scsicmd->cmnd[6] << 24) | |
| 1511 | (scsicmd->cmnd[7] << 16) | |
| 1512 | (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; |
| 1513 | break; |
| 1514 | case WRITE_12: |
| 1515 | case READ_12: |
| 1516 | lba = ((u64)scsicmd->cmnd[2] << 24) | |
| 1517 | (scsicmd->cmnd[3] << 16) | |
| 1518 | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; |
| 1519 | break; |
| 1520 | default: |
| 1521 | lba = ((u64)scsicmd->cmnd[2] << 24) | |
| 1522 | (scsicmd->cmnd[3] << 16) | |
| 1523 | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; |
| 1524 | break; |
| 1525 | } |
| 1526 | printk(KERN_DEBUG |
| 1527 | "io_callback[cpu %d]: lba = %llu, t = %ld.\n", |
| 1528 | smp_processor_id(), (unsigned long long)lba, jiffies); |
| 1529 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | |
Eric Sesterhenn | 125e187 | 2006-06-23 02:06:06 -0700 | [diff] [blame] | 1531 | BUG_ON(fibptr == NULL); |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 1532 | |
| 1533 | scsi_dma_unmap(scsicmd); |
| 1534 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1535 | readreply = (struct aac_read_reply *)fib_data(fibptr); |
Mark Salyzyn | 655d722 | 2008-04-30 16:03:42 -0400 | [diff] [blame] | 1536 | switch (le32_to_cpu(readreply->status)) { |
| 1537 | case ST_OK: |
| 1538 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | |
| 1539 | SAM_STAT_GOOD; |
| 1540 | dev->fsa_dev[cid].sense_data.sense_key = NO_SENSE; |
| 1541 | break; |
| 1542 | case ST_NOT_READY: |
| 1543 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | |
| 1544 | SAM_STAT_CHECK_CONDITION; |
| 1545 | set_sense(&dev->fsa_dev[cid].sense_data, NOT_READY, |
| 1546 | SENCODE_BECOMING_READY, ASENCODE_BECOMING_READY, 0, 0); |
| 1547 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, |
| 1548 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), |
| 1549 | SCSI_SENSE_BUFFERSIZE)); |
| 1550 | break; |
| 1551 | default: |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1552 | #ifdef AAC_DETAILED_STATUS_INFO |
Mark Haverkamp | e53cb35 | 2005-08-03 15:39:09 -0700 | [diff] [blame] | 1553 | printk(KERN_WARNING "io_callback: io failed, status = %d\n", |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1554 | le32_to_cpu(readreply->status)); |
| 1555 | #endif |
Mark Salyzyn | 655d722 | 2008-04-30 16:03:42 -0400 | [diff] [blame] | 1556 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | |
| 1557 | SAM_STAT_CHECK_CONDITION; |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 1558 | set_sense(&dev->fsa_dev[cid].sense_data, |
| 1559 | HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, |
| 1560 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, |
Salyzyn, Mark | 3ace426 | 2008-01-14 07:25:33 -0800 | [diff] [blame] | 1562 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), |
| 1563 | SCSI_SENSE_BUFFERSIZE)); |
Mark Salyzyn | 655d722 | 2008-04-30 16:03:42 -0400 | [diff] [blame] | 1564 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1565 | } |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1566 | aac_fib_complete(fibptr); |
| 1567 | aac_fib_free(fibptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1568 | |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 1569 | scsicmd->scsi_done(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1570 | } |
| 1571 | |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 1572 | static int aac_read(struct scsi_cmnd * scsicmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1573 | { |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1574 | u64 lba; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1575 | u32 count; |
| 1576 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1577 | struct aac_dev *dev; |
| 1578 | struct fib * cmd_fibcontext; |
| 1579 | |
| 1580 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
| 1581 | /* |
| 1582 | * Get block address and transfer length |
| 1583 | */ |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1584 | switch (scsicmd->cmnd[0]) { |
| 1585 | case READ_6: |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 1586 | dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", scmd_id(scsicmd))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1587 | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1588 | lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1589 | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1590 | count = scsicmd->cmnd[4]; |
| 1591 | |
| 1592 | if (count == 0) |
| 1593 | count = 256; |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1594 | break; |
| 1595 | case READ_16: |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 1596 | dprintk((KERN_DEBUG "aachba: received a read(16) command on id %d.\n", scmd_id(scsicmd))); |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1597 | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1598 | lba = ((u64)scsicmd->cmnd[2] << 56) | |
| 1599 | ((u64)scsicmd->cmnd[3] << 48) | |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1600 | ((u64)scsicmd->cmnd[4] << 40) | |
| 1601 | ((u64)scsicmd->cmnd[5] << 32) | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1602 | ((u64)scsicmd->cmnd[6] << 24) | |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1603 | (scsicmd->cmnd[7] << 16) | |
| 1604 | (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1605 | count = (scsicmd->cmnd[10] << 24) | |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1606 | (scsicmd->cmnd[11] << 16) | |
| 1607 | (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13]; |
| 1608 | break; |
| 1609 | case READ_12: |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 1610 | dprintk((KERN_DEBUG "aachba: received a read(12) command on id %d.\n", scmd_id(scsicmd))); |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1611 | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1612 | lba = ((u64)scsicmd->cmnd[2] << 24) | |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1613 | (scsicmd->cmnd[3] << 16) | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1614 | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; |
| 1615 | count = (scsicmd->cmnd[6] << 24) | |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1616 | (scsicmd->cmnd[7] << 16) | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1617 | (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1618 | break; |
| 1619 | default: |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 1620 | dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", scmd_id(scsicmd))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1622 | lba = ((u64)scsicmd->cmnd[2] << 24) | |
| 1623 | (scsicmd->cmnd[3] << 16) | |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1624 | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1625 | count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1626 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | } |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1628 | dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %llu, t = %ld.\n", |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1629 | smp_processor_id(), (unsigned long long)lba, jiffies)); |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1630 | if (aac_adapter_bounds(dev,scsicmd,lba)) |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1631 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1632 | /* |
| 1633 | * Alocate and initialize a Fib |
| 1634 | */ |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1635 | if (!(cmd_fibcontext = aac_fib_alloc(dev))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1636 | return -1; |
| 1637 | } |
| 1638 | |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1639 | status = aac_adapter_read(cmd_fibcontext, scsicmd, lba, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1640 | |
| 1641 | /* |
| 1642 | * Check that the command queued to the controller |
| 1643 | */ |
Mark Haverkamp | 77d644d | 2006-03-27 09:43:40 -0800 | [diff] [blame] | 1644 | if (status == -EINPROGRESS) { |
| 1645 | scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | return 0; |
Mark Haverkamp | 77d644d | 2006-03-27 09:43:40 -0800 | [diff] [blame] | 1647 | } |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1648 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1649 | printk(KERN_WARNING "aac_read: aac_fib_send failed with status: %d.\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1650 | /* |
| 1651 | * For some reason, the Fib didn't queue, return QUEUE_FULL |
| 1652 | */ |
| 1653 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_TASK_SET_FULL; |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 1654 | scsicmd->scsi_done(scsicmd); |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1655 | aac_fib_complete(cmd_fibcontext); |
| 1656 | aac_fib_free(cmd_fibcontext); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1657 | return 0; |
| 1658 | } |
| 1659 | |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 1660 | static int aac_write(struct scsi_cmnd * scsicmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1661 | { |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1662 | u64 lba; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1663 | u32 count; |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 1664 | int fua; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1665 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1666 | struct aac_dev *dev; |
| 1667 | struct fib * cmd_fibcontext; |
| 1668 | |
| 1669 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
| 1670 | /* |
| 1671 | * Get block address and transfer length |
| 1672 | */ |
| 1673 | if (scsicmd->cmnd[0] == WRITE_6) /* 6 byte command */ |
| 1674 | { |
| 1675 | lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; |
| 1676 | count = scsicmd->cmnd[4]; |
| 1677 | if (count == 0) |
| 1678 | count = 256; |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 1679 | fua = 0; |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1680 | } else if (scsicmd->cmnd[0] == WRITE_16) { /* 16 byte command */ |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 1681 | dprintk((KERN_DEBUG "aachba: received a write(16) command on id %d.\n", scmd_id(scsicmd))); |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1682 | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1683 | lba = ((u64)scsicmd->cmnd[2] << 56) | |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1684 | ((u64)scsicmd->cmnd[3] << 48) | |
| 1685 | ((u64)scsicmd->cmnd[4] << 40) | |
| 1686 | ((u64)scsicmd->cmnd[5] << 32) | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1687 | ((u64)scsicmd->cmnd[6] << 24) | |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1688 | (scsicmd->cmnd[7] << 16) | |
| 1689 | (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; |
| 1690 | count = (scsicmd->cmnd[10] << 24) | (scsicmd->cmnd[11] << 16) | |
| 1691 | (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13]; |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 1692 | fua = scsicmd->cmnd[1] & 0x8; |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1693 | } else if (scsicmd->cmnd[0] == WRITE_12) { /* 12 byte command */ |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 1694 | dprintk((KERN_DEBUG "aachba: received a write(12) command on id %d.\n", scmd_id(scsicmd))); |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1695 | |
| 1696 | lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) |
| 1697 | | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; |
| 1698 | count = (scsicmd->cmnd[6] << 24) | (scsicmd->cmnd[7] << 16) |
| 1699 | | (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9]; |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 1700 | fua = scsicmd->cmnd[1] & 0x8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1701 | } else { |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 1702 | dprintk((KERN_DEBUG "aachba: received a write(10) command on id %d.\n", scmd_id(scsicmd))); |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1703 | lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1704 | count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 1705 | fua = scsicmd->cmnd[1] & 0x8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1706 | } |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1707 | dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %llu, t = %ld.\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1708 | smp_processor_id(), (unsigned long long)lba, jiffies)); |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 1709 | if (aac_adapter_bounds(dev,scsicmd,lba)) |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 1710 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1711 | /* |
| 1712 | * Allocate and initialize a Fib then setup a BlockWrite command |
| 1713 | */ |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1714 | if (!(cmd_fibcontext = aac_fib_alloc(dev))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1715 | scsicmd->result = DID_ERROR << 16; |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 1716 | scsicmd->scsi_done(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1717 | return 0; |
| 1718 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1719 | |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 1720 | status = aac_adapter_write(cmd_fibcontext, scsicmd, lba, count, fua); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1721 | |
| 1722 | /* |
| 1723 | * Check that the command queued to the controller |
| 1724 | */ |
Mark Haverkamp | 77d644d | 2006-03-27 09:43:40 -0800 | [diff] [blame] | 1725 | if (status == -EINPROGRESS) { |
| 1726 | scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1727 | return 0; |
| 1728 | } |
| 1729 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1730 | printk(KERN_WARNING "aac_write: aac_fib_send failed with status: %d\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1731 | /* |
| 1732 | * For some reason, the Fib didn't queue, return QUEUE_FULL |
| 1733 | */ |
| 1734 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_TASK_SET_FULL; |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 1735 | scsicmd->scsi_done(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1736 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1737 | aac_fib_complete(cmd_fibcontext); |
| 1738 | aac_fib_free(cmd_fibcontext); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1739 | return 0; |
| 1740 | } |
| 1741 | |
| 1742 | static void synchronize_callback(void *context, struct fib *fibptr) |
| 1743 | { |
| 1744 | struct aac_synchronize_reply *synchronizereply; |
| 1745 | struct scsi_cmnd *cmd; |
| 1746 | |
| 1747 | cmd = context; |
| 1748 | |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 1749 | if (!aac_valid_context(cmd, fibptr)) |
| 1750 | return; |
| 1751 | |
Salyzyn, Mark | b90f90d | 2007-07-27 09:48:49 -0400 | [diff] [blame] | 1752 | dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1753 | smp_processor_id(), jiffies)); |
| 1754 | BUG_ON(fibptr == NULL); |
| 1755 | |
| 1756 | |
| 1757 | synchronizereply = fib_data(fibptr); |
| 1758 | if (le32_to_cpu(synchronizereply->status) == CT_OK) |
Salyzyn, Mark | b90f90d | 2007-07-27 09:48:49 -0400 | [diff] [blame] | 1759 | cmd->result = DID_OK << 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1760 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 1761 | else { |
| 1762 | struct scsi_device *sdev = cmd->device; |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 1763 | struct aac_dev *dev = fibptr->dev; |
Mark Haverkamp | e571877 | 2006-03-27 09:43:25 -0800 | [diff] [blame] | 1764 | u32 cid = sdev_id(sdev); |
Salyzyn, Mark | b90f90d | 2007-07-27 09:48:49 -0400 | [diff] [blame] | 1765 | printk(KERN_WARNING |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1766 | "synchronize_callback: synchronize failed, status = %d\n", |
| 1767 | le32_to_cpu(synchronizereply->status)); |
Salyzyn, Mark | b90f90d | 2007-07-27 09:48:49 -0400 | [diff] [blame] | 1768 | cmd->result = DID_OK << 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1769 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 1770 | set_sense(&dev->fsa_dev[cid].sense_data, |
| 1771 | HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, |
| 1772 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1773 | memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, |
FUJITA Tomonori | b80ca4f | 2008-01-13 15:46:13 +0900 | [diff] [blame] | 1774 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), |
| 1775 | SCSI_SENSE_BUFFERSIZE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1776 | } |
| 1777 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1778 | aac_fib_complete(fibptr); |
| 1779 | aac_fib_free(fibptr); |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 1780 | cmd->scsi_done(cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1781 | } |
| 1782 | |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 1783 | static int aac_synchronize(struct scsi_cmnd *scsicmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1784 | { |
| 1785 | int status; |
| 1786 | struct fib *cmd_fibcontext; |
| 1787 | struct aac_synchronize *synchronizecmd; |
| 1788 | struct scsi_cmnd *cmd; |
| 1789 | struct scsi_device *sdev = scsicmd->device; |
| 1790 | int active = 0; |
Mark Haverkamp | 90ee346 | 2006-08-03 08:03:07 -0700 | [diff] [blame] | 1791 | struct aac_dev *aac; |
Salyzyn, Mark | b90f90d | 2007-07-27 09:48:49 -0400 | [diff] [blame] | 1792 | u64 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | |
| 1793 | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; |
| 1794 | u32 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1795 | unsigned long flags; |
| 1796 | |
| 1797 | /* |
Mark Haverkamp | 77d644d | 2006-03-27 09:43:40 -0800 | [diff] [blame] | 1798 | * Wait for all outstanding queued commands to complete to this |
| 1799 | * specific target (block). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1800 | */ |
| 1801 | spin_lock_irqsave(&sdev->list_lock, flags); |
| 1802 | list_for_each_entry(cmd, &sdev->cmd_list, list) |
Salyzyn, Mark | b90f90d | 2007-07-27 09:48:49 -0400 | [diff] [blame] | 1803 | if (cmd->SCp.phase == AAC_OWNER_FIRMWARE) { |
| 1804 | u64 cmnd_lba; |
| 1805 | u32 cmnd_count; |
| 1806 | |
| 1807 | if (cmd->cmnd[0] == WRITE_6) { |
| 1808 | cmnd_lba = ((cmd->cmnd[1] & 0x1F) << 16) | |
| 1809 | (cmd->cmnd[2] << 8) | |
| 1810 | cmd->cmnd[3]; |
| 1811 | cmnd_count = cmd->cmnd[4]; |
| 1812 | if (cmnd_count == 0) |
| 1813 | cmnd_count = 256; |
| 1814 | } else if (cmd->cmnd[0] == WRITE_16) { |
| 1815 | cmnd_lba = ((u64)cmd->cmnd[2] << 56) | |
| 1816 | ((u64)cmd->cmnd[3] << 48) | |
| 1817 | ((u64)cmd->cmnd[4] << 40) | |
| 1818 | ((u64)cmd->cmnd[5] << 32) | |
| 1819 | ((u64)cmd->cmnd[6] << 24) | |
| 1820 | (cmd->cmnd[7] << 16) | |
| 1821 | (cmd->cmnd[8] << 8) | |
| 1822 | cmd->cmnd[9]; |
| 1823 | cmnd_count = (cmd->cmnd[10] << 24) | |
| 1824 | (cmd->cmnd[11] << 16) | |
| 1825 | (cmd->cmnd[12] << 8) | |
| 1826 | cmd->cmnd[13]; |
| 1827 | } else if (cmd->cmnd[0] == WRITE_12) { |
| 1828 | cmnd_lba = ((u64)cmd->cmnd[2] << 24) | |
| 1829 | (cmd->cmnd[3] << 16) | |
| 1830 | (cmd->cmnd[4] << 8) | |
| 1831 | cmd->cmnd[5]; |
| 1832 | cmnd_count = (cmd->cmnd[6] << 24) | |
| 1833 | (cmd->cmnd[7] << 16) | |
| 1834 | (cmd->cmnd[8] << 8) | |
| 1835 | cmd->cmnd[9]; |
| 1836 | } else if (cmd->cmnd[0] == WRITE_10) { |
| 1837 | cmnd_lba = ((u64)cmd->cmnd[2] << 24) | |
| 1838 | (cmd->cmnd[3] << 16) | |
| 1839 | (cmd->cmnd[4] << 8) | |
| 1840 | cmd->cmnd[5]; |
| 1841 | cmnd_count = (cmd->cmnd[7] << 8) | |
| 1842 | cmd->cmnd[8]; |
| 1843 | } else |
| 1844 | continue; |
| 1845 | if (((cmnd_lba + cmnd_count) < lba) || |
| 1846 | (count && ((lba + count) < cmnd_lba))) |
| 1847 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1848 | ++active; |
| 1849 | break; |
| 1850 | } |
| 1851 | |
| 1852 | spin_unlock_irqrestore(&sdev->list_lock, flags); |
| 1853 | |
| 1854 | /* |
| 1855 | * Yield the processor (requeue for later) |
| 1856 | */ |
| 1857 | if (active) |
| 1858 | return SCSI_MLQUEUE_DEVICE_BUSY; |
| 1859 | |
Salyzyn, Mark | f858317 | 2007-10-30 15:50:49 -0400 | [diff] [blame] | 1860 | aac = (struct aac_dev *)sdev->host->hostdata; |
Mark Haverkamp | 8c867b2 | 2006-08-03 08:03:30 -0700 | [diff] [blame] | 1861 | if (aac->in_reset) |
| 1862 | return SCSI_MLQUEUE_HOST_BUSY; |
| 1863 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1864 | /* |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 1865 | * Allocate and initialize a Fib |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1866 | */ |
Mark Haverkamp | 90ee346 | 2006-08-03 08:03:07 -0700 | [diff] [blame] | 1867 | if (!(cmd_fibcontext = aac_fib_alloc(aac))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1868 | return SCSI_MLQUEUE_HOST_BUSY; |
| 1869 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1870 | aac_fib_init(cmd_fibcontext); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1871 | |
| 1872 | synchronizecmd = fib_data(cmd_fibcontext); |
| 1873 | synchronizecmd->command = cpu_to_le32(VM_ContainerConfig); |
| 1874 | synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE); |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 1875 | synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd)); |
Salyzyn, Mark | b90f90d | 2007-07-27 09:48:49 -0400 | [diff] [blame] | 1876 | synchronizecmd->count = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1877 | cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data)); |
| 1878 | |
| 1879 | /* |
| 1880 | * Now send the Fib to the adapter |
| 1881 | */ |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1882 | status = aac_fib_send(ContainerCommand, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1883 | cmd_fibcontext, |
| 1884 | sizeof(struct aac_synchronize), |
| 1885 | FsaNormal, |
| 1886 | 0, 1, |
| 1887 | (fib_callback)synchronize_callback, |
| 1888 | (void *)scsicmd); |
| 1889 | |
| 1890 | /* |
| 1891 | * Check that the command queued to the controller |
| 1892 | */ |
Mark Haverkamp | 77d644d | 2006-03-27 09:43:40 -0800 | [diff] [blame] | 1893 | if (status == -EINPROGRESS) { |
| 1894 | scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1895 | return 0; |
Mark Haverkamp | 77d644d | 2006-03-27 09:43:40 -0800 | [diff] [blame] | 1896 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1897 | |
Salyzyn, Mark | b90f90d | 2007-07-27 09:48:49 -0400 | [diff] [blame] | 1898 | printk(KERN_WARNING |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 1899 | "aac_synchronize: aac_fib_send failed with status: %d.\n", status); |
| 1900 | aac_fib_complete(cmd_fibcontext); |
| 1901 | aac_fib_free(cmd_fibcontext); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1902 | return SCSI_MLQUEUE_HOST_BUSY; |
| 1903 | } |
| 1904 | |
Mark Salyzyn | 655d722 | 2008-04-30 16:03:42 -0400 | [diff] [blame] | 1905 | static void aac_start_stop_callback(void *context, struct fib *fibptr) |
| 1906 | { |
| 1907 | struct scsi_cmnd *scsicmd = context; |
| 1908 | |
| 1909 | if (!aac_valid_context(scsicmd, fibptr)) |
| 1910 | return; |
| 1911 | |
| 1912 | BUG_ON(fibptr == NULL); |
| 1913 | |
| 1914 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 1915 | |
| 1916 | aac_fib_complete(fibptr); |
| 1917 | aac_fib_free(fibptr); |
| 1918 | scsicmd->scsi_done(scsicmd); |
| 1919 | } |
| 1920 | |
| 1921 | static int aac_start_stop(struct scsi_cmnd *scsicmd) |
| 1922 | { |
| 1923 | int status; |
| 1924 | struct fib *cmd_fibcontext; |
| 1925 | struct aac_power_management *pmcmd; |
| 1926 | struct scsi_device *sdev = scsicmd->device; |
| 1927 | struct aac_dev *aac = (struct aac_dev *)sdev->host->hostdata; |
| 1928 | |
| 1929 | if (!(aac->supplement_adapter_info.SupportedOptions2 & |
| 1930 | AAC_OPTION_POWER_MANAGEMENT)) { |
| 1931 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | |
| 1932 | SAM_STAT_GOOD; |
| 1933 | scsicmd->scsi_done(scsicmd); |
| 1934 | return 0; |
| 1935 | } |
| 1936 | |
| 1937 | if (aac->in_reset) |
| 1938 | return SCSI_MLQUEUE_HOST_BUSY; |
| 1939 | |
| 1940 | /* |
| 1941 | * Allocate and initialize a Fib |
| 1942 | */ |
| 1943 | cmd_fibcontext = aac_fib_alloc(aac); |
| 1944 | if (!cmd_fibcontext) |
| 1945 | return SCSI_MLQUEUE_HOST_BUSY; |
| 1946 | |
| 1947 | aac_fib_init(cmd_fibcontext); |
| 1948 | |
| 1949 | pmcmd = fib_data(cmd_fibcontext); |
| 1950 | pmcmd->command = cpu_to_le32(VM_ContainerConfig); |
| 1951 | pmcmd->type = cpu_to_le32(CT_POWER_MANAGEMENT); |
| 1952 | /* Eject bit ignored, not relevant */ |
| 1953 | pmcmd->sub = (scsicmd->cmnd[4] & 1) ? |
| 1954 | cpu_to_le32(CT_PM_START_UNIT) : cpu_to_le32(CT_PM_STOP_UNIT); |
| 1955 | pmcmd->cid = cpu_to_le32(sdev_id(sdev)); |
| 1956 | pmcmd->parm = (scsicmd->cmnd[1] & 1) ? |
| 1957 | cpu_to_le32(CT_PM_UNIT_IMMEDIATE) : 0; |
| 1958 | |
| 1959 | /* |
| 1960 | * Now send the Fib to the adapter |
| 1961 | */ |
| 1962 | status = aac_fib_send(ContainerCommand, |
| 1963 | cmd_fibcontext, |
| 1964 | sizeof(struct aac_power_management), |
| 1965 | FsaNormal, |
| 1966 | 0, 1, |
| 1967 | (fib_callback)aac_start_stop_callback, |
| 1968 | (void *)scsicmd); |
| 1969 | |
| 1970 | /* |
| 1971 | * Check that the command queued to the controller |
| 1972 | */ |
| 1973 | if (status == -EINPROGRESS) { |
| 1974 | scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; |
| 1975 | return 0; |
| 1976 | } |
| 1977 | |
| 1978 | aac_fib_complete(cmd_fibcontext); |
| 1979 | aac_fib_free(cmd_fibcontext); |
| 1980 | return SCSI_MLQUEUE_HOST_BUSY; |
| 1981 | } |
| 1982 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1983 | /** |
| 1984 | * aac_scsi_cmd() - Process SCSI command |
| 1985 | * @scsicmd: SCSI command block |
| 1986 | * |
| 1987 | * Emulate a SCSI command and queue the required request for the |
| 1988 | * aacraid firmware. |
| 1989 | */ |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1990 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1991 | int aac_scsi_cmd(struct scsi_cmnd * scsicmd) |
| 1992 | { |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 1993 | u32 cid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1994 | struct Scsi_Host *host = scsicmd->device->host; |
| 1995 | struct aac_dev *dev = (struct aac_dev *)host->hostdata; |
| 1996 | struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev; |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 1997 | |
Mark Haverkamp | 90ee346 | 2006-08-03 08:03:07 -0700 | [diff] [blame] | 1998 | if (fsa_dev_ptr == NULL) |
| 1999 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2000 | /* |
| 2001 | * If the bus, id or lun is out of range, return fail |
| 2002 | * Test does not apply to ID 16, the pseudo id for the controller |
| 2003 | * itself. |
| 2004 | */ |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 2005 | cid = scmd_id(scsicmd); |
| 2006 | if (cid != host->this_id) { |
| 2007 | if (scmd_channel(scsicmd) == CONTAINER_CHANNEL) { |
| 2008 | if((cid >= dev->maximum_num_containers) || |
Mark Haverkamp | e571877 | 2006-03-27 09:43:25 -0800 | [diff] [blame] | 2009 | (scsicmd->device->lun != 0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2010 | scsicmd->result = DID_NO_CONNECT << 16; |
| 2011 | scsicmd->scsi_done(scsicmd); |
| 2012 | return 0; |
| 2013 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2014 | |
| 2015 | /* |
| 2016 | * If the target container doesn't exist, it may have |
| 2017 | * been newly created |
| 2018 | */ |
Mark Salyzyn | 655d722 | 2008-04-30 16:03:42 -0400 | [diff] [blame] | 2019 | if (((fsa_dev_ptr[cid].valid & 1) == 0) || |
| 2020 | (fsa_dev_ptr[cid].sense_data.sense_key == |
| 2021 | NOT_READY)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2022 | switch (scsicmd->cmnd[0]) { |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2023 | case SERVICE_ACTION_IN: |
| 2024 | if (!(dev->raw_io_interface) || |
| 2025 | !(dev->raw_io_64) || |
| 2026 | ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16)) |
| 2027 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2028 | case INQUIRY: |
| 2029 | case READ_CAPACITY: |
| 2030 | case TEST_UNIT_READY: |
Mark Haverkamp | 8c867b2 | 2006-08-03 08:03:30 -0700 | [diff] [blame] | 2031 | if (dev->in_reset) |
| 2032 | return -1; |
Mark Haverkamp | fe76df4 | 2007-03-15 12:55:07 -0700 | [diff] [blame] | 2033 | return _aac_probe_container(scsicmd, |
| 2034 | aac_probe_container_callback2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2035 | default: |
| 2036 | break; |
| 2037 | } |
| 2038 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2039 | } else { /* check for physical non-dasd devices */ |
Salyzyn, Mark | cb1042f | 2008-01-17 09:25:07 -0800 | [diff] [blame] | 2040 | if (dev->nondasd_support || expose_physicals || |
| 2041 | dev->jbod) { |
Mark Haverkamp | 8c867b2 | 2006-08-03 08:03:30 -0700 | [diff] [blame] | 2042 | if (dev->in_reset) |
| 2043 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2044 | return aac_send_srb_fib(scsicmd); |
| 2045 | } else { |
| 2046 | scsicmd->result = DID_NO_CONNECT << 16; |
| 2047 | scsicmd->scsi_done(scsicmd); |
| 2048 | return 0; |
| 2049 | } |
| 2050 | } |
| 2051 | } |
| 2052 | /* |
| 2053 | * else Command for the controller itself |
| 2054 | */ |
| 2055 | else if ((scsicmd->cmnd[0] != INQUIRY) && /* only INQUIRY & TUR cmnd supported for controller */ |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 2056 | (scsicmd->cmnd[0] != TEST_UNIT_READY)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2057 | { |
| 2058 | dprintk((KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->cmnd[0])); |
| 2059 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 2060 | set_sense(&dev->fsa_dev[cid].sense_data, |
| 2061 | ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND, |
| 2062 | ASENCODE_INVALID_COMMAND, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2063 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, |
Salyzyn, Mark | 3ace426 | 2008-01-14 07:25:33 -0800 | [diff] [blame] | 2064 | min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), |
| 2065 | SCSI_SENSE_BUFFERSIZE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2066 | scsicmd->scsi_done(scsicmd); |
| 2067 | return 0; |
| 2068 | } |
| 2069 | |
| 2070 | |
| 2071 | /* Handle commands here that don't really require going out to the adapter */ |
| 2072 | switch (scsicmd->cmnd[0]) { |
| 2073 | case INQUIRY: |
| 2074 | { |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 2075 | struct inquiry_data inq_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2076 | |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 2077 | dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", cid)); |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 2078 | memset(&inq_data, 0, sizeof (struct inquiry_data)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2079 | |
Leubner, Achim | d8e96507 | 2009-04-01 07:16:08 -0700 | [diff] [blame] | 2080 | if ((scsicmd->cmnd[1] & 0x1) && aac_wwn) { |
Salyzyn, Mark | 88e2f98 | 2007-07-17 14:01:28 -0400 | [diff] [blame] | 2081 | char *arr = (char *)&inq_data; |
| 2082 | |
| 2083 | /* EVPD bit set */ |
| 2084 | arr[0] = (scmd_id(scsicmd) == host->this_id) ? |
| 2085 | INQD_PDT_PROC : INQD_PDT_DA; |
| 2086 | if (scsicmd->cmnd[2] == 0) { |
| 2087 | /* supported vital product data pages */ |
| 2088 | arr[3] = 2; |
| 2089 | arr[4] = 0x0; |
| 2090 | arr[5] = 0x80; |
| 2091 | arr[1] = scsicmd->cmnd[2]; |
FUJITA Tomonori | d434502 | 2008-03-09 13:44:34 +0900 | [diff] [blame] | 2092 | scsi_sg_copy_from_buffer(scsicmd, &inq_data, |
| 2093 | sizeof(inq_data)); |
Salyzyn, Mark | 88e2f98 | 2007-07-17 14:01:28 -0400 | [diff] [blame] | 2094 | scsicmd->result = DID_OK << 16 | |
| 2095 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 2096 | } else if (scsicmd->cmnd[2] == 0x80) { |
| 2097 | /* unit serial number page */ |
| 2098 | arr[3] = setinqserial(dev, &arr[4], |
| 2099 | scmd_id(scsicmd)); |
| 2100 | arr[1] = scsicmd->cmnd[2]; |
FUJITA Tomonori | d434502 | 2008-03-09 13:44:34 +0900 | [diff] [blame] | 2101 | scsi_sg_copy_from_buffer(scsicmd, &inq_data, |
| 2102 | sizeof(inq_data)); |
Leubner, Achim | d8e96507 | 2009-04-01 07:16:08 -0700 | [diff] [blame] | 2103 | if (aac_wwn != 2) |
| 2104 | return aac_get_container_serial( |
| 2105 | scsicmd); |
| 2106 | /* SLES 10 SP1 special */ |
| 2107 | scsicmd->result = DID_OK << 16 | |
| 2108 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
Salyzyn, Mark | 88e2f98 | 2007-07-17 14:01:28 -0400 | [diff] [blame] | 2109 | } else { |
| 2110 | /* vpd page not implemented */ |
| 2111 | scsicmd->result = DID_OK << 16 | |
| 2112 | COMMAND_COMPLETE << 8 | |
| 2113 | SAM_STAT_CHECK_CONDITION; |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 2114 | set_sense(&dev->fsa_dev[cid].sense_data, |
| 2115 | ILLEGAL_REQUEST, SENCODE_INVALID_CDB_FIELD, |
| 2116 | ASENCODE_NO_SENSE, 7, 2); |
Salyzyn, Mark | 88e2f98 | 2007-07-17 14:01:28 -0400 | [diff] [blame] | 2117 | memcpy(scsicmd->sense_buffer, |
| 2118 | &dev->fsa_dev[cid].sense_data, |
Salyzyn, Mark | 3ace426 | 2008-01-14 07:25:33 -0800 | [diff] [blame] | 2119 | min_t(size_t, |
| 2120 | sizeof(dev->fsa_dev[cid].sense_data), |
| 2121 | SCSI_SENSE_BUFFERSIZE)); |
Salyzyn, Mark | 88e2f98 | 2007-07-17 14:01:28 -0400 | [diff] [blame] | 2122 | } |
| 2123 | scsicmd->scsi_done(scsicmd); |
| 2124 | return 0; |
| 2125 | } |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 2126 | inq_data.inqd_ver = 2; /* claim compliance to SCSI-2 */ |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 2127 | inq_data.inqd_rdf = 2; /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */ |
| 2128 | inq_data.inqd_len = 31; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | /*Format for "pad2" is RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */ |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 2130 | inq_data.inqd_pad2= 0x32 ; /*WBus16|Sync|CmdQue */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2131 | /* |
| 2132 | * Set the Vendor, Product, and Revision Level |
| 2133 | * see: <vendor>.c i.e. aac.c |
| 2134 | */ |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 2135 | if (cid == host->this_id) { |
Tobias Klauser | 6391a11 | 2006-06-08 22:23:48 -0700 | [diff] [blame] | 2136 | setinqstr(dev, (void *) (inq_data.inqd_vid), ARRAY_SIZE(container_types)); |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 2137 | inq_data.inqd_pdt = INQD_PDT_PROC; /* Processor device */ |
FUJITA Tomonori | d434502 | 2008-03-09 13:44:34 +0900 | [diff] [blame] | 2138 | scsi_sg_copy_from_buffer(scsicmd, &inq_data, |
| 2139 | sizeof(inq_data)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2140 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 2141 | scsicmd->scsi_done(scsicmd); |
| 2142 | return 0; |
| 2143 | } |
Mark Haverkamp | 8c867b2 | 2006-08-03 08:03:30 -0700 | [diff] [blame] | 2144 | if (dev->in_reset) |
| 2145 | return -1; |
Mark Haverkamp | 794d060 | 2005-10-24 10:51:53 -0700 | [diff] [blame] | 2146 | setinqstr(dev, (void *) (inq_data.inqd_vid), fsa_dev_ptr[cid].type); |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 2147 | inq_data.inqd_pdt = INQD_PDT_DA; /* Direct/random access device */ |
FUJITA Tomonori | d434502 | 2008-03-09 13:44:34 +0900 | [diff] [blame] | 2148 | scsi_sg_copy_from_buffer(scsicmd, &inq_data, sizeof(inq_data)); |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 2149 | return aac_get_container_name(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2150 | } |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2151 | case SERVICE_ACTION_IN: |
| 2152 | if (!(dev->raw_io_interface) || |
| 2153 | !(dev->raw_io_64) || |
| 2154 | ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16)) |
| 2155 | break; |
| 2156 | { |
| 2157 | u64 capacity; |
Mark Haverkamp | 07ce5eb | 2005-11-08 14:26:33 -0800 | [diff] [blame] | 2158 | char cp[13]; |
FUJITA Tomonori | b271f1c | 2008-02-24 15:25:23 -0800 | [diff] [blame] | 2159 | unsigned int alloc_len; |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2160 | |
| 2161 | dprintk((KERN_DEBUG "READ CAPACITY_16 command.\n")); |
| 2162 | capacity = fsa_dev_ptr[cid].size - 1; |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2163 | cp[0] = (capacity >> 56) & 0xff; |
| 2164 | cp[1] = (capacity >> 48) & 0xff; |
| 2165 | cp[2] = (capacity >> 40) & 0xff; |
| 2166 | cp[3] = (capacity >> 32) & 0xff; |
| 2167 | cp[4] = (capacity >> 24) & 0xff; |
| 2168 | cp[5] = (capacity >> 16) & 0xff; |
| 2169 | cp[6] = (capacity >> 8) & 0xff; |
| 2170 | cp[7] = (capacity >> 0) & 0xff; |
| 2171 | cp[8] = 0; |
| 2172 | cp[9] = 0; |
| 2173 | cp[10] = 2; |
| 2174 | cp[11] = 0; |
Mark Haverkamp | 07ce5eb | 2005-11-08 14:26:33 -0800 | [diff] [blame] | 2175 | cp[12] = 0; |
Mark Haverkamp | 07ce5eb | 2005-11-08 14:26:33 -0800 | [diff] [blame] | 2176 | |
FUJITA Tomonori | b271f1c | 2008-02-24 15:25:23 -0800 | [diff] [blame] | 2177 | alloc_len = ((scsicmd->cmnd[10] << 24) |
| 2178 | + (scsicmd->cmnd[11] << 16) |
| 2179 | + (scsicmd->cmnd[12] << 8) + scsicmd->cmnd[13]); |
| 2180 | |
| 2181 | alloc_len = min_t(size_t, alloc_len, sizeof(cp)); |
FUJITA Tomonori | d434502 | 2008-03-09 13:44:34 +0900 | [diff] [blame] | 2182 | scsi_sg_copy_from_buffer(scsicmd, cp, alloc_len); |
FUJITA Tomonori | b271f1c | 2008-02-24 15:25:23 -0800 | [diff] [blame] | 2183 | if (alloc_len < scsi_bufflen(scsicmd)) |
| 2184 | scsi_set_resid(scsicmd, |
| 2185 | scsi_bufflen(scsicmd) - alloc_len); |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2186 | |
| 2187 | /* Do not cache partition table for arrays */ |
| 2188 | scsicmd->device->removable = 1; |
| 2189 | |
| 2190 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 2191 | scsicmd->scsi_done(scsicmd); |
| 2192 | |
| 2193 | return 0; |
| 2194 | } |
| 2195 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2196 | case READ_CAPACITY: |
| 2197 | { |
| 2198 | u32 capacity; |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 2199 | char cp[8]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2200 | |
| 2201 | dprintk((KERN_DEBUG "READ CAPACITY command.\n")); |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2202 | if (fsa_dev_ptr[cid].size <= 0x100000000ULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2203 | capacity = fsa_dev_ptr[cid].size - 1; |
| 2204 | else |
| 2205 | capacity = (u32)-1; |
Mark Haverkamp | 3b2946c | 2005-08-15 10:50:24 -0700 | [diff] [blame] | 2206 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2207 | cp[0] = (capacity >> 24) & 0xff; |
| 2208 | cp[1] = (capacity >> 16) & 0xff; |
| 2209 | cp[2] = (capacity >> 8) & 0xff; |
| 2210 | cp[3] = (capacity >> 0) & 0xff; |
| 2211 | cp[4] = 0; |
| 2212 | cp[5] = 0; |
| 2213 | cp[6] = 2; |
| 2214 | cp[7] = 0; |
FUJITA Tomonori | d434502 | 2008-03-09 13:44:34 +0900 | [diff] [blame] | 2215 | scsi_sg_copy_from_buffer(scsicmd, cp, sizeof(cp)); |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2216 | /* Do not cache partition table for arrays */ |
| 2217 | scsicmd->device->removable = 1; |
Mark Salyzyn | 655d722 | 2008-04-30 16:03:42 -0400 | [diff] [blame] | 2218 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | |
| 2219 | SAM_STAT_GOOD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | scsicmd->scsi_done(scsicmd); |
| 2221 | |
| 2222 | return 0; |
| 2223 | } |
| 2224 | |
| 2225 | case MODE_SENSE: |
| 2226 | { |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 2227 | char mode_buf[7]; |
| 2228 | int mode_buf_length = 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2229 | |
| 2230 | dprintk((KERN_DEBUG "MODE SENSE command.\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2231 | mode_buf[0] = 3; /* Mode data length */ |
| 2232 | mode_buf[1] = 0; /* Medium type - default */ |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 2233 | mode_buf[2] = 0; /* Device-specific param, |
| 2234 | bit 8: 0/1 = write enabled/protected |
| 2235 | bit 4: 0/1 = FUA enabled */ |
Salyzyn, Mark | 95e852e | 2008-01-08 12:01:07 -0800 | [diff] [blame] | 2236 | if (dev->raw_io_interface && ((aac_cache & 5) != 1)) |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 2237 | mode_buf[2] = 0x10; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2238 | mode_buf[3] = 0; /* Block descriptor length */ |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 2239 | if (((scsicmd->cmnd[2] & 0x3f) == 8) || |
| 2240 | ((scsicmd->cmnd[2] & 0x3f) == 0x3f)) { |
| 2241 | mode_buf[0] = 6; |
| 2242 | mode_buf[4] = 8; |
| 2243 | mode_buf[5] = 1; |
Salyzyn, Mark | 95e852e | 2008-01-08 12:01:07 -0800 | [diff] [blame] | 2244 | mode_buf[6] = ((aac_cache & 6) == 2) |
| 2245 | ? 0 : 0x04; /* WCE */ |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 2246 | mode_buf_length = 7; |
| 2247 | if (mode_buf_length > scsicmd->cmnd[4]) |
| 2248 | mode_buf_length = scsicmd->cmnd[4]; |
| 2249 | } |
FUJITA Tomonori | d434502 | 2008-03-09 13:44:34 +0900 | [diff] [blame] | 2250 | scsi_sg_copy_from_buffer(scsicmd, mode_buf, mode_buf_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2251 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 2252 | scsicmd->scsi_done(scsicmd); |
| 2253 | |
| 2254 | return 0; |
| 2255 | } |
| 2256 | case MODE_SENSE_10: |
| 2257 | { |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 2258 | char mode_buf[11]; |
| 2259 | int mode_buf_length = 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2260 | |
| 2261 | dprintk((KERN_DEBUG "MODE SENSE 10 byte command.\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2262 | mode_buf[0] = 0; /* Mode data length (MSB) */ |
| 2263 | mode_buf[1] = 6; /* Mode data length (LSB) */ |
| 2264 | mode_buf[2] = 0; /* Medium type - default */ |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 2265 | mode_buf[3] = 0; /* Device-specific param, |
| 2266 | bit 8: 0/1 = write enabled/protected |
| 2267 | bit 4: 0/1 = FUA enabled */ |
Salyzyn, Mark | 95e852e | 2008-01-08 12:01:07 -0800 | [diff] [blame] | 2268 | if (dev->raw_io_interface && ((aac_cache & 5) != 1)) |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 2269 | mode_buf[3] = 0x10; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2270 | mode_buf[4] = 0; /* reserved */ |
| 2271 | mode_buf[5] = 0; /* reserved */ |
| 2272 | mode_buf[6] = 0; /* Block descriptor length (MSB) */ |
| 2273 | mode_buf[7] = 0; /* Block descriptor length (LSB) */ |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 2274 | if (((scsicmd->cmnd[2] & 0x3f) == 8) || |
| 2275 | ((scsicmd->cmnd[2] & 0x3f) == 0x3f)) { |
| 2276 | mode_buf[1] = 9; |
| 2277 | mode_buf[8] = 8; |
| 2278 | mode_buf[9] = 1; |
Salyzyn, Mark | 95e852e | 2008-01-08 12:01:07 -0800 | [diff] [blame] | 2279 | mode_buf[10] = ((aac_cache & 6) == 2) |
| 2280 | ? 0 : 0x04; /* WCE */ |
Salyzyn, Mark | 9d399cc | 2007-05-18 14:51:34 -0400 | [diff] [blame] | 2281 | mode_buf_length = 11; |
| 2282 | if (mode_buf_length > scsicmd->cmnd[8]) |
| 2283 | mode_buf_length = scsicmd->cmnd[8]; |
| 2284 | } |
FUJITA Tomonori | d434502 | 2008-03-09 13:44:34 +0900 | [diff] [blame] | 2285 | scsi_sg_copy_from_buffer(scsicmd, mode_buf, mode_buf_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2286 | |
| 2287 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 2288 | scsicmd->scsi_done(scsicmd); |
| 2289 | |
| 2290 | return 0; |
| 2291 | } |
| 2292 | case REQUEST_SENSE: |
| 2293 | dprintk((KERN_DEBUG "REQUEST SENSE command.\n")); |
| 2294 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, sizeof (struct sense_data)); |
| 2295 | memset(&dev->fsa_dev[cid].sense_data, 0, sizeof (struct sense_data)); |
| 2296 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 2297 | scsicmd->scsi_done(scsicmd); |
| 2298 | return 0; |
| 2299 | |
| 2300 | case ALLOW_MEDIUM_REMOVAL: |
| 2301 | dprintk((KERN_DEBUG "LOCK command.\n")); |
| 2302 | if (scsicmd->cmnd[4]) |
| 2303 | fsa_dev_ptr[cid].locked = 1; |
| 2304 | else |
| 2305 | fsa_dev_ptr[cid].locked = 0; |
| 2306 | |
| 2307 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 2308 | scsicmd->scsi_done(scsicmd); |
| 2309 | return 0; |
| 2310 | /* |
| 2311 | * These commands are all No-Ops |
| 2312 | */ |
| 2313 | case TEST_UNIT_READY: |
Mark Salyzyn | 655d722 | 2008-04-30 16:03:42 -0400 | [diff] [blame] | 2314 | if (fsa_dev_ptr[cid].sense_data.sense_key == NOT_READY) { |
| 2315 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | |
| 2316 | SAM_STAT_CHECK_CONDITION; |
| 2317 | set_sense(&dev->fsa_dev[cid].sense_data, |
| 2318 | NOT_READY, SENCODE_BECOMING_READY, |
| 2319 | ASENCODE_BECOMING_READY, 0, 0); |
| 2320 | memcpy(scsicmd->sense_buffer, |
| 2321 | &dev->fsa_dev[cid].sense_data, |
| 2322 | min_t(size_t, |
| 2323 | sizeof(dev->fsa_dev[cid].sense_data), |
| 2324 | SCSI_SENSE_BUFFERSIZE)); |
| 2325 | scsicmd->scsi_done(scsicmd); |
| 2326 | return 0; |
| 2327 | } |
| 2328 | /* FALLTHRU */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2329 | case RESERVE: |
| 2330 | case RELEASE: |
| 2331 | case REZERO_UNIT: |
| 2332 | case REASSIGN_BLOCKS: |
| 2333 | case SEEK_10: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2334 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 2335 | scsicmd->scsi_done(scsicmd); |
| 2336 | return 0; |
Mark Salyzyn | 655d722 | 2008-04-30 16:03:42 -0400 | [diff] [blame] | 2337 | |
| 2338 | case START_STOP: |
| 2339 | return aac_start_stop(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2340 | } |
| 2341 | |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 2342 | switch (scsicmd->cmnd[0]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2343 | { |
| 2344 | case READ_6: |
| 2345 | case READ_10: |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2346 | case READ_12: |
| 2347 | case READ_16: |
Mark Haverkamp | 8c867b2 | 2006-08-03 08:03:30 -0700 | [diff] [blame] | 2348 | if (dev->in_reset) |
| 2349 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2350 | /* |
| 2351 | * Hack to keep track of ordinal number of the device that |
| 2352 | * corresponds to a container. Needed to convert |
| 2353 | * containers to /dev/sd device names |
| 2354 | */ |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 2355 | |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2356 | if (scsicmd->request->rq_disk) |
| 2357 | strlcpy(fsa_dev_ptr[cid].devname, |
| 2358 | scsicmd->request->rq_disk->disk_name, |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 2359 | min(sizeof(fsa_dev_ptr[cid].devname), |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2360 | sizeof(scsicmd->request->rq_disk->disk_name) + 1)); |
Mark Haverkamp | 77d644d | 2006-03-27 09:43:40 -0800 | [diff] [blame] | 2361 | |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 2362 | return aac_read(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2363 | |
| 2364 | case WRITE_6: |
| 2365 | case WRITE_10: |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2366 | case WRITE_12: |
| 2367 | case WRITE_16: |
Mark Haverkamp | 8c867b2 | 2006-08-03 08:03:30 -0700 | [diff] [blame] | 2368 | if (dev->in_reset) |
| 2369 | return -1; |
Mark Haverkamp | 9e7c349 | 2007-03-15 10:26:55 -0700 | [diff] [blame] | 2370 | return aac_write(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2371 | |
| 2372 | case SYNCHRONIZE_CACHE: |
Salyzyn, Mark | 95e852e | 2008-01-08 12:01:07 -0800 | [diff] [blame] | 2373 | if (((aac_cache & 6) == 6) && dev->cache_protected) { |
| 2374 | scsicmd->result = DID_OK << 16 | |
| 2375 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; |
| 2376 | scsicmd->scsi_done(scsicmd); |
| 2377 | return 0; |
| 2378 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2379 | /* Issue FIB to tell Firmware to flush it's cache */ |
Salyzyn, Mark | 95e852e | 2008-01-08 12:01:07 -0800 | [diff] [blame] | 2380 | if ((aac_cache & 6) != 2) |
| 2381 | return aac_synchronize(scsicmd); |
| 2382 | /* FALLTHRU */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2383 | default: |
| 2384 | /* |
| 2385 | * Unhandled commands |
| 2386 | */ |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 2387 | dprintk((KERN_WARNING "Unhandled SCSI Command: 0x%x.\n", scsicmd->cmnd[0])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2388 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; |
Salyzyn, Mark | 8e31e60 | 2008-02-06 13:54:12 -0800 | [diff] [blame] | 2389 | set_sense(&dev->fsa_dev[cid].sense_data, |
| 2390 | ILLEGAL_REQUEST, SENCODE_INVALID_COMMAND, |
| 2391 | ASENCODE_INVALID_COMMAND, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2392 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, |
Salyzyn, Mark | 3ace426 | 2008-01-14 07:25:33 -0800 | [diff] [blame] | 2393 | min_t(size_t, |
| 2394 | sizeof(dev->fsa_dev[cid].sense_data), |
| 2395 | SCSI_SENSE_BUFFERSIZE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2396 | scsicmd->scsi_done(scsicmd); |
| 2397 | return 0; |
| 2398 | } |
| 2399 | } |
| 2400 | |
| 2401 | static int query_disk(struct aac_dev *dev, void __user *arg) |
| 2402 | { |
| 2403 | struct aac_query_disk qd; |
| 2404 | struct fsa_dev_info *fsa_dev_ptr; |
| 2405 | |
| 2406 | fsa_dev_ptr = dev->fsa_dev; |
Mark Haverkamp | 90ee346 | 2006-08-03 08:03:07 -0700 | [diff] [blame] | 2407 | if (!fsa_dev_ptr) |
Mark Haverkamp | 6510135 | 2006-09-19 08:59:23 -0700 | [diff] [blame] | 2408 | return -EBUSY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2409 | if (copy_from_user(&qd, arg, sizeof (struct aac_query_disk))) |
| 2410 | return -EFAULT; |
| 2411 | if (qd.cnum == -1) |
Mark Haverkamp | e571877 | 2006-03-27 09:43:25 -0800 | [diff] [blame] | 2412 | qd.cnum = qd.id; |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 2413 | else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2414 | { |
| 2415 | if (qd.cnum < 0 || qd.cnum >= dev->maximum_num_containers) |
| 2416 | return -EINVAL; |
| 2417 | qd.instance = dev->scsi_host_ptr->host_no; |
| 2418 | qd.bus = 0; |
| 2419 | qd.id = CONTAINER_TO_ID(qd.cnum); |
| 2420 | qd.lun = CONTAINER_TO_LUN(qd.cnum); |
| 2421 | } |
| 2422 | else return -EINVAL; |
| 2423 | |
Salyzyn, Mark | fd622b1 | 2007-07-17 10:59:19 -0400 | [diff] [blame] | 2424 | qd.valid = fsa_dev_ptr[qd.cnum].valid != 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2425 | qd.locked = fsa_dev_ptr[qd.cnum].locked; |
| 2426 | qd.deleted = fsa_dev_ptr[qd.cnum].deleted; |
| 2427 | |
| 2428 | if (fsa_dev_ptr[qd.cnum].devname[0] == '\0') |
| 2429 | qd.unmapped = 1; |
| 2430 | else |
| 2431 | qd.unmapped = 0; |
| 2432 | |
| 2433 | strlcpy(qd.name, fsa_dev_ptr[qd.cnum].devname, |
| 2434 | min(sizeof(qd.name), sizeof(fsa_dev_ptr[qd.cnum].devname) + 1)); |
| 2435 | |
| 2436 | if (copy_to_user(arg, &qd, sizeof (struct aac_query_disk))) |
| 2437 | return -EFAULT; |
| 2438 | return 0; |
| 2439 | } |
| 2440 | |
| 2441 | static int force_delete_disk(struct aac_dev *dev, void __user *arg) |
| 2442 | { |
| 2443 | struct aac_delete_disk dd; |
| 2444 | struct fsa_dev_info *fsa_dev_ptr; |
| 2445 | |
| 2446 | fsa_dev_ptr = dev->fsa_dev; |
Mark Haverkamp | 6510135 | 2006-09-19 08:59:23 -0700 | [diff] [blame] | 2447 | if (!fsa_dev_ptr) |
| 2448 | return -EBUSY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2449 | |
| 2450 | if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk))) |
| 2451 | return -EFAULT; |
| 2452 | |
| 2453 | if (dd.cnum >= dev->maximum_num_containers) |
| 2454 | return -EINVAL; |
| 2455 | /* |
| 2456 | * Mark this container as being deleted. |
| 2457 | */ |
| 2458 | fsa_dev_ptr[dd.cnum].deleted = 1; |
| 2459 | /* |
| 2460 | * Mark the container as no longer valid |
| 2461 | */ |
| 2462 | fsa_dev_ptr[dd.cnum].valid = 0; |
| 2463 | return 0; |
| 2464 | } |
| 2465 | |
| 2466 | static int delete_disk(struct aac_dev *dev, void __user *arg) |
| 2467 | { |
| 2468 | struct aac_delete_disk dd; |
| 2469 | struct fsa_dev_info *fsa_dev_ptr; |
| 2470 | |
| 2471 | fsa_dev_ptr = dev->fsa_dev; |
Mark Haverkamp | 90ee346 | 2006-08-03 08:03:07 -0700 | [diff] [blame] | 2472 | if (!fsa_dev_ptr) |
Mark Haverkamp | 6510135 | 2006-09-19 08:59:23 -0700 | [diff] [blame] | 2473 | return -EBUSY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2474 | |
| 2475 | if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk))) |
| 2476 | return -EFAULT; |
| 2477 | |
| 2478 | if (dd.cnum >= dev->maximum_num_containers) |
| 2479 | return -EINVAL; |
| 2480 | /* |
| 2481 | * If the container is locked, it can not be deleted by the API. |
| 2482 | */ |
| 2483 | if (fsa_dev_ptr[dd.cnum].locked) |
| 2484 | return -EBUSY; |
| 2485 | else { |
| 2486 | /* |
| 2487 | * Mark the container as no longer being valid. |
| 2488 | */ |
| 2489 | fsa_dev_ptr[dd.cnum].valid = 0; |
| 2490 | fsa_dev_ptr[dd.cnum].devname[0] = '\0'; |
| 2491 | return 0; |
| 2492 | } |
| 2493 | } |
| 2494 | |
| 2495 | int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg) |
| 2496 | { |
| 2497 | switch (cmd) { |
| 2498 | case FSACTL_QUERY_DISK: |
| 2499 | return query_disk(dev, arg); |
| 2500 | case FSACTL_DELETE_DISK: |
| 2501 | return delete_disk(dev, arg); |
| 2502 | case FSACTL_FORCE_DELETE_DISK: |
| 2503 | return force_delete_disk(dev, arg); |
| 2504 | case FSACTL_GET_CONTAINERS: |
| 2505 | return aac_get_containers(dev); |
| 2506 | default: |
| 2507 | return -ENOTTY; |
| 2508 | } |
| 2509 | } |
| 2510 | |
| 2511 | /** |
| 2512 | * |
| 2513 | * aac_srb_callback |
| 2514 | * @context: the context set in the fib - here it is scsi cmd |
| 2515 | * @fibptr: pointer to the fib |
| 2516 | * |
| 2517 | * Handles the completion of a scsi command to a non dasd device |
| 2518 | * |
| 2519 | */ |
| 2520 | |
| 2521 | static void aac_srb_callback(void *context, struct fib * fibptr) |
| 2522 | { |
| 2523 | struct aac_dev *dev; |
| 2524 | struct aac_srb_reply *srbreply; |
| 2525 | struct scsi_cmnd *scsicmd; |
| 2526 | |
| 2527 | scsicmd = (struct scsi_cmnd *) context; |
Mark Haverkamp | 03d4433 | 2007-03-15 10:27:45 -0700 | [diff] [blame] | 2528 | |
| 2529 | if (!aac_valid_context(scsicmd, fibptr)) |
| 2530 | return; |
| 2531 | |
Eric Sesterhenn | 125e187 | 2006-06-23 02:06:06 -0700 | [diff] [blame] | 2532 | BUG_ON(fibptr == NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2533 | |
Salyzyn, Mark | 1a65504 | 2007-06-11 16:17:55 -0400 | [diff] [blame] | 2534 | dev = fibptr->dev; |
| 2535 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2536 | srbreply = (struct aac_srb_reply *) fib_data(fibptr); |
| 2537 | |
| 2538 | scsicmd->sense_buffer[0] = '\0'; /* Initialize sense valid flag to false */ |
| 2539 | /* |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 2540 | * Calculate resid for sg |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2541 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2542 | |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2543 | scsi_set_resid(scsicmd, scsi_bufflen(scsicmd) |
| 2544 | - le32_to_cpu(srbreply->data_xfer_length)); |
| 2545 | |
| 2546 | scsi_dma_unmap(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2547 | |
| 2548 | /* |
| 2549 | * First check the fib status |
| 2550 | */ |
| 2551 | |
| 2552 | if (le32_to_cpu(srbreply->status) != ST_OK){ |
| 2553 | int len; |
| 2554 | printk(KERN_WARNING "aac_srb_callback: srb failed, status = %d\n", le32_to_cpu(srbreply->status)); |
Salyzyn, Mark | 3ace426 | 2008-01-14 07:25:33 -0800 | [diff] [blame] | 2555 | len = min_t(u32, le32_to_cpu(srbreply->sense_data_size), |
| 2556 | SCSI_SENSE_BUFFERSIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2557 | scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; |
| 2558 | memcpy(scsicmd->sense_buffer, srbreply->sense_data, len); |
| 2559 | } |
| 2560 | |
| 2561 | /* |
| 2562 | * Next check the srb status |
| 2563 | */ |
| 2564 | switch( (le32_to_cpu(srbreply->srb_status))&0x3f){ |
| 2565 | case SRB_STATUS_ERROR_RECOVERY: |
| 2566 | case SRB_STATUS_PENDING: |
| 2567 | case SRB_STATUS_SUCCESS: |
Mark Haverkamp | bb08f92 | 2006-02-01 09:30:44 -0800 | [diff] [blame] | 2568 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2569 | break; |
| 2570 | case SRB_STATUS_DATA_OVERRUN: |
| 2571 | switch(scsicmd->cmnd[0]){ |
| 2572 | case READ_6: |
| 2573 | case WRITE_6: |
| 2574 | case READ_10: |
| 2575 | case WRITE_10: |
| 2576 | case READ_12: |
| 2577 | case WRITE_12: |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2578 | case READ_16: |
| 2579 | case WRITE_16: |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 2580 | if (le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2581 | printk(KERN_WARNING"aacraid: SCSI CMD underflow\n"); |
| 2582 | } else { |
| 2583 | printk(KERN_WARNING"aacraid: SCSI CMD Data Overrun\n"); |
| 2584 | } |
| 2585 | scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8; |
| 2586 | break; |
| 2587 | case INQUIRY: { |
Mark Haverkamp | bb08f92 | 2006-02-01 09:30:44 -0800 | [diff] [blame] | 2588 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2589 | break; |
| 2590 | } |
| 2591 | default: |
| 2592 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8; |
| 2593 | break; |
| 2594 | } |
| 2595 | break; |
| 2596 | case SRB_STATUS_ABORTED: |
| 2597 | scsicmd->result = DID_ABORT << 16 | ABORT << 8; |
| 2598 | break; |
| 2599 | case SRB_STATUS_ABORT_FAILED: |
| 2600 | // Not sure about this one - but assuming the hba was trying to abort for some reason |
| 2601 | scsicmd->result = DID_ERROR << 16 | ABORT << 8; |
| 2602 | break; |
| 2603 | case SRB_STATUS_PARITY_ERROR: |
| 2604 | scsicmd->result = DID_PARITY << 16 | MSG_PARITY_ERROR << 8; |
| 2605 | break; |
| 2606 | case SRB_STATUS_NO_DEVICE: |
| 2607 | case SRB_STATUS_INVALID_PATH_ID: |
| 2608 | case SRB_STATUS_INVALID_TARGET_ID: |
| 2609 | case SRB_STATUS_INVALID_LUN: |
| 2610 | case SRB_STATUS_SELECTION_TIMEOUT: |
| 2611 | scsicmd->result = DID_NO_CONNECT << 16 | COMMAND_COMPLETE << 8; |
| 2612 | break; |
| 2613 | |
| 2614 | case SRB_STATUS_COMMAND_TIMEOUT: |
| 2615 | case SRB_STATUS_TIMEOUT: |
| 2616 | scsicmd->result = DID_TIME_OUT << 16 | COMMAND_COMPLETE << 8; |
| 2617 | break; |
| 2618 | |
| 2619 | case SRB_STATUS_BUSY: |
Salyzyn, Mark | 760af10 | 2007-06-19 11:41:21 -0400 | [diff] [blame] | 2620 | scsicmd->result = DID_BUS_BUSY << 16 | COMMAND_COMPLETE << 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2621 | break; |
| 2622 | |
| 2623 | case SRB_STATUS_BUS_RESET: |
| 2624 | scsicmd->result = DID_RESET << 16 | COMMAND_COMPLETE << 8; |
| 2625 | break; |
| 2626 | |
| 2627 | case SRB_STATUS_MESSAGE_REJECTED: |
| 2628 | scsicmd->result = DID_ERROR << 16 | MESSAGE_REJECT << 8; |
| 2629 | break; |
| 2630 | case SRB_STATUS_REQUEST_FLUSHED: |
| 2631 | case SRB_STATUS_ERROR: |
| 2632 | case SRB_STATUS_INVALID_REQUEST: |
| 2633 | case SRB_STATUS_REQUEST_SENSE_FAILED: |
| 2634 | case SRB_STATUS_NO_HBA: |
| 2635 | case SRB_STATUS_UNEXPECTED_BUS_FREE: |
| 2636 | case SRB_STATUS_PHASE_SEQUENCE_FAILURE: |
| 2637 | case SRB_STATUS_BAD_SRB_BLOCK_LENGTH: |
| 2638 | case SRB_STATUS_DELAYED_RETRY: |
| 2639 | case SRB_STATUS_BAD_FUNCTION: |
| 2640 | case SRB_STATUS_NOT_STARTED: |
| 2641 | case SRB_STATUS_NOT_IN_USE: |
| 2642 | case SRB_STATUS_FORCE_ABORT: |
| 2643 | case SRB_STATUS_DOMAIN_VALIDATION_FAIL: |
| 2644 | default: |
| 2645 | #ifdef AAC_DETAILED_STATUS_INFO |
| 2646 | printk("aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n", |
| 2647 | le32_to_cpu(srbreply->srb_status) & 0x3F, |
| 2648 | aac_get_status_string( |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 2649 | le32_to_cpu(srbreply->srb_status) & 0x3F), |
| 2650 | scsicmd->cmnd[0], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2651 | le32_to_cpu(srbreply->scsi_status)); |
| 2652 | #endif |
| 2653 | scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8; |
| 2654 | break; |
| 2655 | } |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 2656 | if (le32_to_cpu(srbreply->scsi_status) == SAM_STAT_CHECK_CONDITION) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2657 | int len; |
| 2658 | scsicmd->result |= SAM_STAT_CHECK_CONDITION; |
Salyzyn, Mark | 3ace426 | 2008-01-14 07:25:33 -0800 | [diff] [blame] | 2659 | len = min_t(u32, le32_to_cpu(srbreply->sense_data_size), |
| 2660 | SCSI_SENSE_BUFFERSIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2661 | #ifdef AAC_DETAILED_STATUS_INFO |
Mark Haverkamp | 7a8cf29 | 2005-09-22 09:15:24 -0700 | [diff] [blame] | 2662 | printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n", |
| 2663 | le32_to_cpu(srbreply->status), len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2664 | #endif |
| 2665 | memcpy(scsicmd->sense_buffer, srbreply->sense_data, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2666 | } |
| 2667 | /* |
| 2668 | * OR in the scsi status (already shifted up a bit) |
| 2669 | */ |
| 2670 | scsicmd->result |= le32_to_cpu(srbreply->scsi_status); |
| 2671 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 2672 | aac_fib_complete(fibptr); |
| 2673 | aac_fib_free(fibptr); |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 2674 | scsicmd->scsi_done(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2675 | } |
| 2676 | |
| 2677 | /** |
| 2678 | * |
| 2679 | * aac_send_scb_fib |
| 2680 | * @scsicmd: the scsi command block |
| 2681 | * |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 2682 | * This routine will form a FIB and fill in the aac_srb from the |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2683 | * scsicmd passed in. |
| 2684 | */ |
| 2685 | |
| 2686 | static int aac_send_srb_fib(struct scsi_cmnd* scsicmd) |
| 2687 | { |
| 2688 | struct fib* cmd_fibcontext; |
| 2689 | struct aac_dev* dev; |
| 2690 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2691 | |
Mark Haverkamp | 8497173 | 2005-06-20 11:55:24 -0700 | [diff] [blame] | 2692 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
Mark Haverkamp | e571877 | 2006-03-27 09:43:25 -0800 | [diff] [blame] | 2693 | if (scmd_id(scsicmd) >= dev->maximum_num_physicals || |
Mark Haverkamp | 8497173 | 2005-06-20 11:55:24 -0700 | [diff] [blame] | 2694 | scsicmd->device->lun > 7) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2695 | scsicmd->result = DID_NO_CONNECT << 16; |
| 2696 | scsicmd->scsi_done(scsicmd); |
| 2697 | return 0; |
| 2698 | } |
| 2699 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2700 | /* |
| 2701 | * Allocate and initialize a Fib then setup a BlockWrite command |
| 2702 | */ |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 2703 | if (!(cmd_fibcontext = aac_fib_alloc(dev))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2704 | return -1; |
| 2705 | } |
Mark Haverkamp | e8f32de | 2007-01-23 15:00:30 -0800 | [diff] [blame] | 2706 | status = aac_adapter_scsi(cmd_fibcontext, scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2707 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2708 | /* |
| 2709 | * Check that the command queued to the controller |
| 2710 | */ |
Mark Haverkamp | 77d644d | 2006-03-27 09:43:40 -0800 | [diff] [blame] | 2711 | if (status == -EINPROGRESS) { |
| 2712 | scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2713 | return 0; |
| 2714 | } |
| 2715 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 2716 | printk(KERN_WARNING "aac_srb: aac_fib_send failed with status: %d\n", status); |
| 2717 | aac_fib_complete(cmd_fibcontext); |
| 2718 | aac_fib_free(cmd_fibcontext); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2719 | |
| 2720 | return -1; |
| 2721 | } |
| 2722 | |
| 2723 | static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* psg) |
| 2724 | { |
| 2725 | struct aac_dev *dev; |
| 2726 | unsigned long byte_count = 0; |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2727 | int nseg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2728 | |
| 2729 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
| 2730 | // Get rid of old data |
| 2731 | psg->count = 0; |
| 2732 | psg->sg[0].addr = 0; |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2733 | psg->sg[0].count = 0; |
| 2734 | |
| 2735 | nseg = scsi_dma_map(scsicmd); |
| 2736 | BUG_ON(nseg < 0); |
| 2737 | if (nseg) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2738 | struct scatterlist *sg; |
| 2739 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2740 | |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2741 | psg->count = cpu_to_le32(nseg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2742 | |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2743 | scsi_for_each_sg(scsicmd, sg, nseg, i) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2744 | psg->sg[i].addr = cpu_to_le32(sg_dma_address(sg)); |
| 2745 | psg->sg[i].count = cpu_to_le32(sg_dma_len(sg)); |
| 2746 | byte_count += sg_dma_len(sg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2747 | } |
| 2748 | /* hba wants the size to be exact */ |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2749 | if (byte_count > scsi_bufflen(scsicmd)) { |
| 2750 | u32 temp = le32_to_cpu(psg->sg[i-1].count) - |
| 2751 | (byte_count - scsi_bufflen(scsicmd)); |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 2752 | psg->sg[i-1].count = cpu_to_le32(temp); |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2753 | byte_count = scsi_bufflen(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2754 | } |
| 2755 | /* Check for command underflow */ |
| 2756 | if(scsicmd->underflow && (byte_count < scsicmd->underflow)){ |
| 2757 | printk(KERN_WARNING"aacraid: cmd len %08lX cmd underflow %08X\n", |
| 2758 | byte_count, scsicmd->underflow); |
| 2759 | } |
| 2760 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2761 | return byte_count; |
| 2762 | } |
| 2763 | |
| 2764 | |
| 2765 | static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* psg) |
| 2766 | { |
| 2767 | struct aac_dev *dev; |
| 2768 | unsigned long byte_count = 0; |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 2769 | u64 addr; |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2770 | int nseg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2771 | |
| 2772 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
| 2773 | // Get rid of old data |
| 2774 | psg->count = 0; |
| 2775 | psg->sg[0].addr[0] = 0; |
| 2776 | psg->sg[0].addr[1] = 0; |
| 2777 | psg->sg[0].count = 0; |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2778 | |
| 2779 | nseg = scsi_dma_map(scsicmd); |
| 2780 | BUG_ON(nseg < 0); |
| 2781 | if (nseg) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2782 | struct scatterlist *sg; |
| 2783 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2784 | |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2785 | scsi_for_each_sg(scsicmd, sg, nseg, i) { |
Mark Haverkamp | 1241f35 | 2006-03-27 09:44:23 -0800 | [diff] [blame] | 2786 | int count = sg_dma_len(sg); |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 2787 | addr = sg_dma_address(sg); |
| 2788 | psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff); |
| 2789 | psg->sg[i].addr[1] = cpu_to_le32(addr>>32); |
Mark Haverkamp | 1241f35 | 2006-03-27 09:44:23 -0800 | [diff] [blame] | 2790 | psg->sg[i].count = cpu_to_le32(count); |
| 2791 | byte_count += count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2792 | } |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2793 | psg->count = cpu_to_le32(nseg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2794 | /* hba wants the size to be exact */ |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2795 | if (byte_count > scsi_bufflen(scsicmd)) { |
| 2796 | u32 temp = le32_to_cpu(psg->sg[i-1].count) - |
| 2797 | (byte_count - scsi_bufflen(scsicmd)); |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 2798 | psg->sg[i-1].count = cpu_to_le32(temp); |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2799 | byte_count = scsi_bufflen(scsicmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2800 | } |
| 2801 | /* Check for command underflow */ |
| 2802 | if(scsicmd->underflow && (byte_count < scsicmd->underflow)){ |
| 2803 | printk(KERN_WARNING"aacraid: cmd len %08lX cmd underflow %08X\n", |
| 2804 | byte_count, scsicmd->underflow); |
| 2805 | } |
| 2806 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2807 | return byte_count; |
| 2808 | } |
| 2809 | |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 2810 | static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw* psg) |
| 2811 | { |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 2812 | unsigned long byte_count = 0; |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2813 | int nseg; |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 2814 | |
| 2815 | // Get rid of old data |
| 2816 | psg->count = 0; |
| 2817 | psg->sg[0].next = 0; |
| 2818 | psg->sg[0].prev = 0; |
| 2819 | psg->sg[0].addr[0] = 0; |
| 2820 | psg->sg[0].addr[1] = 0; |
| 2821 | psg->sg[0].count = 0; |
| 2822 | psg->sg[0].flags = 0; |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2823 | |
| 2824 | nseg = scsi_dma_map(scsicmd); |
| 2825 | BUG_ON(nseg < 0); |
| 2826 | if (nseg) { |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 2827 | struct scatterlist *sg; |
| 2828 | int i; |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 2829 | |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2830 | scsi_for_each_sg(scsicmd, sg, nseg, i) { |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 2831 | int count = sg_dma_len(sg); |
| 2832 | u64 addr = sg_dma_address(sg); |
| 2833 | psg->sg[i].next = 0; |
| 2834 | psg->sg[i].prev = 0; |
| 2835 | psg->sg[i].addr[1] = cpu_to_le32((u32)(addr>>32)); |
| 2836 | psg->sg[i].addr[0] = cpu_to_le32((u32)(addr & 0xffffffff)); |
| 2837 | psg->sg[i].count = cpu_to_le32(count); |
| 2838 | psg->sg[i].flags = 0; |
| 2839 | byte_count += count; |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 2840 | } |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2841 | psg->count = cpu_to_le32(nseg); |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 2842 | /* hba wants the size to be exact */ |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2843 | if (byte_count > scsi_bufflen(scsicmd)) { |
| 2844 | u32 temp = le32_to_cpu(psg->sg[i-1].count) - |
| 2845 | (byte_count - scsi_bufflen(scsicmd)); |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 2846 | psg->sg[i-1].count = cpu_to_le32(temp); |
FUJITA Tomonori | 727eead | 2007-05-26 02:00:42 +0900 | [diff] [blame] | 2847 | byte_count = scsi_bufflen(scsicmd); |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 2848 | } |
| 2849 | /* Check for command underflow */ |
| 2850 | if(scsicmd->underflow && (byte_count < scsicmd->underflow)){ |
| 2851 | printk(KERN_WARNING"aacraid: cmd len %08lX cmd underflow %08X\n", |
| 2852 | byte_count, scsicmd->underflow); |
| 2853 | } |
| 2854 | } |
Mark Haverkamp | 0e68c00 | 2005-08-03 15:39:49 -0700 | [diff] [blame] | 2855 | return byte_count; |
| 2856 | } |
| 2857 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2858 | #ifdef AAC_DETAILED_STATUS_INFO |
| 2859 | |
| 2860 | struct aac_srb_status_info { |
| 2861 | u32 status; |
| 2862 | char *str; |
| 2863 | }; |
| 2864 | |
| 2865 | |
| 2866 | static struct aac_srb_status_info srb_status_info[] = { |
| 2867 | { SRB_STATUS_PENDING, "Pending Status"}, |
| 2868 | { SRB_STATUS_SUCCESS, "Success"}, |
| 2869 | { SRB_STATUS_ABORTED, "Aborted Command"}, |
| 2870 | { SRB_STATUS_ABORT_FAILED, "Abort Failed"}, |
Tobias Klauser | 6391a11 | 2006-06-08 22:23:48 -0700 | [diff] [blame] | 2871 | { SRB_STATUS_ERROR, "Error Event"}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2872 | { SRB_STATUS_BUSY, "Device Busy"}, |
| 2873 | { SRB_STATUS_INVALID_REQUEST, "Invalid Request"}, |
| 2874 | { SRB_STATUS_INVALID_PATH_ID, "Invalid Path ID"}, |
| 2875 | { SRB_STATUS_NO_DEVICE, "No Device"}, |
| 2876 | { SRB_STATUS_TIMEOUT, "Timeout"}, |
| 2877 | { SRB_STATUS_SELECTION_TIMEOUT, "Selection Timeout"}, |
| 2878 | { SRB_STATUS_COMMAND_TIMEOUT, "Command Timeout"}, |
| 2879 | { SRB_STATUS_MESSAGE_REJECTED, "Message Rejected"}, |
| 2880 | { SRB_STATUS_BUS_RESET, "Bus Reset"}, |
| 2881 | { SRB_STATUS_PARITY_ERROR, "Parity Error"}, |
| 2882 | { SRB_STATUS_REQUEST_SENSE_FAILED,"Request Sense Failed"}, |
| 2883 | { SRB_STATUS_NO_HBA, "No HBA"}, |
| 2884 | { SRB_STATUS_DATA_OVERRUN, "Data Overrun/Data Underrun"}, |
| 2885 | { SRB_STATUS_UNEXPECTED_BUS_FREE,"Unexpected Bus Free"}, |
| 2886 | { SRB_STATUS_PHASE_SEQUENCE_FAILURE,"Phase Error"}, |
| 2887 | { SRB_STATUS_BAD_SRB_BLOCK_LENGTH,"Bad Srb Block Length"}, |
| 2888 | { SRB_STATUS_REQUEST_FLUSHED, "Request Flushed"}, |
| 2889 | { SRB_STATUS_DELAYED_RETRY, "Delayed Retry"}, |
Tobias Klauser | 6391a11 | 2006-06-08 22:23:48 -0700 | [diff] [blame] | 2890 | { SRB_STATUS_INVALID_LUN, "Invalid LUN"}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2891 | { SRB_STATUS_INVALID_TARGET_ID, "Invalid TARGET ID"}, |
| 2892 | { SRB_STATUS_BAD_FUNCTION, "Bad Function"}, |
| 2893 | { SRB_STATUS_ERROR_RECOVERY, "Error Recovery"}, |
| 2894 | { SRB_STATUS_NOT_STARTED, "Not Started"}, |
| 2895 | { SRB_STATUS_NOT_IN_USE, "Not In Use"}, |
Salyzyn, Mark | 8ce3eca | 2008-01-16 07:39:06 -0800 | [diff] [blame] | 2896 | { SRB_STATUS_FORCE_ABORT, "Force Abort"}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2897 | { SRB_STATUS_DOMAIN_VALIDATION_FAIL,"Domain Validation Failure"}, |
| 2898 | { 0xff, "Unknown Error"} |
| 2899 | }; |
| 2900 | |
| 2901 | char *aac_get_status_string(u32 status) |
| 2902 | { |
| 2903 | int i; |
| 2904 | |
Tobias Klauser | 6391a11 | 2006-06-08 22:23:48 -0700 | [diff] [blame] | 2905 | for (i = 0; i < ARRAY_SIZE(srb_status_info); i++) |
| 2906 | if (srb_status_info[i].status == status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2907 | return srb_status_info[i].str; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2908 | |
| 2909 | return "Bad Status Code"; |
| 2910 | } |
| 2911 | |
| 2912 | #endif |