Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 2 | * QLogic Fibre Channel HBA Driver |
Chad Dupuis | 46152ce | 2012-08-22 14:21:08 -0400 | [diff] [blame] | 3 | * Copyright (c) 2003-2012 QLogic Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | #include "qla_def.h" |
| 8 | |
| 9 | #include <linux/moduleparam.h> |
| 10 | #include <linux/vmalloc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/delay.h> |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 12 | #include <linux/kthread.h> |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 13 | #include <linux/mutex.h> |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 14 | #include <linux/kobject.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 15 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <scsi/scsi_tcq.h> |
| 17 | #include <scsi/scsicam.h> |
| 18 | #include <scsi/scsi_transport.h> |
| 19 | #include <scsi/scsi_transport_fc.h> |
| 20 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 21 | #include "qla_target.h" |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | /* |
| 24 | * Driver version |
| 25 | */ |
| 26 | char qla2x00_version_str[40]; |
| 27 | |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 28 | static int apidev_major; |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | /* |
| 31 | * SRB allocation cache |
| 32 | */ |
Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 33 | static struct kmem_cache *srb_cachep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 35 | /* |
| 36 | * CT6 CTX allocation cache |
| 37 | */ |
| 38 | static struct kmem_cache *ctx_cachep; |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 39 | /* |
| 40 | * error level for logging |
| 41 | */ |
| 42 | int ql_errlev = ql_log_all; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 43 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 44 | static int ql2xenableclass2; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 45 | module_param(ql2xenableclass2, int, S_IRUGO|S_IRUSR); |
| 46 | MODULE_PARM_DESC(ql2xenableclass2, |
| 47 | "Specify if Class 2 operations are supported from the very " |
| 48 | "beginning. Default is 0 - class 2 not supported."); |
| 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | int ql2xlogintimeout = 20; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 51 | module_param(ql2xlogintimeout, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | MODULE_PARM_DESC(ql2xlogintimeout, |
| 53 | "Login timeout value in seconds."); |
| 54 | |
Andrew Vasquez | a7b6184 | 2007-05-07 07:42:59 -0700 | [diff] [blame] | 55 | int qlport_down_retry; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 56 | module_param(qlport_down_retry, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | MODULE_PARM_DESC(qlport_down_retry, |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 58 | "Maximum number of command retries to a port that returns " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | "a PORT-DOWN status."); |
| 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | int ql2xplogiabsentdevice; |
| 62 | module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); |
| 63 | MODULE_PARM_DESC(ql2xplogiabsentdevice, |
| 64 | "Option to enable PLOGI to devices that are not present after " |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 65 | "a Fabric scan. This is needed for several broken switches. " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | "Default is 0 - no PLOGI. 1 - perfom PLOGI."); |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | int ql2xloginretrycount = 0; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 69 | module_param(ql2xloginretrycount, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | MODULE_PARM_DESC(ql2xloginretrycount, |
| 71 | "Specify an alternate value for the NVRAM login retry count."); |
| 72 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 73 | int ql2xallocfwdump = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 74 | module_param(ql2xallocfwdump, int, S_IRUGO); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 75 | MODULE_PARM_DESC(ql2xallocfwdump, |
| 76 | "Option to enable allocation of memory for a firmware dump " |
| 77 | "during HBA initialization. Memory allocation requirements " |
| 78 | "vary by ISP type. Default is 1 - allocate memory."); |
| 79 | |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 80 | int ql2xextended_error_logging; |
Andrew Vasquez | 27d9403 | 2007-03-12 10:41:30 -0700 | [diff] [blame] | 81 | module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 82 | MODULE_PARM_DESC(ql2xextended_error_logging, |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 83 | "Option to enable extended error logging,\n" |
| 84 | "\t\tDefault is 0 - no logging. 0x40000000 - Module Init & Probe.\n" |
| 85 | "\t\t0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.\n" |
| 86 | "\t\t0x08000000 - IO tracing. 0x04000000 - DPC Thread.\n" |
| 87 | "\t\t0x02000000 - Async events. 0x01000000 - Timer routines.\n" |
| 88 | "\t\t0x00800000 - User space. 0x00400000 - Task Management.\n" |
| 89 | "\t\t0x00200000 - AER/EEH. 0x00100000 - Multi Q.\n" |
| 90 | "\t\t0x00080000 - P3P Specific. 0x00040000 - Virtual Port.\n" |
| 91 | "\t\t0x00020000 - Buffer Dump. 0x00010000 - Misc.\n" |
Chad Dupuis | 29f9f90 | 2012-11-21 02:40:41 -0500 | [diff] [blame] | 92 | "\t\t0x00008000 - Verbose. 0x00004000 - Target.\n" |
| 93 | "\t\t0x00002000 - Target Mgmt. 0x00001000 - Target TMF.\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 94 | "\t\t0x7fffffff - For enabling all logs, can be too many logs.\n" |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 95 | "\t\t0x1e400000 - Preferred value for capturing essential " |
| 96 | "debug information (equivalent to old " |
| 97 | "ql2xextended_error_logging=1).\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 98 | "\t\tDo LOGICAL OR of the value to enable more than one level"); |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 99 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 100 | int ql2xshiftctondsd = 6; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 101 | module_param(ql2xshiftctondsd, int, S_IRUGO); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 102 | MODULE_PARM_DESC(ql2xshiftctondsd, |
| 103 | "Set to control shifting of command type processing " |
| 104 | "based on total number of SG elements."); |
| 105 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | static void qla2x00_free_device(scsi_qla_host_t *); |
| 107 | |
Andrew Vasquez | 7e47e5c | 2008-04-24 15:21:26 -0700 | [diff] [blame] | 108 | int ql2xfdmienable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 109 | module_param(ql2xfdmienable, int, S_IRUGO); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 110 | MODULE_PARM_DESC(ql2xfdmienable, |
Ferenc Wagner | 7794a5a | 2010-03-23 18:14:59 +0100 | [diff] [blame] | 111 | "Enables FDMI registrations. " |
| 112 | "0 - no FDMI. Default is 1 - perform FDMI."); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 113 | |
Chad Dupuis | 3c290d0 | 2013-01-30 03:34:38 -0500 | [diff] [blame] | 114 | int ql2xmaxqdepth = MAX_Q_DEPTH; |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 115 | module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR); |
| 116 | MODULE_PARM_DESC(ql2xmaxqdepth, |
Chad Dupuis | e92e4a8 | 2012-08-22 14:21:23 -0400 | [diff] [blame] | 117 | "Maximum queue depth to set for each LUN. " |
| 118 | "Default is 32."); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 119 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 120 | int ql2xenabledif = 2; |
| 121 | module_param(ql2xenabledif, int, S_IRUGO); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 122 | MODULE_PARM_DESC(ql2xenabledif, |
| 123 | " Enable T10-CRC-DIF " |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 124 | " Default is 0 - No DIF Support. 1 - Enable it" |
| 125 | ", 2 - Enable DIF for all types, except Type 0."); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 126 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 127 | int ql2xenablehba_err_chk = 2; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 128 | module_param(ql2xenablehba_err_chk, int, S_IRUGO|S_IWUSR); |
| 129 | MODULE_PARM_DESC(ql2xenablehba_err_chk, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 130 | " Enable T10-CRC-DIF Error isolation by HBA:\n" |
| 131 | " Default is 1.\n" |
| 132 | " 0 -- Error isolation disabled\n" |
| 133 | " 1 -- Error isolation enabled only for DIX Type 0\n" |
| 134 | " 2 -- Error isolation enabled for all Types\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 135 | |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 136 | int ql2xiidmaenable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 137 | module_param(ql2xiidmaenable, int, S_IRUGO); |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 138 | MODULE_PARM_DESC(ql2xiidmaenable, |
| 139 | "Enables iIDMA settings " |
| 140 | "Default is 1 - perform iIDMA. 0 - no iIDMA."); |
| 141 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 142 | int ql2xmaxqueues = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 143 | module_param(ql2xmaxqueues, int, S_IRUGO); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 144 | MODULE_PARM_DESC(ql2xmaxqueues, |
| 145 | "Enables MQ settings " |
Joe Perches | ae68230 | 2010-08-10 18:01:21 -0700 | [diff] [blame] | 146 | "Default is 1 for single queue. Set it to number " |
| 147 | "of queues in MQ mode."); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 148 | |
| 149 | int ql2xmultique_tag; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 150 | module_param(ql2xmultique_tag, int, S_IRUGO); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 151 | MODULE_PARM_DESC(ql2xmultique_tag, |
| 152 | "Enables CPU affinity settings for the driver " |
| 153 | "Default is 0 for no affinity of request and response IO. " |
| 154 | "Set it to 1 to turn on the cpu affinity."); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 155 | |
| 156 | int ql2xfwloadbin; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 157 | module_param(ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 158 | MODULE_PARM_DESC(ql2xfwloadbin, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 159 | "Option to specify location from which to load ISP firmware:.\n" |
| 160 | " 2 -- load firmware via the request_firmware() (hotplug).\n" |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 161 | " interface.\n" |
| 162 | " 1 -- load firmware from flash.\n" |
| 163 | " 0 -- use default semantics.\n"); |
| 164 | |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 165 | int ql2xetsenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 166 | module_param(ql2xetsenable, int, S_IRUGO); |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 167 | MODULE_PARM_DESC(ql2xetsenable, |
| 168 | "Enables firmware ETS burst." |
| 169 | "Default is 0 - skip ETS enablement."); |
| 170 | |
Giridhar Malavali | 6907869 | 2010-05-28 15:08:28 -0700 | [diff] [blame] | 171 | int ql2xdbwr = 1; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 172 | module_param(ql2xdbwr, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 173 | MODULE_PARM_DESC(ql2xdbwr, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 174 | "Option to specify scheme for request queue posting.\n" |
| 175 | " 0 -- Regular doorbell.\n" |
| 176 | " 1 -- CAMRAM doorbell (faster).\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 177 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 178 | int ql2xtargetreset = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 179 | module_param(ql2xtargetreset, int, S_IRUGO); |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 180 | MODULE_PARM_DESC(ql2xtargetreset, |
| 181 | "Enable target reset." |
| 182 | "Default is 1 - use hw defaults."); |
| 183 | |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 184 | int ql2xgffidenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 185 | module_param(ql2xgffidenable, int, S_IRUGO); |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 186 | MODULE_PARM_DESC(ql2xgffidenable, |
| 187 | "Enables GFF_ID checks of port type. " |
| 188 | "Default is 0 - Do not use GFF_ID information."); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 189 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 190 | int ql2xasynctmfenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 191 | module_param(ql2xasynctmfenable, int, S_IRUGO); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 192 | MODULE_PARM_DESC(ql2xasynctmfenable, |
| 193 | "Enables issue of TM IOCBs asynchronously via IOCB mechanism" |
| 194 | "Default is 0 - Issue TM IOCBs via mailbox mechanism."); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 195 | |
| 196 | int ql2xdontresethba; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 197 | module_param(ql2xdontresethba, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 198 | MODULE_PARM_DESC(ql2xdontresethba, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 199 | "Option to specify reset behaviour.\n" |
| 200 | " 0 (Default) -- Reset on failure.\n" |
| 201 | " 1 -- Do not reset on failure.\n"); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 202 | |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 203 | uint ql2xmaxlun = MAX_LUNS; |
| 204 | module_param(ql2xmaxlun, uint, S_IRUGO); |
| 205 | MODULE_PARM_DESC(ql2xmaxlun, |
| 206 | "Defines the maximum LU number to register with the SCSI " |
| 207 | "midlayer. Default is 65535."); |
| 208 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 209 | int ql2xmdcapmask = 0x1F; |
| 210 | module_param(ql2xmdcapmask, int, S_IRUGO); |
| 211 | MODULE_PARM_DESC(ql2xmdcapmask, |
| 212 | "Set the Minidump driver capture mask level. " |
Giridhar Malavali | 6e96fa7 | 2011-11-18 09:03:14 -0800 | [diff] [blame] | 213 | "Default is 0x1F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 214 | |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 215 | int ql2xmdenable = 1; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 216 | module_param(ql2xmdenable, int, S_IRUGO); |
| 217 | MODULE_PARM_DESC(ql2xmdenable, |
| 218 | "Enable/disable MiniDump. " |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 219 | "0 - MiniDump disabled. " |
| 220 | "1 (Default) - MiniDump enabled."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 223 | * SCSI host template entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | */ |
| 225 | static int qla2xxx_slave_configure(struct scsi_device * device); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 226 | static int qla2xxx_slave_alloc(struct scsi_device *); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 227 | static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); |
| 228 | static void qla2xxx_scan_start(struct Scsi_Host *); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 229 | static void qla2xxx_slave_destroy(struct scsi_device *); |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 230 | static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | static int qla2xxx_eh_abort(struct scsi_cmnd *); |
| 232 | static int qla2xxx_eh_device_reset(struct scsi_cmnd *); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 233 | static int qla2xxx_eh_target_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); |
| 235 | static int qla2xxx_eh_host_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 237 | static int qla2x00_change_queue_depth(struct scsi_device *, int, int); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 238 | static int qla2x00_change_queue_type(struct scsi_device *, int); |
| 239 | |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 240 | struct scsi_host_template qla2xxx_driver_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | .module = THIS_MODULE, |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 242 | .name = QLA2XXX_DRIVER_NAME, |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 243 | .queuecommand = qla2xxx_queuecommand, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 244 | |
| 245 | .eh_abort_handler = qla2xxx_eh_abort, |
| 246 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 247 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 248 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 249 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 250 | |
| 251 | .slave_configure = qla2xxx_slave_configure, |
| 252 | |
| 253 | .slave_alloc = qla2xxx_slave_alloc, |
| 254 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 255 | .scan_finished = qla2xxx_scan_finished, |
| 256 | .scan_start = qla2xxx_scan_start, |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 257 | .change_queue_depth = qla2x00_change_queue_depth, |
| 258 | .change_queue_type = qla2x00_change_queue_type, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 259 | .this_id = -1, |
| 260 | .cmd_per_lun = 3, |
| 261 | .use_clustering = ENABLE_CLUSTERING, |
| 262 | .sg_tablesize = SG_ALL, |
| 263 | |
| 264 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 265 | .shost_attrs = qla2x00_host_attrs, |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 266 | |
| 267 | .supported_mode = MODE_INITIATOR, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 268 | }; |
| 269 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 271 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | /* TODO Convert to inlines |
| 274 | * |
| 275 | * Timer routines |
| 276 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 278 | __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 279 | qla2x00_start_timer(scsi_qla_host_t *vha, void *func, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 281 | init_timer(&vha->timer); |
| 282 | vha->timer.expires = jiffies + interval * HZ; |
| 283 | vha->timer.data = (unsigned long)vha; |
| 284 | vha->timer.function = (void (*)(unsigned long))func; |
| 285 | add_timer(&vha->timer); |
| 286 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 290 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 292 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 293 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 294 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 295 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 296 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 297 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 298 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 299 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | } |
| 301 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 302 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 303 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 305 | del_timer_sync(&vha->timer); |
| 306 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | } |
| 308 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | static int qla2x00_do_dpc(void *data); |
| 310 | |
| 311 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 312 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 313 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 314 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 315 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 316 | static void qla2x00_mem_free(struct qla_hw_data *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | /* -------------------------------------------------------------------------- */ |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 319 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 320 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 321 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 322 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 323 | ha->req_q_map = kzalloc(sizeof(struct req_que *) * ha->max_req_queues, |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 324 | GFP_KERNEL); |
| 325 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 326 | ql_log(ql_log_fatal, vha, 0x003b, |
| 327 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 328 | goto fail_req_map; |
| 329 | } |
| 330 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 331 | ha->rsp_q_map = kzalloc(sizeof(struct rsp_que *) * ha->max_rsp_queues, |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 332 | GFP_KERNEL); |
| 333 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 334 | ql_log(ql_log_fatal, vha, 0x003c, |
| 335 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 336 | goto fail_rsp_map; |
| 337 | } |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 338 | /* |
| 339 | * Make sure we record at least the request and response queue zero in |
| 340 | * case we need to free them if part of the probe fails. |
| 341 | */ |
| 342 | ha->rsp_q_map[0] = rsp; |
| 343 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 344 | set_bit(0, ha->rsp_qid_map); |
| 345 | set_bit(0, ha->req_qid_map); |
| 346 | return 1; |
| 347 | |
| 348 | fail_rsp_map: |
| 349 | kfree(ha->req_q_map); |
| 350 | ha->req_q_map = NULL; |
| 351 | fail_req_map: |
| 352 | return -ENOMEM; |
| 353 | } |
| 354 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 355 | static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 356 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 357 | if (req && req->ring) |
| 358 | dma_free_coherent(&ha->pdev->dev, |
| 359 | (req->length + 1) * sizeof(request_t), |
| 360 | req->ring, req->dma); |
| 361 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 362 | if (req) |
| 363 | kfree(req->outstanding_cmds); |
| 364 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 365 | kfree(req); |
| 366 | req = NULL; |
| 367 | } |
| 368 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 369 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 370 | { |
| 371 | if (rsp && rsp->ring) |
| 372 | dma_free_coherent(&ha->pdev->dev, |
| 373 | (rsp->length + 1) * sizeof(response_t), |
| 374 | rsp->ring, rsp->dma); |
| 375 | |
| 376 | kfree(rsp); |
| 377 | rsp = NULL; |
| 378 | } |
| 379 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 380 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 381 | { |
| 382 | struct req_que *req; |
| 383 | struct rsp_que *rsp; |
| 384 | int cnt; |
| 385 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 386 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 387 | req = ha->req_q_map[cnt]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 388 | qla2x00_free_req_que(ha, req); |
| 389 | } |
| 390 | kfree(ha->req_q_map); |
| 391 | ha->req_q_map = NULL; |
| 392 | |
| 393 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
| 394 | rsp = ha->rsp_q_map[cnt]; |
| 395 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 396 | } |
| 397 | kfree(ha->rsp_q_map); |
| 398 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 399 | } |
| 400 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 401 | static int qla25xx_setup_mode(struct scsi_qla_host *vha) |
| 402 | { |
| 403 | uint16_t options = 0; |
| 404 | int ques, req, ret; |
| 405 | struct qla_hw_data *ha = vha->hw; |
| 406 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 407 | if (!(ha->fw_attributes & BIT_6)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 408 | ql_log(ql_log_warn, vha, 0x00d8, |
| 409 | "Firmware is not multi-queue capable.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 410 | goto fail; |
| 411 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 412 | if (ql2xmultique_tag) { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 413 | /* create a request queue for IO */ |
| 414 | options |= BIT_7; |
| 415 | req = qla25xx_create_req_que(ha, options, 0, 0, -1, |
| 416 | QLA_DEFAULT_QUE_QOS); |
| 417 | if (!req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 418 | ql_log(ql_log_warn, vha, 0x00e0, |
| 419 | "Failed to create request queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 420 | goto fail; |
| 421 | } |
Tejun Heo | 278274d | 2011-02-01 11:42:42 +0100 | [diff] [blame] | 422 | ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 423 | vha->req = ha->req_q_map[req]; |
| 424 | options |= BIT_1; |
| 425 | for (ques = 1; ques < ha->max_rsp_queues; ques++) { |
| 426 | ret = qla25xx_create_rsp_que(ha, options, 0, 0, req); |
| 427 | if (!ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 428 | ql_log(ql_log_warn, vha, 0x00e8, |
| 429 | "Failed to create response queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 430 | goto fail2; |
| 431 | } |
| 432 | } |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 433 | ha->flags.cpu_affinity_enabled = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 434 | ql_dbg(ql_dbg_multiq, vha, 0xc007, |
| 435 | "CPU affinity mode enalbed, " |
| 436 | "no. of response queues:%d no. of request queues:%d.\n", |
| 437 | ha->max_rsp_queues, ha->max_req_queues); |
| 438 | ql_dbg(ql_dbg_init, vha, 0x00e9, |
| 439 | "CPU affinity mode enalbed, " |
| 440 | "no. of response queues:%d no. of request queues:%d.\n", |
| 441 | ha->max_rsp_queues, ha->max_req_queues); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 442 | } |
| 443 | return 0; |
| 444 | fail2: |
| 445 | qla25xx_delete_queues(vha); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 446 | destroy_workqueue(ha->wq); |
| 447 | ha->wq = NULL; |
Giridhar Malavali | 0cd33fc | 2011-11-18 09:02:12 -0800 | [diff] [blame] | 448 | vha->req = ha->req_q_map[0]; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 449 | fail: |
| 450 | ha->mqenable = 0; |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 451 | kfree(ha->req_q_map); |
| 452 | kfree(ha->rsp_q_map); |
| 453 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 454 | return 1; |
| 455 | } |
| 456 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 458 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 460 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | static char *pci_bus_modes[] = { |
| 462 | "33", "66", "100", "133", |
| 463 | }; |
| 464 | uint16_t pci_bus; |
| 465 | |
| 466 | strcpy(str, "PCI"); |
| 467 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 468 | if (pci_bus) { |
| 469 | strcat(str, "-X ("); |
| 470 | strcat(str, pci_bus_modes[pci_bus]); |
| 471 | } else { |
| 472 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 473 | strcat(str, " ("); |
| 474 | strcat(str, pci_bus_modes[pci_bus]); |
| 475 | } |
| 476 | strcat(str, " MHz)"); |
| 477 | |
| 478 | return (str); |
| 479 | } |
| 480 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 481 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 482 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 483 | { |
| 484 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 485 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 486 | uint32_t pci_bus; |
| 487 | int pcie_reg; |
| 488 | |
Jon Mason | e67f132 | 2012-07-10 14:57:56 -0700 | [diff] [blame] | 489 | pcie_reg = pci_pcie_cap(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 490 | if (pcie_reg) { |
| 491 | char lwstr[6]; |
| 492 | uint16_t pcie_lstat, lspeed, lwidth; |
| 493 | |
Jon Mason | e67f132 | 2012-07-10 14:57:56 -0700 | [diff] [blame] | 494 | pcie_reg += PCI_EXP_LNKCAP; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 495 | pci_read_config_word(ha->pdev, pcie_reg, &pcie_lstat); |
| 496 | lspeed = pcie_lstat & (BIT_0 | BIT_1 | BIT_2 | BIT_3); |
| 497 | lwidth = (pcie_lstat & |
| 498 | (BIT_4 | BIT_5 | BIT_6 | BIT_7 | BIT_8 | BIT_9)) >> 4; |
| 499 | |
| 500 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 501 | switch (lspeed) { |
| 502 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 503 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 504 | break; |
| 505 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 506 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 507 | break; |
| 508 | case 3: |
| 509 | strcat(str, "8.0GT/s "); |
| 510 | break; |
| 511 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 512 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 513 | break; |
| 514 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 515 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 516 | strcat(str, lwstr); |
| 517 | |
| 518 | return str; |
| 519 | } |
| 520 | |
| 521 | strcpy(str, "PCI"); |
| 522 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 523 | if (pci_bus == 0 || pci_bus == 8) { |
| 524 | strcat(str, " ("); |
| 525 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 526 | } else { |
| 527 | strcat(str, "-X "); |
| 528 | if (pci_bus & BIT_2) |
| 529 | strcat(str, "Mode 2"); |
| 530 | else |
| 531 | strcat(str, "Mode 1"); |
| 532 | strcat(str, " ("); |
| 533 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 534 | } |
| 535 | strcat(str, " MHz)"); |
| 536 | |
| 537 | return str; |
| 538 | } |
| 539 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 540 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 541 | qla2x00_fw_version_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | { |
| 543 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 544 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 545 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | sprintf(str, "%d.%02d.%02d ", ha->fw_major_version, |
| 547 | ha->fw_minor_version, |
| 548 | ha->fw_subminor_version); |
| 549 | |
| 550 | if (ha->fw_attributes & BIT_9) { |
| 551 | strcat(str, "FLX"); |
| 552 | return (str); |
| 553 | } |
| 554 | |
| 555 | switch (ha->fw_attributes & 0xFF) { |
| 556 | case 0x7: |
| 557 | strcat(str, "EF"); |
| 558 | break; |
| 559 | case 0x17: |
| 560 | strcat(str, "TP"); |
| 561 | break; |
| 562 | case 0x37: |
| 563 | strcat(str, "IP"); |
| 564 | break; |
| 565 | case 0x77: |
| 566 | strcat(str, "VI"); |
| 567 | break; |
| 568 | default: |
| 569 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 570 | strcat(str, un_str); |
| 571 | break; |
| 572 | } |
| 573 | if (ha->fw_attributes & 0x100) |
| 574 | strcat(str, "X"); |
| 575 | |
| 576 | return (str); |
| 577 | } |
| 578 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 579 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 580 | qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 581 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 582 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 583 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 584 | sprintf(str, "%d.%02d.%02d (%x)", ha->fw_major_version, |
| 585 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 586 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 587 | } |
| 588 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 589 | void |
| 590 | qla2x00_sp_free_dma(void *vha, void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 591 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 592 | srb_t *sp = (srb_t *)ptr; |
| 593 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 594 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 595 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 596 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 597 | if (sp->flags & SRB_DMA_VALID) { |
| 598 | scsi_dma_unmap(cmd); |
| 599 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 600 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 601 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 602 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 603 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 604 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 605 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 606 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 607 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 608 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 609 | /* List assured to be having elements */ |
| 610 | qla2x00_clean_dsd_pool(ha, sp); |
| 611 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 612 | } |
| 613 | |
| 614 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
| 615 | dma_pool_free(ha->dl_dma_pool, ctx, |
| 616 | ((struct crc_context *)ctx)->crc_ctx_dma); |
| 617 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 618 | } |
| 619 | |
| 620 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
| 621 | struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; |
| 622 | |
| 623 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 624 | ctx1->fcp_cmnd_dma); |
| 625 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 626 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 627 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 628 | mempool_free(ctx1, ha->ctx_mempool); |
| 629 | ctx1 = NULL; |
| 630 | } |
| 631 | |
| 632 | CMD_SP(cmd) = NULL; |
| 633 | mempool_free(sp, ha->srb_mempool); |
| 634 | } |
| 635 | |
| 636 | static void |
| 637 | qla2x00_sp_compl(void *data, void *ptr, int res) |
| 638 | { |
| 639 | struct qla_hw_data *ha = (struct qla_hw_data *)data; |
| 640 | srb_t *sp = (srb_t *)ptr; |
| 641 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 642 | |
| 643 | cmd->result = res; |
| 644 | |
| 645 | if (atomic_read(&sp->ref_count) == 0) { |
| 646 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3015, |
| 647 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 648 | sp, GET_CMD_SP(sp)); |
| 649 | if (ql2xextended_error_logging & ql_dbg_io) |
| 650 | BUG(); |
| 651 | return; |
| 652 | } |
| 653 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 654 | return; |
| 655 | |
| 656 | qla2x00_sp_free_dma(ha, sp); |
| 657 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 658 | } |
| 659 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 661 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 662 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 663 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 664 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 665 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 666 | struct qla_hw_data *ha = vha->hw; |
| 667 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 668 | srb_t *sp; |
| 669 | int rval; |
| 670 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 671 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 672 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 673 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 674 | "PCI Channel IO permanent failure, exiting " |
| 675 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 676 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 677 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 678 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 679 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 680 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 681 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 682 | goto qc24_fail_command; |
| 683 | } |
| 684 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 685 | rval = fc_remote_port_chkready(rport); |
| 686 | if (rval) { |
| 687 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 688 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 689 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 690 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 691 | goto qc24_fail_command; |
| 692 | } |
| 693 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 694 | if (!vha->flags.difdix_supported && |
| 695 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 696 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 697 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 698 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 699 | cmd->result = DID_NO_CONNECT << 16; |
| 700 | goto qc24_fail_command; |
| 701 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 702 | |
| 703 | if (!fcport) { |
| 704 | cmd->result = DID_NO_CONNECT << 16; |
| 705 | goto qc24_fail_command; |
| 706 | } |
| 707 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 708 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 709 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 710 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 711 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 712 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 713 | atomic_read(&fcport->state), |
| 714 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 715 | cmd->result = DID_NO_CONNECT << 16; |
| 716 | goto qc24_fail_command; |
| 717 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 718 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 719 | } |
| 720 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 721 | sp = qla2x00_get_sp(base_vha, fcport, GFP_ATOMIC); |
Chad Dupuis | 3c290d0 | 2013-01-30 03:34:38 -0500 | [diff] [blame] | 722 | if (!sp) { |
| 723 | set_bit(HOST_RAMP_DOWN_QUEUE_DEPTH, &vha->dpc_flags); |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 724 | goto qc24_host_busy; |
Chad Dupuis | 3c290d0 | 2013-01-30 03:34:38 -0500 | [diff] [blame] | 725 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 726 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 727 | sp->u.scmd.cmd = cmd; |
| 728 | sp->type = SRB_SCSI_CMD; |
| 729 | atomic_set(&sp->ref_count, 1); |
| 730 | CMD_SP(cmd) = (void *)sp; |
| 731 | sp->free = qla2x00_sp_free_dma; |
| 732 | sp->done = qla2x00_sp_compl; |
| 733 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 734 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 735 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 736 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 737 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Chad Dupuis | 3c290d0 | 2013-01-30 03:34:38 -0500 | [diff] [blame] | 738 | set_bit(HOST_RAMP_DOWN_QUEUE_DEPTH, &vha->dpc_flags); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 739 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 740 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 741 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 742 | return 0; |
| 743 | |
| 744 | qc24_host_busy_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 745 | qla2x00_sp_free_dma(ha, sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 746 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 747 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 748 | return SCSI_MLQUEUE_HOST_BUSY; |
| 749 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 750 | qc24_target_busy: |
| 751 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 752 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 753 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 754 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 755 | |
| 756 | return 0; |
| 757 | } |
| 758 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | /* |
| 760 | * qla2x00_eh_wait_on_command |
| 761 | * Waits for the command to be returned by the Firmware for some |
| 762 | * max time. |
| 763 | * |
| 764 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | * |
| 767 | * Return: |
| 768 | * Not Found : 0 |
| 769 | * Found : 1 |
| 770 | */ |
| 771 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 772 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 773 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 774 | #define ABORT_POLLING_PERIOD 1000 |
| 775 | #define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 776 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 777 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 778 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 779 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 781 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 782 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 783 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 784 | return ret; |
| 785 | } |
| 786 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 787 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 788 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 789 | } |
| 790 | if (CMD_SP(cmd)) |
| 791 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 792 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 793 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | /* |
| 797 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 798 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 800 | * finally HBA is disabled ie marked offline |
| 801 | * |
| 802 | * Input: |
| 803 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 804 | * |
| 805 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | * Does context switching-Release SPIN_LOCK |
| 807 | * (if any) before calling this routine. |
| 808 | * |
| 809 | * Return: |
| 810 | * Success (Adapter is online) : 0 |
| 811 | * Failed (Adapter is offline/disabled) : 1 |
| 812 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 813 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 814 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 816 | int return_status; |
| 817 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 818 | struct qla_hw_data *ha = vha->hw; |
| 819 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 821 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 822 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 823 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 824 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 825 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | |
| 827 | msleep(1000); |
| 828 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 829 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 830 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | else |
| 832 | return_status = QLA_FUNCTION_FAILED; |
| 833 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | return (return_status); |
| 835 | } |
| 836 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 837 | /* |
| 838 | * qla2x00_wait_for_reset_ready |
| 839 | * Wait till the HBA is online after going through |
| 840 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 841 | * finally HBA is disabled ie marked offline or flash |
| 842 | * operations are in progress. |
| 843 | * |
| 844 | * Input: |
| 845 | * ha - pointer to host adapter structure |
| 846 | * |
| 847 | * Note: |
| 848 | * Does context switching-Release SPIN_LOCK |
| 849 | * (if any) before calling this routine. |
| 850 | * |
| 851 | * Return: |
| 852 | * Success (Adapter is online/no flash ops) : 0 |
| 853 | * Failed (Adapter is offline/disabled/flash ops in progress) : 1 |
| 854 | */ |
Andrew Vasquez | 3dbe756 | 2010-07-23 15:28:37 +0500 | [diff] [blame] | 855 | static int |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 856 | qla2x00_wait_for_reset_ready(scsi_qla_host_t *vha) |
| 857 | { |
| 858 | int return_status; |
| 859 | unsigned long wait_online; |
| 860 | struct qla_hw_data *ha = vha->hw; |
| 861 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 862 | |
| 863 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 864 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 865 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 866 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 867 | ha->optrom_state != QLA_SWAITING || |
| 868 | ha->dpc_active) && time_before(jiffies, wait_online)) |
| 869 | msleep(1000); |
| 870 | |
| 871 | if (base_vha->flags.online && ha->optrom_state == QLA_SWAITING) |
| 872 | return_status = QLA_SUCCESS; |
| 873 | else |
| 874 | return_status = QLA_FUNCTION_FAILED; |
| 875 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 876 | ql_dbg(ql_dbg_taskm, vha, 0x8019, |
| 877 | "%s return status=%d.\n", __func__, return_status); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 878 | |
| 879 | return return_status; |
| 880 | } |
| 881 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 882 | int |
| 883 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 884 | { |
| 885 | int return_status; |
| 886 | unsigned long wait_reset; |
| 887 | struct qla_hw_data *ha = vha->hw; |
| 888 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 889 | |
| 890 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 891 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 892 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 893 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 894 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 895 | |
| 896 | msleep(1000); |
| 897 | |
| 898 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 899 | ha->flags.chip_reset_done) |
| 900 | break; |
| 901 | } |
| 902 | if (ha->flags.chip_reset_done) |
| 903 | return_status = QLA_SUCCESS; |
| 904 | else |
| 905 | return_status = QLA_FUNCTION_FAILED; |
| 906 | |
| 907 | return return_status; |
| 908 | } |
| 909 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 910 | static void |
| 911 | sp_get(struct srb *sp) |
| 912 | { |
| 913 | atomic_inc(&sp->ref_count); |
| 914 | } |
| 915 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | /************************************************************************** |
| 917 | * qla2xxx_eh_abort |
| 918 | * |
| 919 | * Description: |
| 920 | * The abort function will abort the specified command. |
| 921 | * |
| 922 | * Input: |
| 923 | * cmd = Linux SCSI command packet to be aborted. |
| 924 | * |
| 925 | * Returns: |
| 926 | * Either SUCCESS or FAILED. |
| 927 | * |
| 928 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 929 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 931 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 933 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 934 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 935 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 936 | int ret; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 937 | unsigned int id, lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 938 | unsigned long flags; |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 939 | int wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 940 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 942 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 943 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 945 | ret = fc_block_scsi_eh(cmd); |
| 946 | if (ret != 0) |
| 947 | return ret; |
| 948 | ret = SUCCESS; |
| 949 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 950 | id = cmd->device->id; |
| 951 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 952 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 953 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 954 | sp = (srb_t *) CMD_SP(cmd); |
| 955 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 956 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 957 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 958 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 959 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 960 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 961 | "Aborting from RISC nexus=%ld:%d:%d sp=%p cmd=%p\n", |
| 962 | vha->host_no, id, lun, sp, cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 963 | |
| 964 | /* Get a reference to the sp and drop the lock.*/ |
| 965 | sp_get(sp); |
| 966 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 967 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 968 | if (ha->isp_ops->abort_command(sp)) { |
Arun Easi | a55aac7 | 2012-02-09 11:14:03 -0800 | [diff] [blame] | 969 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 970 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 971 | "Abort command mbx failed cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 972 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 973 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 974 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 975 | wait = 1; |
| 976 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 977 | |
| 978 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 979 | sp->done(ha, sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 980 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 981 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 982 | /* Did the command return during mailbox execution? */ |
| 983 | if (ret == FAILED && !CMD_SP(cmd)) |
| 984 | ret = SUCCESS; |
| 985 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 986 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 987 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 988 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 989 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 990 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 991 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 992 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 995 | ql_log(ql_log_info, vha, 0x801c, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 996 | "Abort command issued nexus=%ld:%d:%d -- %d %x.\n", |
| 997 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 999 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | } |
| 1001 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1002 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1003 | qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t, |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1004 | unsigned int l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1006 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1007 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1008 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1009 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1010 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1011 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1013 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1014 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1015 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1016 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1017 | for (cnt = 1; status == QLA_SUCCESS && |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1018 | cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1019 | sp = req->outstanding_cmds[cnt]; |
| 1020 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1021 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1022 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1023 | continue; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1024 | if (vha->vp_idx != sp->fcport->vha->vp_idx) |
| 1025 | continue; |
| 1026 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1027 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1028 | switch (type) { |
| 1029 | case WAIT_HOST: |
| 1030 | match = 1; |
| 1031 | break; |
| 1032 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1033 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1034 | break; |
| 1035 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1036 | match = (cmd->device->id == t && |
| 1037 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1038 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1039 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1040 | if (!match) |
| 1041 | continue; |
| 1042 | |
| 1043 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1044 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1045 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1046 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1047 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1048 | |
| 1049 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | } |
| 1051 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1052 | static char *reset_errors[] = { |
| 1053 | "HBA not online", |
| 1054 | "HBA not ready", |
| 1055 | "Task management failed", |
| 1056 | "Waiting for command completions", |
| 1057 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1058 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1059 | static int |
| 1060 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1061 | struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, unsigned int, int)) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1062 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1063 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1064 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1065 | int err; |
| 1066 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1067 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1068 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1069 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1070 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1071 | err = fc_block_scsi_eh(cmd); |
| 1072 | if (err != 0) |
| 1073 | return err; |
| 1074 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1075 | ql_log(ql_log_info, vha, 0x8009, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1076 | "%s RESET ISSUED nexus=%ld:%d:%d cmd=%p.\n", name, vha->host_no, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1077 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1078 | |
| 1079 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1080 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1081 | ql_log(ql_log_warn, vha, 0x800a, |
| 1082 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1083 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1084 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1085 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1086 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1087 | != QLA_SUCCESS) { |
| 1088 | ql_log(ql_log_warn, vha, 0x800c, |
| 1089 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1090 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1091 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1092 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1093 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1094 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1095 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1096 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1097 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1098 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1099 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1100 | ql_log(ql_log_info, vha, 0x800e, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1101 | "%s RESET SUCCEEDED nexus:%ld:%d:%d cmd=%p.\n", name, |
| 1102 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1103 | |
| 1104 | return SUCCESS; |
| 1105 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1106 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1107 | ql_log(ql_log_info, vha, 0x800f, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1108 | "%s RESET FAILED: %s nexus=%ld:%d:%d cmd=%p.\n", name, |
| 1109 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1110 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1111 | return FAILED; |
| 1112 | } |
| 1113 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1114 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1115 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1116 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1117 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1118 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1119 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1120 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1121 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | } |
| 1123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1125 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1126 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1127 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1128 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1129 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1130 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1131 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | } |
| 1133 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | /************************************************************************** |
| 1135 | * qla2xxx_eh_bus_reset |
| 1136 | * |
| 1137 | * Description: |
| 1138 | * The bus reset function will reset the bus and abort any executing |
| 1139 | * commands. |
| 1140 | * |
| 1141 | * Input: |
| 1142 | * cmd = Linux SCSI command packet of the command that cause the |
| 1143 | * bus reset. |
| 1144 | * |
| 1145 | * Returns: |
| 1146 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1147 | * |
| 1148 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1149 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1151 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1152 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1153 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1154 | int ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1155 | unsigned int id, lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1157 | id = cmd->device->id; |
| 1158 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1159 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1160 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1161 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1162 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1163 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1164 | ret = fc_block_scsi_eh(cmd); |
| 1165 | if (ret != 0) |
| 1166 | return ret; |
| 1167 | ret = FAILED; |
| 1168 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1169 | ql_log(ql_log_info, vha, 0x8012, |
Andrew Vasquez | 46270af | 2012-05-15 14:34:17 -0400 | [diff] [blame] | 1170 | "BUS RESET ISSUED nexus=%ld:%d:%d.\n", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1172 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1173 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1174 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1175 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1176 | } |
| 1177 | |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1178 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1179 | ret = SUCCESS; |
| 1180 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1181 | if (ret == FAILED) |
| 1182 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1183 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1184 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1185 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1186 | QLA_SUCCESS) { |
| 1187 | ql_log(ql_log_warn, vha, 0x8014, |
| 1188 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1189 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1190 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1192 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1193 | ql_log(ql_log_warn, vha, 0x802b, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1194 | "BUS RESET %s nexus=%ld:%d:%d.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1195 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1197 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | } |
| 1199 | |
| 1200 | /************************************************************************** |
| 1201 | * qla2xxx_eh_host_reset |
| 1202 | * |
| 1203 | * Description: |
| 1204 | * The reset function will reset the Adapter. |
| 1205 | * |
| 1206 | * Input: |
| 1207 | * cmd = Linux SCSI command packet of the command that cause the |
| 1208 | * adapter reset. |
| 1209 | * |
| 1210 | * Returns: |
| 1211 | * Either SUCCESS or FAILED. |
| 1212 | * |
| 1213 | * Note: |
| 1214 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1215 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1216 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1217 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1218 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1219 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1220 | int ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1221 | unsigned int id, lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1222 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1223 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1224 | id = cmd->device->id; |
| 1225 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1226 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1227 | ql_log(ql_log_info, vha, 0x8018, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1228 | "ADAPTER RESET ISSUED nexus=%ld:%d:%d.\n", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1229 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1230 | if (qla2x00_wait_for_reset_ready(vha) != QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1231 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1233 | if (vha != base_vha) { |
| 1234 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1235 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1236 | } else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1237 | if (IS_QLA82XX(vha->hw)) { |
| 1238 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1239 | /* Ctx reset success */ |
| 1240 | ret = SUCCESS; |
| 1241 | goto eh_host_reset_lock; |
| 1242 | } |
| 1243 | /* fall thru if ctx reset failed */ |
| 1244 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1245 | if (ha->wq) |
| 1246 | flush_workqueue(ha->wq); |
| 1247 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1248 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1249 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1250 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1251 | /* failed. schedule dpc to try */ |
| 1252 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1253 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1254 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1255 | ql_log(ql_log_warn, vha, 0x802a, |
| 1256 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1257 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1258 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1259 | } |
| 1260 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1261 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1262 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1263 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1264 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1265 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1266 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1268 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1269 | ql_log(ql_log_info, vha, 0x8017, |
| 1270 | "ADAPTER RESET %s nexus=%ld:%d:%d.\n", |
| 1271 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1272 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1273 | return ret; |
| 1274 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1275 | |
| 1276 | /* |
| 1277 | * qla2x00_loop_reset |
| 1278 | * Issue loop reset. |
| 1279 | * |
| 1280 | * Input: |
| 1281 | * ha = adapter block pointer. |
| 1282 | * |
| 1283 | * Returns: |
| 1284 | * 0 = success |
| 1285 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1286 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1287 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1289 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1290 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1291 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1292 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1293 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1294 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1295 | if (fcport->port_type != FCT_TARGET) |
| 1296 | continue; |
| 1297 | |
| 1298 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1299 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1300 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
| 1301 | "Bus Reset failed: Target Reset=%d " |
| 1302 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1303 | } |
| 1304 | } |
| 1305 | } |
| 1306 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1307 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Andrew Vasquez | 0b7e7c5 | 2013-02-08 01:57:42 -0500 | [diff] [blame] | 1308 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1309 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1310 | qla2x00_mark_all_devices_lost(vha, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1311 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1312 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1313 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1314 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1315 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1316 | } |
| 1317 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1318 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1319 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1320 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1321 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1322 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1323 | } |
| 1324 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1325 | /* Issue marker command only when we are going to start the I/O */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1326 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1327 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1328 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1329 | } |
| 1330 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1331 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1332 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1333 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1334 | int que, cnt; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1335 | unsigned long flags; |
| 1336 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1337 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1338 | struct req_que *req; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1339 | |
| 1340 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1341 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1342 | req = ha->req_q_map[que]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1343 | if (!req) |
| 1344 | continue; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1345 | if (!req->outstanding_cmds) |
| 1346 | continue; |
| 1347 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1348 | sp = req->outstanding_cmds[cnt]; |
Andrew Vasquez | e612d46 | 2009-03-24 09:08:04 -0700 | [diff] [blame] | 1349 | if (sp) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1350 | req->outstanding_cmds[cnt] = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1351 | sp->done(vha, sp, res); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1352 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1353 | } |
| 1354 | } |
| 1355 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1356 | } |
| 1357 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1358 | static int |
| 1359 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1360 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1361 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1362 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1363 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1364 | return -ENXIO; |
| 1365 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1366 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1367 | |
| 1368 | return 0; |
| 1369 | } |
| 1370 | |
| 1371 | static int |
| 1372 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1373 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1374 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1375 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1376 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1377 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1378 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1379 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1380 | if (sdev->tagged_supported) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1381 | scsi_activate_tcq(sdev, req->max_q_depth); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1382 | else |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1383 | scsi_deactivate_tcq(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1384 | return 0; |
| 1385 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1386 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1387 | static void |
| 1388 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1389 | { |
| 1390 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1391 | } |
| 1392 | |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1393 | static void qla2x00_handle_queue_full(struct scsi_device *sdev, int qdepth) |
| 1394 | { |
| 1395 | fc_port_t *fcport = (struct fc_port *) sdev->hostdata; |
| 1396 | |
| 1397 | if (!scsi_track_queue_full(sdev, qdepth)) |
| 1398 | return; |
| 1399 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1400 | ql_dbg(ql_dbg_io, fcport->vha, 0x3029, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1401 | "Queue depth adjusted-down to %d for nexus=%ld:%d:%d.\n", |
| 1402 | sdev->queue_depth, fcport->vha->host_no, sdev->id, sdev->lun); |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1403 | } |
| 1404 | |
| 1405 | static void qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, int qdepth) |
| 1406 | { |
| 1407 | fc_port_t *fcport = sdev->hostdata; |
| 1408 | struct scsi_qla_host *vha = fcport->vha; |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1409 | struct req_que *req = NULL; |
| 1410 | |
| 1411 | req = vha->req; |
| 1412 | if (!req) |
| 1413 | return; |
| 1414 | |
| 1415 | if (req->max_q_depth <= sdev->queue_depth || req->max_q_depth < qdepth) |
| 1416 | return; |
| 1417 | |
| 1418 | if (sdev->ordered_tags) |
| 1419 | scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, qdepth); |
| 1420 | else |
| 1421 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, qdepth); |
| 1422 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1423 | ql_dbg(ql_dbg_io, vha, 0x302a, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1424 | "Queue depth adjusted-up to %d for nexus=%ld:%d:%d.\n", |
| 1425 | sdev->queue_depth, fcport->vha->host_no, sdev->id, sdev->lun); |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1426 | } |
| 1427 | |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1428 | static int |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 1429 | qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1430 | { |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1431 | switch (reason) { |
| 1432 | case SCSI_QDEPTH_DEFAULT: |
| 1433 | scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); |
| 1434 | break; |
| 1435 | case SCSI_QDEPTH_QFULL: |
| 1436 | qla2x00_handle_queue_full(sdev, qdepth); |
| 1437 | break; |
| 1438 | case SCSI_QDEPTH_RAMP_UP: |
| 1439 | qla2x00_adjust_sdev_qdepth_up(sdev, qdepth); |
| 1440 | break; |
| 1441 | default: |
Roel Kluin | 08002af | 2010-01-29 11:25:19 +0100 | [diff] [blame] | 1442 | return -EOPNOTSUPP; |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1443 | } |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 1444 | |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1445 | return sdev->queue_depth; |
| 1446 | } |
| 1447 | |
| 1448 | static int |
| 1449 | qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type) |
| 1450 | { |
| 1451 | if (sdev->tagged_supported) { |
| 1452 | scsi_set_tag_type(sdev, tag_type); |
| 1453 | if (tag_type) |
| 1454 | scsi_activate_tcq(sdev, sdev->queue_depth); |
| 1455 | else |
| 1456 | scsi_deactivate_tcq(sdev, sdev->queue_depth); |
| 1457 | } else |
| 1458 | tag_type = 0; |
| 1459 | |
| 1460 | return tag_type; |
| 1461 | } |
| 1462 | |
Chad Dupuis | 3c290d0 | 2013-01-30 03:34:38 -0500 | [diff] [blame] | 1463 | static void |
| 1464 | qla2x00_host_ramp_down_queuedepth(scsi_qla_host_t *vha) |
| 1465 | { |
| 1466 | scsi_qla_host_t *vp; |
| 1467 | struct Scsi_Host *shost; |
| 1468 | struct scsi_device *sdev; |
| 1469 | struct qla_hw_data *ha = vha->hw; |
| 1470 | unsigned long flags; |
| 1471 | |
| 1472 | ha->host_last_rampdown_time = jiffies; |
| 1473 | |
| 1474 | if (ha->cfg_lun_q_depth <= vha->host->cmd_per_lun) |
| 1475 | return; |
| 1476 | |
| 1477 | if ((ha->cfg_lun_q_depth / 2) < vha->host->cmd_per_lun) |
| 1478 | ha->cfg_lun_q_depth = vha->host->cmd_per_lun; |
| 1479 | else |
| 1480 | ha->cfg_lun_q_depth = ha->cfg_lun_q_depth / 2; |
| 1481 | |
| 1482 | /* |
| 1483 | * Geometrically ramp down the queue depth for all devices on this |
| 1484 | * adapter |
| 1485 | */ |
| 1486 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 1487 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 1488 | shost = vp->host; |
| 1489 | shost_for_each_device(sdev, shost) { |
| 1490 | if (sdev->queue_depth > shost->cmd_per_lun) { |
| 1491 | if (sdev->queue_depth < ha->cfg_lun_q_depth) |
| 1492 | continue; |
| 1493 | ql_log(ql_log_warn, vp, 0x3031, |
| 1494 | "%ld:%d:%d: Ramping down queue depth to %d", |
| 1495 | vp->host_no, sdev->id, sdev->lun, |
| 1496 | ha->cfg_lun_q_depth); |
| 1497 | qla2x00_change_queue_depth(sdev, |
| 1498 | ha->cfg_lun_q_depth, SCSI_QDEPTH_DEFAULT); |
| 1499 | } |
| 1500 | } |
| 1501 | } |
| 1502 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 1503 | |
| 1504 | return; |
| 1505 | } |
| 1506 | |
| 1507 | static void |
| 1508 | qla2x00_host_ramp_up_queuedepth(scsi_qla_host_t *vha) |
| 1509 | { |
| 1510 | scsi_qla_host_t *vp; |
| 1511 | struct Scsi_Host *shost; |
| 1512 | struct scsi_device *sdev; |
| 1513 | struct qla_hw_data *ha = vha->hw; |
| 1514 | unsigned long flags; |
| 1515 | |
| 1516 | ha->host_last_rampup_time = jiffies; |
| 1517 | ha->cfg_lun_q_depth++; |
| 1518 | |
| 1519 | /* |
| 1520 | * Linearly ramp up the queue depth for all devices on this |
| 1521 | * adapter |
| 1522 | */ |
| 1523 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 1524 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 1525 | shost = vp->host; |
| 1526 | shost_for_each_device(sdev, shost) { |
| 1527 | if (sdev->queue_depth > ha->cfg_lun_q_depth) |
| 1528 | continue; |
| 1529 | qla2x00_change_queue_depth(sdev, ha->cfg_lun_q_depth, |
| 1530 | SCSI_QDEPTH_RAMP_UP); |
| 1531 | } |
| 1532 | } |
| 1533 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 1534 | |
| 1535 | return; |
| 1536 | } |
| 1537 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1538 | /** |
| 1539 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1540 | * @ha: HA context |
| 1541 | * |
| 1542 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1543 | * supported addressing method. |
| 1544 | */ |
| 1545 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1546 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1547 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1548 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1549 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1550 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1551 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1552 | /* Any upper-dword bits set? */ |
| 1553 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1554 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1555 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1556 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1557 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1558 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1559 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1560 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1562 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1563 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1564 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1565 | } |
| 1566 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1567 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1568 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1569 | { |
| 1570 | unsigned long flags = 0; |
| 1571 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1572 | |
| 1573 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1574 | ha->interrupts_on = 1; |
| 1575 | /* enable risc and host interrupts */ |
| 1576 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1577 | RD_REG_WORD(®->ictrl); |
| 1578 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1579 | |
| 1580 | } |
| 1581 | |
| 1582 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1583 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1584 | { |
| 1585 | unsigned long flags = 0; |
| 1586 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1587 | |
| 1588 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1589 | ha->interrupts_on = 0; |
| 1590 | /* disable risc and host interrupts */ |
| 1591 | WRT_REG_WORD(®->ictrl, 0); |
| 1592 | RD_REG_WORD(®->ictrl); |
| 1593 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1594 | } |
| 1595 | |
| 1596 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1597 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1598 | { |
| 1599 | unsigned long flags = 0; |
| 1600 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1601 | |
| 1602 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1603 | ha->interrupts_on = 1; |
| 1604 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1605 | RD_REG_DWORD(®->ictrl); |
| 1606 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1607 | } |
| 1608 | |
| 1609 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1610 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1611 | { |
| 1612 | unsigned long flags = 0; |
| 1613 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1614 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1615 | if (IS_NOPOLLING_TYPE(ha)) |
| 1616 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1617 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1618 | ha->interrupts_on = 0; |
| 1619 | WRT_REG_DWORD(®->ictrl, 0); |
| 1620 | RD_REG_DWORD(®->ictrl); |
| 1621 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1622 | } |
| 1623 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1624 | static int |
| 1625 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1626 | { |
| 1627 | resource_size_t pio; |
| 1628 | uint16_t msix; |
| 1629 | int cpus; |
| 1630 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1631 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1632 | QLA2XXX_DRIVER_NAME)) { |
| 1633 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1634 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1635 | pci_name(ha->pdev)); |
| 1636 | goto iospace_error_exit; |
| 1637 | } |
| 1638 | if (!(ha->bars & 1)) |
| 1639 | goto skip_pio; |
| 1640 | |
| 1641 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1642 | pio = pci_resource_start(ha->pdev, 0); |
| 1643 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1644 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1645 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1646 | "Invalid pci I/O region size (%s).\n", |
| 1647 | pci_name(ha->pdev)); |
| 1648 | pio = 0; |
| 1649 | } |
| 1650 | } else { |
| 1651 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1652 | "Region #0 no a PIO resource (%s).\n", |
| 1653 | pci_name(ha->pdev)); |
| 1654 | pio = 0; |
| 1655 | } |
| 1656 | ha->pio_address = pio; |
| 1657 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1658 | "PIO address=%llu.\n", |
| 1659 | (unsigned long long)ha->pio_address); |
| 1660 | |
| 1661 | skip_pio: |
| 1662 | /* Use MMIO operations for all accesses. */ |
| 1663 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1664 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1665 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1666 | pci_name(ha->pdev)); |
| 1667 | goto iospace_error_exit; |
| 1668 | } |
| 1669 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1670 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1671 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1672 | pci_name(ha->pdev)); |
| 1673 | goto iospace_error_exit; |
| 1674 | } |
| 1675 | |
| 1676 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1677 | if (!ha->iobase) { |
| 1678 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1679 | "Cannot remap MMIO (%s), aborting.\n", |
| 1680 | pci_name(ha->pdev)); |
| 1681 | goto iospace_error_exit; |
| 1682 | } |
| 1683 | |
| 1684 | /* Determine queue resources */ |
| 1685 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1686 | if ((ql2xmaxqueues <= 1 && !ql2xmultique_tag) || |
| 1687 | (ql2xmaxqueues > 1 && ql2xmultique_tag) || |
| 1688 | (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
| 1689 | goto mqiobase_exit; |
| 1690 | |
| 1691 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1692 | pci_resource_len(ha->pdev, 3)); |
| 1693 | if (ha->mqiobase) { |
| 1694 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 1695 | "MQIO Base=%p.\n", ha->mqiobase); |
| 1696 | /* Read MSIX vector size of the board */ |
| 1697 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
| 1698 | ha->msix_count = msix; |
| 1699 | /* Max queues are bounded by available msix vectors */ |
| 1700 | /* queue 0 uses two msix vectors */ |
| 1701 | if (ql2xmultique_tag) { |
| 1702 | cpus = num_online_cpus(); |
| 1703 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1704 | (cpus + 1) : (ha->msix_count - 1); |
| 1705 | ha->max_req_queues = 2; |
| 1706 | } else if (ql2xmaxqueues > 1) { |
| 1707 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1708 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1709 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc008, |
| 1710 | "QoS mode set, max no of request queues:%d.\n", |
| 1711 | ha->max_req_queues); |
| 1712 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0019, |
| 1713 | "QoS mode set, max no of request queues:%d.\n", |
| 1714 | ha->max_req_queues); |
| 1715 | } |
| 1716 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
| 1717 | "MSI-X vector count: %d.\n", msix); |
| 1718 | } else |
| 1719 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 1720 | "BAR 3 not enabled.\n"); |
| 1721 | |
| 1722 | mqiobase_exit: |
| 1723 | ha->msix_count = ha->max_rsp_queues + 1; |
| 1724 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
| 1725 | "MSIX Count:%d.\n", ha->msix_count); |
| 1726 | return (0); |
| 1727 | |
| 1728 | iospace_error_exit: |
| 1729 | return (-ENOMEM); |
| 1730 | } |
| 1731 | |
| 1732 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1733 | static int |
| 1734 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 1735 | { |
| 1736 | uint16_t msix; |
| 1737 | int cpus; |
| 1738 | |
| 1739 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1740 | QLA2XXX_DRIVER_NAME)) { |
| 1741 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 1742 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1743 | pci_name(ha->pdev)); |
| 1744 | |
| 1745 | goto iospace_error_exit; |
| 1746 | } |
| 1747 | |
| 1748 | /* Use MMIO operations for all accesses. */ |
| 1749 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 1750 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 1751 | "Invalid pci I/O region size (%s).\n", |
| 1752 | pci_name(ha->pdev)); |
| 1753 | goto iospace_error_exit; |
| 1754 | } |
| 1755 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1756 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 1757 | "Invalid PCI mem region size (%s), aborting\n", |
| 1758 | pci_name(ha->pdev)); |
| 1759 | goto iospace_error_exit; |
| 1760 | } |
| 1761 | |
| 1762 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 1763 | if (!ha->iobase) { |
| 1764 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 1765 | "Cannot remap MMIO (%s), aborting.\n", |
| 1766 | pci_name(ha->pdev)); |
| 1767 | goto iospace_error_exit; |
| 1768 | } |
| 1769 | |
| 1770 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 1771 | /* 83XX 26XX always use MQ type access for queues |
| 1772 | * - mbar 2, a.k.a region 4 */ |
| 1773 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1774 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 1775 | pci_resource_len(ha->pdev, 4)); |
| 1776 | |
| 1777 | if (!ha->mqiobase) { |
| 1778 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 1779 | "BAR2/region4 not enabled\n"); |
| 1780 | goto mqiobase_exit; |
| 1781 | } |
| 1782 | |
| 1783 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 1784 | pci_resource_len(ha->pdev, 2)); |
| 1785 | if (ha->msixbase) { |
| 1786 | /* Read MSIX vector size of the board */ |
| 1787 | pci_read_config_word(ha->pdev, |
| 1788 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
| 1789 | ha->msix_count = msix; |
| 1790 | /* Max queues are bounded by available msix vectors */ |
| 1791 | /* queue 0 uses two msix vectors */ |
| 1792 | if (ql2xmultique_tag) { |
| 1793 | cpus = num_online_cpus(); |
| 1794 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1795 | (cpus + 1) : (ha->msix_count - 1); |
| 1796 | ha->max_req_queues = 2; |
| 1797 | } else if (ql2xmaxqueues > 1) { |
| 1798 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1799 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1800 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc00c, |
| 1801 | "QoS mode set, max no of request queues:%d.\n", |
| 1802 | ha->max_req_queues); |
| 1803 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b, |
| 1804 | "QoS mode set, max no of request queues:%d.\n", |
| 1805 | ha->max_req_queues); |
| 1806 | } |
| 1807 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
| 1808 | "MSI-X vector count: %d.\n", msix); |
| 1809 | } else |
| 1810 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 1811 | "BAR 1 not enabled.\n"); |
| 1812 | |
| 1813 | mqiobase_exit: |
| 1814 | ha->msix_count = ha->max_rsp_queues + 1; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 1815 | |
| 1816 | qlt_83xx_iospace_config(ha); |
| 1817 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1818 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
| 1819 | "MSIX Count:%d.\n", ha->msix_count); |
| 1820 | return 0; |
| 1821 | |
| 1822 | iospace_error_exit: |
| 1823 | return -ENOMEM; |
| 1824 | } |
| 1825 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1826 | static struct isp_operations qla2100_isp_ops = { |
| 1827 | .pci_config = qla2100_pci_config, |
| 1828 | .reset_chip = qla2x00_reset_chip, |
| 1829 | .chip_diag = qla2x00_chip_diag, |
| 1830 | .config_rings = qla2x00_config_rings, |
| 1831 | .reset_adapter = qla2x00_reset_adapter, |
| 1832 | .nvram_config = qla2x00_nvram_config, |
| 1833 | .update_fw_options = qla2x00_update_fw_options, |
| 1834 | .load_risc = qla2x00_load_risc, |
| 1835 | .pci_info_str = qla2x00_pci_info_str, |
| 1836 | .fw_version_str = qla2x00_fw_version_str, |
| 1837 | .intr_handler = qla2100_intr_handler, |
| 1838 | .enable_intrs = qla2x00_enable_intrs, |
| 1839 | .disable_intrs = qla2x00_disable_intrs, |
| 1840 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1841 | .target_reset = qla2x00_abort_target, |
| 1842 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1843 | .fabric_login = qla2x00_login_fabric, |
| 1844 | .fabric_logout = qla2x00_fabric_logout, |
| 1845 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1846 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1847 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1848 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1849 | .read_nvram = qla2x00_read_nvram_data, |
| 1850 | .write_nvram = qla2x00_write_nvram_data, |
| 1851 | .fw_dump = qla2100_fw_dump, |
| 1852 | .beacon_on = NULL, |
| 1853 | .beacon_off = NULL, |
| 1854 | .beacon_blink = NULL, |
| 1855 | .read_optrom = qla2x00_read_optrom_data, |
| 1856 | .write_optrom = qla2x00_write_optrom_data, |
| 1857 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1858 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1859 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1860 | .iospace_config = qla2x00_iospace_config, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1861 | }; |
| 1862 | |
| 1863 | static struct isp_operations qla2300_isp_ops = { |
| 1864 | .pci_config = qla2300_pci_config, |
| 1865 | .reset_chip = qla2x00_reset_chip, |
| 1866 | .chip_diag = qla2x00_chip_diag, |
| 1867 | .config_rings = qla2x00_config_rings, |
| 1868 | .reset_adapter = qla2x00_reset_adapter, |
| 1869 | .nvram_config = qla2x00_nvram_config, |
| 1870 | .update_fw_options = qla2x00_update_fw_options, |
| 1871 | .load_risc = qla2x00_load_risc, |
| 1872 | .pci_info_str = qla2x00_pci_info_str, |
| 1873 | .fw_version_str = qla2x00_fw_version_str, |
| 1874 | .intr_handler = qla2300_intr_handler, |
| 1875 | .enable_intrs = qla2x00_enable_intrs, |
| 1876 | .disable_intrs = qla2x00_disable_intrs, |
| 1877 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1878 | .target_reset = qla2x00_abort_target, |
| 1879 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1880 | .fabric_login = qla2x00_login_fabric, |
| 1881 | .fabric_logout = qla2x00_fabric_logout, |
| 1882 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1883 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1884 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1885 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1886 | .read_nvram = qla2x00_read_nvram_data, |
| 1887 | .write_nvram = qla2x00_write_nvram_data, |
| 1888 | .fw_dump = qla2300_fw_dump, |
| 1889 | .beacon_on = qla2x00_beacon_on, |
| 1890 | .beacon_off = qla2x00_beacon_off, |
| 1891 | .beacon_blink = qla2x00_beacon_blink, |
| 1892 | .read_optrom = qla2x00_read_optrom_data, |
| 1893 | .write_optrom = qla2x00_write_optrom_data, |
| 1894 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1895 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1896 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1897 | .iospace_config = qla2x00_iospace_config, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1898 | }; |
| 1899 | |
| 1900 | static struct isp_operations qla24xx_isp_ops = { |
| 1901 | .pci_config = qla24xx_pci_config, |
| 1902 | .reset_chip = qla24xx_reset_chip, |
| 1903 | .chip_diag = qla24xx_chip_diag, |
| 1904 | .config_rings = qla24xx_config_rings, |
| 1905 | .reset_adapter = qla24xx_reset_adapter, |
| 1906 | .nvram_config = qla24xx_nvram_config, |
| 1907 | .update_fw_options = qla24xx_update_fw_options, |
| 1908 | .load_risc = qla24xx_load_risc, |
| 1909 | .pci_info_str = qla24xx_pci_info_str, |
| 1910 | .fw_version_str = qla24xx_fw_version_str, |
| 1911 | .intr_handler = qla24xx_intr_handler, |
| 1912 | .enable_intrs = qla24xx_enable_intrs, |
| 1913 | .disable_intrs = qla24xx_disable_intrs, |
| 1914 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1915 | .target_reset = qla24xx_abort_target, |
| 1916 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1917 | .fabric_login = qla24xx_login_fabric, |
| 1918 | .fabric_logout = qla24xx_fabric_logout, |
| 1919 | .calc_req_entries = NULL, |
| 1920 | .build_iocbs = NULL, |
| 1921 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1922 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1923 | .read_nvram = qla24xx_read_nvram_data, |
| 1924 | .write_nvram = qla24xx_write_nvram_data, |
| 1925 | .fw_dump = qla24xx_fw_dump, |
| 1926 | .beacon_on = qla24xx_beacon_on, |
| 1927 | .beacon_off = qla24xx_beacon_off, |
| 1928 | .beacon_blink = qla24xx_beacon_blink, |
| 1929 | .read_optrom = qla24xx_read_optrom_data, |
| 1930 | .write_optrom = qla24xx_write_optrom_data, |
| 1931 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1932 | .start_scsi = qla24xx_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1933 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1934 | .iospace_config = qla2x00_iospace_config, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1935 | }; |
| 1936 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1937 | static struct isp_operations qla25xx_isp_ops = { |
| 1938 | .pci_config = qla25xx_pci_config, |
| 1939 | .reset_chip = qla24xx_reset_chip, |
| 1940 | .chip_diag = qla24xx_chip_diag, |
| 1941 | .config_rings = qla24xx_config_rings, |
| 1942 | .reset_adapter = qla24xx_reset_adapter, |
| 1943 | .nvram_config = qla24xx_nvram_config, |
| 1944 | .update_fw_options = qla24xx_update_fw_options, |
| 1945 | .load_risc = qla24xx_load_risc, |
| 1946 | .pci_info_str = qla24xx_pci_info_str, |
| 1947 | .fw_version_str = qla24xx_fw_version_str, |
| 1948 | .intr_handler = qla24xx_intr_handler, |
| 1949 | .enable_intrs = qla24xx_enable_intrs, |
| 1950 | .disable_intrs = qla24xx_disable_intrs, |
| 1951 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1952 | .target_reset = qla24xx_abort_target, |
| 1953 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1954 | .fabric_login = qla24xx_login_fabric, |
| 1955 | .fabric_logout = qla24xx_fabric_logout, |
| 1956 | .calc_req_entries = NULL, |
| 1957 | .build_iocbs = NULL, |
| 1958 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1959 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1960 | .read_nvram = qla25xx_read_nvram_data, |
| 1961 | .write_nvram = qla25xx_write_nvram_data, |
| 1962 | .fw_dump = qla25xx_fw_dump, |
| 1963 | .beacon_on = qla24xx_beacon_on, |
| 1964 | .beacon_off = qla24xx_beacon_off, |
| 1965 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 1966 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1967 | .write_optrom = qla24xx_write_optrom_data, |
| 1968 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1969 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1970 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1971 | .iospace_config = qla2x00_iospace_config, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1972 | }; |
| 1973 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1974 | static struct isp_operations qla81xx_isp_ops = { |
| 1975 | .pci_config = qla25xx_pci_config, |
| 1976 | .reset_chip = qla24xx_reset_chip, |
| 1977 | .chip_diag = qla24xx_chip_diag, |
| 1978 | .config_rings = qla24xx_config_rings, |
| 1979 | .reset_adapter = qla24xx_reset_adapter, |
| 1980 | .nvram_config = qla81xx_nvram_config, |
| 1981 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 1982 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1983 | .pci_info_str = qla24xx_pci_info_str, |
| 1984 | .fw_version_str = qla24xx_fw_version_str, |
| 1985 | .intr_handler = qla24xx_intr_handler, |
| 1986 | .enable_intrs = qla24xx_enable_intrs, |
| 1987 | .disable_intrs = qla24xx_disable_intrs, |
| 1988 | .abort_command = qla24xx_abort_command, |
| 1989 | .target_reset = qla24xx_abort_target, |
| 1990 | .lun_reset = qla24xx_lun_reset, |
| 1991 | .fabric_login = qla24xx_login_fabric, |
| 1992 | .fabric_logout = qla24xx_fabric_logout, |
| 1993 | .calc_req_entries = NULL, |
| 1994 | .build_iocbs = NULL, |
| 1995 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1996 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 1997 | .read_nvram = NULL, |
| 1998 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1999 | .fw_dump = qla81xx_fw_dump, |
| 2000 | .beacon_on = qla24xx_beacon_on, |
| 2001 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2002 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2003 | .read_optrom = qla25xx_read_optrom_data, |
| 2004 | .write_optrom = qla24xx_write_optrom_data, |
| 2005 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 2006 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2007 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2008 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2009 | }; |
| 2010 | |
| 2011 | static struct isp_operations qla82xx_isp_ops = { |
| 2012 | .pci_config = qla82xx_pci_config, |
| 2013 | .reset_chip = qla82xx_reset_chip, |
| 2014 | .chip_diag = qla24xx_chip_diag, |
| 2015 | .config_rings = qla82xx_config_rings, |
| 2016 | .reset_adapter = qla24xx_reset_adapter, |
| 2017 | .nvram_config = qla81xx_nvram_config, |
| 2018 | .update_fw_options = qla24xx_update_fw_options, |
| 2019 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 2020 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2021 | .fw_version_str = qla24xx_fw_version_str, |
| 2022 | .intr_handler = qla82xx_intr_handler, |
| 2023 | .enable_intrs = qla82xx_enable_intrs, |
| 2024 | .disable_intrs = qla82xx_disable_intrs, |
| 2025 | .abort_command = qla24xx_abort_command, |
| 2026 | .target_reset = qla24xx_abort_target, |
| 2027 | .lun_reset = qla24xx_lun_reset, |
| 2028 | .fabric_login = qla24xx_login_fabric, |
| 2029 | .fabric_logout = qla24xx_fabric_logout, |
| 2030 | .calc_req_entries = NULL, |
| 2031 | .build_iocbs = NULL, |
| 2032 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2033 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2034 | .read_nvram = qla24xx_read_nvram_data, |
| 2035 | .write_nvram = qla24xx_write_nvram_data, |
| 2036 | .fw_dump = qla24xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 2037 | .beacon_on = qla82xx_beacon_on, |
| 2038 | .beacon_off = qla82xx_beacon_off, |
| 2039 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2040 | .read_optrom = qla82xx_read_optrom_data, |
| 2041 | .write_optrom = qla82xx_write_optrom_data, |
| 2042 | .get_flash_version = qla24xx_get_flash_version, |
| 2043 | .start_scsi = qla82xx_start_scsi, |
| 2044 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2045 | .iospace_config = qla82xx_iospace_config, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2046 | }; |
| 2047 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2048 | static struct isp_operations qla83xx_isp_ops = { |
| 2049 | .pci_config = qla25xx_pci_config, |
| 2050 | .reset_chip = qla24xx_reset_chip, |
| 2051 | .chip_diag = qla24xx_chip_diag, |
| 2052 | .config_rings = qla24xx_config_rings, |
| 2053 | .reset_adapter = qla24xx_reset_adapter, |
| 2054 | .nvram_config = qla81xx_nvram_config, |
| 2055 | .update_fw_options = qla81xx_update_fw_options, |
| 2056 | .load_risc = qla81xx_load_risc, |
| 2057 | .pci_info_str = qla24xx_pci_info_str, |
| 2058 | .fw_version_str = qla24xx_fw_version_str, |
| 2059 | .intr_handler = qla24xx_intr_handler, |
| 2060 | .enable_intrs = qla24xx_enable_intrs, |
| 2061 | .disable_intrs = qla24xx_disable_intrs, |
| 2062 | .abort_command = qla24xx_abort_command, |
| 2063 | .target_reset = qla24xx_abort_target, |
| 2064 | .lun_reset = qla24xx_lun_reset, |
| 2065 | .fabric_login = qla24xx_login_fabric, |
| 2066 | .fabric_logout = qla24xx_fabric_logout, |
| 2067 | .calc_req_entries = NULL, |
| 2068 | .build_iocbs = NULL, |
| 2069 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2070 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2071 | .read_nvram = NULL, |
| 2072 | .write_nvram = NULL, |
| 2073 | .fw_dump = qla83xx_fw_dump, |
| 2074 | .beacon_on = qla24xx_beacon_on, |
| 2075 | .beacon_off = qla24xx_beacon_off, |
| 2076 | .beacon_blink = qla83xx_beacon_blink, |
| 2077 | .read_optrom = qla25xx_read_optrom_data, |
| 2078 | .write_optrom = qla24xx_write_optrom_data, |
| 2079 | .get_flash_version = qla24xx_get_flash_version, |
| 2080 | .start_scsi = qla24xx_dif_start_scsi, |
| 2081 | .abort_isp = qla2x00_abort_isp, |
| 2082 | .iospace_config = qla83xx_iospace_config, |
| 2083 | }; |
| 2084 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2085 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2086 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2087 | { |
| 2088 | ha->device_type = DT_EXTENDED_IDS; |
| 2089 | switch (ha->pdev->device) { |
| 2090 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
| 2091 | ha->device_type |= DT_ISP2100; |
| 2092 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2093 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2094 | break; |
| 2095 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
| 2096 | ha->device_type |= DT_ISP2200; |
| 2097 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2098 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2099 | break; |
| 2100 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
| 2101 | ha->device_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2102 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2103 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2104 | break; |
| 2105 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
| 2106 | ha->device_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2107 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2108 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2109 | break; |
| 2110 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
| 2111 | ha->device_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2112 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2113 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2114 | ha->pdev->subsystem_device == 0x0170) |
| 2115 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2116 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2117 | break; |
| 2118 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
| 2119 | ha->device_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2120 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2121 | break; |
| 2122 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
| 2123 | ha->device_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2124 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2125 | break; |
| 2126 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
| 2127 | ha->device_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2128 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2129 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2130 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2131 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2132 | break; |
| 2133 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
| 2134 | ha->device_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2135 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2136 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2137 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2138 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2139 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2140 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
| 2141 | ha->device_type |= DT_ISP8432; |
| 2142 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2143 | ha->device_type |= DT_FWI2; |
| 2144 | ha->device_type |= DT_IIDMA; |
| 2145 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2146 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2147 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
| 2148 | ha->device_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2149 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2150 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2151 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2152 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
| 2153 | ha->device_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2154 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2155 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2156 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2157 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
| 2158 | ha->device_type |= DT_ISP2532; |
| 2159 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2160 | ha->device_type |= DT_FWI2; |
| 2161 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2162 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2163 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2164 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
| 2165 | ha->device_type |= DT_ISP8001; |
| 2166 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2167 | ha->device_type |= DT_FWI2; |
| 2168 | ha->device_type |= DT_IIDMA; |
| 2169 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2170 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2171 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
| 2172 | ha->device_type |= DT_ISP8021; |
| 2173 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2174 | ha->device_type |= DT_FWI2; |
| 2175 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2176 | /* Initialize 82XX ISP flags */ |
| 2177 | qla82xx_init_flags(ha); |
| 2178 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2179 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
| 2180 | ha->device_type |= DT_ISP2031; |
| 2181 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2182 | ha->device_type |= DT_FWI2; |
| 2183 | ha->device_type |= DT_IIDMA; |
| 2184 | ha->device_type |= DT_T10_PI; |
| 2185 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2186 | break; |
| 2187 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
| 2188 | ha->device_type |= DT_ISP8031; |
| 2189 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2190 | ha->device_type |= DT_FWI2; |
| 2191 | ha->device_type |= DT_IIDMA; |
| 2192 | ha->device_type |= DT_T10_PI; |
| 2193 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2194 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2195 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2196 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2197 | if (IS_QLA82XX(ha)) |
| 2198 | ha->port_no = !(ha->portnum & 1); |
| 2199 | else |
| 2200 | /* Get adapter physical port no from interrupt pin register. */ |
| 2201 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
| 2202 | |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2203 | if (ha->port_no & 1) |
| 2204 | ha->flags.port0 = 1; |
| 2205 | else |
| 2206 | ha->flags.port0 = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2207 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2208 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2209 | ha->device_type, ha->flags.port0, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2210 | } |
| 2211 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2212 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2213 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2214 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2215 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2216 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2217 | if (vha->hw->flags.running_gold_fw) |
| 2218 | return; |
| 2219 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2220 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2221 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2222 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2223 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2224 | } |
| 2225 | |
| 2226 | static int |
| 2227 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2228 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2229 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2230 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2231 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2232 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2233 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2234 | return 1; |
| 2235 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2236 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2237 | } |
| 2238 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2239 | /* |
| 2240 | * PCI driver interface |
| 2241 | */ |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 2242 | static int |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2243 | qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2244 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2245 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2246 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2247 | scsi_qla_host_t *base_vha = NULL; |
| 2248 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2249 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2250 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2251 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2252 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2253 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2254 | struct req_que *req = NULL; |
| 2255 | struct rsp_que *rsp = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2256 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2257 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2258 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2259 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2260 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2261 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2262 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2263 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2264 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2265 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2266 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2267 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
| 2268 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2269 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2270 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2271 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2272 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2273 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2274 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2275 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2276 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2277 | if (mem_only) { |
| 2278 | if (pci_enable_device_mem(pdev)) |
| 2279 | goto probe_out; |
| 2280 | } else { |
| 2281 | if (pci_enable_device(pdev)) |
| 2282 | goto probe_out; |
| 2283 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2284 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2285 | /* This may fail but that's ok */ |
| 2286 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2287 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2288 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2289 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2290 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2291 | "Unable to allocate memory for ha.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2292 | goto probe_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2293 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2294 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2295 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2296 | ha->pdev = pdev; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2297 | ha->tgt.enable_class_2 = ql2xenableclass2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2298 | |
| 2299 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2300 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2301 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2302 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2303 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2304 | mutex_init(&ha->selflogin_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2305 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2306 | /* Set ISP-type information. */ |
| 2307 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2308 | |
| 2309 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2310 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
| 2311 | IS_QLA83XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2312 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2313 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2314 | ha->prev_topology = 0; |
| 2315 | ha->init_cb_size = sizeof(init_cb_t); |
| 2316 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2317 | ha->optrom_size = OPTROM_SIZE_2300; |
Chad Dupuis | 3c290d0 | 2013-01-30 03:34:38 -0500 | [diff] [blame] | 2318 | ha->cfg_lun_q_depth = ql2xmaxqdepth; |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2319 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2320 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2321 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2322 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2323 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2324 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2325 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2326 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2327 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2328 | ha->flash_conf_off = ~0; |
| 2329 | ha->flash_data_off = ~0; |
| 2330 | ha->nvram_conf_off = ~0; |
| 2331 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2332 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2333 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2334 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2335 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2336 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2337 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2338 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2339 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2340 | ha->flash_conf_off = ~0; |
| 2341 | ha->flash_data_off = ~0; |
| 2342 | ha->nvram_conf_off = ~0; |
| 2343 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2344 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2345 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2346 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2347 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2348 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2349 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2350 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2351 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2352 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2353 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2354 | ha->flash_conf_off = ~0; |
| 2355 | ha->flash_data_off = ~0; |
| 2356 | ha->nvram_conf_off = ~0; |
| 2357 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2358 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2359 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2360 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2361 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2362 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2363 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2364 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2365 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2366 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2367 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2368 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2369 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2370 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2371 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2372 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2373 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2374 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2375 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2376 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2377 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2378 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2379 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2380 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2381 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2382 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2383 | ha->gid_list_info_size = 8; |
| 2384 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2385 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2386 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2387 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2388 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2389 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2390 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2391 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2392 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2393 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2394 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2395 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 2396 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2397 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2398 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2399 | ha->gid_list_info_size = 8; |
| 2400 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2401 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2402 | ha->isp_ops = &qla81xx_isp_ops; |
| 2403 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2404 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2405 | ha->nvram_conf_off = ~0; |
| 2406 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2407 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2408 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2409 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2410 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2411 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2412 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2413 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2414 | ha->gid_list_info_size = 8; |
| 2415 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2416 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2417 | ha->isp_ops = &qla82xx_isp_ops; |
| 2418 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2419 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2420 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2421 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2422 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2423 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2424 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2425 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2426 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2427 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | b8aa4bd | 2013-01-30 03:34:40 -0500 | [diff] [blame] | 2428 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2429 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2430 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2431 | ha->gid_list_info_size = 8; |
| 2432 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2433 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2434 | ha->isp_ops = &qla83xx_isp_ops; |
| 2435 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2436 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2437 | ha->nvram_conf_off = ~0; |
| 2438 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2440 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2441 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 2442 | "mbx_count=%d, req_length=%d, " |
| 2443 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2444 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 2445 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2446 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 2447 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2448 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2449 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 2450 | "isp_ops=%p, flash_conf_off=%d, " |
| 2451 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 2452 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 2453 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2454 | |
| 2455 | /* Configure PCI I/O space */ |
| 2456 | ret = ha->isp_ops->iospace_config(ha); |
| 2457 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2458 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2459 | |
| 2460 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 2461 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 2462 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 2463 | mutex_init(&ha->vport_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2464 | init_completion(&ha->mbx_cmd_comp); |
| 2465 | complete(&ha->mbx_cmd_comp); |
| 2466 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 2467 | init_completion(&ha->dcbx_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2468 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2469 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2470 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 2471 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2472 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 2473 | "64 Bit addressing is %s.\n", |
| 2474 | ha->flags.enable_64bit_addressing ? "enable" : |
| 2475 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2476 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2477 | if (!ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2478 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 2479 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2480 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2481 | goto probe_hw_failed; |
| 2482 | } |
| 2483 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2484 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2485 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2486 | req->max_q_depth = ql2xmaxqdepth; |
| 2487 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2488 | |
| 2489 | base_vha = qla2x00_create_host(sht, ha); |
| 2490 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2491 | ret = -ENOMEM; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2492 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2493 | qla2x00_free_req_que(ha, req); |
| 2494 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2495 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2496 | } |
| 2497 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2498 | pci_set_drvdata(pdev, base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2499 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2500 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2501 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2502 | host->can_queue = req->length + 128; |
| 2503 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2504 | base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2505 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2506 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 2507 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2508 | |
| 2509 | /* Set the SG table size based on ISP type */ |
| 2510 | if (!IS_FWI2_CAPABLE(ha)) { |
| 2511 | if (IS_QLA2100(ha)) |
| 2512 | host->sg_tablesize = 32; |
| 2513 | } else { |
| 2514 | if (!IS_QLA82XX(ha)) |
| 2515 | host->sg_tablesize = QLA_SG_ALL; |
| 2516 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2517 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 2518 | "can_queue=%d, req=%p, " |
| 2519 | "mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 2520 | host->can_queue, base_vha->req, |
| 2521 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2522 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2523 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 2524 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2525 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2526 | host->max_cmd_len = 32; |
| 2527 | else |
| 2528 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 2529 | host->max_channel = MAX_BUSES - 1; |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 2530 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2531 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2532 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2533 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2534 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 2535 | "max_id=%d this_id=%d " |
| 2536 | "cmd_per_len=%d unique_id=%d max_cmd_len=%d max_channel=%d " |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2537 | "max_lun=%d transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2538 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 2539 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 2540 | host->transportt, sht->vendor_id); |
| 2541 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2542 | que_init: |
| 2543 | /* Alloc arrays of request and response ring ptrs */ |
| 2544 | if (!qla2x00_alloc_queues(ha, req, rsp)) { |
| 2545 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 2546 | "Failed to allocate memory for queue pointers..." |
| 2547 | "aborting.\n"); |
| 2548 | goto probe_init_failed; |
| 2549 | } |
| 2550 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2551 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2552 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2553 | /* Set up the irqs */ |
| 2554 | ret = qla2x00_request_irqs(ha, rsp); |
| 2555 | if (ret) |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2556 | goto probe_init_failed; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2557 | |
| 2558 | pci_save_state(pdev); |
| 2559 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2560 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2561 | rsp->req = req; |
| 2562 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2563 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2564 | /* FWI2-capable only. */ |
| 2565 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 2566 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 2567 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 2568 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2569 | if (ha->mqenable || IS_QLA83XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2570 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 2571 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 2572 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 2573 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 2574 | } |
| 2575 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2576 | if (IS_QLA82XX(ha)) { |
| 2577 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 2578 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 2579 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 2580 | } |
| 2581 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2582 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 2583 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2584 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2585 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 2586 | "req->req_q_in=%p req->req_q_out=%p " |
| 2587 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2588 | req->req_q_in, req->req_q_out, |
| 2589 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 2590 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 2591 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2592 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2593 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 2594 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2595 | req->req_q_in, req->req_q_out, rsp->rsp_q_in, rsp->rsp_q_out); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2596 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2597 | if (qla2x00_initialize_adapter(base_vha)) { |
| 2598 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 2599 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 2600 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2601 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2602 | if (IS_QLA82XX(ha)) { |
| 2603 | qla82xx_idc_lock(ha); |
| 2604 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2605 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2606 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2607 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 2608 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2609 | } |
| 2610 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2611 | ret = -ENODEV; |
| 2612 | goto probe_failed; |
| 2613 | } |
| 2614 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2615 | if (ha->mqenable) { |
| 2616 | if (qla25xx_setup_mode(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2617 | ql_log(ql_log_warn, base_vha, 0x00ec, |
| 2618 | "Failed to create queues, falling back to single queue mode.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2619 | goto que_init; |
| 2620 | } |
| 2621 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2622 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2623 | if (ha->flags.running_gold_fw) |
| 2624 | goto skip_dpc; |
| 2625 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2626 | /* |
| 2627 | * Startup the kernel thread for this host adapter |
| 2628 | */ |
| 2629 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2630 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2631 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2632 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 2633 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2634 | ret = PTR_ERR(ha->dpc_thread); |
| 2635 | goto probe_failed; |
| 2636 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2637 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 2638 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2639 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2640 | /* |
| 2641 | * If we're not coming up in initiator mode, we might sit for |
| 2642 | * a while without waking up the dpc thread, which leads to a |
| 2643 | * stuck process warning. So just kick the dpc once here and |
| 2644 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 2645 | */ |
| 2646 | qla2xxx_wake_dpc(base_vha); |
| 2647 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 2648 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 2649 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 2650 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 2651 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 2652 | |
| 2653 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 2654 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 2655 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 2656 | INIT_WORK(&ha->idc_state_handler, |
| 2657 | qla83xx_idc_state_handler_work); |
| 2658 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 2659 | qla83xx_nic_core_unrecoverable_work); |
| 2660 | } |
| 2661 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2662 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2663 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 2664 | base_vha->host->irq = ha->pdev->irq; |
| 2665 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2666 | /* Initialized the timer */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2667 | qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2668 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 2669 | "Started qla2x00_timer with " |
| 2670 | "interval=%d.\n", WATCH_INTERVAL); |
| 2671 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 2672 | "Detected hba at address=%p.\n", |
| 2673 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2674 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2675 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2676 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2677 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2678 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2679 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 2680 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2681 | if (ql2xenabledif == 1) |
| 2682 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2683 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2684 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2685 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2686 | | SHOST_DIF_TYPE3_PROTECTION |
| 2687 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2688 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2689 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2690 | |
| 2691 | guard = SHOST_DIX_GUARD_CRC; |
| 2692 | |
| 2693 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 2694 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 2695 | guard |= SHOST_DIX_GUARD_IP; |
| 2696 | |
| 2697 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2698 | } else |
| 2699 | base_vha->flags.difdix_supported = 0; |
| 2700 | } |
| 2701 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2702 | ha->isp_ops->enable_intrs(ha); |
| 2703 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2704 | ret = scsi_add_host(host, &pdev->dev); |
| 2705 | if (ret) |
| 2706 | goto probe_failed; |
| 2707 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 2708 | base_vha->flags.init_done = 1; |
| 2709 | base_vha->flags.online = 1; |
| 2710 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2711 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 2712 | "Init done and hba is online.\n"); |
| 2713 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2714 | if (qla_ini_mode_enabled(base_vha)) |
| 2715 | scsi_scan_host(host); |
| 2716 | else |
| 2717 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 2718 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2719 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2720 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2721 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2722 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2723 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2724 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2725 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2726 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 2727 | "QLogic %s - %s.\n", |
| 2728 | ha->model_number, ha->model_desc ? ha->model_desc : ""); |
| 2729 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 2730 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 2731 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 2732 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 2733 | base_vha->host_no, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2734 | ha->isp_ops->fw_version_str(base_vha, fw_str)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2735 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2736 | qlt_add_target(ha, base_vha); |
| 2737 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2738 | return 0; |
| 2739 | |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2740 | probe_init_failed: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2741 | qla2x00_free_req_que(ha, req); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2742 | ha->req_q_map[0] = NULL; |
| 2743 | clear_bit(0, ha->req_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2744 | qla2x00_free_rsp_que(ha, rsp); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2745 | ha->rsp_q_map[0] = NULL; |
| 2746 | clear_bit(0, ha->rsp_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2747 | ha->max_req_queues = ha->max_rsp_queues = 0; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2748 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2749 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2750 | if (base_vha->timer_active) |
| 2751 | qla2x00_stop_timer(base_vha); |
| 2752 | base_vha->flags.online = 0; |
| 2753 | if (ha->dpc_thread) { |
| 2754 | struct task_struct *t = ha->dpc_thread; |
| 2755 | |
| 2756 | ha->dpc_thread = NULL; |
| 2757 | kthread_stop(t); |
| 2758 | } |
| 2759 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2760 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2761 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2762 | scsi_host_put(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2763 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2764 | probe_hw_failed: |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2765 | if (IS_QLA82XX(ha)) { |
| 2766 | qla82xx_idc_lock(ha); |
| 2767 | qla82xx_clear_drv_active(ha); |
| 2768 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2769 | } |
| 2770 | iospace_config_failed: |
| 2771 | if (IS_QLA82XX(ha)) { |
| 2772 | if (!ha->nx_pcibase) |
| 2773 | iounmap((device_reg_t __iomem *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2774 | if (!ql2xdbwr) |
| 2775 | iounmap((device_reg_t __iomem *)ha->nxdb_wr_ptr); |
| 2776 | } else { |
| 2777 | if (ha->iobase) |
| 2778 | iounmap(ha->iobase); |
| 2779 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2780 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 2781 | kfree(ha); |
| 2782 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2783 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2784 | probe_out: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2785 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2786 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2787 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2788 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 2789 | static void |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2790 | qla2x00_stop_dpc_thread(scsi_qla_host_t *vha) |
| 2791 | { |
| 2792 | struct qla_hw_data *ha = vha->hw; |
| 2793 | struct task_struct *t = ha->dpc_thread; |
| 2794 | |
| 2795 | if (ha->dpc_thread == NULL) |
| 2796 | return; |
| 2797 | /* |
| 2798 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 2799 | * so we need to zero it out. |
| 2800 | */ |
| 2801 | ha->dpc_thread = NULL; |
| 2802 | kthread_stop(t); |
| 2803 | } |
| 2804 | |
| 2805 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 2806 | qla2x00_shutdown(struct pci_dev *pdev) |
| 2807 | { |
| 2808 | scsi_qla_host_t *vha; |
| 2809 | struct qla_hw_data *ha; |
| 2810 | |
Masanari Iida | 552f3f9 | 2013-02-08 01:57:44 -0500 | [diff] [blame^] | 2811 | if (!atomic_read(&pdev->enable_cnt)) |
| 2812 | return; |
| 2813 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 2814 | vha = pci_get_drvdata(pdev); |
| 2815 | ha = vha->hw; |
| 2816 | |
| 2817 | /* Turn-off FCE trace */ |
| 2818 | if (ha->flags.fce_enabled) { |
| 2819 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 2820 | ha->flags.fce_enabled = 0; |
| 2821 | } |
| 2822 | |
| 2823 | /* Turn-off EFT trace */ |
| 2824 | if (ha->eft) |
| 2825 | qla2x00_disable_eft_trace(vha); |
| 2826 | |
| 2827 | /* Stop currently executing firmware. */ |
| 2828 | qla2x00_try_to_stop_firmware(vha); |
| 2829 | |
| 2830 | /* Turn adapter off line */ |
| 2831 | vha->flags.online = 0; |
| 2832 | |
| 2833 | /* turn-off interrupts on the card */ |
| 2834 | if (ha->interrupts_on) { |
| 2835 | vha->flags.init_done = 0; |
| 2836 | ha->isp_ops->disable_intrs(ha); |
| 2837 | } |
| 2838 | |
| 2839 | qla2x00_free_irqs(vha); |
| 2840 | |
| 2841 | qla2x00_free_fw_dump(ha); |
| 2842 | } |
| 2843 | |
| 2844 | static void |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2845 | qla2x00_remove_one(struct pci_dev *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2846 | { |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2847 | scsi_qla_host_t *base_vha, *vha; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2848 | struct qla_hw_data *ha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2849 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2850 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2851 | /* |
| 2852 | * If the PCI device is disabled that means that probe failed and any |
| 2853 | * resources should be have cleaned up on probe exit. |
| 2854 | */ |
| 2855 | if (!atomic_read(&pdev->enable_cnt)) |
| 2856 | return; |
| 2857 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2858 | base_vha = pci_get_drvdata(pdev); |
| 2859 | ha = base_vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2860 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2861 | ha->flags.host_shutting_down = 1; |
| 2862 | |
Giridhar Malavali | 220d36b | 2012-11-21 02:39:55 -0500 | [diff] [blame] | 2863 | set_bit(UNLOADING, &base_vha->dpc_flags); |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2864 | mutex_lock(&ha->vport_lock); |
| 2865 | while (ha->cur_vport_count) { |
| 2866 | struct Scsi_Host *scsi_host; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2867 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2868 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2869 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2870 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 2871 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 2872 | vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list); |
| 2873 | scsi_host = scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2874 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2875 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 2876 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2877 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2878 | fc_vport_terminate(vha->fc_vport); |
| 2879 | scsi_host_put(vha->host); |
| 2880 | |
| 2881 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2882 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2883 | mutex_unlock(&ha->vport_lock); |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 2884 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2885 | if (IS_QLA8031(ha)) { |
| 2886 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 2887 | "Clearing fcoe driver presence.\n"); |
| 2888 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 2889 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 2890 | "Error while clearing DRV-Presence.\n"); |
| 2891 | } |
| 2892 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2893 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 2894 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2895 | qla2x00_dfs_remove(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2896 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2897 | qla84xx_put_chip(base_vha); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2898 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2899 | /* Disable timer */ |
| 2900 | if (base_vha->timer_active) |
| 2901 | qla2x00_stop_timer(base_vha); |
| 2902 | |
| 2903 | base_vha->flags.online = 0; |
| 2904 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2905 | /* Flush the work queue and remove it */ |
| 2906 | if (ha->wq) { |
| 2907 | flush_workqueue(ha->wq); |
| 2908 | destroy_workqueue(ha->wq); |
| 2909 | ha->wq = NULL; |
| 2910 | } |
| 2911 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2912 | /* Cancel all work and destroy DPC workqueues */ |
| 2913 | if (ha->dpc_lp_wq) { |
| 2914 | cancel_work_sync(&ha->idc_aen); |
| 2915 | destroy_workqueue(ha->dpc_lp_wq); |
| 2916 | ha->dpc_lp_wq = NULL; |
| 2917 | } |
| 2918 | |
| 2919 | if (ha->dpc_hp_wq) { |
| 2920 | cancel_work_sync(&ha->nic_core_reset); |
| 2921 | cancel_work_sync(&ha->idc_state_handler); |
| 2922 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 2923 | destroy_workqueue(ha->dpc_hp_wq); |
| 2924 | ha->dpc_hp_wq = NULL; |
| 2925 | } |
| 2926 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2927 | /* Kill the kernel thread for this host */ |
| 2928 | if (ha->dpc_thread) { |
| 2929 | struct task_struct *t = ha->dpc_thread; |
| 2930 | |
| 2931 | /* |
| 2932 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 2933 | * so we need to zero it out. |
| 2934 | */ |
| 2935 | ha->dpc_thread = NULL; |
| 2936 | kthread_stop(t); |
| 2937 | } |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2938 | qlt_remove_target(ha, base_vha); |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2939 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2940 | qla2x00_free_sysfs_attr(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2941 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2942 | fc_remove_host(base_vha->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 2943 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2944 | scsi_remove_host(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2945 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2946 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2947 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2948 | scsi_host_put(base_vha->host); |
| 2949 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2950 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 2951 | qla82xx_idc_lock(ha); |
| 2952 | qla82xx_clear_drv_active(ha); |
| 2953 | qla82xx_idc_unlock(ha); |
| 2954 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2955 | iounmap((device_reg_t __iomem *)ha->nx_pcibase); |
| 2956 | if (!ql2xdbwr) |
| 2957 | iounmap((device_reg_t __iomem *)ha->nxdb_wr_ptr); |
| 2958 | } else { |
| 2959 | if (ha->iobase) |
| 2960 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2961 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2962 | if (ha->mqiobase) |
| 2963 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2964 | |
| 2965 | if (IS_QLA83XX(ha) && ha->msixbase) |
| 2966 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2967 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2968 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2969 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 2970 | kfree(ha); |
| 2971 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2972 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2973 | pci_disable_pcie_error_reporting(pdev); |
| 2974 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 2975 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2976 | pci_set_drvdata(pdev, NULL); |
| 2977 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2978 | |
| 2979 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2980 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2981 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2982 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2983 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2984 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 2985 | |
| 2986 | /* Disable timer */ |
| 2987 | if (vha->timer_active) |
| 2988 | qla2x00_stop_timer(vha); |
| 2989 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2990 | qla2x00_stop_dpc_thread(vha); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2991 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2992 | qla25xx_delete_queues(vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2993 | if (ha->flags.fce_enabled) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2994 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2995 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2996 | if (ha->eft) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2997 | qla2x00_disable_eft_trace(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2998 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2999 | /* Stop currently executing firmware. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3000 | qla2x00_try_to_stop_firmware(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3001 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3002 | vha->flags.online = 0; |
| 3003 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3004 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3005 | if (ha->interrupts_on) { |
| 3006 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 3007 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3008 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3009 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3010 | qla2x00_free_irqs(vha); |
| 3011 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3012 | qla2x00_free_fcports(vha); |
| 3013 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3014 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3015 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 3016 | qla82xx_md_free(vha); |
| 3017 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3018 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3019 | } |
| 3020 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3021 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 3022 | { |
| 3023 | fc_port_t *fcport, *tfcport; |
| 3024 | |
| 3025 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 3026 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3027 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3028 | kfree(fcport); |
| 3029 | fcport = NULL; |
| 3030 | } |
| 3031 | } |
| 3032 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3033 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3034 | qla2x00_schedule_rport_del(struct scsi_qla_host *vha, fc_port_t *fcport, |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3035 | int defer) |
| 3036 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3037 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3038 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3039 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3040 | |
| 3041 | if (!fcport->rport) |
| 3042 | return; |
| 3043 | |
| 3044 | rport = fcport->rport; |
| 3045 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3046 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3047 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3048 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3049 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3050 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 3051 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3052 | } else { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3053 | fc_remote_port_delete(rport); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3054 | qlt_fc_port_deleted(vha, fcport); |
| 3055 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3056 | } |
| 3057 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3058 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3059 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 3060 | * |
| 3061 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 3062 | * |
| 3063 | * Return: None. |
| 3064 | * |
| 3065 | * Context: |
| 3066 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3067 | void qla2x00_mark_device_lost(scsi_qla_host_t *vha, fc_port_t *fcport, |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3068 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3069 | { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3070 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3071 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3072 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3073 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3074 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3075 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3076 | * We may need to retry the login, so don't change the state of the |
| 3077 | * port but do the retries. |
| 3078 | */ |
| 3079 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3080 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3081 | |
| 3082 | if (!do_login) |
| 3083 | return; |
| 3084 | |
| 3085 | if (fcport->login_retry == 0) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3086 | fcport->login_retry = vha->hw->login_retry_count; |
| 3087 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3088 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3089 | ql_dbg(ql_dbg_disc, vha, 0x2067, |
| 3090 | "Port login retry " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3091 | "%02x%02x%02x%02x%02x%02x%02x%02x, " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3092 | "id = 0x%04x retry cnt=%d.\n", |
| 3093 | fcport->port_name[0], fcport->port_name[1], |
| 3094 | fcport->port_name[2], fcport->port_name[3], |
| 3095 | fcport->port_name[4], fcport->port_name[5], |
| 3096 | fcport->port_name[6], fcport->port_name[7], |
| 3097 | fcport->loop_id, fcport->login_retry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3098 | } |
| 3099 | } |
| 3100 | |
| 3101 | /* |
| 3102 | * qla2x00_mark_all_devices_lost |
| 3103 | * Updates fcport state when device goes offline. |
| 3104 | * |
| 3105 | * Input: |
| 3106 | * ha = adapter block pointer. |
| 3107 | * fcport = port structure pointer. |
| 3108 | * |
| 3109 | * Return: |
| 3110 | * None. |
| 3111 | * |
| 3112 | * Context: |
| 3113 | */ |
| 3114 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3115 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3116 | { |
| 3117 | fc_port_t *fcport; |
| 3118 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3119 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3120 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3121 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3123 | /* |
| 3124 | * No point in marking the device as lost, if the device is |
| 3125 | * already DEAD. |
| 3126 | */ |
| 3127 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3128 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3129 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3130 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3131 | if (defer) |
| 3132 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3133 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3134 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3135 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3136 | } |
| 3137 | } |
| 3138 | |
| 3139 | /* |
| 3140 | * qla2x00_mem_alloc |
| 3141 | * Allocates adapter memory. |
| 3142 | * |
| 3143 | * Returns: |
| 3144 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3145 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3146 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3147 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3148 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3149 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3150 | { |
| 3151 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3152 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3153 | ha->init_cb = dma_alloc_coherent(&ha->pdev->dev, ha->init_cb_size, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3154 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3155 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3156 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3157 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3158 | if (qlt_mem_alloc(ha) < 0) |
| 3159 | goto fail_free_init_cb; |
| 3160 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3161 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3162 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3163 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3164 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3165 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3166 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3167 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3168 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3169 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3170 | if (IS_QLA82XX(ha)) { |
| 3171 | /* Allocate cache for CT6 Ctx. */ |
| 3172 | if (!ctx_cachep) { |
| 3173 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3174 | sizeof(struct ct6_dsd), 0, |
| 3175 | SLAB_HWCACHE_ALIGN, NULL); |
| 3176 | if (!ctx_cachep) |
| 3177 | goto fail_free_gid_list; |
| 3178 | } |
| 3179 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3180 | ctx_cachep); |
| 3181 | if (!ha->ctx_mempool) |
| 3182 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3183 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3184 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3185 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3186 | } |
| 3187 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3188 | /* Get memory for cached NVRAM */ |
| 3189 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3190 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3191 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3192 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3193 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3194 | ha->pdev->device); |
| 3195 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3196 | DMA_POOL_SIZE, 8, 0); |
| 3197 | if (!ha->s_dma_pool) |
| 3198 | goto fail_free_nvram; |
| 3199 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3200 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3201 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3202 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3203 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3204 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3205 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3206 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3207 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3208 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3209 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3210 | goto fail_s_dma_pool; |
| 3211 | } |
| 3212 | |
| 3213 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3214 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3215 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3216 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3217 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3218 | goto fail_dl_dma_pool; |
| 3219 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3220 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3221 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3222 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3223 | } |
| 3224 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3225 | /* Allocate memory for SNS commands */ |
| 3226 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3227 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3228 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3229 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3230 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3231 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3232 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 3233 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3234 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3235 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3236 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3237 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3238 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3239 | goto fail_dma_pool; |
| 3240 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3241 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3242 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3243 | if (!ha->ct_sns) |
| 3244 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3245 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 3246 | "ms_iocb=%p ct_sns=%p.\n", |
| 3247 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3248 | } |
| 3249 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3250 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3251 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 3252 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3253 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 3254 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3255 | goto fail_req; |
| 3256 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3257 | (*req)->length = req_len; |
| 3258 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3259 | ((*req)->length + 1) * sizeof(request_t), |
| 3260 | &(*req)->dma, GFP_KERNEL); |
| 3261 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3262 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 3263 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3264 | goto fail_req_ring; |
| 3265 | } |
| 3266 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3267 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 3268 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3269 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 3270 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3271 | goto fail_rsp; |
| 3272 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3273 | (*rsp)->hw = ha; |
| 3274 | (*rsp)->length = rsp_len; |
| 3275 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3276 | ((*rsp)->length + 1) * sizeof(response_t), |
| 3277 | &(*rsp)->dma, GFP_KERNEL); |
| 3278 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3279 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 3280 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3281 | goto fail_rsp_ring; |
| 3282 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3283 | (*req)->rsp = *rsp; |
| 3284 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3285 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 3286 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 3287 | "rsp->length=%d rsp->ring=%p.\n", |
| 3288 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 3289 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3290 | /* Allocate memory for NVRAM data for vports */ |
| 3291 | if (ha->nvram_npiv_size) { |
| 3292 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3293 | ha->nvram_npiv_size, GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3294 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3295 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 3296 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3297 | goto fail_npiv_info; |
| 3298 | } |
| 3299 | } else |
| 3300 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3301 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3302 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3303 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3304 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3305 | &ha->ex_init_cb_dma); |
| 3306 | if (!ha->ex_init_cb) |
| 3307 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3308 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 3309 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3310 | } |
| 3311 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3312 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 3313 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3314 | /* Get consistent memory allocated for Async Port-Database. */ |
| 3315 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3316 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3317 | &ha->async_pd_dma); |
| 3318 | if (!ha->async_pd) |
| 3319 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3320 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 3321 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3322 | } |
| 3323 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3324 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3325 | |
| 3326 | /* Allocate memory for our loop_id bitmap */ |
| 3327 | ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), |
| 3328 | GFP_KERNEL); |
| 3329 | if (!ha->loop_id_map) |
| 3330 | goto fail_async_pd; |
| 3331 | else { |
| 3332 | qla2x00_set_reserved_loop_ids(ha); |
| 3333 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
| 3334 | "loop_id_map=%p. \n", ha->loop_id_map); |
| 3335 | } |
| 3336 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3337 | return 1; |
| 3338 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3339 | fail_async_pd: |
| 3340 | dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3341 | fail_ex_init_cb: |
| 3342 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3343 | fail_npiv_info: |
| 3344 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 3345 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 3346 | (*rsp)->ring = NULL; |
| 3347 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3348 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3349 | kfree(*rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3350 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3351 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 3352 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 3353 | (*req)->ring = NULL; |
| 3354 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3355 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3356 | kfree(*req); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3357 | fail_req: |
| 3358 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 3359 | ha->ct_sns, ha->ct_sns_dma); |
| 3360 | ha->ct_sns = NULL; |
| 3361 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3362 | fail_free_ms_iocb: |
| 3363 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3364 | ha->ms_iocb = NULL; |
| 3365 | ha->ms_iocb_dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3366 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3367 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3368 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3369 | ha->fcp_cmnd_dma_pool = NULL; |
| 3370 | } |
| 3371 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3372 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3373 | dma_pool_destroy(ha->dl_dma_pool); |
| 3374 | ha->dl_dma_pool = NULL; |
| 3375 | } |
| 3376 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3377 | dma_pool_destroy(ha->s_dma_pool); |
| 3378 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3379 | fail_free_nvram: |
| 3380 | kfree(ha->nvram); |
| 3381 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3382 | fail_free_ctx_mempool: |
| 3383 | mempool_destroy(ha->ctx_mempool); |
| 3384 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3385 | fail_free_srb_mempool: |
| 3386 | mempool_destroy(ha->srb_mempool); |
| 3387 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3388 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3389 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3390 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3391 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3392 | ha->gid_list = NULL; |
| 3393 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3394 | fail_free_tgt_mem: |
| 3395 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3396 | fail_free_init_cb: |
| 3397 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 3398 | ha->init_cb_dma); |
| 3399 | ha->init_cb = NULL; |
| 3400 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3401 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3402 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 3403 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3404 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3405 | } |
| 3406 | |
| 3407 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3408 | * qla2x00_free_fw_dump |
| 3409 | * Frees fw dump stuff. |
| 3410 | * |
| 3411 | * Input: |
| 3412 | * ha = adapter block pointer. |
| 3413 | */ |
| 3414 | static void |
| 3415 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 3416 | { |
| 3417 | if (ha->fce) |
| 3418 | dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce, |
| 3419 | ha->fce_dma); |
| 3420 | |
| 3421 | if (ha->fw_dump) { |
| 3422 | if (ha->eft) |
| 3423 | dma_free_coherent(&ha->pdev->dev, |
| 3424 | ntohl(ha->fw_dump->eft_size), ha->eft, ha->eft_dma); |
| 3425 | vfree(ha->fw_dump); |
| 3426 | } |
| 3427 | ha->fce = NULL; |
| 3428 | ha->fce_dma = 0; |
| 3429 | ha->eft = NULL; |
| 3430 | ha->eft_dma = 0; |
| 3431 | ha->fw_dump = NULL; |
| 3432 | ha->fw_dumped = 0; |
| 3433 | ha->fw_dump_reading = 0; |
| 3434 | } |
| 3435 | |
| 3436 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3437 | * qla2x00_mem_free |
| 3438 | * Frees all adapter allocated memory. |
| 3439 | * |
| 3440 | * Input: |
| 3441 | * ha = adapter block pointer. |
| 3442 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 3443 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3444 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3445 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3446 | qla2x00_free_fw_dump(ha); |
| 3447 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3448 | if (ha->mctp_dump) |
| 3449 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 3450 | ha->mctp_dump_dma); |
| 3451 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3452 | if (ha->srb_mempool) |
| 3453 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3454 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 3455 | if (ha->dcbx_tlv) |
| 3456 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 3457 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 3458 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 3459 | if (ha->xgmac_data) |
| 3460 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 3461 | ha->xgmac_data, ha->xgmac_data_dma); |
| 3462 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3463 | if (ha->sns_cmd) |
| 3464 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3465 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3466 | |
| 3467 | if (ha->ct_sns) |
| 3468 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3469 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3470 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3471 | if (ha->sfp_data) |
| 3472 | dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); |
| 3473 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3474 | if (ha->ms_iocb) |
| 3475 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3476 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3477 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3478 | dma_pool_free(ha->s_dma_pool, |
| 3479 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3480 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3481 | if (ha->async_pd) |
| 3482 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 3483 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3484 | if (ha->s_dma_pool) |
| 3485 | dma_pool_destroy(ha->s_dma_pool); |
| 3486 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3487 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3488 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3489 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3490 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3491 | if (IS_QLA82XX(ha)) { |
| 3492 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 3493 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 3494 | |
| 3495 | /* clean up allocated prev pool */ |
| 3496 | list_for_each_entry_safe(dsd_ptr, |
| 3497 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 3498 | dma_pool_free(ha->dl_dma_pool, |
| 3499 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 3500 | list_del(&dsd_ptr->list); |
| 3501 | kfree(dsd_ptr); |
| 3502 | } |
| 3503 | } |
| 3504 | } |
| 3505 | |
| 3506 | if (ha->dl_dma_pool) |
| 3507 | dma_pool_destroy(ha->dl_dma_pool); |
| 3508 | |
| 3509 | if (ha->fcp_cmnd_dma_pool) |
| 3510 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3511 | |
| 3512 | if (ha->ctx_mempool) |
| 3513 | mempool_destroy(ha->ctx_mempool); |
| 3514 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3515 | qlt_mem_free(ha); |
| 3516 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3517 | if (ha->init_cb) |
| 3518 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3519 | ha->init_cb, ha->init_cb_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3520 | vfree(ha->optrom_buffer); |
| 3521 | kfree(ha->nvram); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3522 | kfree(ha->npiv_info); |
Andrew Vasquez | 7a67735 | 2012-02-09 11:15:56 -0800 | [diff] [blame] | 3523 | kfree(ha->swl); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3524 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3525 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3526 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3527 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3528 | ha->sns_cmd = NULL; |
| 3529 | ha->sns_cmd_dma = 0; |
| 3530 | ha->ct_sns = NULL; |
| 3531 | ha->ct_sns_dma = 0; |
| 3532 | ha->ms_iocb = NULL; |
| 3533 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3534 | ha->init_cb = NULL; |
| 3535 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3536 | ha->ex_init_cb = NULL; |
| 3537 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3538 | ha->async_pd = NULL; |
| 3539 | ha->async_pd_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3540 | |
| 3541 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3542 | ha->dl_dma_pool = NULL; |
| 3543 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3544 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3545 | ha->gid_list = NULL; |
| 3546 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3547 | |
| 3548 | ha->tgt.atio_ring = NULL; |
| 3549 | ha->tgt.atio_dma = 0; |
| 3550 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3551 | } |
| 3552 | |
| 3553 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 3554 | struct qla_hw_data *ha) |
| 3555 | { |
| 3556 | struct Scsi_Host *host; |
| 3557 | struct scsi_qla_host *vha = NULL; |
| 3558 | |
| 3559 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
| 3560 | if (host == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3561 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 3562 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3563 | goto fail; |
| 3564 | } |
| 3565 | |
| 3566 | /* Clear our data area */ |
| 3567 | vha = shost_priv(host); |
| 3568 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 3569 | |
| 3570 | vha->host = host; |
| 3571 | vha->host_no = host->host_no; |
| 3572 | vha->hw = ha; |
| 3573 | |
| 3574 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 3575 | INIT_LIST_HEAD(&vha->work_list); |
| 3576 | INIT_LIST_HEAD(&vha->list); |
| 3577 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3578 | spin_lock_init(&vha->work_lock); |
| 3579 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3580 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3581 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 3582 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 3583 | vha->host, vha->hw, vha, |
| 3584 | dev_name(&(ha->pdev->dev))); |
| 3585 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3586 | return vha; |
| 3587 | |
| 3588 | fail: |
| 3589 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3590 | } |
| 3591 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 3592 | static struct qla_work_evt * |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3593 | qla2x00_alloc_work(struct scsi_qla_host *vha, enum qla_work_type type) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3594 | { |
| 3595 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3596 | uint8_t bail; |
| 3597 | |
| 3598 | QLA_VHA_MARK_BUSY(vha, bail); |
| 3599 | if (bail) |
| 3600 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3601 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3602 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3603 | if (!e) { |
| 3604 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3605 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3606 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3607 | |
| 3608 | INIT_LIST_HEAD(&e->list); |
| 3609 | e->type = type; |
| 3610 | e->flags = QLA_EVT_FLAG_FREE; |
| 3611 | return e; |
| 3612 | } |
| 3613 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 3614 | static int |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3615 | qla2x00_post_work(struct scsi_qla_host *vha, struct qla_work_evt *e) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3616 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3617 | unsigned long flags; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3618 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3619 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3620 | list_add_tail(&e->list, &vha->work_list); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3621 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3622 | qla2xxx_wake_dpc(vha); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3623 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3624 | return QLA_SUCCESS; |
| 3625 | } |
| 3626 | |
| 3627 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3628 | qla2x00_post_aen_work(struct scsi_qla_host *vha, enum fc_host_event_code code, |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3629 | u32 data) |
| 3630 | { |
| 3631 | struct qla_work_evt *e; |
| 3632 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3633 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3634 | if (!e) |
| 3635 | return QLA_FUNCTION_FAILED; |
| 3636 | |
| 3637 | e->u.aen.code = code; |
| 3638 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3639 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3640 | } |
| 3641 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3642 | int |
| 3643 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 3644 | { |
| 3645 | struct qla_work_evt *e; |
| 3646 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3647 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3648 | if (!e) |
| 3649 | return QLA_FUNCTION_FAILED; |
| 3650 | |
| 3651 | memcpy(e->u.idc_ack.mb, mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3652 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3653 | } |
| 3654 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3655 | #define qla2x00_post_async_work(name, type) \ |
| 3656 | int qla2x00_post_async_##name##_work( \ |
| 3657 | struct scsi_qla_host *vha, \ |
| 3658 | fc_port_t *fcport, uint16_t *data) \ |
| 3659 | { \ |
| 3660 | struct qla_work_evt *e; \ |
| 3661 | \ |
| 3662 | e = qla2x00_alloc_work(vha, type); \ |
| 3663 | if (!e) \ |
| 3664 | return QLA_FUNCTION_FAILED; \ |
| 3665 | \ |
| 3666 | e->u.logio.fcport = fcport; \ |
| 3667 | if (data) { \ |
| 3668 | e->u.logio.data[0] = data[0]; \ |
| 3669 | e->u.logio.data[1] = data[1]; \ |
| 3670 | } \ |
| 3671 | return qla2x00_post_work(vha, e); \ |
| 3672 | } |
| 3673 | |
| 3674 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
| 3675 | qla2x00_post_async_work(login_done, QLA_EVT_ASYNC_LOGIN_DONE); |
| 3676 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 3677 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3678 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 3679 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3680 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 3681 | int |
| 3682 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 3683 | { |
| 3684 | struct qla_work_evt *e; |
| 3685 | |
| 3686 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 3687 | if (!e) |
| 3688 | return QLA_FUNCTION_FAILED; |
| 3689 | |
| 3690 | e->u.uevent.code = code; |
| 3691 | return qla2x00_post_work(vha, e); |
| 3692 | } |
| 3693 | |
| 3694 | static void |
| 3695 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 3696 | { |
| 3697 | char event_string[40]; |
| 3698 | char *envp[] = { event_string, NULL }; |
| 3699 | |
| 3700 | switch (code) { |
| 3701 | case QLA_UEVENT_CODE_FW_DUMP: |
| 3702 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 3703 | vha->host_no); |
| 3704 | break; |
| 3705 | default: |
| 3706 | /* do nothing */ |
| 3707 | break; |
| 3708 | } |
| 3709 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 3710 | } |
| 3711 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3712 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3713 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3714 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3715 | struct qla_work_evt *e, *tmp; |
| 3716 | unsigned long flags; |
| 3717 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3718 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3719 | spin_lock_irqsave(&vha->work_lock, flags); |
| 3720 | list_splice_init(&vha->work_list, &work); |
| 3721 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 3722 | |
| 3723 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3724 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3725 | |
| 3726 | switch (e->type) { |
| 3727 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3728 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3729 | e->u.aen.code, e->u.aen.data); |
| 3730 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3731 | case QLA_EVT_IDC_ACK: |
| 3732 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 3733 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3734 | case QLA_EVT_ASYNC_LOGIN: |
| 3735 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 3736 | e->u.logio.data); |
| 3737 | break; |
| 3738 | case QLA_EVT_ASYNC_LOGIN_DONE: |
| 3739 | qla2x00_async_login_done(vha, e->u.logio.fcport, |
| 3740 | e->u.logio.data); |
| 3741 | break; |
| 3742 | case QLA_EVT_ASYNC_LOGOUT: |
| 3743 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 3744 | break; |
| 3745 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 3746 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 3747 | e->u.logio.data); |
| 3748 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3749 | case QLA_EVT_ASYNC_ADISC: |
| 3750 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 3751 | e->u.logio.data); |
| 3752 | break; |
| 3753 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 3754 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 3755 | e->u.logio.data); |
| 3756 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 3757 | case QLA_EVT_UEVENT: |
| 3758 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 3759 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3760 | } |
| 3761 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 3762 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3763 | |
| 3764 | /* For each work completed decrement vha ref count */ |
| 3765 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3766 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3767 | } |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3768 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3769 | /* Relogins all the fcports of a vport |
| 3770 | * Context: dpc thread |
| 3771 | */ |
| 3772 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 3773 | { |
| 3774 | fc_port_t *fcport; |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 3775 | int status; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3776 | uint16_t next_loopid = 0; |
| 3777 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3778 | uint16_t data[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3779 | |
| 3780 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 3781 | /* |
| 3782 | * If the port is not ONLINE then try to login |
| 3783 | * to it if we haven't run out of retries. |
| 3784 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3785 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
| 3786 | fcport->login_retry && !(fcport->flags & FCF_ASYNC_SENT)) { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3787 | fcport->login_retry--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3788 | if (fcport->flags & FCF_FABRIC_DEVICE) { |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3789 | if (fcport->flags & FCF_FCP2_DEVICE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3790 | ha->isp_ops->fabric_logout(vha, |
| 3791 | fcport->loop_id, |
| 3792 | fcport->d_id.b.domain, |
| 3793 | fcport->d_id.b.area, |
| 3794 | fcport->d_id.b.al_pa); |
| 3795 | |
Joe Carnuccio | 03bcfb5 | 2011-03-30 11:46:27 -0700 | [diff] [blame] | 3796 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
| 3797 | fcport->loop_id = next_loopid = |
| 3798 | ha->min_external_loopid; |
| 3799 | status = qla2x00_find_new_loop_id( |
| 3800 | vha, fcport); |
| 3801 | if (status != QLA_SUCCESS) { |
| 3802 | /* Ran out of IDs to use */ |
| 3803 | break; |
| 3804 | } |
| 3805 | } |
| 3806 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3807 | if (IS_ALOGIO_CAPABLE(ha)) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3808 | fcport->flags |= FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3809 | data[0] = 0; |
| 3810 | data[1] = QLA_LOGIO_LOGIN_RETRIED; |
| 3811 | status = qla2x00_post_async_login_work( |
| 3812 | vha, fcport, data); |
| 3813 | if (status == QLA_SUCCESS) |
| 3814 | continue; |
| 3815 | /* Attempt a retry. */ |
| 3816 | status = 1; |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 3817 | } else { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3818 | status = qla2x00_fabric_login(vha, |
| 3819 | fcport, &next_loopid); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 3820 | if (status == QLA_SUCCESS) { |
| 3821 | int status2; |
| 3822 | uint8_t opts; |
| 3823 | |
| 3824 | opts = 0; |
| 3825 | if (fcport->flags & |
| 3826 | FCF_FCP2_DEVICE) |
| 3827 | opts |= BIT_1; |
Saurav Kashyap | 0300396 | 2012-11-21 02:40:31 -0500 | [diff] [blame] | 3828 | status2 = |
| 3829 | qla2x00_get_port_database( |
| 3830 | vha, fcport, opts); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 3831 | if (status2 != QLA_SUCCESS) |
| 3832 | status = 1; |
| 3833 | } |
| 3834 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3835 | } else |
| 3836 | status = qla2x00_local_device_login(vha, |
| 3837 | fcport); |
| 3838 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3839 | if (status == QLA_SUCCESS) { |
| 3840 | fcport->old_loop_id = fcport->loop_id; |
| 3841 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3842 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 3843 | "Port login OK: logged in ID 0x%x.\n", |
| 3844 | fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3845 | |
| 3846 | qla2x00_update_fcport(vha, fcport); |
| 3847 | |
| 3848 | } else if (status == 1) { |
| 3849 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 3850 | /* retry the login again */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3851 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 3852 | "Retrying %d login again loop_id 0x%x.\n", |
| 3853 | fcport->login_retry, fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3854 | } else { |
| 3855 | fcport->login_retry = 0; |
| 3856 | } |
| 3857 | |
| 3858 | if (fcport->login_retry == 0 && status != QLA_SUCCESS) |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3859 | qla2x00_clear_loop_id(fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3860 | } |
| 3861 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 3862 | break; |
| 3863 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3864 | } |
| 3865 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3866 | /* Schedule work on any of the dpc-workqueues */ |
| 3867 | void |
| 3868 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 3869 | { |
| 3870 | struct qla_hw_data *ha = base_vha->hw; |
| 3871 | |
| 3872 | switch (work_code) { |
| 3873 | case MBA_IDC_AEN: /* 0x8200 */ |
| 3874 | if (ha->dpc_lp_wq) |
| 3875 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 3876 | break; |
| 3877 | |
| 3878 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 3879 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 3880 | if (ha->dpc_hp_wq) |
| 3881 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 3882 | } else |
| 3883 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 3884 | "NIC Core reset is already active. Skip " |
| 3885 | "scheduling it again.\n"); |
| 3886 | break; |
| 3887 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 3888 | if (ha->dpc_hp_wq) |
| 3889 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 3890 | break; |
| 3891 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 3892 | if (ha->dpc_hp_wq) |
| 3893 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 3894 | break; |
| 3895 | default: |
| 3896 | ql_log(ql_log_warn, base_vha, 0xb05f, |
| 3897 | "Unknow work-code=0x%x.\n", work_code); |
| 3898 | } |
| 3899 | |
| 3900 | return; |
| 3901 | } |
| 3902 | |
| 3903 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 3904 | void |
| 3905 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 3906 | { |
| 3907 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 3908 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3909 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 3910 | uint32_t dev_state = 0; |
| 3911 | |
| 3912 | qla83xx_idc_lock(base_vha, 0); |
| 3913 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 3914 | qla83xx_reset_ownership(base_vha); |
| 3915 | if (ha->flags.nic_core_reset_owner) { |
| 3916 | ha->flags.nic_core_reset_owner = 0; |
| 3917 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 3918 | QLA8XXX_DEV_FAILED); |
| 3919 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 3920 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 3921 | } |
| 3922 | qla83xx_idc_unlock(base_vha, 0); |
| 3923 | } |
| 3924 | |
| 3925 | /* Work: Execute IDC state handler */ |
| 3926 | void |
| 3927 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 3928 | { |
| 3929 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 3930 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3931 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 3932 | uint32_t dev_state = 0; |
| 3933 | |
| 3934 | qla83xx_idc_lock(base_vha, 0); |
| 3935 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 3936 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 3937 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 3938 | qla83xx_idc_state_handler(base_vha); |
| 3939 | qla83xx_idc_unlock(base_vha, 0); |
| 3940 | } |
| 3941 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 3942 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3943 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 3944 | { |
| 3945 | int rval = QLA_SUCCESS; |
| 3946 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 3947 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 3948 | |
| 3949 | do { |
| 3950 | if (time_after(jiffies, heart_beat_wait)) { |
| 3951 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 3952 | "Nic Core f/w is not alive.\n"); |
| 3953 | rval = QLA_FUNCTION_FAILED; |
| 3954 | break; |
| 3955 | } |
| 3956 | |
| 3957 | qla83xx_idc_lock(base_vha, 0); |
| 3958 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 3959 | &heart_beat_counter1); |
| 3960 | qla83xx_idc_unlock(base_vha, 0); |
| 3961 | msleep(100); |
| 3962 | qla83xx_idc_lock(base_vha, 0); |
| 3963 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 3964 | &heart_beat_counter2); |
| 3965 | qla83xx_idc_unlock(base_vha, 0); |
| 3966 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 3967 | |
| 3968 | return rval; |
| 3969 | } |
| 3970 | |
| 3971 | /* Work: Perform NIC Core Reset handling */ |
| 3972 | void |
| 3973 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 3974 | { |
| 3975 | struct qla_hw_data *ha = |
| 3976 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 3977 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 3978 | uint32_t dev_state = 0; |
| 3979 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3980 | if (IS_QLA2031(ha)) { |
| 3981 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 3982 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 3983 | "Failed to dump mctp\n"); |
| 3984 | return; |
| 3985 | } |
| 3986 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3987 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 3988 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 3989 | qla83xx_idc_lock(base_vha, 0); |
| 3990 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 3991 | &dev_state); |
| 3992 | qla83xx_idc_unlock(base_vha, 0); |
| 3993 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 3994 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 3995 | "Nic Core f/w is alive.\n"); |
| 3996 | return; |
| 3997 | } |
| 3998 | } |
| 3999 | |
| 4000 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 4001 | if (qla83xx_nic_core_reset(base_vha)) { |
| 4002 | /* NIC Core reset failed. */ |
| 4003 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 4004 | "NIC Core reset failed.\n"); |
| 4005 | } |
| 4006 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 4007 | } |
| 4008 | } |
| 4009 | |
| 4010 | /* Work: Handle 8200 IDC aens */ |
| 4011 | void |
| 4012 | qla83xx_service_idc_aen(struct work_struct *work) |
| 4013 | { |
| 4014 | struct qla_hw_data *ha = |
| 4015 | container_of(work, struct qla_hw_data, idc_aen); |
| 4016 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4017 | uint32_t dev_state, idc_control; |
| 4018 | |
| 4019 | qla83xx_idc_lock(base_vha, 0); |
| 4020 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4021 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 4022 | qla83xx_idc_unlock(base_vha, 0); |
| 4023 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 4024 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 4025 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 4026 | "Application requested NIC Core Reset.\n"); |
| 4027 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4028 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 4029 | QLA_SUCCESS) { |
| 4030 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 4031 | "Other protocol driver requested NIC Core Reset.\n"); |
| 4032 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4033 | } |
| 4034 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 4035 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 4036 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4037 | } |
| 4038 | } |
| 4039 | |
| 4040 | static void |
| 4041 | qla83xx_wait_logic(void) |
| 4042 | { |
| 4043 | int i; |
| 4044 | |
| 4045 | /* Yield CPU */ |
| 4046 | if (!in_interrupt()) { |
| 4047 | /* |
| 4048 | * Wait about 200ms before retrying again. |
| 4049 | * This controls the number of retries for single |
| 4050 | * lock operation. |
| 4051 | */ |
| 4052 | msleep(100); |
| 4053 | schedule(); |
| 4054 | } else { |
| 4055 | for (i = 0; i < 20; i++) |
| 4056 | cpu_relax(); /* This a nop instr on i386 */ |
| 4057 | } |
| 4058 | } |
| 4059 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4060 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4061 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 4062 | { |
| 4063 | int rval; |
| 4064 | uint32_t data; |
| 4065 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 4066 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 4067 | struct qla_hw_data *ha = base_vha->hw; |
| 4068 | |
| 4069 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 4070 | if (rval) |
| 4071 | return rval; |
| 4072 | |
| 4073 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 4074 | return QLA_SUCCESS; |
| 4075 | } else { |
| 4076 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 4077 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4078 | data); |
| 4079 | if (rval) |
| 4080 | return rval; |
| 4081 | |
| 4082 | msleep(200); |
| 4083 | |
| 4084 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4085 | &data); |
| 4086 | if (rval) |
| 4087 | return rval; |
| 4088 | |
| 4089 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 4090 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 4091 | ~(idc_lck_rcvry_stage_mask)); |
| 4092 | rval = qla83xx_wr_reg(base_vha, |
| 4093 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 4094 | if (rval) |
| 4095 | return rval; |
| 4096 | |
| 4097 | /* Forcefully perform IDC UnLock */ |
| 4098 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 4099 | &data); |
| 4100 | if (rval) |
| 4101 | return rval; |
| 4102 | /* Clear lock-id by setting 0xff */ |
| 4103 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4104 | 0xff); |
| 4105 | if (rval) |
| 4106 | return rval; |
| 4107 | /* Clear lock-recovery by setting 0x0 */ |
| 4108 | rval = qla83xx_wr_reg(base_vha, |
| 4109 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 4110 | if (rval) |
| 4111 | return rval; |
| 4112 | } else |
| 4113 | return QLA_SUCCESS; |
| 4114 | } |
| 4115 | |
| 4116 | return rval; |
| 4117 | } |
| 4118 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4119 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4120 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 4121 | { |
| 4122 | int rval = QLA_SUCCESS; |
| 4123 | uint32_t o_drv_lockid, n_drv_lockid; |
| 4124 | unsigned long lock_recovery_timeout; |
| 4125 | |
| 4126 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 4127 | retry_lockid: |
| 4128 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 4129 | if (rval) |
| 4130 | goto exit; |
| 4131 | |
| 4132 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 4133 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 4134 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 4135 | return QLA_SUCCESS; |
| 4136 | else |
| 4137 | return QLA_FUNCTION_FAILED; |
| 4138 | } |
| 4139 | |
| 4140 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 4141 | if (rval) |
| 4142 | goto exit; |
| 4143 | |
| 4144 | if (o_drv_lockid == n_drv_lockid) { |
| 4145 | qla83xx_wait_logic(); |
| 4146 | goto retry_lockid; |
| 4147 | } else |
| 4148 | return QLA_SUCCESS; |
| 4149 | |
| 4150 | exit: |
| 4151 | return rval; |
| 4152 | } |
| 4153 | |
| 4154 | void |
| 4155 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4156 | { |
| 4157 | uint16_t options = (requester_id << 15) | BIT_6; |
| 4158 | uint32_t data; |
| 4159 | struct qla_hw_data *ha = base_vha->hw; |
| 4160 | |
| 4161 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 4162 | retry_lock: |
| 4163 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 4164 | == QLA_SUCCESS) { |
| 4165 | if (data) { |
| 4166 | /* Setting lock-id to our function-number */ |
| 4167 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4168 | ha->portnum); |
| 4169 | } else { |
| 4170 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
| 4171 | "Failed to acquire IDC lock. retrying...\n"); |
| 4172 | |
| 4173 | /* Retry/Perform IDC-Lock recovery */ |
| 4174 | if (qla83xx_idc_lock_recovery(base_vha) |
| 4175 | == QLA_SUCCESS) { |
| 4176 | qla83xx_wait_logic(); |
| 4177 | goto retry_lock; |
| 4178 | } else |
| 4179 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 4180 | "IDC Lock recovery FAILED.\n"); |
| 4181 | } |
| 4182 | |
| 4183 | } |
| 4184 | |
| 4185 | return; |
| 4186 | |
| 4187 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 4188 | retry_lock2: |
| 4189 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4190 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 4191 | "Failed to acquire IDC lock. retrying...\n"); |
| 4192 | /* Retry/Perform IDC-Lock recovery */ |
| 4193 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 4194 | qla83xx_wait_logic(); |
| 4195 | goto retry_lock2; |
| 4196 | } else |
| 4197 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 4198 | "IDC Lock recovery FAILED.\n"); |
| 4199 | } |
| 4200 | |
| 4201 | return; |
| 4202 | } |
| 4203 | |
| 4204 | void |
| 4205 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4206 | { |
| 4207 | uint16_t options = (requester_id << 15) | BIT_7, retry; |
| 4208 | uint32_t data; |
| 4209 | struct qla_hw_data *ha = base_vha->hw; |
| 4210 | |
| 4211 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 4212 | * remote registers |
| 4213 | */ |
| 4214 | retry = 0; |
| 4215 | retry_unlock: |
| 4216 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 4217 | == QLA_SUCCESS) { |
| 4218 | if (data == ha->portnum) { |
| 4219 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 4220 | /* Clearing lock-id by setting 0xff */ |
| 4221 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 4222 | } else if (retry < 10) { |
| 4223 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 4224 | |
| 4225 | /* Retry for IDC-unlock */ |
| 4226 | qla83xx_wait_logic(); |
| 4227 | retry++; |
| 4228 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
| 4229 | "Failed to release IDC lock, retyring=%d\n", retry); |
| 4230 | goto retry_unlock; |
| 4231 | } |
| 4232 | } else if (retry < 10) { |
| 4233 | /* Retry for IDC-unlock */ |
| 4234 | qla83xx_wait_logic(); |
| 4235 | retry++; |
| 4236 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
| 4237 | "Failed to read drv-lockid, retyring=%d\n", retry); |
| 4238 | goto retry_unlock; |
| 4239 | } |
| 4240 | |
| 4241 | return; |
| 4242 | |
| 4243 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 4244 | retry = 0; |
| 4245 | retry_unlock2: |
| 4246 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4247 | if (retry < 10) { |
| 4248 | /* Retry for IDC-unlock */ |
| 4249 | qla83xx_wait_logic(); |
| 4250 | retry++; |
| 4251 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
| 4252 | "Failed to release IDC lock, retyring=%d\n", retry); |
| 4253 | goto retry_unlock2; |
| 4254 | } |
| 4255 | } |
| 4256 | |
| 4257 | return; |
| 4258 | } |
| 4259 | |
| 4260 | int |
| 4261 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4262 | { |
| 4263 | int rval = QLA_SUCCESS; |
| 4264 | struct qla_hw_data *ha = vha->hw; |
| 4265 | uint32_t drv_presence; |
| 4266 | |
| 4267 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4268 | if (rval == QLA_SUCCESS) { |
| 4269 | drv_presence |= (1 << ha->portnum); |
| 4270 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4271 | drv_presence); |
| 4272 | } |
| 4273 | |
| 4274 | return rval; |
| 4275 | } |
| 4276 | |
| 4277 | int |
| 4278 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4279 | { |
| 4280 | int rval = QLA_SUCCESS; |
| 4281 | |
| 4282 | qla83xx_idc_lock(vha, 0); |
| 4283 | rval = __qla83xx_set_drv_presence(vha); |
| 4284 | qla83xx_idc_unlock(vha, 0); |
| 4285 | |
| 4286 | return rval; |
| 4287 | } |
| 4288 | |
| 4289 | int |
| 4290 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4291 | { |
| 4292 | int rval = QLA_SUCCESS; |
| 4293 | struct qla_hw_data *ha = vha->hw; |
| 4294 | uint32_t drv_presence; |
| 4295 | |
| 4296 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4297 | if (rval == QLA_SUCCESS) { |
| 4298 | drv_presence &= ~(1 << ha->portnum); |
| 4299 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4300 | drv_presence); |
| 4301 | } |
| 4302 | |
| 4303 | return rval; |
| 4304 | } |
| 4305 | |
| 4306 | int |
| 4307 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4308 | { |
| 4309 | int rval = QLA_SUCCESS; |
| 4310 | |
| 4311 | qla83xx_idc_lock(vha, 0); |
| 4312 | rval = __qla83xx_clear_drv_presence(vha); |
| 4313 | qla83xx_idc_unlock(vha, 0); |
| 4314 | |
| 4315 | return rval; |
| 4316 | } |
| 4317 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4318 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4319 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 4320 | { |
| 4321 | struct qla_hw_data *ha = vha->hw; |
| 4322 | uint32_t drv_ack, drv_presence; |
| 4323 | unsigned long ack_timeout; |
| 4324 | |
| 4325 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 4326 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 4327 | while (1) { |
| 4328 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 4329 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 4330 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4331 | break; |
| 4332 | |
| 4333 | if (time_after_eq(jiffies, ack_timeout)) { |
| 4334 | ql_log(ql_log_warn, vha, 0xb067, |
| 4335 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 4336 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 4337 | /* |
| 4338 | * The function(s) which did not ack in time are forced |
| 4339 | * to withdraw any further participation in the IDC |
| 4340 | * reset. |
| 4341 | */ |
| 4342 | if (drv_ack != drv_presence) |
| 4343 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4344 | drv_ack); |
| 4345 | break; |
| 4346 | } |
| 4347 | |
| 4348 | qla83xx_idc_unlock(vha, 0); |
| 4349 | msleep(1000); |
| 4350 | qla83xx_idc_lock(vha, 0); |
| 4351 | } |
| 4352 | |
| 4353 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 4354 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 4355 | } |
| 4356 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4357 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4358 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 4359 | { |
| 4360 | int rval = QLA_SUCCESS; |
| 4361 | uint32_t idc_control; |
| 4362 | |
| 4363 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 4364 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 4365 | |
| 4366 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 4367 | __qla83xx_get_idc_control(vha, &idc_control); |
| 4368 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 4369 | __qla83xx_set_idc_control(vha, 0); |
| 4370 | |
| 4371 | qla83xx_idc_unlock(vha, 0); |
| 4372 | rval = qla83xx_restart_nic_firmware(vha); |
| 4373 | qla83xx_idc_lock(vha, 0); |
| 4374 | |
| 4375 | if (rval != QLA_SUCCESS) { |
| 4376 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 4377 | "Failed to restart NIC f/w.\n"); |
| 4378 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 4379 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 4380 | } else { |
| 4381 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 4382 | "Success in restarting nic f/w.\n"); |
| 4383 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 4384 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 4385 | } |
| 4386 | |
| 4387 | return rval; |
| 4388 | } |
| 4389 | |
| 4390 | /* Assumes idc_lock always held on entry */ |
| 4391 | int |
| 4392 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 4393 | { |
| 4394 | struct qla_hw_data *ha = base_vha->hw; |
| 4395 | int rval = QLA_SUCCESS; |
| 4396 | unsigned long dev_init_timeout; |
| 4397 | uint32_t dev_state; |
| 4398 | |
| 4399 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 4400 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 4401 | |
| 4402 | while (1) { |
| 4403 | |
| 4404 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 4405 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 4406 | "Initialization TIMEOUT!\n"); |
| 4407 | /* Init timeout. Disable further NIC Core |
| 4408 | * communication. |
| 4409 | */ |
| 4410 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4411 | QLA8XXX_DEV_FAILED); |
| 4412 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 4413 | "HW State: FAILED.\n"); |
| 4414 | } |
| 4415 | |
| 4416 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4417 | switch (dev_state) { |
| 4418 | case QLA8XXX_DEV_READY: |
| 4419 | if (ha->flags.nic_core_reset_owner) |
| 4420 | qla83xx_idc_audit(base_vha, |
| 4421 | IDC_AUDIT_COMPLETION); |
| 4422 | ha->flags.nic_core_reset_owner = 0; |
| 4423 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 4424 | "Reset_owner reset by 0x%x.\n", |
| 4425 | ha->portnum); |
| 4426 | goto exit; |
| 4427 | case QLA8XXX_DEV_COLD: |
| 4428 | if (ha->flags.nic_core_reset_owner) |
| 4429 | rval = qla83xx_device_bootstrap(base_vha); |
| 4430 | else { |
| 4431 | /* Wait for AEN to change device-state */ |
| 4432 | qla83xx_idc_unlock(base_vha, 0); |
| 4433 | msleep(1000); |
| 4434 | qla83xx_idc_lock(base_vha, 0); |
| 4435 | } |
| 4436 | break; |
| 4437 | case QLA8XXX_DEV_INITIALIZING: |
| 4438 | /* Wait for AEN to change device-state */ |
| 4439 | qla83xx_idc_unlock(base_vha, 0); |
| 4440 | msleep(1000); |
| 4441 | qla83xx_idc_lock(base_vha, 0); |
| 4442 | break; |
| 4443 | case QLA8XXX_DEV_NEED_RESET: |
| 4444 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 4445 | qla83xx_need_reset_handler(base_vha); |
| 4446 | else { |
| 4447 | /* Wait for AEN to change device-state */ |
| 4448 | qla83xx_idc_unlock(base_vha, 0); |
| 4449 | msleep(1000); |
| 4450 | qla83xx_idc_lock(base_vha, 0); |
| 4451 | } |
| 4452 | /* reset timeout value after need reset handler */ |
| 4453 | dev_init_timeout = jiffies + |
| 4454 | (ha->fcoe_dev_init_timeout * HZ); |
| 4455 | break; |
| 4456 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 4457 | /* XXX: DEBUG for now */ |
| 4458 | qla83xx_idc_unlock(base_vha, 0); |
| 4459 | msleep(1000); |
| 4460 | qla83xx_idc_lock(base_vha, 0); |
| 4461 | break; |
| 4462 | case QLA8XXX_DEV_QUIESCENT: |
| 4463 | /* XXX: DEBUG for now */ |
| 4464 | if (ha->flags.quiesce_owner) |
| 4465 | goto exit; |
| 4466 | |
| 4467 | qla83xx_idc_unlock(base_vha, 0); |
| 4468 | msleep(1000); |
| 4469 | qla83xx_idc_lock(base_vha, 0); |
| 4470 | dev_init_timeout = jiffies + |
| 4471 | (ha->fcoe_dev_init_timeout * HZ); |
| 4472 | break; |
| 4473 | case QLA8XXX_DEV_FAILED: |
| 4474 | if (ha->flags.nic_core_reset_owner) |
| 4475 | qla83xx_idc_audit(base_vha, |
| 4476 | IDC_AUDIT_COMPLETION); |
| 4477 | ha->flags.nic_core_reset_owner = 0; |
| 4478 | __qla83xx_clear_drv_presence(base_vha); |
| 4479 | qla83xx_idc_unlock(base_vha, 0); |
| 4480 | qla8xxx_dev_failed_handler(base_vha); |
| 4481 | rval = QLA_FUNCTION_FAILED; |
| 4482 | qla83xx_idc_lock(base_vha, 0); |
| 4483 | goto exit; |
| 4484 | case QLA8XXX_BAD_VALUE: |
| 4485 | qla83xx_idc_unlock(base_vha, 0); |
| 4486 | msleep(1000); |
| 4487 | qla83xx_idc_lock(base_vha, 0); |
| 4488 | break; |
| 4489 | default: |
| 4490 | ql_log(ql_log_warn, base_vha, 0xb071, |
| 4491 | "Unknow Device State: %x.\n", dev_state); |
| 4492 | qla83xx_idc_unlock(base_vha, 0); |
| 4493 | qla8xxx_dev_failed_handler(base_vha); |
| 4494 | rval = QLA_FUNCTION_FAILED; |
| 4495 | qla83xx_idc_lock(base_vha, 0); |
| 4496 | goto exit; |
| 4497 | } |
| 4498 | } |
| 4499 | |
| 4500 | exit: |
| 4501 | return rval; |
| 4502 | } |
| 4503 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4504 | /************************************************************************** |
| 4505 | * qla2x00_do_dpc |
| 4506 | * This kernel thread is a task that is schedule by the interrupt handler |
| 4507 | * to perform the background processing for interrupts. |
| 4508 | * |
| 4509 | * Notes: |
| 4510 | * This task always run in the context of a kernel thread. It |
| 4511 | * is kick-off by the driver's detect code and starts up |
| 4512 | * up one per adapter. It immediately goes to sleep and waits for |
| 4513 | * some fibre event. When either the interrupt handler or |
| 4514 | * the timer routine detects a event it will one of the task |
| 4515 | * bits then wake us up. |
| 4516 | **************************************************************************/ |
| 4517 | static int |
| 4518 | qla2x00_do_dpc(void *data) |
| 4519 | { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4520 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4521 | scsi_qla_host_t *base_vha; |
| 4522 | struct qla_hw_data *ha; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 4523 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4524 | ha = (struct qla_hw_data *)data; |
| 4525 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4526 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4527 | set_user_nice(current, -20); |
| 4528 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 4529 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4530 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4531 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 4532 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4533 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4534 | schedule(); |
| 4535 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4536 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4537 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 4538 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4539 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4540 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4541 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 4542 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4543 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4544 | } |
| 4545 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4546 | ha->dpc_active = 1; |
| 4547 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4548 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 4549 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 4550 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4551 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4552 | qla2x00_do_work(base_vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4553 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4554 | if (IS_QLA82XX(ha)) { |
| 4555 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 4556 | &base_vha->dpc_flags)) { |
| 4557 | qla82xx_idc_lock(ha); |
| 4558 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4559 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4560 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4561 | ql_log(ql_log_info, base_vha, 0x4004, |
| 4562 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4563 | qla82xx_device_state_handler(base_vha); |
| 4564 | continue; |
| 4565 | } |
| 4566 | |
| 4567 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 4568 | &base_vha->dpc_flags)) { |
| 4569 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4570 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 4571 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4572 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 4573 | &base_vha->dpc_flags))) { |
| 4574 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 4575 | /* FCoE-ctx reset failed. |
| 4576 | * Escalate to chip-reset |
| 4577 | */ |
| 4578 | set_bit(ISP_ABORT_NEEDED, |
| 4579 | &base_vha->dpc_flags); |
| 4580 | } |
| 4581 | clear_bit(ABORT_ISP_ACTIVE, |
| 4582 | &base_vha->dpc_flags); |
| 4583 | } |
| 4584 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4585 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 4586 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4587 | } |
| 4588 | } |
| 4589 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4590 | if (test_and_clear_bit(ISP_ABORT_NEEDED, |
| 4591 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4592 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4593 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 4594 | "ISP abort scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4595 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4596 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4597 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4598 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4599 | /* failed. retry later */ |
| 4600 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4601 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4602 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4603 | clear_bit(ABORT_ISP_ACTIVE, |
| 4604 | &base_vha->dpc_flags); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 4605 | } |
| 4606 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4607 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 4608 | "ISP abort end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4609 | } |
| 4610 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 4611 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 4612 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4613 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 4614 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 4615 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4616 | if (test_bit(SCR_PENDING, &base_vha->dpc_flags)) { |
| 4617 | int ret; |
| 4618 | ret = qla2x00_send_change_request(base_vha, 0x3, 0); |
| 4619 | if (ret != QLA_SUCCESS) |
| 4620 | ql_log(ql_log_warn, base_vha, 0x121, |
| 4621 | "Failed to enable receiving of RSCN " |
| 4622 | "requests: 0x%x.\n", ret); |
| 4623 | clear_bit(SCR_PENDING, &base_vha->dpc_flags); |
| 4624 | } |
| 4625 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4626 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4627 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 4628 | "Quiescence mode scheduled.\n"); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 4629 | if (IS_QLA82XX(ha)) { |
| 4630 | qla82xx_device_state_handler(base_vha); |
| 4631 | clear_bit(ISP_QUIESCE_NEEDED, |
| 4632 | &base_vha->dpc_flags); |
| 4633 | if (!ha->flags.quiesce_owner) { |
| 4634 | qla2x00_perform_loop_resync(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4635 | |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 4636 | qla82xx_idc_lock(ha); |
| 4637 | qla82xx_clear_qsnt_ready(base_vha); |
| 4638 | qla82xx_idc_unlock(ha); |
| 4639 | } |
| 4640 | } else { |
| 4641 | clear_bit(ISP_QUIESCE_NEEDED, |
| 4642 | &base_vha->dpc_flags); |
| 4643 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4644 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4645 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 4646 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4647 | } |
| 4648 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4649 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
| 4650 | &base_vha->dpc_flags) && |
| 4651 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4652 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4653 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 4654 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4655 | qla2x00_rst_aen(base_vha); |
| 4656 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4657 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 4658 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4659 | } |
| 4660 | |
| 4661 | /* Retry each device up to login retry count */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4662 | if ((test_and_clear_bit(RELOGIN_NEEDED, |
| 4663 | &base_vha->dpc_flags)) && |
| 4664 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 4665 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4666 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4667 | ql_dbg(ql_dbg_dpc, base_vha, 0x400d, |
| 4668 | "Relogin scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4669 | qla2x00_relogin(base_vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4670 | ql_dbg(ql_dbg_dpc, base_vha, 0x400e, |
| 4671 | "Relogin end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4672 | } |
| 4673 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4674 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
| 4675 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4676 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4677 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 4678 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4679 | |
| 4680 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4681 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4682 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4683 | rval = qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4684 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4685 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 4686 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4687 | } |
| 4688 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4689 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 4690 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4691 | } |
| 4692 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4693 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 4694 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 4695 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 4696 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 4697 | } |
| 4698 | |
Chad Dupuis | 3c290d0 | 2013-01-30 03:34:38 -0500 | [diff] [blame] | 4699 | if (test_and_clear_bit(HOST_RAMP_DOWN_QUEUE_DEPTH, |
| 4700 | &base_vha->dpc_flags)) { |
| 4701 | /* Prevents simultaneous ramp up and down */ |
| 4702 | clear_bit(HOST_RAMP_UP_QUEUE_DEPTH, |
| 4703 | &base_vha->dpc_flags); |
| 4704 | qla2x00_host_ramp_down_queuedepth(base_vha); |
| 4705 | } |
| 4706 | |
| 4707 | if (test_and_clear_bit(HOST_RAMP_UP_QUEUE_DEPTH, |
| 4708 | &base_vha->dpc_flags)) |
| 4709 | qla2x00_host_ramp_up_queuedepth(base_vha); |
| 4710 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4711 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 4712 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4713 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4714 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
| 4715 | &base_vha->dpc_flags)) |
| 4716 | ha->isp_ops->beacon_blink(base_vha); |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 4717 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4718 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4719 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4720 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4721 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 4722 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4723 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 4724 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4725 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4726 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 4727 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4728 | |
| 4729 | /* |
| 4730 | * Make sure that nobody tries to wake us up again. |
| 4731 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4732 | ha->dpc_active = 0; |
| 4733 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4734 | /* Cleanup any residual CTX SRBs. */ |
| 4735 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 4736 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4737 | return 0; |
| 4738 | } |
| 4739 | |
| 4740 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4741 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4742 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4743 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 4744 | struct task_struct *t = ha->dpc_thread; |
| 4745 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4746 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 4747 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4748 | } |
| 4749 | |
| 4750 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4751 | * qla2x00_rst_aen |
| 4752 | * Processes asynchronous reset. |
| 4753 | * |
| 4754 | * Input: |
| 4755 | * ha = adapter block pointer. |
| 4756 | */ |
| 4757 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4758 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4759 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4760 | if (vha->flags.online && !vha->flags.reset_active && |
| 4761 | !atomic_read(&vha->loop_down_timer) && |
| 4762 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4763 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4764 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4765 | |
| 4766 | /* |
| 4767 | * Issue marker command only when we are going to start |
| 4768 | * the I/O. |
| 4769 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4770 | vha->marker_needed = 1; |
| 4771 | } while (!atomic_read(&vha->loop_down_timer) && |
| 4772 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4773 | } |
| 4774 | } |
| 4775 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4776 | /************************************************************************** |
| 4777 | * qla2x00_timer |
| 4778 | * |
| 4779 | * Description: |
| 4780 | * One second timer |
| 4781 | * |
| 4782 | * Context: Interrupt |
| 4783 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4784 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4785 | qla2x00_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4786 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4787 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4788 | int start_dpc = 0; |
| 4789 | int index; |
| 4790 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4791 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4792 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4793 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4794 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 4795 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4796 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 4797 | "EEH = %d, restarting timer.\n", |
| 4798 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 4799 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 4800 | return; |
| 4801 | } |
| 4802 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4803 | /* Hardware read to raise pending EEH errors during mailbox waits. */ |
| 4804 | if (!pci_channel_offline(ha->pdev)) |
| 4805 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4806 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 4807 | /* Make sure qla82xx_watchdog is run only for physical port */ |
| 4808 | if (!vha->vp_idx && IS_QLA82XX(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4809 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 4810 | start_dpc++; |
| 4811 | qla82xx_watchdog(vha); |
| 4812 | } |
| 4813 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4814 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4815 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 4816 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 4817 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4818 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4819 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4820 | if (atomic_read(&vha->loop_down_timer) == |
| 4821 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4822 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4823 | ql_log(ql_log_info, vha, 0x6008, |
| 4824 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4825 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4826 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 4827 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4828 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 4829 | /* |
| 4830 | * Schedule an ISP abort to return any FCP2-device |
| 4831 | * commands. |
| 4832 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4833 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4834 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4835 | spin_lock_irqsave(&ha->hardware_lock, |
| 4836 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4837 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4838 | for (index = 1; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 4839 | index < req->num_outstanding_cmds; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4840 | index++) { |
| 4841 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 4842 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4843 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4844 | if (!sp) |
| 4845 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 4846 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 4847 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4848 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 4849 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4850 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4851 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 4852 | if (IS_QLA82XX(ha)) |
| 4853 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 4854 | &vha->dpc_flags); |
| 4855 | else |
| 4856 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4857 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4858 | break; |
| 4859 | } |
| 4860 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4861 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4862 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4863 | start_dpc++; |
| 4864 | } |
| 4865 | |
| 4866 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4867 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 4868 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4869 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4870 | "Loop down - aborting ISP.\n"); |
| 4871 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 4872 | if (IS_QLA82XX(ha)) |
| 4873 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 4874 | &vha->dpc_flags); |
| 4875 | else |
| 4876 | set_bit(ISP_ABORT_NEEDED, |
| 4877 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4878 | } |
| 4879 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4880 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 4881 | "Loop down - seconds remaining %d.\n", |
| 4882 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4883 | } |
| 4884 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 4885 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 4886 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 4887 | /* There is no beacon_blink function for ISP82xx */ |
| 4888 | if (!IS_QLA82XX(ha)) { |
| 4889 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 4890 | start_dpc++; |
| 4891 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 4892 | } |
| 4893 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 4894 | /* Process any deferred work. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4895 | if (!list_empty(&vha->work_list)) |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 4896 | start_dpc++; |
| 4897 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4898 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4899 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 4900 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 4901 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4902 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4903 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 4904 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4905 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 4906 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4907 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Chad Dupuis | 3c290d0 | 2013-01-30 03:34:38 -0500 | [diff] [blame] | 4908 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags) || |
| 4909 | test_bit(HOST_RAMP_DOWN_QUEUE_DEPTH, &vha->dpc_flags) || |
| 4910 | test_bit(HOST_RAMP_UP_QUEUE_DEPTH, &vha->dpc_flags))) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4911 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 4912 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 4913 | "fcport_update_needed=%d start_dpc=%d " |
| 4914 | "reset_marker_needed=%d", |
| 4915 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 4916 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 4917 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 4918 | start_dpc, |
| 4919 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 4920 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 4921 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 4922 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
Chad Dupuis | 3c290d0 | 2013-01-30 03:34:38 -0500 | [diff] [blame] | 4923 | "relogin_needed=%d, host_ramp_down_needed=%d " |
| 4924 | "host_ramp_up_needed=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4925 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 4926 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 4927 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 4928 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
Chad Dupuis | 3c290d0 | 2013-01-30 03:34:38 -0500 | [diff] [blame] | 4929 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags), |
| 4930 | test_bit(HOST_RAMP_UP_QUEUE_DEPTH, &vha->dpc_flags), |
| 4931 | test_bit(HOST_RAMP_DOWN_QUEUE_DEPTH, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4932 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4933 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4934 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4935 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4936 | } |
| 4937 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4938 | /* Firmware interface routines. */ |
| 4939 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4940 | #define FW_BLOBS 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4941 | #define FW_ISP21XX 0 |
| 4942 | #define FW_ISP22XX 1 |
| 4943 | #define FW_ISP2300 2 |
| 4944 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 4945 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 4946 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 4947 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4948 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4949 | #define FW_ISP2031 8 |
| 4950 | #define FW_ISP8031 9 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4951 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 4952 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 4953 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 4954 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 4955 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 4956 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 4957 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 4958 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4959 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4960 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 4961 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 4962 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 4963 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4964 | |
| 4965 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 4966 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 4967 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 4968 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 4969 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 4970 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 4971 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 4972 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4973 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4974 | { .name = FW_FILE_ISP2031, }, |
| 4975 | { .name = FW_FILE_ISP8031, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4976 | }; |
| 4977 | |
| 4978 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4979 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4980 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4981 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4982 | struct fw_blob *blob; |
| 4983 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4984 | if (IS_QLA2100(ha)) { |
| 4985 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 4986 | } else if (IS_QLA2200(ha)) { |
| 4987 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 4988 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4989 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 4990 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4991 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4992 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4993 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 4994 | } else if (IS_QLA25XX(ha)) { |
| 4995 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 4996 | } else if (IS_QLA81XX(ha)) { |
| 4997 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4998 | } else if (IS_QLA82XX(ha)) { |
| 4999 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5000 | } else if (IS_QLA2031(ha)) { |
| 5001 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 5002 | } else if (IS_QLA8031(ha)) { |
| 5003 | blob = &qla_fw_blobs[FW_ISP8031]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 5004 | } else { |
| 5005 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5006 | } |
| 5007 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5008 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5009 | if (blob->fw) |
| 5010 | goto out; |
| 5011 | |
| 5012 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5013 | ql_log(ql_log_warn, vha, 0x0063, |
| 5014 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5015 | blob->fw = NULL; |
| 5016 | blob = NULL; |
| 5017 | goto out; |
| 5018 | } |
| 5019 | |
| 5020 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5021 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5022 | return blob; |
| 5023 | } |
| 5024 | |
| 5025 | static void |
| 5026 | qla2x00_release_firmware(void) |
| 5027 | { |
| 5028 | int idx; |
| 5029 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5030 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5031 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 5032 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5033 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5034 | } |
| 5035 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5036 | static pci_ers_result_t |
| 5037 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 5038 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5039 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 5040 | struct qla_hw_data *ha = vha->hw; |
| 5041 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5042 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 5043 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 5044 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5045 | switch (state) { |
| 5046 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5047 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5048 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 5049 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5050 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5051 | /* For ISP82XX complete any pending mailbox cmd */ |
| 5052 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5053 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 5054 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 5055 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5056 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5057 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5058 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 5059 | /* Return back all IOs */ |
| 5060 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5061 | return PCI_ERS_RESULT_NEED_RESET; |
| 5062 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5063 | ha->flags.pci_channel_io_perm_failure = 1; |
| 5064 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5065 | return PCI_ERS_RESULT_DISCONNECT; |
| 5066 | } |
| 5067 | return PCI_ERS_RESULT_NEED_RESET; |
| 5068 | } |
| 5069 | |
| 5070 | static pci_ers_result_t |
| 5071 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 5072 | { |
| 5073 | int risc_paused = 0; |
| 5074 | uint32_t stat; |
| 5075 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5076 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5077 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5078 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 5079 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 5080 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 5081 | if (IS_QLA82XX(ha)) |
| 5082 | return PCI_ERS_RESULT_RECOVERED; |
| 5083 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5084 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 5085 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 5086 | stat = RD_REG_DWORD(®->hccr); |
| 5087 | if (stat & HCCR_RISC_PAUSE) |
| 5088 | risc_paused = 1; |
| 5089 | } else if (IS_QLA23XX(ha)) { |
| 5090 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 5091 | if (stat & HSR_RISC_PAUSED) |
| 5092 | risc_paused = 1; |
| 5093 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 5094 | stat = RD_REG_DWORD(®24->host_status); |
| 5095 | if (stat & HSRX_RISC_PAUSED) |
| 5096 | risc_paused = 1; |
| 5097 | } |
| 5098 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 5099 | |
| 5100 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5101 | ql_log(ql_log_info, base_vha, 0x9003, |
| 5102 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5103 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5104 | |
| 5105 | return PCI_ERS_RESULT_NEED_RESET; |
| 5106 | } else |
| 5107 | return PCI_ERS_RESULT_RECOVERED; |
| 5108 | } |
| 5109 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5110 | static uint32_t |
| 5111 | qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5112 | { |
| 5113 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 5114 | uint32_t drv_active = 0; |
| 5115 | struct qla_hw_data *ha = base_vha->hw; |
| 5116 | int fn; |
| 5117 | struct pci_dev *other_pdev = NULL; |
| 5118 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5119 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 5120 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5121 | |
| 5122 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5123 | |
| 5124 | if (base_vha->flags.online) { |
| 5125 | /* Abort all outstanding commands, |
| 5126 | * so as to be requeued later */ |
| 5127 | qla2x00_abort_isp_cleanup(base_vha); |
| 5128 | } |
| 5129 | |
| 5130 | |
| 5131 | fn = PCI_FUNC(ha->pdev->devfn); |
| 5132 | while (fn > 0) { |
| 5133 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5134 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 5135 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5136 | other_pdev = |
| 5137 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 5138 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 5139 | fn)); |
| 5140 | |
| 5141 | if (!other_pdev) |
| 5142 | continue; |
| 5143 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5144 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 5145 | "Found PCI func available and enable at 0x%x.\n", |
| 5146 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5147 | pci_dev_put(other_pdev); |
| 5148 | break; |
| 5149 | } |
| 5150 | pci_dev_put(other_pdev); |
| 5151 | } |
| 5152 | |
| 5153 | if (!fn) { |
| 5154 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5155 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 5156 | "This devfn is reset owner = 0x%x.\n", |
| 5157 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5158 | qla82xx_idc_lock(ha); |
| 5159 | |
| 5160 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5161 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5162 | |
| 5163 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 5164 | QLA82XX_IDC_VERSION); |
| 5165 | |
| 5166 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5167 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 5168 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5169 | |
| 5170 | qla82xx_idc_unlock(ha); |
| 5171 | /* Reset if device is not already reset |
| 5172 | * drv_active would be 0 if a reset has already been done |
| 5173 | */ |
| 5174 | if (drv_active) |
| 5175 | rval = qla82xx_start_firmware(base_vha); |
| 5176 | else |
| 5177 | rval = QLA_SUCCESS; |
| 5178 | qla82xx_idc_lock(ha); |
| 5179 | |
| 5180 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5181 | ql_log(ql_log_info, base_vha, 0x900b, |
| 5182 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5183 | qla82xx_clear_drv_active(ha); |
| 5184 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5185 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5186 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5187 | ql_log(ql_log_info, base_vha, 0x900c, |
| 5188 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5189 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5190 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5191 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5192 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5193 | rval = qla82xx_restart_isp(base_vha); |
| 5194 | qla82xx_idc_lock(ha); |
| 5195 | /* Clear driver state register */ |
| 5196 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 5197 | qla82xx_set_drv_active(base_vha); |
| 5198 | } |
| 5199 | qla82xx_idc_unlock(ha); |
| 5200 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5201 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 5202 | "This devfn is not reset owner = 0x%x.\n", |
| 5203 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5204 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5205 | QLA8XXX_DEV_READY)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5206 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5207 | rval = qla82xx_restart_isp(base_vha); |
| 5208 | qla82xx_idc_lock(ha); |
| 5209 | qla82xx_set_drv_active(base_vha); |
| 5210 | qla82xx_idc_unlock(ha); |
| 5211 | } |
| 5212 | } |
| 5213 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5214 | |
| 5215 | return rval; |
| 5216 | } |
| 5217 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5218 | static pci_ers_result_t |
| 5219 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 5220 | { |
| 5221 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5222 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5223 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5224 | struct rsp_que *rsp; |
| 5225 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5226 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5227 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 5228 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5229 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5230 | /* Workaround: qla2xxx driver which access hardware earlier |
| 5231 | * needs error state to be pci_channel_io_online. |
| 5232 | * Otherwise mailbox command timesout. |
| 5233 | */ |
| 5234 | pdev->error_state = pci_channel_io_normal; |
| 5235 | |
| 5236 | pci_restore_state(pdev); |
| 5237 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 5238 | /* pci_restore_state() clears the saved_state flag of the device |
| 5239 | * save restored state which resets saved_state flag |
| 5240 | */ |
| 5241 | pci_save_state(pdev); |
| 5242 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 5243 | if (ha->mem_only) |
| 5244 | rc = pci_enable_device_mem(pdev); |
| 5245 | else |
| 5246 | rc = pci_enable_device(pdev); |
| 5247 | |
| 5248 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5249 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5250 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5251 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5252 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5253 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5254 | rsp = ha->rsp_q_map[0]; |
| 5255 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5256 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5257 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5258 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5259 | goto exit_slot_reset; |
| 5260 | |
| 5261 | if (IS_QLA82XX(ha)) { |
| 5262 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 5263 | ret = PCI_ERS_RESULT_RECOVERED; |
| 5264 | goto exit_slot_reset; |
| 5265 | } else |
| 5266 | goto exit_slot_reset; |
| 5267 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5268 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5269 | while (ha->flags.mbox_busy && retries--) |
| 5270 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5271 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5272 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5273 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5274 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5275 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5276 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5277 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5278 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5279 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 5280 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5281 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5282 | return ret; |
| 5283 | } |
| 5284 | |
| 5285 | static void |
| 5286 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 5287 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5288 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5289 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5290 | int ret; |
| 5291 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5292 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 5293 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5294 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5295 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5296 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5297 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 5298 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5299 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5300 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 5301 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 5302 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5303 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5304 | } |
| 5305 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 5306 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5307 | .error_detected = qla2xxx_pci_error_detected, |
| 5308 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 5309 | .slot_reset = qla2xxx_pci_slot_reset, |
| 5310 | .resume = qla2xxx_pci_resume, |
| 5311 | }; |
| 5312 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5313 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5314 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 5315 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 5316 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 5317 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 5318 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 5319 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 5320 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 5321 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 5322 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5323 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5324 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 5325 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5326 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5327 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5328 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5329 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 5330 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5331 | { 0 }, |
| 5332 | }; |
| 5333 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 5334 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5335 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 5336 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 5337 | .driver = { |
| 5338 | .owner = THIS_MODULE, |
| 5339 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5340 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5341 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 5342 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 5343 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5344 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5345 | }; |
| 5346 | |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5347 | static struct file_operations apidev_fops = { |
| 5348 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 5349 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5350 | }; |
| 5351 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5352 | /** |
| 5353 | * qla2x00_module_init - Module initialization. |
| 5354 | **/ |
| 5355 | static int __init |
| 5356 | qla2x00_module_init(void) |
| 5357 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5358 | int ret = 0; |
| 5359 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5360 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 5361 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 5362 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5363 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5364 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 5365 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5366 | return -ENOMEM; |
| 5367 | } |
| 5368 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5369 | /* Initialize target kmem_cache and mem_pools */ |
| 5370 | ret = qlt_init(); |
| 5371 | if (ret < 0) { |
| 5372 | kmem_cache_destroy(srb_cachep); |
| 5373 | return ret; |
| 5374 | } else if (ret > 0) { |
| 5375 | /* |
| 5376 | * If initiator mode is explictly disabled by qlt_init(), |
| 5377 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 5378 | * performing scsi_scan_target() during LOOP UP event. |
| 5379 | */ |
| 5380 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 5381 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 5382 | } |
| 5383 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5384 | /* Derive version string. */ |
| 5385 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 5386 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 5387 | strcat(qla2x00_version_str, "-debug"); |
| 5388 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 5389 | qla2xxx_transport_template = |
| 5390 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5391 | if (!qla2xxx_transport_template) { |
| 5392 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5393 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 5394 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5395 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5396 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5397 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5398 | |
| 5399 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 5400 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5401 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 5402 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5403 | } |
| 5404 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5405 | qla2xxx_transport_vport_template = |
| 5406 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 5407 | if (!qla2xxx_transport_vport_template) { |
| 5408 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5409 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5410 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5411 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 5412 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5413 | return -ENODEV; |
| 5414 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5415 | ql_log(ql_log_info, NULL, 0x0005, |
| 5416 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 5417 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5418 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5419 | if (ret) { |
| 5420 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5421 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5422 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5423 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5424 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 5425 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 5426 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5427 | } |
| 5428 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5429 | } |
| 5430 | |
| 5431 | /** |
| 5432 | * qla2x00_module_exit - Module cleanup. |
| 5433 | **/ |
| 5434 | static void __exit |
| 5435 | qla2x00_module_exit(void) |
| 5436 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5437 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5438 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5439 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 5440 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5441 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5442 | if (ctx_cachep) |
| 5443 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5444 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5445 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5446 | } |
| 5447 | |
| 5448 | module_init(qla2x00_module_init); |
| 5449 | module_exit(qla2x00_module_exit); |
| 5450 | |
| 5451 | MODULE_AUTHOR("QLogic Corporation"); |
| 5452 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 5453 | MODULE_LICENSE("GPL"); |
| 5454 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5455 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 5456 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 5457 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 5458 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 5459 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 5460 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |