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 |
Armen Baloyan | bd21eaf | 2014-04-11 16:54:24 -0400 | [diff] [blame] | 3 | * Copyright (c) 2003-2014 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 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | int ql2xlogintimeout = 20; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 52 | module_param(ql2xlogintimeout, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | MODULE_PARM_DESC(ql2xlogintimeout, |
| 54 | "Login timeout value in seconds."); |
| 55 | |
Andrew Vasquez | a7b6184 | 2007-05-07 07:42:59 -0700 | [diff] [blame] | 56 | int qlport_down_retry; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 57 | module_param(qlport_down_retry, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | MODULE_PARM_DESC(qlport_down_retry, |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 59 | "Maximum number of command retries to a port that returns " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | "a PORT-DOWN status."); |
| 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | int ql2xplogiabsentdevice; |
| 63 | module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); |
| 64 | MODULE_PARM_DESC(ql2xplogiabsentdevice, |
| 65 | "Option to enable PLOGI to devices that are not present after " |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 66 | "a Fabric scan. This is needed for several broken switches. " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | "Default is 0 - no PLOGI. 1 - perfom PLOGI."); |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | int ql2xloginretrycount = 0; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 70 | module_param(ql2xloginretrycount, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | MODULE_PARM_DESC(ql2xloginretrycount, |
| 72 | "Specify an alternate value for the NVRAM login retry count."); |
| 73 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 74 | int ql2xallocfwdump = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 75 | module_param(ql2xallocfwdump, int, S_IRUGO); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 76 | MODULE_PARM_DESC(ql2xallocfwdump, |
| 77 | "Option to enable allocation of memory for a firmware dump " |
| 78 | "during HBA initialization. Memory allocation requirements " |
| 79 | "vary by ISP type. Default is 1 - allocate memory."); |
| 80 | |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 81 | int ql2xextended_error_logging; |
Andrew Vasquez | 27d9403 | 2007-03-12 10:41:30 -0700 | [diff] [blame] | 82 | module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 83 | MODULE_PARM_DESC(ql2xextended_error_logging, |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 84 | "Option to enable extended error logging,\n" |
| 85 | "\t\tDefault is 0 - no logging. 0x40000000 - Module Init & Probe.\n" |
| 86 | "\t\t0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.\n" |
| 87 | "\t\t0x08000000 - IO tracing. 0x04000000 - DPC Thread.\n" |
| 88 | "\t\t0x02000000 - Async events. 0x01000000 - Timer routines.\n" |
| 89 | "\t\t0x00800000 - User space. 0x00400000 - Task Management.\n" |
| 90 | "\t\t0x00200000 - AER/EEH. 0x00100000 - Multi Q.\n" |
| 91 | "\t\t0x00080000 - P3P Specific. 0x00040000 - Virtual Port.\n" |
| 92 | "\t\t0x00020000 - Buffer Dump. 0x00010000 - Misc.\n" |
Chad Dupuis | 29f9f90 | 2012-11-21 02:40:41 -0500 | [diff] [blame] | 93 | "\t\t0x00008000 - Verbose. 0x00004000 - Target.\n" |
| 94 | "\t\t0x00002000 - Target Mgmt. 0x00001000 - Target TMF.\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 95 | "\t\t0x7fffffff - For enabling all logs, can be too many logs.\n" |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 96 | "\t\t0x1e400000 - Preferred value for capturing essential " |
| 97 | "debug information (equivalent to old " |
| 98 | "ql2xextended_error_logging=1).\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 99 | "\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] | 100 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 101 | int ql2xshiftctondsd = 6; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 102 | module_param(ql2xshiftctondsd, int, S_IRUGO); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 103 | MODULE_PARM_DESC(ql2xshiftctondsd, |
| 104 | "Set to control shifting of command type processing " |
| 105 | "based on total number of SG elements."); |
| 106 | |
Andrew Vasquez | 7e47e5c | 2008-04-24 15:21:26 -0700 | [diff] [blame] | 107 | int ql2xfdmienable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 108 | module_param(ql2xfdmienable, int, S_IRUGO); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 109 | MODULE_PARM_DESC(ql2xfdmienable, |
Ferenc Wagner | 7794a5a | 2010-03-23 18:14:59 +0100 | [diff] [blame] | 110 | "Enables FDMI registrations. " |
| 111 | "0 - no FDMI. Default is 1 - perform FDMI."); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 112 | |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 113 | #define MAX_Q_DEPTH 32 |
| 114 | static 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, |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 123 | " Enable T10-CRC-DIF:\n" |
| 124 | " Default is 2.\n" |
| 125 | " 0 -- No DIF Support\n" |
| 126 | " 1 -- Enable DIF for all types\n" |
| 127 | " 2 -- Enable DIF for all types, except Type 0.\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 128 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 129 | int ql2xenablehba_err_chk = 2; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 130 | module_param(ql2xenablehba_err_chk, int, S_IRUGO|S_IWUSR); |
| 131 | MODULE_PARM_DESC(ql2xenablehba_err_chk, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 132 | " Enable T10-CRC-DIF Error isolation by HBA:\n" |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 133 | " Default is 2.\n" |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 134 | " 0 -- Error isolation disabled\n" |
| 135 | " 1 -- Error isolation enabled only for DIX Type 0\n" |
| 136 | " 2 -- Error isolation enabled for all Types\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 137 | |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 138 | int ql2xiidmaenable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 139 | module_param(ql2xiidmaenable, int, S_IRUGO); |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 140 | MODULE_PARM_DESC(ql2xiidmaenable, |
| 141 | "Enables iIDMA settings " |
| 142 | "Default is 1 - perform iIDMA. 0 - no iIDMA."); |
| 143 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 144 | int ql2xmaxqueues = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 145 | module_param(ql2xmaxqueues, int, S_IRUGO); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 146 | MODULE_PARM_DESC(ql2xmaxqueues, |
| 147 | "Enables MQ settings " |
Joe Perches | ae68230 | 2010-08-10 18:01:21 -0700 | [diff] [blame] | 148 | "Default is 1 for single queue. Set it to number " |
| 149 | "of queues in MQ mode."); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 150 | |
| 151 | int ql2xmultique_tag; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 152 | module_param(ql2xmultique_tag, int, S_IRUGO); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 153 | MODULE_PARM_DESC(ql2xmultique_tag, |
| 154 | "Enables CPU affinity settings for the driver " |
| 155 | "Default is 0 for no affinity of request and response IO. " |
| 156 | "Set it to 1 to turn on the cpu affinity."); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 157 | |
| 158 | int ql2xfwloadbin; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 159 | module_param(ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 160 | MODULE_PARM_DESC(ql2xfwloadbin, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 161 | "Option to specify location from which to load ISP firmware:.\n" |
| 162 | " 2 -- load firmware via the request_firmware() (hotplug).\n" |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 163 | " interface.\n" |
| 164 | " 1 -- load firmware from flash.\n" |
| 165 | " 0 -- use default semantics.\n"); |
| 166 | |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 167 | int ql2xetsenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 168 | module_param(ql2xetsenable, int, S_IRUGO); |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 169 | MODULE_PARM_DESC(ql2xetsenable, |
| 170 | "Enables firmware ETS burst." |
| 171 | "Default is 0 - skip ETS enablement."); |
| 172 | |
Giridhar Malavali | 6907869 | 2010-05-28 15:08:28 -0700 | [diff] [blame] | 173 | int ql2xdbwr = 1; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 174 | module_param(ql2xdbwr, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 175 | MODULE_PARM_DESC(ql2xdbwr, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 176 | "Option to specify scheme for request queue posting.\n" |
| 177 | " 0 -- Regular doorbell.\n" |
| 178 | " 1 -- CAMRAM doorbell (faster).\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 179 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 180 | int ql2xtargetreset = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 181 | module_param(ql2xtargetreset, int, S_IRUGO); |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 182 | MODULE_PARM_DESC(ql2xtargetreset, |
| 183 | "Enable target reset." |
| 184 | "Default is 1 - use hw defaults."); |
| 185 | |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 186 | int ql2xgffidenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 187 | module_param(ql2xgffidenable, int, S_IRUGO); |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 188 | MODULE_PARM_DESC(ql2xgffidenable, |
| 189 | "Enables GFF_ID checks of port type. " |
| 190 | "Default is 0 - Do not use GFF_ID information."); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 191 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 192 | int ql2xasynctmfenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 193 | module_param(ql2xasynctmfenable, int, S_IRUGO); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 194 | MODULE_PARM_DESC(ql2xasynctmfenable, |
| 195 | "Enables issue of TM IOCBs asynchronously via IOCB mechanism" |
| 196 | "Default is 0 - Issue TM IOCBs via mailbox mechanism."); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 197 | |
| 198 | int ql2xdontresethba; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 199 | module_param(ql2xdontresethba, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 200 | MODULE_PARM_DESC(ql2xdontresethba, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 201 | "Option to specify reset behaviour.\n" |
| 202 | " 0 (Default) -- Reset on failure.\n" |
| 203 | " 1 -- Do not reset on failure.\n"); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 204 | |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 205 | uint64_t ql2xmaxlun = MAX_LUNS; |
| 206 | module_param(ql2xmaxlun, ullong, S_IRUGO); |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 207 | MODULE_PARM_DESC(ql2xmaxlun, |
| 208 | "Defines the maximum LU number to register with the SCSI " |
| 209 | "midlayer. Default is 65535."); |
| 210 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 211 | int ql2xmdcapmask = 0x1F; |
| 212 | module_param(ql2xmdcapmask, int, S_IRUGO); |
| 213 | MODULE_PARM_DESC(ql2xmdcapmask, |
| 214 | "Set the Minidump driver capture mask level. " |
Giridhar Malavali | 6e96fa7 | 2011-11-18 09:03:14 -0800 | [diff] [blame] | 215 | "Default is 0x1F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 216 | |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 217 | int ql2xmdenable = 1; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 218 | module_param(ql2xmdenable, int, S_IRUGO); |
| 219 | MODULE_PARM_DESC(ql2xmdenable, |
| 220 | "Enable/disable MiniDump. " |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 221 | "0 - MiniDump disabled. " |
| 222 | "1 (Default) - MiniDump enabled."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 223 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 225 | * SCSI host template entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | */ |
| 227 | static int qla2xxx_slave_configure(struct scsi_device * device); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 228 | static int qla2xxx_slave_alloc(struct scsi_device *); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 229 | static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); |
| 230 | static void qla2xxx_scan_start(struct Scsi_Host *); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 231 | static void qla2xxx_slave_destroy(struct scsi_device *); |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 232 | static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | static int qla2xxx_eh_abort(struct scsi_cmnd *); |
| 234 | static int qla2xxx_eh_device_reset(struct scsi_cmnd *); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 235 | static int qla2xxx_eh_target_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); |
| 237 | static int qla2xxx_eh_host_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 239 | static int qla2x00_change_queue_depth(struct scsi_device *, int, int); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 240 | static int qla2x00_change_queue_type(struct scsi_device *, int); |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 241 | static void qla2x00_clear_drv_active(struct qla_hw_data *); |
Saurav Kashyap | 3491255 | 2013-06-25 11:27:18 -0400 | [diff] [blame] | 242 | static void qla2x00_free_device(scsi_qla_host_t *); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 243 | |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 244 | struct scsi_host_template qla2xxx_driver_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | .module = THIS_MODULE, |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 246 | .name = QLA2XXX_DRIVER_NAME, |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 247 | .queuecommand = qla2xxx_queuecommand, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 248 | |
| 249 | .eh_abort_handler = qla2xxx_eh_abort, |
| 250 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 251 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 252 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 253 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 254 | |
| 255 | .slave_configure = qla2xxx_slave_configure, |
| 256 | |
| 257 | .slave_alloc = qla2xxx_slave_alloc, |
| 258 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 259 | .scan_finished = qla2xxx_scan_finished, |
| 260 | .scan_start = qla2xxx_scan_start, |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 261 | .change_queue_depth = qla2x00_change_queue_depth, |
| 262 | .change_queue_type = qla2x00_change_queue_type, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 263 | .this_id = -1, |
| 264 | .cmd_per_lun = 3, |
| 265 | .use_clustering = ENABLE_CLUSTERING, |
| 266 | .sg_tablesize = SG_ALL, |
| 267 | |
| 268 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 269 | .shost_attrs = qla2x00_host_attrs, |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 270 | |
| 271 | .supported_mode = MODE_INITIATOR, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 272 | }; |
| 273 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 275 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | /* TODO Convert to inlines |
| 278 | * |
| 279 | * Timer routines |
| 280 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 282 | __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 283 | 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] | 284 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 285 | init_timer(&vha->timer); |
| 286 | vha->timer.expires = jiffies + interval * HZ; |
| 287 | vha->timer.data = (unsigned long)vha; |
| 288 | vha->timer.function = (void (*)(unsigned long))func; |
| 289 | add_timer(&vha->timer); |
| 290 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 294 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 296 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 297 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 298 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 299 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 300 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 301 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 302 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 303 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | } |
| 305 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 306 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 307 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 309 | del_timer_sync(&vha->timer); |
| 310 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | } |
| 312 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | static int qla2x00_do_dpc(void *data); |
| 314 | |
| 315 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 316 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 317 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 318 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 319 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 320 | static void qla2x00_mem_free(struct qla_hw_data *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | /* -------------------------------------------------------------------------- */ |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 323 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 324 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 325 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 326 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 327 | 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] | 328 | GFP_KERNEL); |
| 329 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 330 | ql_log(ql_log_fatal, vha, 0x003b, |
| 331 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 332 | goto fail_req_map; |
| 333 | } |
| 334 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 335 | 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] | 336 | GFP_KERNEL); |
| 337 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 338 | ql_log(ql_log_fatal, vha, 0x003c, |
| 339 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 340 | goto fail_rsp_map; |
| 341 | } |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 342 | /* |
| 343 | * Make sure we record at least the request and response queue zero in |
| 344 | * case we need to free them if part of the probe fails. |
| 345 | */ |
| 346 | ha->rsp_q_map[0] = rsp; |
| 347 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 348 | set_bit(0, ha->rsp_qid_map); |
| 349 | set_bit(0, ha->req_qid_map); |
| 350 | return 1; |
| 351 | |
| 352 | fail_rsp_map: |
| 353 | kfree(ha->req_q_map); |
| 354 | ha->req_q_map = NULL; |
| 355 | fail_req_map: |
| 356 | return -ENOMEM; |
| 357 | } |
| 358 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 359 | 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] | 360 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 361 | if (IS_QLAFX00(ha)) { |
| 362 | if (req && req->ring_fx00) |
| 363 | dma_free_coherent(&ha->pdev->dev, |
| 364 | (req->length_fx00 + 1) * sizeof(request_t), |
| 365 | req->ring_fx00, req->dma_fx00); |
| 366 | } else if (req && req->ring) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 367 | dma_free_coherent(&ha->pdev->dev, |
| 368 | (req->length + 1) * sizeof(request_t), |
| 369 | req->ring, req->dma); |
| 370 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 371 | if (req) |
| 372 | kfree(req->outstanding_cmds); |
| 373 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 374 | kfree(req); |
| 375 | req = NULL; |
| 376 | } |
| 377 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 378 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 379 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 380 | if (IS_QLAFX00(ha)) { |
| 381 | if (rsp && rsp->ring) |
| 382 | dma_free_coherent(&ha->pdev->dev, |
| 383 | (rsp->length_fx00 + 1) * sizeof(request_t), |
| 384 | rsp->ring_fx00, rsp->dma_fx00); |
| 385 | } else if (rsp && rsp->ring) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 386 | dma_free_coherent(&ha->pdev->dev, |
| 387 | (rsp->length + 1) * sizeof(response_t), |
| 388 | rsp->ring, rsp->dma); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 389 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 390 | kfree(rsp); |
| 391 | rsp = NULL; |
| 392 | } |
| 393 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 394 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 395 | { |
| 396 | struct req_que *req; |
| 397 | struct rsp_que *rsp; |
| 398 | int cnt; |
| 399 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 400 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 401 | req = ha->req_q_map[cnt]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 402 | qla2x00_free_req_que(ha, req); |
| 403 | } |
| 404 | kfree(ha->req_q_map); |
| 405 | ha->req_q_map = NULL; |
| 406 | |
| 407 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
| 408 | rsp = ha->rsp_q_map[cnt]; |
| 409 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 410 | } |
| 411 | kfree(ha->rsp_q_map); |
| 412 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 413 | } |
| 414 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 415 | static int qla25xx_setup_mode(struct scsi_qla_host *vha) |
| 416 | { |
| 417 | uint16_t options = 0; |
| 418 | int ques, req, ret; |
| 419 | struct qla_hw_data *ha = vha->hw; |
| 420 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 421 | if (!(ha->fw_attributes & BIT_6)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 422 | ql_log(ql_log_warn, vha, 0x00d8, |
| 423 | "Firmware is not multi-queue capable.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 424 | goto fail; |
| 425 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 426 | if (ql2xmultique_tag) { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 427 | /* create a request queue for IO */ |
| 428 | options |= BIT_7; |
| 429 | req = qla25xx_create_req_que(ha, options, 0, 0, -1, |
| 430 | QLA_DEFAULT_QUE_QOS); |
| 431 | if (!req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 432 | ql_log(ql_log_warn, vha, 0x00e0, |
| 433 | "Failed to create request queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 434 | goto fail; |
| 435 | } |
Tejun Heo | 278274d5 | 2011-02-01 11:42:42 +0100 | [diff] [blame] | 436 | ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 437 | vha->req = ha->req_q_map[req]; |
| 438 | options |= BIT_1; |
| 439 | for (ques = 1; ques < ha->max_rsp_queues; ques++) { |
| 440 | ret = qla25xx_create_rsp_que(ha, options, 0, 0, req); |
| 441 | if (!ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 442 | ql_log(ql_log_warn, vha, 0x00e8, |
| 443 | "Failed to create response queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 444 | goto fail2; |
| 445 | } |
| 446 | } |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 447 | ha->flags.cpu_affinity_enabled = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 448 | ql_dbg(ql_dbg_multiq, vha, 0xc007, |
| 449 | "CPU affinity mode enalbed, " |
| 450 | "no. of response queues:%d no. of request queues:%d.\n", |
| 451 | ha->max_rsp_queues, ha->max_req_queues); |
| 452 | ql_dbg(ql_dbg_init, vha, 0x00e9, |
| 453 | "CPU affinity mode enalbed, " |
| 454 | "no. of response queues:%d no. of request queues:%d.\n", |
| 455 | ha->max_rsp_queues, ha->max_req_queues); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 456 | } |
| 457 | return 0; |
| 458 | fail2: |
| 459 | qla25xx_delete_queues(vha); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 460 | destroy_workqueue(ha->wq); |
| 461 | ha->wq = NULL; |
Giridhar Malavali | 0cd33fc | 2011-11-18 09:02:12 -0800 | [diff] [blame] | 462 | vha->req = ha->req_q_map[0]; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 463 | fail: |
| 464 | ha->mqenable = 0; |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 465 | kfree(ha->req_q_map); |
| 466 | kfree(ha->rsp_q_map); |
| 467 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 468 | return 1; |
| 469 | } |
| 470 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 472 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 474 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | static char *pci_bus_modes[] = { |
| 476 | "33", "66", "100", "133", |
| 477 | }; |
| 478 | uint16_t pci_bus; |
| 479 | |
| 480 | strcpy(str, "PCI"); |
| 481 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 482 | if (pci_bus) { |
| 483 | strcat(str, "-X ("); |
| 484 | strcat(str, pci_bus_modes[pci_bus]); |
| 485 | } else { |
| 486 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 487 | strcat(str, " ("); |
| 488 | strcat(str, pci_bus_modes[pci_bus]); |
| 489 | } |
| 490 | strcat(str, " MHz)"); |
| 491 | |
| 492 | return (str); |
| 493 | } |
| 494 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 495 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 496 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 497 | { |
| 498 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 499 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 500 | uint32_t pci_bus; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 501 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 502 | if (pci_is_pcie(ha->pdev)) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 503 | char lwstr[6]; |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 504 | uint32_t lstat, lspeed, lwidth; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 505 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 506 | pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); |
| 507 | lspeed = lstat & PCI_EXP_LNKCAP_SLS; |
| 508 | lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 509 | |
| 510 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 511 | switch (lspeed) { |
| 512 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 513 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 514 | break; |
| 515 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 516 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 517 | break; |
| 518 | case 3: |
| 519 | strcat(str, "8.0GT/s "); |
| 520 | break; |
| 521 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 522 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 523 | break; |
| 524 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 525 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 526 | strcat(str, lwstr); |
| 527 | |
| 528 | return str; |
| 529 | } |
| 530 | |
| 531 | strcpy(str, "PCI"); |
| 532 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 533 | if (pci_bus == 0 || pci_bus == 8) { |
| 534 | strcat(str, " ("); |
| 535 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 536 | } else { |
| 537 | strcat(str, "-X "); |
| 538 | if (pci_bus & BIT_2) |
| 539 | strcat(str, "Mode 2"); |
| 540 | else |
| 541 | strcat(str, "Mode 1"); |
| 542 | strcat(str, " ("); |
| 543 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 544 | } |
| 545 | strcat(str, " MHz)"); |
| 546 | |
| 547 | return str; |
| 548 | } |
| 549 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 550 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 551 | qla2x00_fw_version_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | { |
| 553 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 554 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 555 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | sprintf(str, "%d.%02d.%02d ", ha->fw_major_version, |
| 557 | ha->fw_minor_version, |
| 558 | ha->fw_subminor_version); |
| 559 | |
| 560 | if (ha->fw_attributes & BIT_9) { |
| 561 | strcat(str, "FLX"); |
| 562 | return (str); |
| 563 | } |
| 564 | |
| 565 | switch (ha->fw_attributes & 0xFF) { |
| 566 | case 0x7: |
| 567 | strcat(str, "EF"); |
| 568 | break; |
| 569 | case 0x17: |
| 570 | strcat(str, "TP"); |
| 571 | break; |
| 572 | case 0x37: |
| 573 | strcat(str, "IP"); |
| 574 | break; |
| 575 | case 0x77: |
| 576 | strcat(str, "VI"); |
| 577 | break; |
| 578 | default: |
| 579 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 580 | strcat(str, un_str); |
| 581 | break; |
| 582 | } |
| 583 | if (ha->fw_attributes & 0x100) |
| 584 | strcat(str, "X"); |
| 585 | |
| 586 | return (str); |
| 587 | } |
| 588 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 589 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 590 | qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 591 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 592 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 593 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 594 | sprintf(str, "%d.%02d.%02d (%x)", ha->fw_major_version, |
| 595 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 596 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 597 | } |
| 598 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 599 | void |
| 600 | qla2x00_sp_free_dma(void *vha, void *ptr) |
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 | srb_t *sp = (srb_t *)ptr; |
| 603 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 604 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 605 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 606 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 607 | if (sp->flags & SRB_DMA_VALID) { |
| 608 | scsi_dma_unmap(cmd); |
| 609 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 610 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 611 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 612 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 613 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 614 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 615 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 616 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 617 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 618 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 619 | /* List assured to be having elements */ |
Quinn Tran | f83adb6 | 2014-04-11 16:54:43 -0400 | [diff] [blame] | 620 | qla2x00_clean_dsd_pool(ha, sp, NULL); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 621 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 622 | } |
| 623 | |
| 624 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
| 625 | dma_pool_free(ha->dl_dma_pool, ctx, |
| 626 | ((struct crc_context *)ctx)->crc_ctx_dma); |
| 627 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 628 | } |
| 629 | |
| 630 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
| 631 | struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; |
| 632 | |
| 633 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 634 | ctx1->fcp_cmnd_dma); |
| 635 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 636 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 637 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 638 | mempool_free(ctx1, ha->ctx_mempool); |
| 639 | ctx1 = NULL; |
| 640 | } |
| 641 | |
| 642 | CMD_SP(cmd) = NULL; |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 643 | qla2x00_rel_sp(sp->fcport->vha, sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 644 | } |
| 645 | |
Fengguang Wu | 14b0680 | 2013-04-25 01:29:19 -0400 | [diff] [blame] | 646 | static void |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 647 | qla2x00_sp_compl(void *data, void *ptr, int res) |
| 648 | { |
| 649 | struct qla_hw_data *ha = (struct qla_hw_data *)data; |
| 650 | srb_t *sp = (srb_t *)ptr; |
| 651 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 652 | |
| 653 | cmd->result = res; |
| 654 | |
| 655 | if (atomic_read(&sp->ref_count) == 0) { |
| 656 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3015, |
| 657 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 658 | sp, GET_CMD_SP(sp)); |
| 659 | if (ql2xextended_error_logging & ql_dbg_io) |
| 660 | BUG(); |
| 661 | return; |
| 662 | } |
| 663 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 664 | return; |
| 665 | |
| 666 | qla2x00_sp_free_dma(ha, sp); |
| 667 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 668 | } |
| 669 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 670 | /* If we are SP1 here, we need to still take and release the host_lock as SP1 |
| 671 | * does not have the changes necessary to avoid taking host->host_lock. |
| 672 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 674 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 675 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 676 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 677 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 678 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 679 | struct qla_hw_data *ha = vha->hw; |
| 680 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 681 | srb_t *sp; |
| 682 | int rval; |
| 683 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 684 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 685 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 686 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 687 | "PCI Channel IO permanent failure, exiting " |
| 688 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 689 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 690 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 691 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 692 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 693 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 694 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 695 | goto qc24_fail_command; |
| 696 | } |
| 697 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 698 | rval = fc_remote_port_chkready(rport); |
| 699 | if (rval) { |
| 700 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 701 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 702 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 703 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 704 | goto qc24_fail_command; |
| 705 | } |
| 706 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 707 | if (!vha->flags.difdix_supported && |
| 708 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 709 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 710 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 711 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 712 | cmd->result = DID_NO_CONNECT << 16; |
| 713 | goto qc24_fail_command; |
| 714 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 715 | |
| 716 | if (!fcport) { |
| 717 | cmd->result = DID_NO_CONNECT << 16; |
| 718 | goto qc24_fail_command; |
| 719 | } |
| 720 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 721 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 722 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 723 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 724 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 725 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 726 | atomic_read(&fcport->state), |
| 727 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 728 | cmd->result = DID_NO_CONNECT << 16; |
| 729 | goto qc24_fail_command; |
| 730 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 731 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 732 | } |
| 733 | |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 734 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 735 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 736 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 737 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 738 | sp->u.scmd.cmd = cmd; |
| 739 | sp->type = SRB_SCSI_CMD; |
| 740 | atomic_set(&sp->ref_count, 1); |
| 741 | CMD_SP(cmd) = (void *)sp; |
| 742 | sp->free = qla2x00_sp_free_dma; |
| 743 | sp->done = qla2x00_sp_compl; |
| 744 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 745 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 746 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 747 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 748 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 749 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 750 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 751 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 752 | return 0; |
| 753 | |
| 754 | qc24_host_busy_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 755 | qla2x00_sp_free_dma(ha, sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 756 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 757 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 758 | return SCSI_MLQUEUE_HOST_BUSY; |
| 759 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 760 | qc24_target_busy: |
| 761 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 762 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 763 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 764 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 765 | |
| 766 | return 0; |
| 767 | } |
| 768 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | /* |
| 770 | * qla2x00_eh_wait_on_command |
| 771 | * Waits for the command to be returned by the Firmware for some |
| 772 | * max time. |
| 773 | * |
| 774 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | * |
| 777 | * Return: |
| 778 | * Not Found : 0 |
| 779 | * Found : 1 |
| 780 | */ |
| 781 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 782 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 784 | #define ABORT_POLLING_PERIOD 1000 |
Chad Dupuis | 478c3b0 | 2014-04-11 16:54:35 -0400 | [diff] [blame] | 785 | #define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 786 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 787 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 788 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 789 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 791 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 792 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 793 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 794 | return ret; |
| 795 | } |
| 796 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 797 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 798 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 799 | } |
| 800 | if (CMD_SP(cmd)) |
| 801 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 803 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | /* |
| 807 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 808 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 810 | * finally HBA is disabled ie marked offline |
| 811 | * |
| 812 | * Input: |
| 813 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 814 | * |
| 815 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | * Does context switching-Release SPIN_LOCK |
| 817 | * (if any) before calling this routine. |
| 818 | * |
| 819 | * Return: |
| 820 | * Success (Adapter is online) : 0 |
| 821 | * Failed (Adapter is offline/disabled) : 1 |
| 822 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 823 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 824 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 826 | int return_status; |
| 827 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 828 | struct qla_hw_data *ha = vha->hw; |
| 829 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 831 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 832 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 833 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 834 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 835 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | |
| 837 | msleep(1000); |
| 838 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 839 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 840 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | else |
| 842 | return_status = QLA_FUNCTION_FAILED; |
| 843 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | return (return_status); |
| 845 | } |
| 846 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 847 | /* |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 848 | * qla2x00_wait_for_hba_ready |
| 849 | * Wait till the HBA is ready before doing driver unload |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 850 | * |
| 851 | * Input: |
| 852 | * ha - pointer to host adapter structure |
| 853 | * |
| 854 | * Note: |
| 855 | * Does context switching-Release SPIN_LOCK |
| 856 | * (if any) before calling this routine. |
| 857 | * |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 858 | */ |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 859 | static void |
| 860 | qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 861 | { |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 862 | struct qla_hw_data *ha = vha->hw; |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 863 | |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 864 | while ((!(vha->flags.online) || ha->dpc_active || |
| 865 | ha->flags.mbox_busy)) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 866 | msleep(1000); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 867 | } |
| 868 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 869 | int |
| 870 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 871 | { |
| 872 | int return_status; |
| 873 | unsigned long wait_reset; |
| 874 | struct qla_hw_data *ha = vha->hw; |
| 875 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 876 | |
| 877 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 878 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 879 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 880 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 881 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 882 | |
| 883 | msleep(1000); |
| 884 | |
| 885 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 886 | ha->flags.chip_reset_done) |
| 887 | break; |
| 888 | } |
| 889 | if (ha->flags.chip_reset_done) |
| 890 | return_status = QLA_SUCCESS; |
| 891 | else |
| 892 | return_status = QLA_FUNCTION_FAILED; |
| 893 | |
| 894 | return return_status; |
| 895 | } |
| 896 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 897 | static void |
| 898 | sp_get(struct srb *sp) |
| 899 | { |
| 900 | atomic_inc(&sp->ref_count); |
| 901 | } |
| 902 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | /************************************************************************** |
| 904 | * qla2xxx_eh_abort |
| 905 | * |
| 906 | * Description: |
| 907 | * The abort function will abort the specified command. |
| 908 | * |
| 909 | * Input: |
| 910 | * cmd = Linux SCSI command packet to be aborted. |
| 911 | * |
| 912 | * Returns: |
| 913 | * Either SUCCESS or FAILED. |
| 914 | * |
| 915 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 916 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 918 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 920 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 921 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 922 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 923 | int ret; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 924 | unsigned int id; |
| 925 | uint64_t lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 926 | unsigned long flags; |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 927 | int rval, wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 928 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 930 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 931 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 933 | ret = fc_block_scsi_eh(cmd); |
| 934 | if (ret != 0) |
| 935 | return ret; |
| 936 | ret = SUCCESS; |
| 937 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 938 | id = cmd->device->id; |
| 939 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 940 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 941 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 942 | sp = (srb_t *) CMD_SP(cmd); |
| 943 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 944 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 945 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 946 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 947 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 948 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 949 | "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 950 | vha->host_no, id, lun, sp, cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 951 | |
| 952 | /* Get a reference to the sp and drop the lock.*/ |
| 953 | sp_get(sp); |
| 954 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 955 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 956 | rval = ha->isp_ops->abort_command(sp); |
| 957 | if (rval) { |
| 958 | if (rval == QLA_FUNCTION_PARAMETER_ERROR) { |
| 959 | /* |
| 960 | * Decrement the ref_count since we can't find the |
| 961 | * command |
| 962 | */ |
| 963 | atomic_dec(&sp->ref_count); |
| 964 | ret = SUCCESS; |
| 965 | } else |
| 966 | ret = FAILED; |
| 967 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 968 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 969 | "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 970 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 971 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 972 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 973 | wait = 1; |
| 974 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 975 | |
| 976 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 977 | /* |
| 978 | * Clear the slot in the oustanding_cmds array if we can't find the |
| 979 | * command to reclaim the resources. |
| 980 | */ |
| 981 | if (rval == QLA_FUNCTION_PARAMETER_ERROR) |
| 982 | vha->req->outstanding_cmds[sp->handle] = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 983 | sp->done(ha, sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 984 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 985 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 986 | /* Did the command return during mailbox execution? */ |
| 987 | if (ret == FAILED && !CMD_SP(cmd)) |
| 988 | ret = SUCCESS; |
| 989 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 990 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 991 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 992 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 993 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 994 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 995 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 996 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 999 | ql_log(ql_log_info, vha, 0x801c, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1000 | "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1001 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1003 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | } |
| 1005 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1006 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1007 | qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1008 | uint64_t l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1010 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1011 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1012 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1013 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1014 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1015 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1016 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1017 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1018 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1019 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1020 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1021 | for (cnt = 1; status == QLA_SUCCESS && |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1022 | cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1023 | sp = req->outstanding_cmds[cnt]; |
| 1024 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1025 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1026 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1027 | continue; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1028 | if (vha->vp_idx != sp->fcport->vha->vp_idx) |
| 1029 | continue; |
| 1030 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1031 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1032 | switch (type) { |
| 1033 | case WAIT_HOST: |
| 1034 | match = 1; |
| 1035 | break; |
| 1036 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1037 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1038 | break; |
| 1039 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1040 | match = (cmd->device->id == t && |
| 1041 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1042 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1043 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1044 | if (!match) |
| 1045 | continue; |
| 1046 | |
| 1047 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1048 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1049 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1051 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1052 | |
| 1053 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | } |
| 1055 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1056 | static char *reset_errors[] = { |
| 1057 | "HBA not online", |
| 1058 | "HBA not ready", |
| 1059 | "Task management failed", |
| 1060 | "Waiting for command completions", |
| 1061 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1063 | static int |
| 1064 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1065 | struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, uint64_t, int)) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1066 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1067 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1068 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1069 | int err; |
| 1070 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1071 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1072 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1073 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1074 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1075 | err = fc_block_scsi_eh(cmd); |
| 1076 | if (err != 0) |
| 1077 | return err; |
| 1078 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1079 | ql_log(ql_log_info, vha, 0x8009, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1080 | "%s RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", name, vha->host_no, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1081 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1082 | |
| 1083 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1084 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1085 | ql_log(ql_log_warn, vha, 0x800a, |
| 1086 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1087 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1088 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1089 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1090 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1091 | != QLA_SUCCESS) { |
| 1092 | ql_log(ql_log_warn, vha, 0x800c, |
| 1093 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1094 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1095 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1096 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1097 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1098 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1099 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1100 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1101 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1102 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1103 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1104 | ql_log(ql_log_info, vha, 0x800e, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1105 | "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1106 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1107 | |
| 1108 | return SUCCESS; |
| 1109 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1110 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1111 | ql_log(ql_log_info, vha, 0x800f, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1112 | "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1113 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1114 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1115 | return FAILED; |
| 1116 | } |
| 1117 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1118 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1119 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1120 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1121 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1122 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1123 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1124 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1125 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1126 | } |
| 1127 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1128 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1129 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1131 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1132 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1134 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1135 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1136 | } |
| 1137 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1138 | /************************************************************************** |
| 1139 | * qla2xxx_eh_bus_reset |
| 1140 | * |
| 1141 | * Description: |
| 1142 | * The bus reset function will reset the bus and abort any executing |
| 1143 | * commands. |
| 1144 | * |
| 1145 | * Input: |
| 1146 | * cmd = Linux SCSI command packet of the command that cause the |
| 1147 | * bus reset. |
| 1148 | * |
| 1149 | * Returns: |
| 1150 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1151 | * |
| 1152 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1153 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1154 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1155 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1156 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1157 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1158 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1159 | unsigned int id; |
| 1160 | uint64_t lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1161 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1162 | id = cmd->device->id; |
| 1163 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1164 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1165 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1166 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1167 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1169 | ret = fc_block_scsi_eh(cmd); |
| 1170 | if (ret != 0) |
| 1171 | return ret; |
| 1172 | ret = FAILED; |
| 1173 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1174 | ql_log(ql_log_info, vha, 0x8012, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1175 | "BUS RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1176 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1177 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1178 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1179 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1180 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1181 | } |
| 1182 | |
Saurav Kashyap | ad537689 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1183 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1184 | ret = SUCCESS; |
| 1185 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1186 | if (ret == FAILED) |
| 1187 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1189 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1190 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1191 | QLA_SUCCESS) { |
| 1192 | ql_log(ql_log_warn, vha, 0x8014, |
| 1193 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1194 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1195 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1197 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1198 | ql_log(ql_log_warn, vha, 0x802b, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1199 | "BUS RESET %s nexus=%ld:%d:%llu.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1200 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1201 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1202 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1203 | } |
| 1204 | |
| 1205 | /************************************************************************** |
| 1206 | * qla2xxx_eh_host_reset |
| 1207 | * |
| 1208 | * Description: |
| 1209 | * The reset function will reset the Adapter. |
| 1210 | * |
| 1211 | * Input: |
| 1212 | * cmd = Linux SCSI command packet of the command that cause the |
| 1213 | * adapter reset. |
| 1214 | * |
| 1215 | * Returns: |
| 1216 | * Either SUCCESS or FAILED. |
| 1217 | * |
| 1218 | * Note: |
| 1219 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1220 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1222 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1223 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1224 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1225 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1226 | unsigned int id; |
| 1227 | uint64_t lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1228 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1229 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1230 | id = cmd->device->id; |
| 1231 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1232 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1233 | ql_log(ql_log_info, vha, 0x8018, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1234 | "ADAPTER RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1235 | |
Chad Dupuis | 63ee707 | 2014-04-11 16:54:46 -0400 | [diff] [blame] | 1236 | /* |
| 1237 | * No point in issuing another reset if one is active. Also do not |
| 1238 | * attempt a reset if we are updating flash. |
| 1239 | */ |
| 1240 | if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1241 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1243 | if (vha != base_vha) { |
| 1244 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1245 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1246 | } else { |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1247 | if (IS_P3P_TYPE(vha->hw)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1248 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1249 | /* Ctx reset success */ |
| 1250 | ret = SUCCESS; |
| 1251 | goto eh_host_reset_lock; |
| 1252 | } |
| 1253 | /* fall thru if ctx reset failed */ |
| 1254 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1255 | if (ha->wq) |
| 1256 | flush_workqueue(ha->wq); |
| 1257 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1258 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1259 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1260 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1261 | /* failed. schedule dpc to try */ |
| 1262 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1263 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1264 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1265 | ql_log(ql_log_warn, vha, 0x802a, |
| 1266 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1267 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1268 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1269 | } |
| 1270 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1271 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1272 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1273 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1274 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1275 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1276 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1277 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1278 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1279 | ql_log(ql_log_info, vha, 0x8017, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1280 | "ADAPTER RESET %s nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1281 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1282 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1283 | return ret; |
| 1284 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1285 | |
| 1286 | /* |
| 1287 | * qla2x00_loop_reset |
| 1288 | * Issue loop reset. |
| 1289 | * |
| 1290 | * Input: |
| 1291 | * ha = adapter block pointer. |
| 1292 | * |
| 1293 | * Returns: |
| 1294 | * 0 = success |
| 1295 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1296 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1297 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1298 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1299 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1300 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1301 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1302 | |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1303 | if (IS_QLAFX00(ha)) { |
| 1304 | return qlafx00_loop_reset(vha); |
| 1305 | } |
| 1306 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1307 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1308 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1309 | if (fcport->port_type != FCT_TARGET) |
| 1310 | continue; |
| 1311 | |
| 1312 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1313 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1314 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1315 | "Bus Reset failed: Reset=%d " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1316 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1317 | } |
| 1318 | } |
| 1319 | } |
| 1320 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1321 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1322 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Andrew Vasquez | 0b7e7c5 | 2013-02-08 01:57:42 -0500 | [diff] [blame] | 1323 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1324 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1325 | qla2x00_mark_all_devices_lost(vha, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1326 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1327 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1328 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1329 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1330 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1331 | } |
| 1332 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1333 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1334 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad537689 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1335 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1336 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1337 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1338 | } |
| 1339 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | /* 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] | 1341 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1342 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1343 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | } |
| 1345 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1346 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1347 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1348 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1349 | int que, cnt; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1350 | unsigned long flags; |
| 1351 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1352 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1353 | struct req_que *req; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1354 | |
| 1355 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1356 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1357 | req = ha->req_q_map[que]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1358 | if (!req) |
| 1359 | continue; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1360 | if (!req->outstanding_cmds) |
| 1361 | continue; |
| 1362 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1363 | sp = req->outstanding_cmds[cnt]; |
Andrew Vasquez | e612d46 | 2009-03-24 09:08:04 -0700 | [diff] [blame] | 1364 | if (sp) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1365 | req->outstanding_cmds[cnt] = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1366 | sp->done(vha, sp, res); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1367 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1368 | } |
| 1369 | } |
| 1370 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1371 | } |
| 1372 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1373 | static int |
| 1374 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1375 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1376 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1377 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1378 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1379 | return -ENXIO; |
| 1380 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1381 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1382 | |
| 1383 | return 0; |
| 1384 | } |
| 1385 | |
| 1386 | static int |
| 1387 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1388 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1389 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1390 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1391 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1392 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1393 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1394 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1395 | if (sdev->tagged_supported) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1396 | scsi_activate_tcq(sdev, req->max_q_depth); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1397 | else |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1398 | scsi_deactivate_tcq(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1399 | return 0; |
| 1400 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1401 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1402 | static void |
| 1403 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1404 | { |
| 1405 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1406 | } |
| 1407 | |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1408 | static void qla2x00_handle_queue_full(struct scsi_device *sdev, int qdepth) |
| 1409 | { |
| 1410 | fc_port_t *fcport = (struct fc_port *) sdev->hostdata; |
| 1411 | |
| 1412 | if (!scsi_track_queue_full(sdev, qdepth)) |
| 1413 | return; |
| 1414 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1415 | ql_dbg(ql_dbg_io, fcport->vha, 0x3029, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1416 | "Queue depth adjusted-down to %d for nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1417 | sdev->queue_depth, fcport->vha->host_no, sdev->id, sdev->lun); |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1418 | } |
| 1419 | |
| 1420 | static void qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, int qdepth) |
| 1421 | { |
| 1422 | fc_port_t *fcport = sdev->hostdata; |
| 1423 | struct scsi_qla_host *vha = fcport->vha; |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1424 | struct req_que *req = NULL; |
| 1425 | |
| 1426 | req = vha->req; |
| 1427 | if (!req) |
| 1428 | return; |
| 1429 | |
| 1430 | if (req->max_q_depth <= sdev->queue_depth || req->max_q_depth < qdepth) |
| 1431 | return; |
| 1432 | |
| 1433 | if (sdev->ordered_tags) |
| 1434 | scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, qdepth); |
| 1435 | else |
| 1436 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, qdepth); |
| 1437 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1438 | ql_dbg(ql_dbg_io, vha, 0x302a, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1439 | "Queue depth adjusted-up to %d for nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1440 | sdev->queue_depth, fcport->vha->host_no, sdev->id, sdev->lun); |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1441 | } |
| 1442 | |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1443 | static int |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 1444 | qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1445 | { |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1446 | switch (reason) { |
| 1447 | case SCSI_QDEPTH_DEFAULT: |
| 1448 | scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); |
| 1449 | break; |
| 1450 | case SCSI_QDEPTH_QFULL: |
| 1451 | qla2x00_handle_queue_full(sdev, qdepth); |
| 1452 | break; |
| 1453 | case SCSI_QDEPTH_RAMP_UP: |
| 1454 | qla2x00_adjust_sdev_qdepth_up(sdev, qdepth); |
| 1455 | break; |
| 1456 | default: |
Roel Kluin | 08002af | 2010-01-29 11:25:19 +0100 | [diff] [blame] | 1457 | return -EOPNOTSUPP; |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1458 | } |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 1459 | |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1460 | return sdev->queue_depth; |
| 1461 | } |
| 1462 | |
| 1463 | static int |
| 1464 | qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type) |
| 1465 | { |
| 1466 | if (sdev->tagged_supported) { |
| 1467 | scsi_set_tag_type(sdev, tag_type); |
| 1468 | if (tag_type) |
| 1469 | scsi_activate_tcq(sdev, sdev->queue_depth); |
| 1470 | else |
| 1471 | scsi_deactivate_tcq(sdev, sdev->queue_depth); |
| 1472 | } else |
| 1473 | tag_type = 0; |
| 1474 | |
| 1475 | return tag_type; |
| 1476 | } |
| 1477 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1478 | /** |
| 1479 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1480 | * @ha: HA context |
| 1481 | * |
| 1482 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1483 | * supported addressing method. |
| 1484 | */ |
| 1485 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1486 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1487 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1488 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1490 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1491 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1492 | /* Any upper-dword bits set? */ |
| 1493 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1494 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1495 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1496 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1497 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1498 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1499 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1500 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1501 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1502 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1503 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1504 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1505 | } |
| 1506 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1507 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1508 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1509 | { |
| 1510 | unsigned long flags = 0; |
| 1511 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1512 | |
| 1513 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1514 | ha->interrupts_on = 1; |
| 1515 | /* enable risc and host interrupts */ |
| 1516 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1517 | RD_REG_WORD(®->ictrl); |
| 1518 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1519 | |
| 1520 | } |
| 1521 | |
| 1522 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1523 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1524 | { |
| 1525 | unsigned long flags = 0; |
| 1526 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1527 | |
| 1528 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1529 | ha->interrupts_on = 0; |
| 1530 | /* disable risc and host interrupts */ |
| 1531 | WRT_REG_WORD(®->ictrl, 0); |
| 1532 | RD_REG_WORD(®->ictrl); |
| 1533 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1534 | } |
| 1535 | |
| 1536 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1537 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1538 | { |
| 1539 | unsigned long flags = 0; |
| 1540 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1541 | |
| 1542 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1543 | ha->interrupts_on = 1; |
| 1544 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1545 | RD_REG_DWORD(®->ictrl); |
| 1546 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1547 | } |
| 1548 | |
| 1549 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1550 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1551 | { |
| 1552 | unsigned long flags = 0; |
| 1553 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1554 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1555 | if (IS_NOPOLLING_TYPE(ha)) |
| 1556 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1557 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1558 | ha->interrupts_on = 0; |
| 1559 | WRT_REG_DWORD(®->ictrl, 0); |
| 1560 | RD_REG_DWORD(®->ictrl); |
| 1561 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1562 | } |
| 1563 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1564 | static int |
| 1565 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1566 | { |
| 1567 | resource_size_t pio; |
| 1568 | uint16_t msix; |
| 1569 | int cpus; |
| 1570 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1571 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1572 | QLA2XXX_DRIVER_NAME)) { |
| 1573 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1574 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1575 | pci_name(ha->pdev)); |
| 1576 | goto iospace_error_exit; |
| 1577 | } |
| 1578 | if (!(ha->bars & 1)) |
| 1579 | goto skip_pio; |
| 1580 | |
| 1581 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1582 | pio = pci_resource_start(ha->pdev, 0); |
| 1583 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1584 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1585 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1586 | "Invalid pci I/O region size (%s).\n", |
| 1587 | pci_name(ha->pdev)); |
| 1588 | pio = 0; |
| 1589 | } |
| 1590 | } else { |
| 1591 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1592 | "Region #0 no a PIO resource (%s).\n", |
| 1593 | pci_name(ha->pdev)); |
| 1594 | pio = 0; |
| 1595 | } |
| 1596 | ha->pio_address = pio; |
| 1597 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1598 | "PIO address=%llu.\n", |
| 1599 | (unsigned long long)ha->pio_address); |
| 1600 | |
| 1601 | skip_pio: |
| 1602 | /* Use MMIO operations for all accesses. */ |
| 1603 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1604 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1605 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1606 | pci_name(ha->pdev)); |
| 1607 | goto iospace_error_exit; |
| 1608 | } |
| 1609 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1610 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1611 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1612 | pci_name(ha->pdev)); |
| 1613 | goto iospace_error_exit; |
| 1614 | } |
| 1615 | |
| 1616 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1617 | if (!ha->iobase) { |
| 1618 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1619 | "Cannot remap MMIO (%s), aborting.\n", |
| 1620 | pci_name(ha->pdev)); |
| 1621 | goto iospace_error_exit; |
| 1622 | } |
| 1623 | |
| 1624 | /* Determine queue resources */ |
| 1625 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1626 | if ((ql2xmaxqueues <= 1 && !ql2xmultique_tag) || |
| 1627 | (ql2xmaxqueues > 1 && ql2xmultique_tag) || |
| 1628 | (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
| 1629 | goto mqiobase_exit; |
| 1630 | |
| 1631 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1632 | pci_resource_len(ha->pdev, 3)); |
| 1633 | if (ha->mqiobase) { |
| 1634 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 1635 | "MQIO Base=%p.\n", ha->mqiobase); |
| 1636 | /* Read MSIX vector size of the board */ |
| 1637 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
| 1638 | ha->msix_count = msix; |
| 1639 | /* Max queues are bounded by available msix vectors */ |
| 1640 | /* queue 0 uses two msix vectors */ |
| 1641 | if (ql2xmultique_tag) { |
| 1642 | cpus = num_online_cpus(); |
| 1643 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1644 | (cpus + 1) : (ha->msix_count - 1); |
| 1645 | ha->max_req_queues = 2; |
| 1646 | } else if (ql2xmaxqueues > 1) { |
| 1647 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1648 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1649 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc008, |
| 1650 | "QoS mode set, max no of request queues:%d.\n", |
| 1651 | ha->max_req_queues); |
| 1652 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0019, |
| 1653 | "QoS mode set, max no of request queues:%d.\n", |
| 1654 | ha->max_req_queues); |
| 1655 | } |
| 1656 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
| 1657 | "MSI-X vector count: %d.\n", msix); |
| 1658 | } else |
| 1659 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 1660 | "BAR 3 not enabled.\n"); |
| 1661 | |
| 1662 | mqiobase_exit: |
| 1663 | ha->msix_count = ha->max_rsp_queues + 1; |
| 1664 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
| 1665 | "MSIX Count:%d.\n", ha->msix_count); |
| 1666 | return (0); |
| 1667 | |
| 1668 | iospace_error_exit: |
| 1669 | return (-ENOMEM); |
| 1670 | } |
| 1671 | |
| 1672 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1673 | static int |
| 1674 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 1675 | { |
| 1676 | uint16_t msix; |
| 1677 | int cpus; |
| 1678 | |
| 1679 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1680 | QLA2XXX_DRIVER_NAME)) { |
| 1681 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 1682 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1683 | pci_name(ha->pdev)); |
| 1684 | |
| 1685 | goto iospace_error_exit; |
| 1686 | } |
| 1687 | |
| 1688 | /* Use MMIO operations for all accesses. */ |
| 1689 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 1690 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 1691 | "Invalid pci I/O region size (%s).\n", |
| 1692 | pci_name(ha->pdev)); |
| 1693 | goto iospace_error_exit; |
| 1694 | } |
| 1695 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1696 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 1697 | "Invalid PCI mem region size (%s), aborting\n", |
| 1698 | pci_name(ha->pdev)); |
| 1699 | goto iospace_error_exit; |
| 1700 | } |
| 1701 | |
| 1702 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 1703 | if (!ha->iobase) { |
| 1704 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 1705 | "Cannot remap MMIO (%s), aborting.\n", |
| 1706 | pci_name(ha->pdev)); |
| 1707 | goto iospace_error_exit; |
| 1708 | } |
| 1709 | |
| 1710 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 1711 | /* 83XX 26XX always use MQ type access for queues |
| 1712 | * - mbar 2, a.k.a region 4 */ |
| 1713 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1714 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 1715 | pci_resource_len(ha->pdev, 4)); |
| 1716 | |
| 1717 | if (!ha->mqiobase) { |
| 1718 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 1719 | "BAR2/region4 not enabled\n"); |
| 1720 | goto mqiobase_exit; |
| 1721 | } |
| 1722 | |
| 1723 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 1724 | pci_resource_len(ha->pdev, 2)); |
| 1725 | if (ha->msixbase) { |
| 1726 | /* Read MSIX vector size of the board */ |
| 1727 | pci_read_config_word(ha->pdev, |
| 1728 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
| 1729 | ha->msix_count = msix; |
| 1730 | /* Max queues are bounded by available msix vectors */ |
| 1731 | /* queue 0 uses two msix vectors */ |
| 1732 | if (ql2xmultique_tag) { |
| 1733 | cpus = num_online_cpus(); |
| 1734 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1735 | (cpus + 1) : (ha->msix_count - 1); |
| 1736 | ha->max_req_queues = 2; |
| 1737 | } else if (ql2xmaxqueues > 1) { |
| 1738 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1739 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1740 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc00c, |
| 1741 | "QoS mode set, max no of request queues:%d.\n", |
| 1742 | ha->max_req_queues); |
| 1743 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b, |
| 1744 | "QoS mode set, max no of request queues:%d.\n", |
| 1745 | ha->max_req_queues); |
| 1746 | } |
| 1747 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
| 1748 | "MSI-X vector count: %d.\n", msix); |
| 1749 | } else |
| 1750 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 1751 | "BAR 1 not enabled.\n"); |
| 1752 | |
| 1753 | mqiobase_exit: |
| 1754 | ha->msix_count = ha->max_rsp_queues + 1; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 1755 | |
| 1756 | qlt_83xx_iospace_config(ha); |
| 1757 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1758 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
| 1759 | "MSIX Count:%d.\n", ha->msix_count); |
| 1760 | return 0; |
| 1761 | |
| 1762 | iospace_error_exit: |
| 1763 | return -ENOMEM; |
| 1764 | } |
| 1765 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1766 | static struct isp_operations qla2100_isp_ops = { |
| 1767 | .pci_config = qla2100_pci_config, |
| 1768 | .reset_chip = qla2x00_reset_chip, |
| 1769 | .chip_diag = qla2x00_chip_diag, |
| 1770 | .config_rings = qla2x00_config_rings, |
| 1771 | .reset_adapter = qla2x00_reset_adapter, |
| 1772 | .nvram_config = qla2x00_nvram_config, |
| 1773 | .update_fw_options = qla2x00_update_fw_options, |
| 1774 | .load_risc = qla2x00_load_risc, |
| 1775 | .pci_info_str = qla2x00_pci_info_str, |
| 1776 | .fw_version_str = qla2x00_fw_version_str, |
| 1777 | .intr_handler = qla2100_intr_handler, |
| 1778 | .enable_intrs = qla2x00_enable_intrs, |
| 1779 | .disable_intrs = qla2x00_disable_intrs, |
| 1780 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1781 | .target_reset = qla2x00_abort_target, |
| 1782 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1783 | .fabric_login = qla2x00_login_fabric, |
| 1784 | .fabric_logout = qla2x00_fabric_logout, |
| 1785 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1786 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1787 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1788 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1789 | .read_nvram = qla2x00_read_nvram_data, |
| 1790 | .write_nvram = qla2x00_write_nvram_data, |
| 1791 | .fw_dump = qla2100_fw_dump, |
| 1792 | .beacon_on = NULL, |
| 1793 | .beacon_off = NULL, |
| 1794 | .beacon_blink = NULL, |
| 1795 | .read_optrom = qla2x00_read_optrom_data, |
| 1796 | .write_optrom = qla2x00_write_optrom_data, |
| 1797 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1798 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1799 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1800 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1801 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1802 | }; |
| 1803 | |
| 1804 | static struct isp_operations qla2300_isp_ops = { |
| 1805 | .pci_config = qla2300_pci_config, |
| 1806 | .reset_chip = qla2x00_reset_chip, |
| 1807 | .chip_diag = qla2x00_chip_diag, |
| 1808 | .config_rings = qla2x00_config_rings, |
| 1809 | .reset_adapter = qla2x00_reset_adapter, |
| 1810 | .nvram_config = qla2x00_nvram_config, |
| 1811 | .update_fw_options = qla2x00_update_fw_options, |
| 1812 | .load_risc = qla2x00_load_risc, |
| 1813 | .pci_info_str = qla2x00_pci_info_str, |
| 1814 | .fw_version_str = qla2x00_fw_version_str, |
| 1815 | .intr_handler = qla2300_intr_handler, |
| 1816 | .enable_intrs = qla2x00_enable_intrs, |
| 1817 | .disable_intrs = qla2x00_disable_intrs, |
| 1818 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1819 | .target_reset = qla2x00_abort_target, |
| 1820 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1821 | .fabric_login = qla2x00_login_fabric, |
| 1822 | .fabric_logout = qla2x00_fabric_logout, |
| 1823 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1824 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1825 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1826 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1827 | .read_nvram = qla2x00_read_nvram_data, |
| 1828 | .write_nvram = qla2x00_write_nvram_data, |
| 1829 | .fw_dump = qla2300_fw_dump, |
| 1830 | .beacon_on = qla2x00_beacon_on, |
| 1831 | .beacon_off = qla2x00_beacon_off, |
| 1832 | .beacon_blink = qla2x00_beacon_blink, |
| 1833 | .read_optrom = qla2x00_read_optrom_data, |
| 1834 | .write_optrom = qla2x00_write_optrom_data, |
| 1835 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1836 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1837 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1838 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1839 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1840 | }; |
| 1841 | |
| 1842 | static struct isp_operations qla24xx_isp_ops = { |
| 1843 | .pci_config = qla24xx_pci_config, |
| 1844 | .reset_chip = qla24xx_reset_chip, |
| 1845 | .chip_diag = qla24xx_chip_diag, |
| 1846 | .config_rings = qla24xx_config_rings, |
| 1847 | .reset_adapter = qla24xx_reset_adapter, |
| 1848 | .nvram_config = qla24xx_nvram_config, |
| 1849 | .update_fw_options = qla24xx_update_fw_options, |
| 1850 | .load_risc = qla24xx_load_risc, |
| 1851 | .pci_info_str = qla24xx_pci_info_str, |
| 1852 | .fw_version_str = qla24xx_fw_version_str, |
| 1853 | .intr_handler = qla24xx_intr_handler, |
| 1854 | .enable_intrs = qla24xx_enable_intrs, |
| 1855 | .disable_intrs = qla24xx_disable_intrs, |
| 1856 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1857 | .target_reset = qla24xx_abort_target, |
| 1858 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1859 | .fabric_login = qla24xx_login_fabric, |
| 1860 | .fabric_logout = qla24xx_fabric_logout, |
| 1861 | .calc_req_entries = NULL, |
| 1862 | .build_iocbs = NULL, |
| 1863 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1864 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1865 | .read_nvram = qla24xx_read_nvram_data, |
| 1866 | .write_nvram = qla24xx_write_nvram_data, |
| 1867 | .fw_dump = qla24xx_fw_dump, |
| 1868 | .beacon_on = qla24xx_beacon_on, |
| 1869 | .beacon_off = qla24xx_beacon_off, |
| 1870 | .beacon_blink = qla24xx_beacon_blink, |
| 1871 | .read_optrom = qla24xx_read_optrom_data, |
| 1872 | .write_optrom = qla24xx_write_optrom_data, |
| 1873 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1874 | .start_scsi = qla24xx_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1875 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1876 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1877 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1878 | }; |
| 1879 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1880 | static struct isp_operations qla25xx_isp_ops = { |
| 1881 | .pci_config = qla25xx_pci_config, |
| 1882 | .reset_chip = qla24xx_reset_chip, |
| 1883 | .chip_diag = qla24xx_chip_diag, |
| 1884 | .config_rings = qla24xx_config_rings, |
| 1885 | .reset_adapter = qla24xx_reset_adapter, |
| 1886 | .nvram_config = qla24xx_nvram_config, |
| 1887 | .update_fw_options = qla24xx_update_fw_options, |
| 1888 | .load_risc = qla24xx_load_risc, |
| 1889 | .pci_info_str = qla24xx_pci_info_str, |
| 1890 | .fw_version_str = qla24xx_fw_version_str, |
| 1891 | .intr_handler = qla24xx_intr_handler, |
| 1892 | .enable_intrs = qla24xx_enable_intrs, |
| 1893 | .disable_intrs = qla24xx_disable_intrs, |
| 1894 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1895 | .target_reset = qla24xx_abort_target, |
| 1896 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1897 | .fabric_login = qla24xx_login_fabric, |
| 1898 | .fabric_logout = qla24xx_fabric_logout, |
| 1899 | .calc_req_entries = NULL, |
| 1900 | .build_iocbs = NULL, |
| 1901 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1902 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1903 | .read_nvram = qla25xx_read_nvram_data, |
| 1904 | .write_nvram = qla25xx_write_nvram_data, |
| 1905 | .fw_dump = qla25xx_fw_dump, |
| 1906 | .beacon_on = qla24xx_beacon_on, |
| 1907 | .beacon_off = qla24xx_beacon_off, |
| 1908 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 1909 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1910 | .write_optrom = qla24xx_write_optrom_data, |
| 1911 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1912 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1913 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1914 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1915 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1916 | }; |
| 1917 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1918 | static struct isp_operations qla81xx_isp_ops = { |
| 1919 | .pci_config = qla25xx_pci_config, |
| 1920 | .reset_chip = qla24xx_reset_chip, |
| 1921 | .chip_diag = qla24xx_chip_diag, |
| 1922 | .config_rings = qla24xx_config_rings, |
| 1923 | .reset_adapter = qla24xx_reset_adapter, |
| 1924 | .nvram_config = qla81xx_nvram_config, |
| 1925 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 1926 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1927 | .pci_info_str = qla24xx_pci_info_str, |
| 1928 | .fw_version_str = qla24xx_fw_version_str, |
| 1929 | .intr_handler = qla24xx_intr_handler, |
| 1930 | .enable_intrs = qla24xx_enable_intrs, |
| 1931 | .disable_intrs = qla24xx_disable_intrs, |
| 1932 | .abort_command = qla24xx_abort_command, |
| 1933 | .target_reset = qla24xx_abort_target, |
| 1934 | .lun_reset = qla24xx_lun_reset, |
| 1935 | .fabric_login = qla24xx_login_fabric, |
| 1936 | .fabric_logout = qla24xx_fabric_logout, |
| 1937 | .calc_req_entries = NULL, |
| 1938 | .build_iocbs = NULL, |
| 1939 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1940 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 1941 | .read_nvram = NULL, |
| 1942 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1943 | .fw_dump = qla81xx_fw_dump, |
| 1944 | .beacon_on = qla24xx_beacon_on, |
| 1945 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1946 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1947 | .read_optrom = qla25xx_read_optrom_data, |
| 1948 | .write_optrom = qla24xx_write_optrom_data, |
| 1949 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 1950 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1951 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1952 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1953 | .initialize_adapter = qla2x00_initialize_adapter, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1954 | }; |
| 1955 | |
| 1956 | static struct isp_operations qla82xx_isp_ops = { |
| 1957 | .pci_config = qla82xx_pci_config, |
| 1958 | .reset_chip = qla82xx_reset_chip, |
| 1959 | .chip_diag = qla24xx_chip_diag, |
| 1960 | .config_rings = qla82xx_config_rings, |
| 1961 | .reset_adapter = qla24xx_reset_adapter, |
| 1962 | .nvram_config = qla81xx_nvram_config, |
| 1963 | .update_fw_options = qla24xx_update_fw_options, |
| 1964 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 1965 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1966 | .fw_version_str = qla24xx_fw_version_str, |
| 1967 | .intr_handler = qla82xx_intr_handler, |
| 1968 | .enable_intrs = qla82xx_enable_intrs, |
| 1969 | .disable_intrs = qla82xx_disable_intrs, |
| 1970 | .abort_command = qla24xx_abort_command, |
| 1971 | .target_reset = qla24xx_abort_target, |
| 1972 | .lun_reset = qla24xx_lun_reset, |
| 1973 | .fabric_login = qla24xx_login_fabric, |
| 1974 | .fabric_logout = qla24xx_fabric_logout, |
| 1975 | .calc_req_entries = NULL, |
| 1976 | .build_iocbs = NULL, |
| 1977 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1978 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1979 | .read_nvram = qla24xx_read_nvram_data, |
| 1980 | .write_nvram = qla24xx_write_nvram_data, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 1981 | .fw_dump = qla82xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 1982 | .beacon_on = qla82xx_beacon_on, |
| 1983 | .beacon_off = qla82xx_beacon_off, |
| 1984 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1985 | .read_optrom = qla82xx_read_optrom_data, |
| 1986 | .write_optrom = qla82xx_write_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1987 | .get_flash_version = qla82xx_get_flash_version, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1988 | .start_scsi = qla82xx_start_scsi, |
| 1989 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1990 | .iospace_config = qla82xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1991 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1992 | }; |
| 1993 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1994 | static struct isp_operations qla8044_isp_ops = { |
| 1995 | .pci_config = qla82xx_pci_config, |
| 1996 | .reset_chip = qla82xx_reset_chip, |
| 1997 | .chip_diag = qla24xx_chip_diag, |
| 1998 | .config_rings = qla82xx_config_rings, |
| 1999 | .reset_adapter = qla24xx_reset_adapter, |
| 2000 | .nvram_config = qla81xx_nvram_config, |
| 2001 | .update_fw_options = qla24xx_update_fw_options, |
| 2002 | .load_risc = qla82xx_load_risc, |
| 2003 | .pci_info_str = qla24xx_pci_info_str, |
| 2004 | .fw_version_str = qla24xx_fw_version_str, |
| 2005 | .intr_handler = qla8044_intr_handler, |
| 2006 | .enable_intrs = qla82xx_enable_intrs, |
| 2007 | .disable_intrs = qla82xx_disable_intrs, |
| 2008 | .abort_command = qla24xx_abort_command, |
| 2009 | .target_reset = qla24xx_abort_target, |
| 2010 | .lun_reset = qla24xx_lun_reset, |
| 2011 | .fabric_login = qla24xx_login_fabric, |
| 2012 | .fabric_logout = qla24xx_fabric_logout, |
| 2013 | .calc_req_entries = NULL, |
| 2014 | .build_iocbs = NULL, |
| 2015 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2016 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2017 | .read_nvram = NULL, |
| 2018 | .write_nvram = NULL, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2019 | .fw_dump = qla8044_fw_dump, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2020 | .beacon_on = qla82xx_beacon_on, |
| 2021 | .beacon_off = qla82xx_beacon_off, |
| 2022 | .beacon_blink = NULL, |
Saurav Kashyap | 888e639 | 2014-02-26 04:15:13 -0500 | [diff] [blame] | 2023 | .read_optrom = qla8044_read_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2024 | .write_optrom = qla8044_write_optrom_data, |
| 2025 | .get_flash_version = qla82xx_get_flash_version, |
| 2026 | .start_scsi = qla82xx_start_scsi, |
| 2027 | .abort_isp = qla8044_abort_isp, |
| 2028 | .iospace_config = qla82xx_iospace_config, |
| 2029 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2030 | }; |
| 2031 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2032 | static struct isp_operations qla83xx_isp_ops = { |
| 2033 | .pci_config = qla25xx_pci_config, |
| 2034 | .reset_chip = qla24xx_reset_chip, |
| 2035 | .chip_diag = qla24xx_chip_diag, |
| 2036 | .config_rings = qla24xx_config_rings, |
| 2037 | .reset_adapter = qla24xx_reset_adapter, |
| 2038 | .nvram_config = qla81xx_nvram_config, |
| 2039 | .update_fw_options = qla81xx_update_fw_options, |
| 2040 | .load_risc = qla81xx_load_risc, |
| 2041 | .pci_info_str = qla24xx_pci_info_str, |
| 2042 | .fw_version_str = qla24xx_fw_version_str, |
| 2043 | .intr_handler = qla24xx_intr_handler, |
| 2044 | .enable_intrs = qla24xx_enable_intrs, |
| 2045 | .disable_intrs = qla24xx_disable_intrs, |
| 2046 | .abort_command = qla24xx_abort_command, |
| 2047 | .target_reset = qla24xx_abort_target, |
| 2048 | .lun_reset = qla24xx_lun_reset, |
| 2049 | .fabric_login = qla24xx_login_fabric, |
| 2050 | .fabric_logout = qla24xx_fabric_logout, |
| 2051 | .calc_req_entries = NULL, |
| 2052 | .build_iocbs = NULL, |
| 2053 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2054 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2055 | .read_nvram = NULL, |
| 2056 | .write_nvram = NULL, |
| 2057 | .fw_dump = qla83xx_fw_dump, |
| 2058 | .beacon_on = qla24xx_beacon_on, |
| 2059 | .beacon_off = qla24xx_beacon_off, |
| 2060 | .beacon_blink = qla83xx_beacon_blink, |
| 2061 | .read_optrom = qla25xx_read_optrom_data, |
| 2062 | .write_optrom = qla24xx_write_optrom_data, |
| 2063 | .get_flash_version = qla24xx_get_flash_version, |
| 2064 | .start_scsi = qla24xx_dif_start_scsi, |
| 2065 | .abort_isp = qla2x00_abort_isp, |
| 2066 | .iospace_config = qla83xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2067 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2068 | }; |
| 2069 | |
| 2070 | static struct isp_operations qlafx00_isp_ops = { |
| 2071 | .pci_config = qlafx00_pci_config, |
| 2072 | .reset_chip = qlafx00_soft_reset, |
| 2073 | .chip_diag = qlafx00_chip_diag, |
| 2074 | .config_rings = qlafx00_config_rings, |
| 2075 | .reset_adapter = qlafx00_soft_reset, |
| 2076 | .nvram_config = NULL, |
| 2077 | .update_fw_options = NULL, |
| 2078 | .load_risc = NULL, |
| 2079 | .pci_info_str = qlafx00_pci_info_str, |
| 2080 | .fw_version_str = qlafx00_fw_version_str, |
| 2081 | .intr_handler = qlafx00_intr_handler, |
| 2082 | .enable_intrs = qlafx00_enable_intrs, |
| 2083 | .disable_intrs = qlafx00_disable_intrs, |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2084 | .abort_command = qla24xx_async_abort_command, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2085 | .target_reset = qlafx00_abort_target, |
| 2086 | .lun_reset = qlafx00_lun_reset, |
| 2087 | .fabric_login = NULL, |
| 2088 | .fabric_logout = NULL, |
| 2089 | .calc_req_entries = NULL, |
| 2090 | .build_iocbs = NULL, |
| 2091 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2092 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2093 | .read_nvram = qla24xx_read_nvram_data, |
| 2094 | .write_nvram = qla24xx_write_nvram_data, |
| 2095 | .fw_dump = NULL, |
| 2096 | .beacon_on = qla24xx_beacon_on, |
| 2097 | .beacon_off = qla24xx_beacon_off, |
| 2098 | .beacon_blink = NULL, |
| 2099 | .read_optrom = qla24xx_read_optrom_data, |
| 2100 | .write_optrom = qla24xx_write_optrom_data, |
| 2101 | .get_flash_version = qla24xx_get_flash_version, |
| 2102 | .start_scsi = qlafx00_start_scsi, |
| 2103 | .abort_isp = qlafx00_abort_isp, |
| 2104 | .iospace_config = qlafx00_iospace_config, |
| 2105 | .initialize_adapter = qlafx00_initialize_adapter, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2106 | }; |
| 2107 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2108 | static struct isp_operations qla27xx_isp_ops = { |
| 2109 | .pci_config = qla25xx_pci_config, |
| 2110 | .reset_chip = qla24xx_reset_chip, |
| 2111 | .chip_diag = qla24xx_chip_diag, |
| 2112 | .config_rings = qla24xx_config_rings, |
| 2113 | .reset_adapter = qla24xx_reset_adapter, |
| 2114 | .nvram_config = qla81xx_nvram_config, |
| 2115 | .update_fw_options = qla81xx_update_fw_options, |
| 2116 | .load_risc = qla81xx_load_risc, |
| 2117 | .pci_info_str = qla24xx_pci_info_str, |
| 2118 | .fw_version_str = qla24xx_fw_version_str, |
| 2119 | .intr_handler = qla24xx_intr_handler, |
| 2120 | .enable_intrs = qla24xx_enable_intrs, |
| 2121 | .disable_intrs = qla24xx_disable_intrs, |
| 2122 | .abort_command = qla24xx_abort_command, |
| 2123 | .target_reset = qla24xx_abort_target, |
| 2124 | .lun_reset = qla24xx_lun_reset, |
| 2125 | .fabric_login = qla24xx_login_fabric, |
| 2126 | .fabric_logout = qla24xx_fabric_logout, |
| 2127 | .calc_req_entries = NULL, |
| 2128 | .build_iocbs = NULL, |
| 2129 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2130 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2131 | .read_nvram = NULL, |
| 2132 | .write_nvram = NULL, |
| 2133 | .fw_dump = qla27xx_fwdump, |
| 2134 | .beacon_on = qla24xx_beacon_on, |
| 2135 | .beacon_off = qla24xx_beacon_off, |
| 2136 | .beacon_blink = qla83xx_beacon_blink, |
| 2137 | .read_optrom = qla25xx_read_optrom_data, |
| 2138 | .write_optrom = qla24xx_write_optrom_data, |
| 2139 | .get_flash_version = qla24xx_get_flash_version, |
| 2140 | .start_scsi = qla24xx_dif_start_scsi, |
| 2141 | .abort_isp = qla2x00_abort_isp, |
| 2142 | .iospace_config = qla83xx_iospace_config, |
| 2143 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2144 | }; |
| 2145 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2146 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2147 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2148 | { |
| 2149 | ha->device_type = DT_EXTENDED_IDS; |
| 2150 | switch (ha->pdev->device) { |
| 2151 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
| 2152 | ha->device_type |= DT_ISP2100; |
| 2153 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2154 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2155 | break; |
| 2156 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
| 2157 | ha->device_type |= DT_ISP2200; |
| 2158 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2159 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2160 | break; |
| 2161 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
| 2162 | ha->device_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2163 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2164 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2165 | break; |
| 2166 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
| 2167 | ha->device_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2168 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2169 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2170 | break; |
| 2171 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
| 2172 | ha->device_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2173 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2174 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2175 | ha->pdev->subsystem_device == 0x0170) |
| 2176 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2177 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2178 | break; |
| 2179 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
| 2180 | ha->device_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2181 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2182 | break; |
| 2183 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
| 2184 | ha->device_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2185 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2186 | break; |
| 2187 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
| 2188 | ha->device_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2189 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2190 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2191 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2192 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2193 | break; |
| 2194 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
| 2195 | ha->device_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2196 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2197 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2198 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2199 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2200 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2201 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
| 2202 | ha->device_type |= DT_ISP8432; |
| 2203 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2204 | ha->device_type |= DT_FWI2; |
| 2205 | ha->device_type |= DT_IIDMA; |
| 2206 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2207 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2208 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
| 2209 | ha->device_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2210 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2211 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2212 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2213 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
| 2214 | ha->device_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2215 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2216 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2217 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2218 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
| 2219 | ha->device_type |= DT_ISP2532; |
| 2220 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2221 | ha->device_type |= DT_FWI2; |
| 2222 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2223 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2224 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2225 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
| 2226 | ha->device_type |= DT_ISP8001; |
| 2227 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2228 | ha->device_type |= DT_FWI2; |
| 2229 | ha->device_type |= DT_IIDMA; |
| 2230 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2231 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2232 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
| 2233 | ha->device_type |= DT_ISP8021; |
| 2234 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2235 | ha->device_type |= DT_FWI2; |
| 2236 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2237 | /* Initialize 82XX ISP flags */ |
| 2238 | qla82xx_init_flags(ha); |
| 2239 | break; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2240 | case PCI_DEVICE_ID_QLOGIC_ISP8044: |
| 2241 | ha->device_type |= DT_ISP8044; |
| 2242 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2243 | ha->device_type |= DT_FWI2; |
| 2244 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2245 | /* Initialize 82XX ISP flags */ |
| 2246 | qla82xx_init_flags(ha); |
| 2247 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2248 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
| 2249 | ha->device_type |= DT_ISP2031; |
| 2250 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2251 | ha->device_type |= DT_FWI2; |
| 2252 | ha->device_type |= DT_IIDMA; |
| 2253 | ha->device_type |= DT_T10_PI; |
| 2254 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2255 | break; |
| 2256 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
| 2257 | ha->device_type |= DT_ISP8031; |
| 2258 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2259 | ha->device_type |= DT_FWI2; |
| 2260 | ha->device_type |= DT_IIDMA; |
| 2261 | ha->device_type |= DT_T10_PI; |
| 2262 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2263 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2264 | case PCI_DEVICE_ID_QLOGIC_ISPF001: |
| 2265 | ha->device_type |= DT_ISPFX00; |
| 2266 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2267 | case PCI_DEVICE_ID_QLOGIC_ISP2071: |
| 2268 | ha->device_type |= DT_ISP2071; |
| 2269 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2270 | ha->device_type |= DT_FWI2; |
| 2271 | ha->device_type |= DT_IIDMA; |
| 2272 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2273 | break; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2274 | case PCI_DEVICE_ID_QLOGIC_ISP2271: |
| 2275 | ha->device_type |= DT_ISP2271; |
| 2276 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2277 | ha->device_type |= DT_FWI2; |
| 2278 | ha->device_type |= DT_IIDMA; |
| 2279 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2280 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2281 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2282 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2283 | if (IS_QLA82XX(ha)) |
Saurav Kashyap | 43a9c38 | 2014-02-26 04:15:16 -0500 | [diff] [blame] | 2284 | ha->port_no = ha->portnum & 1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2285 | else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2286 | /* Get adapter physical port no from interrupt pin register. */ |
| 2287 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2288 | if (IS_QLA27XX(ha)) |
| 2289 | ha->port_no--; |
| 2290 | else |
| 2291 | ha->port_no = !(ha->port_no & 1); |
| 2292 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2293 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2294 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2295 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2296 | ha->device_type, ha->port_no, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2297 | } |
| 2298 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2299 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2300 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2301 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2302 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2303 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2304 | if (vha->hw->flags.running_gold_fw) |
| 2305 | return; |
| 2306 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2307 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2308 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2309 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2310 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2311 | } |
| 2312 | |
| 2313 | static int |
| 2314 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2315 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2316 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2317 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2318 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2319 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2320 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2321 | return 1; |
| 2322 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2323 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2324 | } |
| 2325 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2326 | /* |
| 2327 | * PCI driver interface |
| 2328 | */ |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 2329 | static int |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2330 | 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] | 2331 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2332 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2333 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2334 | scsi_qla_host_t *base_vha = NULL; |
| 2335 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2336 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2337 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2338 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2339 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2340 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2341 | struct req_que *req = NULL; |
| 2342 | struct rsp_que *rsp = NULL; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2343 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2344 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2345 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2346 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2347 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2348 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2349 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2350 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2351 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2352 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2353 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2354 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031 || |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2355 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISPF001 || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2356 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8044 || |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2357 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2071 || |
| 2358 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2359 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2360 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2361 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2362 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2363 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2364 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2365 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2366 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2367 | if (mem_only) { |
| 2368 | if (pci_enable_device_mem(pdev)) |
| 2369 | goto probe_out; |
| 2370 | } else { |
| 2371 | if (pci_enable_device(pdev)) |
| 2372 | goto probe_out; |
| 2373 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2374 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2375 | /* This may fail but that's ok */ |
| 2376 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2377 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2378 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2379 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2380 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2381 | "Unable to allocate memory for ha.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2382 | goto probe_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2383 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2384 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2385 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2386 | ha->pdev = pdev; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2387 | ha->tgt.enable_class_2 = ql2xenableclass2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2388 | |
| 2389 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2390 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2391 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2392 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2393 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2394 | mutex_init(&ha->selflogin_lock); |
Chad Dupuis | 7a8ab9c | 2014-02-26 04:14:56 -0500 | [diff] [blame] | 2395 | mutex_init(&ha->optrom_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2396 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2397 | /* Set ISP-type information. */ |
| 2398 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2399 | |
| 2400 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2401 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2402 | IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2403 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2404 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2405 | ha->prev_topology = 0; |
| 2406 | ha->init_cb_size = sizeof(init_cb_t); |
| 2407 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2408 | ha->optrom_size = OPTROM_SIZE_2300; |
| 2409 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2410 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2411 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2412 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2413 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2414 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2415 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2416 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2417 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2418 | ha->flash_conf_off = ~0; |
| 2419 | ha->flash_data_off = ~0; |
| 2420 | ha->nvram_conf_off = ~0; |
| 2421 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2422 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2423 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2424 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2425 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2426 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2427 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2428 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2429 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2430 | ha->flash_conf_off = ~0; |
| 2431 | ha->flash_data_off = ~0; |
| 2432 | ha->nvram_conf_off = ~0; |
| 2433 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2434 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2435 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2436 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2437 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2438 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2439 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2440 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2441 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2442 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2443 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2444 | ha->flash_conf_off = ~0; |
| 2445 | ha->flash_data_off = ~0; |
| 2446 | ha->nvram_conf_off = ~0; |
| 2447 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2448 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2449 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2450 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2451 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2452 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2453 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2454 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2455 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2456 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2457 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2458 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2459 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2460 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2461 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2462 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2463 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2464 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2465 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2466 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2467 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2468 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2469 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2470 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2471 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2472 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2473 | ha->gid_list_info_size = 8; |
| 2474 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2475 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2476 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2477 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2478 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2479 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2480 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2481 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2482 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2483 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2484 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2485 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 2486 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2487 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2488 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2489 | ha->gid_list_info_size = 8; |
| 2490 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2491 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2492 | ha->isp_ops = &qla81xx_isp_ops; |
| 2493 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2494 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2495 | ha->nvram_conf_off = ~0; |
| 2496 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2497 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2498 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2499 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2500 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2501 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2502 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2503 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2504 | ha->gid_list_info_size = 8; |
| 2505 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2506 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2507 | ha->isp_ops = &qla82xx_isp_ops; |
| 2508 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2509 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2510 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2511 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2512 | } else if (IS_QLA8044(ha)) { |
| 2513 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2514 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2515 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2516 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2517 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2518 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2519 | ha->gid_list_info_size = 8; |
| 2520 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2521 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2522 | ha->isp_ops = &qla8044_isp_ops; |
| 2523 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2524 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2525 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2526 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2527 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2528 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2529 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2530 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2531 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2532 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | b8aa4bd | 2013-01-30 03:34:40 -0500 | [diff] [blame] | 2533 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2534 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2535 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2536 | ha->gid_list_info_size = 8; |
| 2537 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2538 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2539 | ha->isp_ops = &qla83xx_isp_ops; |
| 2540 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2541 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2542 | ha->nvram_conf_off = ~0; |
| 2543 | ha->nvram_data_off = ~0; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2544 | } else if (IS_QLAFX00(ha)) { |
| 2545 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_FX00; |
| 2546 | ha->mbx_count = MAILBOX_REGISTER_COUNT_FX00; |
| 2547 | ha->aen_mbx_count = AEN_MAILBOX_REGISTER_COUNT_FX00; |
| 2548 | req_length = REQUEST_ENTRY_CNT_FX00; |
| 2549 | rsp_length = RESPONSE_ENTRY_CNT_FX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2550 | ha->isp_ops = &qlafx00_isp_ops; |
| 2551 | ha->port_down_retry_count = 30; /* default value */ |
| 2552 | ha->mr.fw_hbt_cnt = QLAFX00_HEARTBEAT_INTERVAL; |
| 2553 | ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; |
Armen Baloyan | 71e5600 | 2013-08-27 01:37:38 -0400 | [diff] [blame] | 2554 | ha->mr.fw_critemp_timer_tick = QLAFX00_CRITEMP_INTERVAL; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2555 | ha->mr.fw_hbt_en = 1; |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 2556 | ha->mr.host_info_resend = false; |
| 2557 | ha->mr.hinfo_resend_timer_tick = QLAFX00_HINFO_RESEND_INTERVAL; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2558 | } else if (IS_QLA27XX(ha)) { |
| 2559 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
| 2560 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2561 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2562 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2563 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2564 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2565 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2566 | ha->gid_list_info_size = 8; |
| 2567 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2568 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2569 | ha->isp_ops = &qla27xx_isp_ops; |
| 2570 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2571 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2572 | ha->nvram_conf_off = ~0; |
| 2573 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2574 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2575 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2576 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 2577 | "mbx_count=%d, req_length=%d, " |
| 2578 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2579 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 2580 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2581 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 2582 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2583 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2584 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 2585 | "isp_ops=%p, flash_conf_off=%d, " |
| 2586 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 2587 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 2588 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2589 | |
| 2590 | /* Configure PCI I/O space */ |
| 2591 | ret = ha->isp_ops->iospace_config(ha); |
| 2592 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2593 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2594 | |
| 2595 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 2596 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 2597 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 2598 | mutex_init(&ha->vport_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2599 | init_completion(&ha->mbx_cmd_comp); |
| 2600 | complete(&ha->mbx_cmd_comp); |
| 2601 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 2602 | init_completion(&ha->dcbx_comp); |
Chad Dupuis | f356bef | 2013-02-08 01:58:04 -0500 | [diff] [blame] | 2603 | init_completion(&ha->lb_portup_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2604 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2605 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2606 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 2607 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2608 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 2609 | "64 Bit addressing is %s.\n", |
| 2610 | ha->flags.enable_64bit_addressing ? "enable" : |
| 2611 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2612 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Dan Carpenter | b2a72ec3 | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 2613 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2614 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 2615 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2616 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2617 | goto probe_hw_failed; |
| 2618 | } |
| 2619 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2620 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2621 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2622 | req->max_q_depth = ql2xmaxqdepth; |
| 2623 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2624 | |
| 2625 | base_vha = qla2x00_create_host(sht, ha); |
| 2626 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2627 | ret = -ENOMEM; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2628 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2629 | qla2x00_free_req_que(ha, req); |
| 2630 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2631 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2632 | } |
| 2633 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2634 | pci_set_drvdata(pdev, base_vha); |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame^] | 2635 | set_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2636 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2637 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2638 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2639 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2640 | base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2641 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2642 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 2643 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2644 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2645 | /* Setup fcport template structure. */ |
| 2646 | ha->mr.fcport.vha = base_vha; |
| 2647 | ha->mr.fcport.port_type = FCT_UNKNOWN; |
| 2648 | ha->mr.fcport.loop_id = FC_NO_LOOP_ID; |
| 2649 | qla2x00_set_fcport_state(&ha->mr.fcport, FCS_UNCONFIGURED); |
| 2650 | ha->mr.fcport.supported_classes = FC_COS_UNSPECIFIED; |
| 2651 | ha->mr.fcport.scan_state = 1; |
| 2652 | |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2653 | /* Set the SG table size based on ISP type */ |
| 2654 | if (!IS_FWI2_CAPABLE(ha)) { |
| 2655 | if (IS_QLA2100(ha)) |
| 2656 | host->sg_tablesize = 32; |
| 2657 | } else { |
| 2658 | if (!IS_QLA82XX(ha)) |
| 2659 | host->sg_tablesize = QLA_SG_ALL; |
| 2660 | } |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2661 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2662 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 2663 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2664 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2665 | host->max_cmd_len = 32; |
| 2666 | else |
| 2667 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 2668 | host->max_channel = MAX_BUSES - 1; |
Hannes Reinecke | 755f516 | 2014-06-03 10:58:54 +0200 | [diff] [blame] | 2669 | /* Older HBAs support only 16-bit LUNs */ |
| 2670 | if (!IS_QLAFX00(ha) && !IS_FWI2_CAPABLE(ha) && |
| 2671 | ql2xmaxlun > 0xffff) |
| 2672 | host->max_lun = 0xffff; |
| 2673 | else |
| 2674 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2675 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2676 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2677 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2678 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 2679 | "max_id=%d this_id=%d " |
| 2680 | "cmd_per_len=%d unique_id=%d max_cmd_len=%d max_channel=%d " |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 2681 | "max_lun=%llu transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2682 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 2683 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 2684 | host->transportt, sht->vendor_id); |
| 2685 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2686 | que_init: |
| 2687 | /* Alloc arrays of request and response ring ptrs */ |
| 2688 | if (!qla2x00_alloc_queues(ha, req, rsp)) { |
| 2689 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 2690 | "Failed to allocate memory for queue pointers..." |
| 2691 | "aborting.\n"); |
| 2692 | goto probe_init_failed; |
| 2693 | } |
| 2694 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2695 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2696 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2697 | /* Set up the irqs */ |
| 2698 | ret = qla2x00_request_irqs(ha, rsp); |
| 2699 | if (ret) |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2700 | goto probe_init_failed; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2701 | |
| 2702 | pci_save_state(pdev); |
| 2703 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2704 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2705 | rsp->req = req; |
| 2706 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2707 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2708 | if (IS_QLAFX00(ha)) { |
| 2709 | ha->rsp_q_map[0] = rsp; |
| 2710 | ha->req_q_map[0] = req; |
| 2711 | set_bit(0, ha->req_qid_map); |
| 2712 | set_bit(0, ha->rsp_qid_map); |
| 2713 | } |
| 2714 | |
Andrew Vasquez | 08029990 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2715 | /* FWI2-capable only. */ |
| 2716 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 2717 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 2718 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 2719 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2720 | if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | 08029990 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2721 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 2722 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 2723 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 2724 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 2725 | } |
| 2726 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2727 | if (IS_QLAFX00(ha)) { |
| 2728 | req->req_q_in = &ha->iobase->ispfx00.req_q_in; |
| 2729 | req->req_q_out = &ha->iobase->ispfx00.req_q_out; |
| 2730 | rsp->rsp_q_in = &ha->iobase->ispfx00.rsp_q_in; |
| 2731 | rsp->rsp_q_out = &ha->iobase->ispfx00.rsp_q_out; |
| 2732 | } |
| 2733 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2734 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2735 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 2736 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 2737 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 2738 | } |
| 2739 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2740 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 2741 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2742 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2743 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 2744 | "req->req_q_in=%p req->req_q_out=%p " |
| 2745 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2746 | req->req_q_in, req->req_q_out, |
| 2747 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 2748 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 2749 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2750 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2751 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 2752 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2753 | 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] | 2754 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2755 | if (ha->isp_ops->initialize_adapter(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2756 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 2757 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 2758 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2759 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2760 | if (IS_QLA82XX(ha)) { |
| 2761 | qla82xx_idc_lock(ha); |
| 2762 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2763 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2764 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2765 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 2766 | "HW State: FAILED.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2767 | } else if (IS_QLA8044(ha)) { |
| 2768 | qla8044_idc_lock(ha); |
| 2769 | qla8044_wr_direct(base_vha, |
| 2770 | QLA8044_CRB_DEV_STATE_INDEX, |
| 2771 | QLA8XXX_DEV_FAILED); |
| 2772 | qla8044_idc_unlock(ha); |
| 2773 | ql_log(ql_log_fatal, base_vha, 0x0150, |
| 2774 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2775 | } |
| 2776 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2777 | ret = -ENODEV; |
| 2778 | goto probe_failed; |
| 2779 | } |
| 2780 | |
Chad Dupuis | 3b1bef64 | 2014-02-26 04:15:04 -0500 | [diff] [blame] | 2781 | if (IS_QLAFX00(ha)) |
| 2782 | host->can_queue = QLAFX00_MAX_CANQUEUE; |
| 2783 | else |
| 2784 | host->can_queue = req->num_outstanding_cmds - 10; |
| 2785 | |
| 2786 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 2787 | "can_queue=%d, req=%p, mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 2788 | host->can_queue, base_vha->req, |
| 2789 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
| 2790 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2791 | if (ha->mqenable) { |
| 2792 | if (qla25xx_setup_mode(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2793 | ql_log(ql_log_warn, base_vha, 0x00ec, |
| 2794 | "Failed to create queues, falling back to single queue mode.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2795 | goto que_init; |
| 2796 | } |
| 2797 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2798 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2799 | if (ha->flags.running_gold_fw) |
| 2800 | goto skip_dpc; |
| 2801 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2802 | /* |
| 2803 | * Startup the kernel thread for this host adapter |
| 2804 | */ |
| 2805 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2806 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2807 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2808 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 2809 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2810 | ret = PTR_ERR(ha->dpc_thread); |
| 2811 | goto probe_failed; |
| 2812 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2813 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 2814 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2815 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2816 | /* |
| 2817 | * If we're not coming up in initiator mode, we might sit for |
| 2818 | * a while without waking up the dpc thread, which leads to a |
| 2819 | * stuck process warning. So just kick the dpc once here and |
| 2820 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 2821 | */ |
| 2822 | qla2xxx_wake_dpc(base_vha); |
| 2823 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 2824 | INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); |
| 2825 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 2826 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 2827 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 2828 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 2829 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 2830 | |
| 2831 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 2832 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 2833 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 2834 | INIT_WORK(&ha->idc_state_handler, |
| 2835 | qla83xx_idc_state_handler_work); |
| 2836 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 2837 | qla83xx_nic_core_unrecoverable_work); |
| 2838 | } |
| 2839 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2840 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2841 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 2842 | base_vha->host->irq = ha->pdev->irq; |
| 2843 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2844 | /* Initialized the timer */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2845 | qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2846 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 2847 | "Started qla2x00_timer with " |
| 2848 | "interval=%d.\n", WATCH_INTERVAL); |
| 2849 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 2850 | "Detected hba at address=%p.\n", |
| 2851 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2852 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2853 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2854 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2855 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2856 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2857 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 2858 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2859 | if (ql2xenabledif == 1) |
| 2860 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2861 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2862 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2863 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2864 | | SHOST_DIF_TYPE3_PROTECTION |
| 2865 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2866 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2867 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2868 | |
| 2869 | guard = SHOST_DIX_GUARD_CRC; |
| 2870 | |
| 2871 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 2872 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 2873 | guard |= SHOST_DIX_GUARD_IP; |
| 2874 | |
| 2875 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2876 | } else |
| 2877 | base_vha->flags.difdix_supported = 0; |
| 2878 | } |
| 2879 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2880 | ha->isp_ops->enable_intrs(ha); |
| 2881 | |
Armen Baloyan | 1fe19ee | 2013-08-27 01:37:41 -0400 | [diff] [blame] | 2882 | if (IS_QLAFX00(ha)) { |
| 2883 | ret = qlafx00_fx_disc(base_vha, |
| 2884 | &base_vha->hw->mr.fcport, FXDISC_GET_CONFIG_INFO); |
| 2885 | host->sg_tablesize = (ha->mr.extended_io_enabled) ? |
| 2886 | QLA_SG_ALL : 128; |
| 2887 | } |
| 2888 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2889 | ret = scsi_add_host(host, &pdev->dev); |
| 2890 | if (ret) |
| 2891 | goto probe_failed; |
| 2892 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 2893 | base_vha->flags.init_done = 1; |
| 2894 | base_vha->flags.online = 1; |
Saurav Kashyap | edaa5c7 | 2014-04-11 16:54:14 -0400 | [diff] [blame] | 2895 | ha->prev_minidump_failed = 0; |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 2896 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2897 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 2898 | "Init done and hba is online.\n"); |
| 2899 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2900 | if (qla_ini_mode_enabled(base_vha)) |
| 2901 | scsi_scan_host(host); |
| 2902 | else |
| 2903 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 2904 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2905 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2906 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2907 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2908 | if (IS_QLAFX00(ha)) { |
| 2909 | ret = qlafx00_fx_disc(base_vha, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2910 | &base_vha->hw->mr.fcport, FXDISC_GET_PORT_INFO); |
| 2911 | |
| 2912 | /* Register system information */ |
| 2913 | ret = qlafx00_fx_disc(base_vha, |
| 2914 | &base_vha->hw->mr.fcport, FXDISC_REG_HOST_INFO); |
| 2915 | } |
| 2916 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2917 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2918 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2919 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2920 | |
Armen Baloyan | 03eb912 | 2013-10-30 03:38:22 -0400 | [diff] [blame] | 2921 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 2922 | "QLogic %s - %s.\n", ha->model_number, ha->model_desc); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2923 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 2924 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 2925 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 2926 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 2927 | base_vha->host_no, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2928 | ha->isp_ops->fw_version_str(base_vha, fw_str)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2929 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2930 | qlt_add_target(ha, base_vha); |
| 2931 | |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame^] | 2932 | clear_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2933 | return 0; |
| 2934 | |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2935 | probe_init_failed: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2936 | qla2x00_free_req_que(ha, req); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2937 | ha->req_q_map[0] = NULL; |
| 2938 | clear_bit(0, ha->req_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2939 | qla2x00_free_rsp_que(ha, rsp); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2940 | ha->rsp_q_map[0] = NULL; |
| 2941 | clear_bit(0, ha->rsp_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2942 | ha->max_req_queues = ha->max_rsp_queues = 0; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2943 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2944 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2945 | if (base_vha->timer_active) |
| 2946 | qla2x00_stop_timer(base_vha); |
| 2947 | base_vha->flags.online = 0; |
| 2948 | if (ha->dpc_thread) { |
| 2949 | struct task_struct *t = ha->dpc_thread; |
| 2950 | |
| 2951 | ha->dpc_thread = NULL; |
| 2952 | kthread_stop(t); |
| 2953 | } |
| 2954 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2955 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2956 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2957 | scsi_host_put(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2958 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2959 | probe_hw_failed: |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 2960 | qla2x00_clear_drv_active(ha); |
| 2961 | |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2962 | iospace_config_failed: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2963 | if (IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2964 | if (!ha->nx_pcibase) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2965 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2966 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2967 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2968 | } else { |
| 2969 | if (ha->iobase) |
| 2970 | iounmap(ha->iobase); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2971 | if (ha->cregbase) |
| 2972 | iounmap(ha->cregbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2973 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2974 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 2975 | kfree(ha); |
| 2976 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2977 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2978 | probe_out: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2979 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2980 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2981 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2982 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 2983 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 2984 | qla2x00_shutdown(struct pci_dev *pdev) |
| 2985 | { |
| 2986 | scsi_qla_host_t *vha; |
| 2987 | struct qla_hw_data *ha; |
| 2988 | |
Masanari Iida | 552f3f9 | 2013-02-08 01:57:44 -0500 | [diff] [blame] | 2989 | if (!atomic_read(&pdev->enable_cnt)) |
| 2990 | return; |
| 2991 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 2992 | vha = pci_get_drvdata(pdev); |
| 2993 | ha = vha->hw; |
| 2994 | |
Armen Baloyan | 4247934 | 2013-08-27 01:37:37 -0400 | [diff] [blame] | 2995 | /* Notify ISPFX00 firmware */ |
| 2996 | if (IS_QLAFX00(ha)) |
| 2997 | qlafx00_driver_shutdown(vha, 20); |
| 2998 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 2999 | /* Turn-off FCE trace */ |
| 3000 | if (ha->flags.fce_enabled) { |
| 3001 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 3002 | ha->flags.fce_enabled = 0; |
| 3003 | } |
| 3004 | |
| 3005 | /* Turn-off EFT trace */ |
| 3006 | if (ha->eft) |
| 3007 | qla2x00_disable_eft_trace(vha); |
| 3008 | |
| 3009 | /* Stop currently executing firmware. */ |
| 3010 | qla2x00_try_to_stop_firmware(vha); |
| 3011 | |
| 3012 | /* Turn adapter off line */ |
| 3013 | vha->flags.online = 0; |
| 3014 | |
| 3015 | /* turn-off interrupts on the card */ |
| 3016 | if (ha->interrupts_on) { |
| 3017 | vha->flags.init_done = 0; |
| 3018 | ha->isp_ops->disable_intrs(ha); |
| 3019 | } |
| 3020 | |
| 3021 | qla2x00_free_irqs(vha); |
| 3022 | |
| 3023 | qla2x00_free_fw_dump(ha); |
| 3024 | } |
| 3025 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3026 | /* Deletes all the virtual ports for a given ha */ |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3027 | static void |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3028 | qla2x00_delete_all_vps(struct qla_hw_data *ha, scsi_qla_host_t *base_vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3029 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3030 | struct Scsi_Host *scsi_host; |
| 3031 | scsi_qla_host_t *vha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3032 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3033 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3034 | mutex_lock(&ha->vport_lock); |
| 3035 | while (ha->cur_vport_count) { |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3036 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3037 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3038 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 3039 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 3040 | vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3041 | scsi_host = scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3042 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3043 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3044 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3045 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3046 | fc_vport_terminate(vha->fc_vport); |
| 3047 | scsi_host_put(vha->host); |
| 3048 | |
| 3049 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3050 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3051 | mutex_unlock(&ha->vport_lock); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3052 | } |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3053 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3054 | /* Stops all deferred work threads */ |
| 3055 | static void |
| 3056 | qla2x00_destroy_deferred_work(struct qla_hw_data *ha) |
| 3057 | { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3058 | /* Flush the work queue and remove it */ |
| 3059 | if (ha->wq) { |
| 3060 | flush_workqueue(ha->wq); |
| 3061 | destroy_workqueue(ha->wq); |
| 3062 | ha->wq = NULL; |
| 3063 | } |
| 3064 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3065 | /* Cancel all work and destroy DPC workqueues */ |
| 3066 | if (ha->dpc_lp_wq) { |
| 3067 | cancel_work_sync(&ha->idc_aen); |
| 3068 | destroy_workqueue(ha->dpc_lp_wq); |
| 3069 | ha->dpc_lp_wq = NULL; |
| 3070 | } |
| 3071 | |
| 3072 | if (ha->dpc_hp_wq) { |
| 3073 | cancel_work_sync(&ha->nic_core_reset); |
| 3074 | cancel_work_sync(&ha->idc_state_handler); |
| 3075 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 3076 | destroy_workqueue(ha->dpc_hp_wq); |
| 3077 | ha->dpc_hp_wq = NULL; |
| 3078 | } |
| 3079 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3080 | /* Kill the kernel thread for this host */ |
| 3081 | if (ha->dpc_thread) { |
| 3082 | struct task_struct *t = ha->dpc_thread; |
| 3083 | |
| 3084 | /* |
| 3085 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 3086 | * so we need to zero it out. |
| 3087 | */ |
| 3088 | ha->dpc_thread = NULL; |
| 3089 | kthread_stop(t); |
| 3090 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3091 | } |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3092 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3093 | static void |
| 3094 | qla2x00_unmap_iobases(struct qla_hw_data *ha) |
| 3095 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3096 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 3097 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3098 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3099 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3100 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3101 | } else { |
| 3102 | if (ha->iobase) |
| 3103 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3104 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3105 | if (ha->cregbase) |
| 3106 | iounmap(ha->cregbase); |
| 3107 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3108 | if (ha->mqiobase) |
| 3109 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3110 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3111 | if ((IS_QLA83XX(ha) || IS_QLA27XX(ha)) && ha->msixbase) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3112 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3113 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3114 | } |
| 3115 | |
| 3116 | static void |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3117 | qla2x00_clear_drv_active(struct qla_hw_data *ha) |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3118 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3119 | if (IS_QLA8044(ha)) { |
| 3120 | qla8044_idc_lock(ha); |
Saurav Kashyap | c41afc9 | 2013-11-07 02:54:56 -0500 | [diff] [blame] | 3121 | qla8044_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3122 | qla8044_idc_unlock(ha); |
| 3123 | } else if (IS_QLA82XX(ha)) { |
| 3124 | qla82xx_idc_lock(ha); |
| 3125 | qla82xx_clear_drv_active(ha); |
| 3126 | qla82xx_idc_unlock(ha); |
| 3127 | } |
| 3128 | } |
| 3129 | |
| 3130 | static void |
| 3131 | qla2x00_remove_one(struct pci_dev *pdev) |
| 3132 | { |
| 3133 | scsi_qla_host_t *base_vha; |
| 3134 | struct qla_hw_data *ha; |
| 3135 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3136 | base_vha = pci_get_drvdata(pdev); |
| 3137 | ha = base_vha->hw; |
| 3138 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3139 | /* Indicate device removal to prevent future board_disable and wait |
| 3140 | * until any pending board_disable has completed. */ |
| 3141 | set_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags); |
| 3142 | cancel_work_sync(&ha->board_disable); |
| 3143 | |
| 3144 | /* |
| 3145 | * If the PCI device is disabled then there was a PCI-disconnect and |
| 3146 | * qla2x00_disable_board_on_pci_error has taken care of most of the |
| 3147 | * resources. |
| 3148 | */ |
| 3149 | if (!atomic_read(&pdev->enable_cnt)) { |
| 3150 | scsi_host_put(base_vha->host); |
| 3151 | kfree(ha); |
| 3152 | pci_set_drvdata(pdev, NULL); |
| 3153 | return; |
| 3154 | } |
| 3155 | |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 3156 | qla2x00_wait_for_hba_ready(base_vha); |
| 3157 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3158 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 3159 | |
| 3160 | if (IS_QLAFX00(ha)) |
| 3161 | qlafx00_driver_shutdown(base_vha, 20); |
| 3162 | |
| 3163 | qla2x00_delete_all_vps(ha, base_vha); |
| 3164 | |
| 3165 | if (IS_QLA8031(ha)) { |
| 3166 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 3167 | "Clearing fcoe driver presence.\n"); |
| 3168 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 3169 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 3170 | "Error while clearing DRV-Presence.\n"); |
| 3171 | } |
| 3172 | |
| 3173 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 3174 | |
| 3175 | qla2x00_dfs_remove(base_vha); |
| 3176 | |
| 3177 | qla84xx_put_chip(base_vha); |
| 3178 | |
| 3179 | /* Disable timer */ |
| 3180 | if (base_vha->timer_active) |
| 3181 | qla2x00_stop_timer(base_vha); |
| 3182 | |
| 3183 | base_vha->flags.online = 0; |
| 3184 | |
| 3185 | qla2x00_destroy_deferred_work(ha); |
| 3186 | |
| 3187 | qlt_remove_target(ha, base_vha); |
| 3188 | |
| 3189 | qla2x00_free_sysfs_attr(base_vha, true); |
| 3190 | |
| 3191 | fc_remove_host(base_vha->host); |
| 3192 | |
| 3193 | scsi_remove_host(base_vha->host); |
| 3194 | |
| 3195 | qla2x00_free_device(base_vha); |
| 3196 | |
| 3197 | scsi_host_put(base_vha->host); |
| 3198 | |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3199 | qla2x00_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3200 | |
| 3201 | qla2x00_unmap_iobases(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3202 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3203 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3204 | kfree(ha); |
| 3205 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3206 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3207 | pci_disable_pcie_error_reporting(pdev); |
| 3208 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 3209 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3210 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3211 | |
| 3212 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3213 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3214 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3215 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3216 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3217 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 3218 | |
| 3219 | /* Disable timer */ |
| 3220 | if (vha->timer_active) |
| 3221 | qla2x00_stop_timer(vha); |
| 3222 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3223 | qla25xx_delete_queues(vha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3224 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3225 | if (ha->flags.fce_enabled) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3226 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3227 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3228 | if (ha->eft) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3229 | qla2x00_disable_eft_trace(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3230 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3231 | /* Stop currently executing firmware. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3232 | qla2x00_try_to_stop_firmware(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3233 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3234 | vha->flags.online = 0; |
| 3235 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3236 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3237 | if (ha->interrupts_on) { |
| 3238 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 3239 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3240 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3241 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3242 | qla2x00_free_irqs(vha); |
| 3243 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3244 | qla2x00_free_fcports(vha); |
| 3245 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3246 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3247 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 3248 | qla82xx_md_free(vha); |
| 3249 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3250 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3251 | } |
| 3252 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3253 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 3254 | { |
| 3255 | fc_port_t *fcport, *tfcport; |
| 3256 | |
| 3257 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 3258 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3259 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3260 | kfree(fcport); |
| 3261 | fcport = NULL; |
| 3262 | } |
| 3263 | } |
| 3264 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3265 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3266 | 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] | 3267 | int defer) |
| 3268 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3269 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3270 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3271 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3272 | |
| 3273 | if (!fcport->rport) |
| 3274 | return; |
| 3275 | |
| 3276 | rport = fcport->rport; |
| 3277 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3278 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3279 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3280 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3281 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3282 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 3283 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3284 | } else { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3285 | fc_remote_port_delete(rport); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3286 | qlt_fc_port_deleted(vha, fcport); |
| 3287 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3288 | } |
| 3289 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3290 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3291 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 3292 | * |
| 3293 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 3294 | * |
| 3295 | * Return: None. |
| 3296 | * |
| 3297 | * Context: |
| 3298 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3299 | 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] | 3300 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3301 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3302 | if (IS_QLAFX00(vha->hw)) { |
| 3303 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
| 3304 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3305 | return; |
| 3306 | } |
| 3307 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3308 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3309 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3310 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3311 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3312 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3313 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3314 | * We may need to retry the login, so don't change the state of the |
| 3315 | * port but do the retries. |
| 3316 | */ |
| 3317 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3318 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3319 | |
| 3320 | if (!do_login) |
| 3321 | return; |
| 3322 | |
| 3323 | if (fcport->login_retry == 0) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3324 | fcport->login_retry = vha->hw->login_retry_count; |
| 3325 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3326 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3327 | ql_dbg(ql_dbg_disc, vha, 0x2067, |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 3328 | "Port login retry %8phN, id = 0x%04x retry cnt=%d.\n", |
| 3329 | fcport->port_name, fcport->loop_id, fcport->login_retry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3330 | } |
| 3331 | } |
| 3332 | |
| 3333 | /* |
| 3334 | * qla2x00_mark_all_devices_lost |
| 3335 | * Updates fcport state when device goes offline. |
| 3336 | * |
| 3337 | * Input: |
| 3338 | * ha = adapter block pointer. |
| 3339 | * fcport = port structure pointer. |
| 3340 | * |
| 3341 | * Return: |
| 3342 | * None. |
| 3343 | * |
| 3344 | * Context: |
| 3345 | */ |
| 3346 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3347 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3348 | { |
| 3349 | fc_port_t *fcport; |
| 3350 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3351 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3352 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3353 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3354 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3355 | /* |
| 3356 | * No point in marking the device as lost, if the device is |
| 3357 | * already DEAD. |
| 3358 | */ |
| 3359 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3360 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3361 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3362 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3363 | if (defer) |
| 3364 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3365 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3366 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3367 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3368 | } |
| 3369 | } |
| 3370 | |
| 3371 | /* |
| 3372 | * qla2x00_mem_alloc |
| 3373 | * Allocates adapter memory. |
| 3374 | * |
| 3375 | * Returns: |
| 3376 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3377 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3378 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3379 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3380 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3381 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3382 | { |
| 3383 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3384 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3385 | 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] | 3386 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3387 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3388 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3389 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3390 | if (qlt_mem_alloc(ha) < 0) |
| 3391 | goto fail_free_init_cb; |
| 3392 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3393 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3394 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3395 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3396 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3397 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3398 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3399 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3400 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3401 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3402 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3403 | /* Allocate cache for CT6 Ctx. */ |
| 3404 | if (!ctx_cachep) { |
| 3405 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3406 | sizeof(struct ct6_dsd), 0, |
| 3407 | SLAB_HWCACHE_ALIGN, NULL); |
| 3408 | if (!ctx_cachep) |
| 3409 | goto fail_free_gid_list; |
| 3410 | } |
| 3411 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3412 | ctx_cachep); |
| 3413 | if (!ha->ctx_mempool) |
| 3414 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3415 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3416 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3417 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3418 | } |
| 3419 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3420 | /* Get memory for cached NVRAM */ |
| 3421 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3422 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3423 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3424 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3425 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3426 | ha->pdev->device); |
| 3427 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3428 | DMA_POOL_SIZE, 8, 0); |
| 3429 | if (!ha->s_dma_pool) |
| 3430 | goto fail_free_nvram; |
| 3431 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3432 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3433 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3434 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3435 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3436 | if (IS_P3P_TYPE(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3437 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3438 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3439 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3440 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3441 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3442 | goto fail_s_dma_pool; |
| 3443 | } |
| 3444 | |
| 3445 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3446 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3447 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3448 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3449 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3450 | goto fail_dl_dma_pool; |
| 3451 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3452 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3453 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3454 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3455 | } |
| 3456 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3457 | /* Allocate memory for SNS commands */ |
| 3458 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3459 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3460 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3461 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3462 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3463 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3464 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 3465 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3466 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3467 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3468 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3469 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3470 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3471 | goto fail_dma_pool; |
| 3472 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3473 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3474 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3475 | if (!ha->ct_sns) |
| 3476 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3477 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 3478 | "ms_iocb=%p ct_sns=%p.\n", |
| 3479 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3480 | } |
| 3481 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3482 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3483 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 3484 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3485 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 3486 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3487 | goto fail_req; |
| 3488 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3489 | (*req)->length = req_len; |
| 3490 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3491 | ((*req)->length + 1) * sizeof(request_t), |
| 3492 | &(*req)->dma, GFP_KERNEL); |
| 3493 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3494 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 3495 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3496 | goto fail_req_ring; |
| 3497 | } |
| 3498 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3499 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 3500 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3501 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 3502 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3503 | goto fail_rsp; |
| 3504 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3505 | (*rsp)->hw = ha; |
| 3506 | (*rsp)->length = rsp_len; |
| 3507 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3508 | ((*rsp)->length + 1) * sizeof(response_t), |
| 3509 | &(*rsp)->dma, GFP_KERNEL); |
| 3510 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3511 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 3512 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3513 | goto fail_rsp_ring; |
| 3514 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3515 | (*req)->rsp = *rsp; |
| 3516 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3517 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 3518 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 3519 | "rsp->length=%d rsp->ring=%p.\n", |
| 3520 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 3521 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3522 | /* Allocate memory for NVRAM data for vports */ |
| 3523 | if (ha->nvram_npiv_size) { |
| 3524 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3525 | ha->nvram_npiv_size, GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3526 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3527 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 3528 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3529 | goto fail_npiv_info; |
| 3530 | } |
| 3531 | } else |
| 3532 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3533 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3534 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3535 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3536 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3537 | &ha->ex_init_cb_dma); |
| 3538 | if (!ha->ex_init_cb) |
| 3539 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3540 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 3541 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3542 | } |
| 3543 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3544 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 3545 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3546 | /* Get consistent memory allocated for Async Port-Database. */ |
| 3547 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3548 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3549 | &ha->async_pd_dma); |
| 3550 | if (!ha->async_pd) |
| 3551 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3552 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 3553 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3554 | } |
| 3555 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3556 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3557 | |
| 3558 | /* Allocate memory for our loop_id bitmap */ |
| 3559 | ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), |
| 3560 | GFP_KERNEL); |
| 3561 | if (!ha->loop_id_map) |
| 3562 | goto fail_async_pd; |
| 3563 | else { |
| 3564 | qla2x00_set_reserved_loop_ids(ha); |
| 3565 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
Dan Carpenter | b2a72ec3 | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3566 | "loop_id_map=%p.\n", ha->loop_id_map); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3567 | } |
| 3568 | |
Dan Carpenter | b2a72ec3 | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3569 | return 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3570 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3571 | fail_async_pd: |
| 3572 | 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] | 3573 | fail_ex_init_cb: |
| 3574 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3575 | fail_npiv_info: |
| 3576 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 3577 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 3578 | (*rsp)->ring = NULL; |
| 3579 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3580 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3581 | kfree(*rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3582 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3583 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 3584 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 3585 | (*req)->ring = NULL; |
| 3586 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3587 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3588 | kfree(*req); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3589 | fail_req: |
| 3590 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 3591 | ha->ct_sns, ha->ct_sns_dma); |
| 3592 | ha->ct_sns = NULL; |
| 3593 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3594 | fail_free_ms_iocb: |
| 3595 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3596 | ha->ms_iocb = NULL; |
| 3597 | ha->ms_iocb_dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3598 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3599 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3600 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3601 | ha->fcp_cmnd_dma_pool = NULL; |
| 3602 | } |
| 3603 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3604 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3605 | dma_pool_destroy(ha->dl_dma_pool); |
| 3606 | ha->dl_dma_pool = NULL; |
| 3607 | } |
| 3608 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3609 | dma_pool_destroy(ha->s_dma_pool); |
| 3610 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3611 | fail_free_nvram: |
| 3612 | kfree(ha->nvram); |
| 3613 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3614 | fail_free_ctx_mempool: |
| 3615 | mempool_destroy(ha->ctx_mempool); |
| 3616 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3617 | fail_free_srb_mempool: |
| 3618 | mempool_destroy(ha->srb_mempool); |
| 3619 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3620 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3621 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3622 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3623 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3624 | ha->gid_list = NULL; |
| 3625 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3626 | fail_free_tgt_mem: |
| 3627 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3628 | fail_free_init_cb: |
| 3629 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 3630 | ha->init_cb_dma); |
| 3631 | ha->init_cb = NULL; |
| 3632 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3633 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3634 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 3635 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3636 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3637 | } |
| 3638 | |
| 3639 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3640 | * qla2x00_free_fw_dump |
| 3641 | * Frees fw dump stuff. |
| 3642 | * |
| 3643 | * Input: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3644 | * ha = adapter block pointer |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3645 | */ |
| 3646 | static void |
| 3647 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 3648 | { |
| 3649 | if (ha->fce) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3650 | dma_free_coherent(&ha->pdev->dev, |
| 3651 | FCE_SIZE, ha->fce, ha->fce_dma); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3652 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3653 | if (ha->eft) |
| 3654 | dma_free_coherent(&ha->pdev->dev, |
| 3655 | EFT_SIZE, ha->eft, ha->eft_dma); |
| 3656 | |
| 3657 | if (ha->fw_dump) |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3658 | vfree(ha->fw_dump); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3659 | if (ha->fw_dump_template) |
| 3660 | vfree(ha->fw_dump_template); |
| 3661 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3662 | ha->fce = NULL; |
| 3663 | ha->fce_dma = 0; |
| 3664 | ha->eft = NULL; |
| 3665 | ha->eft_dma = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3666 | ha->fw_dumped = 0; |
Hiral Patel | 61f098d | 2014-04-11 16:54:21 -0400 | [diff] [blame] | 3667 | ha->fw_dump_cap_flags = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3668 | ha->fw_dump_reading = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3669 | ha->fw_dump = NULL; |
| 3670 | ha->fw_dump_len = 0; |
| 3671 | ha->fw_dump_template = NULL; |
| 3672 | ha->fw_dump_template_len = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3673 | } |
| 3674 | |
| 3675 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3676 | * qla2x00_mem_free |
| 3677 | * Frees all adapter allocated memory. |
| 3678 | * |
| 3679 | * Input: |
| 3680 | * ha = adapter block pointer. |
| 3681 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 3682 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3683 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3684 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3685 | qla2x00_free_fw_dump(ha); |
| 3686 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3687 | if (ha->mctp_dump) |
| 3688 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 3689 | ha->mctp_dump_dma); |
| 3690 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3691 | if (ha->srb_mempool) |
| 3692 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3693 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 3694 | if (ha->dcbx_tlv) |
| 3695 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 3696 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 3697 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 3698 | if (ha->xgmac_data) |
| 3699 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 3700 | ha->xgmac_data, ha->xgmac_data_dma); |
| 3701 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3702 | if (ha->sns_cmd) |
| 3703 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3704 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3705 | |
| 3706 | if (ha->ct_sns) |
| 3707 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3708 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3709 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3710 | if (ha->sfp_data) |
| 3711 | dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); |
| 3712 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3713 | if (ha->ms_iocb) |
| 3714 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3715 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3716 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3717 | dma_pool_free(ha->s_dma_pool, |
| 3718 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3719 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3720 | if (ha->async_pd) |
| 3721 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 3722 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3723 | if (ha->s_dma_pool) |
| 3724 | dma_pool_destroy(ha->s_dma_pool); |
| 3725 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3726 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3727 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3728 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3729 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3730 | if (IS_QLA82XX(ha)) { |
| 3731 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 3732 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 3733 | |
| 3734 | /* clean up allocated prev pool */ |
| 3735 | list_for_each_entry_safe(dsd_ptr, |
| 3736 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 3737 | dma_pool_free(ha->dl_dma_pool, |
| 3738 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 3739 | list_del(&dsd_ptr->list); |
| 3740 | kfree(dsd_ptr); |
| 3741 | } |
| 3742 | } |
| 3743 | } |
| 3744 | |
| 3745 | if (ha->dl_dma_pool) |
| 3746 | dma_pool_destroy(ha->dl_dma_pool); |
| 3747 | |
| 3748 | if (ha->fcp_cmnd_dma_pool) |
| 3749 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3750 | |
| 3751 | if (ha->ctx_mempool) |
| 3752 | mempool_destroy(ha->ctx_mempool); |
| 3753 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3754 | qlt_mem_free(ha); |
| 3755 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3756 | if (ha->init_cb) |
| 3757 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3758 | ha->init_cb, ha->init_cb_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3759 | vfree(ha->optrom_buffer); |
| 3760 | kfree(ha->nvram); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3761 | kfree(ha->npiv_info); |
Andrew Vasquez | 7a67735 | 2012-02-09 11:15:56 -0800 | [diff] [blame] | 3762 | kfree(ha->swl); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3763 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3764 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3765 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3766 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3767 | ha->sns_cmd = NULL; |
| 3768 | ha->sns_cmd_dma = 0; |
| 3769 | ha->ct_sns = NULL; |
| 3770 | ha->ct_sns_dma = 0; |
| 3771 | ha->ms_iocb = NULL; |
| 3772 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3773 | ha->init_cb = NULL; |
| 3774 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3775 | ha->ex_init_cb = NULL; |
| 3776 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3777 | ha->async_pd = NULL; |
| 3778 | ha->async_pd_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3779 | |
| 3780 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3781 | ha->dl_dma_pool = NULL; |
| 3782 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3783 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3784 | ha->gid_list = NULL; |
| 3785 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3786 | |
| 3787 | ha->tgt.atio_ring = NULL; |
| 3788 | ha->tgt.atio_dma = 0; |
| 3789 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3790 | } |
| 3791 | |
| 3792 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 3793 | struct qla_hw_data *ha) |
| 3794 | { |
| 3795 | struct Scsi_Host *host; |
| 3796 | struct scsi_qla_host *vha = NULL; |
| 3797 | |
| 3798 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
| 3799 | if (host == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3800 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 3801 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3802 | goto fail; |
| 3803 | } |
| 3804 | |
| 3805 | /* Clear our data area */ |
| 3806 | vha = shost_priv(host); |
| 3807 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 3808 | |
| 3809 | vha->host = host; |
| 3810 | vha->host_no = host->host_no; |
| 3811 | vha->hw = ha; |
| 3812 | |
| 3813 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 3814 | INIT_LIST_HEAD(&vha->work_list); |
| 3815 | INIT_LIST_HEAD(&vha->list); |
| 3816 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3817 | spin_lock_init(&vha->work_lock); |
| 3818 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3819 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3820 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 3821 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 3822 | vha->host, vha->hw, vha, |
| 3823 | dev_name(&(ha->pdev->dev))); |
| 3824 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3825 | return vha; |
| 3826 | |
| 3827 | fail: |
| 3828 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3829 | } |
| 3830 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 3831 | static struct qla_work_evt * |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3832 | 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] | 3833 | { |
| 3834 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3835 | uint8_t bail; |
| 3836 | |
| 3837 | QLA_VHA_MARK_BUSY(vha, bail); |
| 3838 | if (bail) |
| 3839 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3840 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3841 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3842 | if (!e) { |
| 3843 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3844 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3845 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3846 | |
| 3847 | INIT_LIST_HEAD(&e->list); |
| 3848 | e->type = type; |
| 3849 | e->flags = QLA_EVT_FLAG_FREE; |
| 3850 | return e; |
| 3851 | } |
| 3852 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 3853 | static int |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3854 | 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] | 3855 | { |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3856 | unsigned long flags; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3857 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3858 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3859 | list_add_tail(&e->list, &vha->work_list); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3860 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3861 | qla2xxx_wake_dpc(vha); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3862 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3863 | return QLA_SUCCESS; |
| 3864 | } |
| 3865 | |
| 3866 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3867 | 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] | 3868 | u32 data) |
| 3869 | { |
| 3870 | struct qla_work_evt *e; |
| 3871 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3872 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3873 | if (!e) |
| 3874 | return QLA_FUNCTION_FAILED; |
| 3875 | |
| 3876 | e->u.aen.code = code; |
| 3877 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3878 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3879 | } |
| 3880 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3881 | int |
| 3882 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 3883 | { |
| 3884 | struct qla_work_evt *e; |
| 3885 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3886 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3887 | if (!e) |
| 3888 | return QLA_FUNCTION_FAILED; |
| 3889 | |
| 3890 | memcpy(e->u.idc_ack.mb, mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3891 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3892 | } |
| 3893 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3894 | #define qla2x00_post_async_work(name, type) \ |
| 3895 | int qla2x00_post_async_##name##_work( \ |
| 3896 | struct scsi_qla_host *vha, \ |
| 3897 | fc_port_t *fcport, uint16_t *data) \ |
| 3898 | { \ |
| 3899 | struct qla_work_evt *e; \ |
| 3900 | \ |
| 3901 | e = qla2x00_alloc_work(vha, type); \ |
| 3902 | if (!e) \ |
| 3903 | return QLA_FUNCTION_FAILED; \ |
| 3904 | \ |
| 3905 | e->u.logio.fcport = fcport; \ |
| 3906 | if (data) { \ |
| 3907 | e->u.logio.data[0] = data[0]; \ |
| 3908 | e->u.logio.data[1] = data[1]; \ |
| 3909 | } \ |
| 3910 | return qla2x00_post_work(vha, e); \ |
| 3911 | } |
| 3912 | |
| 3913 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
| 3914 | qla2x00_post_async_work(login_done, QLA_EVT_ASYNC_LOGIN_DONE); |
| 3915 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 3916 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3917 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 3918 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3919 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 3920 | int |
| 3921 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 3922 | { |
| 3923 | struct qla_work_evt *e; |
| 3924 | |
| 3925 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 3926 | if (!e) |
| 3927 | return QLA_FUNCTION_FAILED; |
| 3928 | |
| 3929 | e->u.uevent.code = code; |
| 3930 | return qla2x00_post_work(vha, e); |
| 3931 | } |
| 3932 | |
| 3933 | static void |
| 3934 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 3935 | { |
| 3936 | char event_string[40]; |
| 3937 | char *envp[] = { event_string, NULL }; |
| 3938 | |
| 3939 | switch (code) { |
| 3940 | case QLA_UEVENT_CODE_FW_DUMP: |
| 3941 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 3942 | vha->host_no); |
| 3943 | break; |
| 3944 | default: |
| 3945 | /* do nothing */ |
| 3946 | break; |
| 3947 | } |
| 3948 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 3949 | } |
| 3950 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3951 | int |
| 3952 | qlafx00_post_aenfx_work(struct scsi_qla_host *vha, uint32_t evtcode, |
| 3953 | uint32_t *data, int cnt) |
| 3954 | { |
| 3955 | struct qla_work_evt *e; |
| 3956 | |
| 3957 | e = qla2x00_alloc_work(vha, QLA_EVT_AENFX); |
| 3958 | if (!e) |
| 3959 | return QLA_FUNCTION_FAILED; |
| 3960 | |
| 3961 | e->u.aenfx.evtcode = evtcode; |
| 3962 | e->u.aenfx.count = cnt; |
| 3963 | memcpy(e->u.aenfx.mbx, data, sizeof(*data) * cnt); |
| 3964 | return qla2x00_post_work(vha, e); |
| 3965 | } |
| 3966 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3967 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3968 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3969 | { |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3970 | struct qla_work_evt *e, *tmp; |
| 3971 | unsigned long flags; |
| 3972 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3973 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3974 | spin_lock_irqsave(&vha->work_lock, flags); |
| 3975 | list_splice_init(&vha->work_list, &work); |
| 3976 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 3977 | |
| 3978 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3979 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3980 | |
| 3981 | switch (e->type) { |
| 3982 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3983 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3984 | e->u.aen.code, e->u.aen.data); |
| 3985 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3986 | case QLA_EVT_IDC_ACK: |
| 3987 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 3988 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3989 | case QLA_EVT_ASYNC_LOGIN: |
| 3990 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 3991 | e->u.logio.data); |
| 3992 | break; |
| 3993 | case QLA_EVT_ASYNC_LOGIN_DONE: |
| 3994 | qla2x00_async_login_done(vha, e->u.logio.fcport, |
| 3995 | e->u.logio.data); |
| 3996 | break; |
| 3997 | case QLA_EVT_ASYNC_LOGOUT: |
| 3998 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 3999 | break; |
| 4000 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 4001 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 4002 | e->u.logio.data); |
| 4003 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4004 | case QLA_EVT_ASYNC_ADISC: |
| 4005 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 4006 | e->u.logio.data); |
| 4007 | break; |
| 4008 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 4009 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 4010 | e->u.logio.data); |
| 4011 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4012 | case QLA_EVT_UEVENT: |
| 4013 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 4014 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4015 | case QLA_EVT_AENFX: |
| 4016 | qlafx00_process_aen(vha, e); |
| 4017 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4018 | } |
| 4019 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 4020 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4021 | |
| 4022 | /* For each work completed decrement vha ref count */ |
| 4023 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4024 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4025 | } |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4026 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4027 | /* Relogins all the fcports of a vport |
| 4028 | * Context: dpc thread |
| 4029 | */ |
| 4030 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 4031 | { |
| 4032 | fc_port_t *fcport; |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 4033 | int status; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4034 | uint16_t next_loopid = 0; |
| 4035 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4036 | uint16_t data[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4037 | |
| 4038 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 4039 | /* |
| 4040 | * If the port is not ONLINE then try to login |
| 4041 | * to it if we haven't run out of retries. |
| 4042 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4043 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
| 4044 | fcport->login_retry && !(fcport->flags & FCF_ASYNC_SENT)) { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4045 | fcport->login_retry--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4046 | if (fcport->flags & FCF_FABRIC_DEVICE) { |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 4047 | if (fcport->flags & FCF_FCP2_DEVICE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4048 | ha->isp_ops->fabric_logout(vha, |
| 4049 | fcport->loop_id, |
| 4050 | fcport->d_id.b.domain, |
| 4051 | fcport->d_id.b.area, |
| 4052 | fcport->d_id.b.al_pa); |
| 4053 | |
Joe Carnuccio | 03bcfb5 | 2011-03-30 11:46:27 -0700 | [diff] [blame] | 4054 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
| 4055 | fcport->loop_id = next_loopid = |
| 4056 | ha->min_external_loopid; |
| 4057 | status = qla2x00_find_new_loop_id( |
| 4058 | vha, fcport); |
| 4059 | if (status != QLA_SUCCESS) { |
| 4060 | /* Ran out of IDs to use */ |
| 4061 | break; |
| 4062 | } |
| 4063 | } |
| 4064 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4065 | if (IS_ALOGIO_CAPABLE(ha)) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4066 | fcport->flags |= FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4067 | data[0] = 0; |
| 4068 | data[1] = QLA_LOGIO_LOGIN_RETRIED; |
| 4069 | status = qla2x00_post_async_login_work( |
| 4070 | vha, fcport, data); |
| 4071 | if (status == QLA_SUCCESS) |
| 4072 | continue; |
| 4073 | /* Attempt a retry. */ |
| 4074 | status = 1; |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4075 | } else { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4076 | status = qla2x00_fabric_login(vha, |
| 4077 | fcport, &next_loopid); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4078 | if (status == QLA_SUCCESS) { |
| 4079 | int status2; |
| 4080 | uint8_t opts; |
| 4081 | |
| 4082 | opts = 0; |
| 4083 | if (fcport->flags & |
| 4084 | FCF_FCP2_DEVICE) |
| 4085 | opts |= BIT_1; |
Saurav Kashyap | 0300396 | 2012-11-21 02:40:31 -0500 | [diff] [blame] | 4086 | status2 = |
| 4087 | qla2x00_get_port_database( |
| 4088 | vha, fcport, opts); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4089 | if (status2 != QLA_SUCCESS) |
| 4090 | status = 1; |
| 4091 | } |
| 4092 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4093 | } else |
| 4094 | status = qla2x00_local_device_login(vha, |
| 4095 | fcport); |
| 4096 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4097 | if (status == QLA_SUCCESS) { |
| 4098 | fcport->old_loop_id = fcport->loop_id; |
| 4099 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4100 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 4101 | "Port login OK: logged in ID 0x%x.\n", |
| 4102 | fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4103 | |
| 4104 | qla2x00_update_fcport(vha, fcport); |
| 4105 | |
| 4106 | } else if (status == 1) { |
| 4107 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 4108 | /* retry the login again */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4109 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 4110 | "Retrying %d login again loop_id 0x%x.\n", |
| 4111 | fcport->login_retry, fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4112 | } else { |
| 4113 | fcport->login_retry = 0; |
| 4114 | } |
| 4115 | |
| 4116 | if (fcport->login_retry == 0 && status != QLA_SUCCESS) |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4117 | qla2x00_clear_loop_id(fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4118 | } |
| 4119 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 4120 | break; |
| 4121 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4122 | } |
| 4123 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4124 | /* Schedule work on any of the dpc-workqueues */ |
| 4125 | void |
| 4126 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 4127 | { |
| 4128 | struct qla_hw_data *ha = base_vha->hw; |
| 4129 | |
| 4130 | switch (work_code) { |
| 4131 | case MBA_IDC_AEN: /* 0x8200 */ |
| 4132 | if (ha->dpc_lp_wq) |
| 4133 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 4134 | break; |
| 4135 | |
| 4136 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 4137 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4138 | if (ha->dpc_hp_wq) |
| 4139 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 4140 | } else |
| 4141 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 4142 | "NIC Core reset is already active. Skip " |
| 4143 | "scheduling it again.\n"); |
| 4144 | break; |
| 4145 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 4146 | if (ha->dpc_hp_wq) |
| 4147 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 4148 | break; |
| 4149 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 4150 | if (ha->dpc_hp_wq) |
| 4151 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 4152 | break; |
| 4153 | default: |
| 4154 | ql_log(ql_log_warn, base_vha, 0xb05f, |
| 4155 | "Unknow work-code=0x%x.\n", work_code); |
| 4156 | } |
| 4157 | |
| 4158 | return; |
| 4159 | } |
| 4160 | |
| 4161 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 4162 | void |
| 4163 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 4164 | { |
| 4165 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4166 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4167 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4168 | uint32_t dev_state = 0; |
| 4169 | |
| 4170 | qla83xx_idc_lock(base_vha, 0); |
| 4171 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4172 | qla83xx_reset_ownership(base_vha); |
| 4173 | if (ha->flags.nic_core_reset_owner) { |
| 4174 | ha->flags.nic_core_reset_owner = 0; |
| 4175 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4176 | QLA8XXX_DEV_FAILED); |
| 4177 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 4178 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4179 | } |
| 4180 | qla83xx_idc_unlock(base_vha, 0); |
| 4181 | } |
| 4182 | |
| 4183 | /* Work: Execute IDC state handler */ |
| 4184 | void |
| 4185 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 4186 | { |
| 4187 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4188 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4189 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4190 | uint32_t dev_state = 0; |
| 4191 | |
| 4192 | qla83xx_idc_lock(base_vha, 0); |
| 4193 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4194 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 4195 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 4196 | qla83xx_idc_state_handler(base_vha); |
| 4197 | qla83xx_idc_unlock(base_vha, 0); |
| 4198 | } |
| 4199 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4200 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4201 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 4202 | { |
| 4203 | int rval = QLA_SUCCESS; |
| 4204 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 4205 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 4206 | |
| 4207 | do { |
| 4208 | if (time_after(jiffies, heart_beat_wait)) { |
| 4209 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 4210 | "Nic Core f/w is not alive.\n"); |
| 4211 | rval = QLA_FUNCTION_FAILED; |
| 4212 | break; |
| 4213 | } |
| 4214 | |
| 4215 | qla83xx_idc_lock(base_vha, 0); |
| 4216 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4217 | &heart_beat_counter1); |
| 4218 | qla83xx_idc_unlock(base_vha, 0); |
| 4219 | msleep(100); |
| 4220 | qla83xx_idc_lock(base_vha, 0); |
| 4221 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4222 | &heart_beat_counter2); |
| 4223 | qla83xx_idc_unlock(base_vha, 0); |
| 4224 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 4225 | |
| 4226 | return rval; |
| 4227 | } |
| 4228 | |
| 4229 | /* Work: Perform NIC Core Reset handling */ |
| 4230 | void |
| 4231 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 4232 | { |
| 4233 | struct qla_hw_data *ha = |
| 4234 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 4235 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4236 | uint32_t dev_state = 0; |
| 4237 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4238 | if (IS_QLA2031(ha)) { |
| 4239 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 4240 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 4241 | "Failed to dump mctp\n"); |
| 4242 | return; |
| 4243 | } |
| 4244 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4245 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4246 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 4247 | qla83xx_idc_lock(base_vha, 0); |
| 4248 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4249 | &dev_state); |
| 4250 | qla83xx_idc_unlock(base_vha, 0); |
| 4251 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 4252 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 4253 | "Nic Core f/w is alive.\n"); |
| 4254 | return; |
| 4255 | } |
| 4256 | } |
| 4257 | |
| 4258 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 4259 | if (qla83xx_nic_core_reset(base_vha)) { |
| 4260 | /* NIC Core reset failed. */ |
| 4261 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 4262 | "NIC Core reset failed.\n"); |
| 4263 | } |
| 4264 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 4265 | } |
| 4266 | } |
| 4267 | |
| 4268 | /* Work: Handle 8200 IDC aens */ |
| 4269 | void |
| 4270 | qla83xx_service_idc_aen(struct work_struct *work) |
| 4271 | { |
| 4272 | struct qla_hw_data *ha = |
| 4273 | container_of(work, struct qla_hw_data, idc_aen); |
| 4274 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4275 | uint32_t dev_state, idc_control; |
| 4276 | |
| 4277 | qla83xx_idc_lock(base_vha, 0); |
| 4278 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4279 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 4280 | qla83xx_idc_unlock(base_vha, 0); |
| 4281 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 4282 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 4283 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 4284 | "Application requested NIC Core Reset.\n"); |
| 4285 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4286 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 4287 | QLA_SUCCESS) { |
| 4288 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 4289 | "Other protocol driver requested NIC Core Reset.\n"); |
| 4290 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4291 | } |
| 4292 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 4293 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 4294 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4295 | } |
| 4296 | } |
| 4297 | |
| 4298 | static void |
| 4299 | qla83xx_wait_logic(void) |
| 4300 | { |
| 4301 | int i; |
| 4302 | |
| 4303 | /* Yield CPU */ |
| 4304 | if (!in_interrupt()) { |
| 4305 | /* |
| 4306 | * Wait about 200ms before retrying again. |
| 4307 | * This controls the number of retries for single |
| 4308 | * lock operation. |
| 4309 | */ |
| 4310 | msleep(100); |
| 4311 | schedule(); |
| 4312 | } else { |
| 4313 | for (i = 0; i < 20; i++) |
| 4314 | cpu_relax(); /* This a nop instr on i386 */ |
| 4315 | } |
| 4316 | } |
| 4317 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4318 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4319 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 4320 | { |
| 4321 | int rval; |
| 4322 | uint32_t data; |
| 4323 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 4324 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 4325 | struct qla_hw_data *ha = base_vha->hw; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4326 | ql_dbg(ql_dbg_p3p, base_vha, 0xb086, |
| 4327 | "Trying force recovery of the IDC lock.\n"); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4328 | |
| 4329 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 4330 | if (rval) |
| 4331 | return rval; |
| 4332 | |
| 4333 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 4334 | return QLA_SUCCESS; |
| 4335 | } else { |
| 4336 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 4337 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4338 | data); |
| 4339 | if (rval) |
| 4340 | return rval; |
| 4341 | |
| 4342 | msleep(200); |
| 4343 | |
| 4344 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4345 | &data); |
| 4346 | if (rval) |
| 4347 | return rval; |
| 4348 | |
| 4349 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 4350 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 4351 | ~(idc_lck_rcvry_stage_mask)); |
| 4352 | rval = qla83xx_wr_reg(base_vha, |
| 4353 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 4354 | if (rval) |
| 4355 | return rval; |
| 4356 | |
| 4357 | /* Forcefully perform IDC UnLock */ |
| 4358 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 4359 | &data); |
| 4360 | if (rval) |
| 4361 | return rval; |
| 4362 | /* Clear lock-id by setting 0xff */ |
| 4363 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4364 | 0xff); |
| 4365 | if (rval) |
| 4366 | return rval; |
| 4367 | /* Clear lock-recovery by setting 0x0 */ |
| 4368 | rval = qla83xx_wr_reg(base_vha, |
| 4369 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 4370 | if (rval) |
| 4371 | return rval; |
| 4372 | } else |
| 4373 | return QLA_SUCCESS; |
| 4374 | } |
| 4375 | |
| 4376 | return rval; |
| 4377 | } |
| 4378 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4379 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4380 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 4381 | { |
| 4382 | int rval = QLA_SUCCESS; |
| 4383 | uint32_t o_drv_lockid, n_drv_lockid; |
| 4384 | unsigned long lock_recovery_timeout; |
| 4385 | |
| 4386 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 4387 | retry_lockid: |
| 4388 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 4389 | if (rval) |
| 4390 | goto exit; |
| 4391 | |
| 4392 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 4393 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 4394 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 4395 | return QLA_SUCCESS; |
| 4396 | else |
| 4397 | return QLA_FUNCTION_FAILED; |
| 4398 | } |
| 4399 | |
| 4400 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 4401 | if (rval) |
| 4402 | goto exit; |
| 4403 | |
| 4404 | if (o_drv_lockid == n_drv_lockid) { |
| 4405 | qla83xx_wait_logic(); |
| 4406 | goto retry_lockid; |
| 4407 | } else |
| 4408 | return QLA_SUCCESS; |
| 4409 | |
| 4410 | exit: |
| 4411 | return rval; |
| 4412 | } |
| 4413 | |
| 4414 | void |
| 4415 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4416 | { |
| 4417 | uint16_t options = (requester_id << 15) | BIT_6; |
| 4418 | uint32_t data; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4419 | uint32_t lock_owner; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4420 | struct qla_hw_data *ha = base_vha->hw; |
| 4421 | |
| 4422 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 4423 | retry_lock: |
| 4424 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 4425 | == QLA_SUCCESS) { |
| 4426 | if (data) { |
| 4427 | /* Setting lock-id to our function-number */ |
| 4428 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4429 | ha->portnum); |
| 4430 | } else { |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4431 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4432 | &lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4433 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4434 | "Failed to acquire IDC lock, acquired by %d, " |
| 4435 | "retrying...\n", lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4436 | |
| 4437 | /* Retry/Perform IDC-Lock recovery */ |
| 4438 | if (qla83xx_idc_lock_recovery(base_vha) |
| 4439 | == QLA_SUCCESS) { |
| 4440 | qla83xx_wait_logic(); |
| 4441 | goto retry_lock; |
| 4442 | } else |
| 4443 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 4444 | "IDC Lock recovery FAILED.\n"); |
| 4445 | } |
| 4446 | |
| 4447 | } |
| 4448 | |
| 4449 | return; |
| 4450 | |
| 4451 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 4452 | retry_lock2: |
| 4453 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4454 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 4455 | "Failed to acquire IDC lock. retrying...\n"); |
| 4456 | /* Retry/Perform IDC-Lock recovery */ |
| 4457 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 4458 | qla83xx_wait_logic(); |
| 4459 | goto retry_lock2; |
| 4460 | } else |
| 4461 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 4462 | "IDC Lock recovery FAILED.\n"); |
| 4463 | } |
| 4464 | |
| 4465 | return; |
| 4466 | } |
| 4467 | |
| 4468 | void |
| 4469 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4470 | { |
| 4471 | uint16_t options = (requester_id << 15) | BIT_7, retry; |
| 4472 | uint32_t data; |
| 4473 | struct qla_hw_data *ha = base_vha->hw; |
| 4474 | |
| 4475 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 4476 | * remote registers |
| 4477 | */ |
| 4478 | retry = 0; |
| 4479 | retry_unlock: |
| 4480 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 4481 | == QLA_SUCCESS) { |
| 4482 | if (data == ha->portnum) { |
| 4483 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 4484 | /* Clearing lock-id by setting 0xff */ |
| 4485 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 4486 | } else if (retry < 10) { |
| 4487 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 4488 | |
| 4489 | /* Retry for IDC-unlock */ |
| 4490 | qla83xx_wait_logic(); |
| 4491 | retry++; |
| 4492 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
| 4493 | "Failed to release IDC lock, retyring=%d\n", retry); |
| 4494 | goto retry_unlock; |
| 4495 | } |
| 4496 | } else if (retry < 10) { |
| 4497 | /* Retry for IDC-unlock */ |
| 4498 | qla83xx_wait_logic(); |
| 4499 | retry++; |
| 4500 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
| 4501 | "Failed to read drv-lockid, retyring=%d\n", retry); |
| 4502 | goto retry_unlock; |
| 4503 | } |
| 4504 | |
| 4505 | return; |
| 4506 | |
| 4507 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 4508 | retry = 0; |
| 4509 | retry_unlock2: |
| 4510 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4511 | if (retry < 10) { |
| 4512 | /* Retry for IDC-unlock */ |
| 4513 | qla83xx_wait_logic(); |
| 4514 | retry++; |
| 4515 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
| 4516 | "Failed to release IDC lock, retyring=%d\n", retry); |
| 4517 | goto retry_unlock2; |
| 4518 | } |
| 4519 | } |
| 4520 | |
| 4521 | return; |
| 4522 | } |
| 4523 | |
| 4524 | int |
| 4525 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4526 | { |
| 4527 | int rval = QLA_SUCCESS; |
| 4528 | struct qla_hw_data *ha = vha->hw; |
| 4529 | uint32_t drv_presence; |
| 4530 | |
| 4531 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4532 | if (rval == QLA_SUCCESS) { |
| 4533 | drv_presence |= (1 << ha->portnum); |
| 4534 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4535 | drv_presence); |
| 4536 | } |
| 4537 | |
| 4538 | return rval; |
| 4539 | } |
| 4540 | |
| 4541 | int |
| 4542 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4543 | { |
| 4544 | int rval = QLA_SUCCESS; |
| 4545 | |
| 4546 | qla83xx_idc_lock(vha, 0); |
| 4547 | rval = __qla83xx_set_drv_presence(vha); |
| 4548 | qla83xx_idc_unlock(vha, 0); |
| 4549 | |
| 4550 | return rval; |
| 4551 | } |
| 4552 | |
| 4553 | int |
| 4554 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4555 | { |
| 4556 | int rval = QLA_SUCCESS; |
| 4557 | struct qla_hw_data *ha = vha->hw; |
| 4558 | uint32_t drv_presence; |
| 4559 | |
| 4560 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4561 | if (rval == QLA_SUCCESS) { |
| 4562 | drv_presence &= ~(1 << ha->portnum); |
| 4563 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4564 | drv_presence); |
| 4565 | } |
| 4566 | |
| 4567 | return rval; |
| 4568 | } |
| 4569 | |
| 4570 | int |
| 4571 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4572 | { |
| 4573 | int rval = QLA_SUCCESS; |
| 4574 | |
| 4575 | qla83xx_idc_lock(vha, 0); |
| 4576 | rval = __qla83xx_clear_drv_presence(vha); |
| 4577 | qla83xx_idc_unlock(vha, 0); |
| 4578 | |
| 4579 | return rval; |
| 4580 | } |
| 4581 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4582 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4583 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 4584 | { |
| 4585 | struct qla_hw_data *ha = vha->hw; |
| 4586 | uint32_t drv_ack, drv_presence; |
| 4587 | unsigned long ack_timeout; |
| 4588 | |
| 4589 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 4590 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 4591 | while (1) { |
| 4592 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 4593 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 4594 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4595 | break; |
| 4596 | |
| 4597 | if (time_after_eq(jiffies, ack_timeout)) { |
| 4598 | ql_log(ql_log_warn, vha, 0xb067, |
| 4599 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 4600 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 4601 | /* |
| 4602 | * The function(s) which did not ack in time are forced |
| 4603 | * to withdraw any further participation in the IDC |
| 4604 | * reset. |
| 4605 | */ |
| 4606 | if (drv_ack != drv_presence) |
| 4607 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4608 | drv_ack); |
| 4609 | break; |
| 4610 | } |
| 4611 | |
| 4612 | qla83xx_idc_unlock(vha, 0); |
| 4613 | msleep(1000); |
| 4614 | qla83xx_idc_lock(vha, 0); |
| 4615 | } |
| 4616 | |
| 4617 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 4618 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 4619 | } |
| 4620 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4621 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4622 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 4623 | { |
| 4624 | int rval = QLA_SUCCESS; |
| 4625 | uint32_t idc_control; |
| 4626 | |
| 4627 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 4628 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 4629 | |
| 4630 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 4631 | __qla83xx_get_idc_control(vha, &idc_control); |
| 4632 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 4633 | __qla83xx_set_idc_control(vha, 0); |
| 4634 | |
| 4635 | qla83xx_idc_unlock(vha, 0); |
| 4636 | rval = qla83xx_restart_nic_firmware(vha); |
| 4637 | qla83xx_idc_lock(vha, 0); |
| 4638 | |
| 4639 | if (rval != QLA_SUCCESS) { |
| 4640 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 4641 | "Failed to restart NIC f/w.\n"); |
| 4642 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 4643 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 4644 | } else { |
| 4645 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 4646 | "Success in restarting nic f/w.\n"); |
| 4647 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 4648 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 4649 | } |
| 4650 | |
| 4651 | return rval; |
| 4652 | } |
| 4653 | |
| 4654 | /* Assumes idc_lock always held on entry */ |
| 4655 | int |
| 4656 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 4657 | { |
| 4658 | struct qla_hw_data *ha = base_vha->hw; |
| 4659 | int rval = QLA_SUCCESS; |
| 4660 | unsigned long dev_init_timeout; |
| 4661 | uint32_t dev_state; |
| 4662 | |
| 4663 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 4664 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 4665 | |
| 4666 | while (1) { |
| 4667 | |
| 4668 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 4669 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 4670 | "Initialization TIMEOUT!\n"); |
| 4671 | /* Init timeout. Disable further NIC Core |
| 4672 | * communication. |
| 4673 | */ |
| 4674 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4675 | QLA8XXX_DEV_FAILED); |
| 4676 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 4677 | "HW State: FAILED.\n"); |
| 4678 | } |
| 4679 | |
| 4680 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4681 | switch (dev_state) { |
| 4682 | case QLA8XXX_DEV_READY: |
| 4683 | if (ha->flags.nic_core_reset_owner) |
| 4684 | qla83xx_idc_audit(base_vha, |
| 4685 | IDC_AUDIT_COMPLETION); |
| 4686 | ha->flags.nic_core_reset_owner = 0; |
| 4687 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 4688 | "Reset_owner reset by 0x%x.\n", |
| 4689 | ha->portnum); |
| 4690 | goto exit; |
| 4691 | case QLA8XXX_DEV_COLD: |
| 4692 | if (ha->flags.nic_core_reset_owner) |
| 4693 | rval = qla83xx_device_bootstrap(base_vha); |
| 4694 | else { |
| 4695 | /* Wait for AEN to change device-state */ |
| 4696 | qla83xx_idc_unlock(base_vha, 0); |
| 4697 | msleep(1000); |
| 4698 | qla83xx_idc_lock(base_vha, 0); |
| 4699 | } |
| 4700 | break; |
| 4701 | case QLA8XXX_DEV_INITIALIZING: |
| 4702 | /* Wait for AEN to change device-state */ |
| 4703 | qla83xx_idc_unlock(base_vha, 0); |
| 4704 | msleep(1000); |
| 4705 | qla83xx_idc_lock(base_vha, 0); |
| 4706 | break; |
| 4707 | case QLA8XXX_DEV_NEED_RESET: |
| 4708 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 4709 | qla83xx_need_reset_handler(base_vha); |
| 4710 | else { |
| 4711 | /* Wait for AEN to change device-state */ |
| 4712 | qla83xx_idc_unlock(base_vha, 0); |
| 4713 | msleep(1000); |
| 4714 | qla83xx_idc_lock(base_vha, 0); |
| 4715 | } |
| 4716 | /* reset timeout value after need reset handler */ |
| 4717 | dev_init_timeout = jiffies + |
| 4718 | (ha->fcoe_dev_init_timeout * HZ); |
| 4719 | break; |
| 4720 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 4721 | /* XXX: DEBUG for now */ |
| 4722 | qla83xx_idc_unlock(base_vha, 0); |
| 4723 | msleep(1000); |
| 4724 | qla83xx_idc_lock(base_vha, 0); |
| 4725 | break; |
| 4726 | case QLA8XXX_DEV_QUIESCENT: |
| 4727 | /* XXX: DEBUG for now */ |
| 4728 | if (ha->flags.quiesce_owner) |
| 4729 | goto exit; |
| 4730 | |
| 4731 | qla83xx_idc_unlock(base_vha, 0); |
| 4732 | msleep(1000); |
| 4733 | qla83xx_idc_lock(base_vha, 0); |
| 4734 | dev_init_timeout = jiffies + |
| 4735 | (ha->fcoe_dev_init_timeout * HZ); |
| 4736 | break; |
| 4737 | case QLA8XXX_DEV_FAILED: |
| 4738 | if (ha->flags.nic_core_reset_owner) |
| 4739 | qla83xx_idc_audit(base_vha, |
| 4740 | IDC_AUDIT_COMPLETION); |
| 4741 | ha->flags.nic_core_reset_owner = 0; |
| 4742 | __qla83xx_clear_drv_presence(base_vha); |
| 4743 | qla83xx_idc_unlock(base_vha, 0); |
| 4744 | qla8xxx_dev_failed_handler(base_vha); |
| 4745 | rval = QLA_FUNCTION_FAILED; |
| 4746 | qla83xx_idc_lock(base_vha, 0); |
| 4747 | goto exit; |
| 4748 | case QLA8XXX_BAD_VALUE: |
| 4749 | qla83xx_idc_unlock(base_vha, 0); |
| 4750 | msleep(1000); |
| 4751 | qla83xx_idc_lock(base_vha, 0); |
| 4752 | break; |
| 4753 | default: |
| 4754 | ql_log(ql_log_warn, base_vha, 0xb071, |
| 4755 | "Unknow Device State: %x.\n", dev_state); |
| 4756 | qla83xx_idc_unlock(base_vha, 0); |
| 4757 | qla8xxx_dev_failed_handler(base_vha); |
| 4758 | rval = QLA_FUNCTION_FAILED; |
| 4759 | qla83xx_idc_lock(base_vha, 0); |
| 4760 | goto exit; |
| 4761 | } |
| 4762 | } |
| 4763 | |
| 4764 | exit: |
| 4765 | return rval; |
| 4766 | } |
| 4767 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 4768 | void |
| 4769 | qla2x00_disable_board_on_pci_error(struct work_struct *work) |
| 4770 | { |
| 4771 | struct qla_hw_data *ha = container_of(work, struct qla_hw_data, |
| 4772 | board_disable); |
| 4773 | struct pci_dev *pdev = ha->pdev; |
| 4774 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4775 | |
| 4776 | ql_log(ql_log_warn, base_vha, 0x015b, |
| 4777 | "Disabling adapter.\n"); |
| 4778 | |
| 4779 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 4780 | |
| 4781 | qla2x00_delete_all_vps(ha, base_vha); |
| 4782 | |
| 4783 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 4784 | |
| 4785 | qla2x00_dfs_remove(base_vha); |
| 4786 | |
| 4787 | qla84xx_put_chip(base_vha); |
| 4788 | |
| 4789 | if (base_vha->timer_active) |
| 4790 | qla2x00_stop_timer(base_vha); |
| 4791 | |
| 4792 | base_vha->flags.online = 0; |
| 4793 | |
| 4794 | qla2x00_destroy_deferred_work(ha); |
| 4795 | |
| 4796 | /* |
| 4797 | * Do not try to stop beacon blink as it will issue a mailbox |
| 4798 | * command. |
| 4799 | */ |
| 4800 | qla2x00_free_sysfs_attr(base_vha, false); |
| 4801 | |
| 4802 | fc_remove_host(base_vha->host); |
| 4803 | |
| 4804 | scsi_remove_host(base_vha->host); |
| 4805 | |
| 4806 | base_vha->flags.init_done = 0; |
| 4807 | qla25xx_delete_queues(base_vha); |
| 4808 | qla2x00_free_irqs(base_vha); |
| 4809 | qla2x00_free_fcports(base_vha); |
| 4810 | qla2x00_mem_free(ha); |
| 4811 | qla82xx_md_free(base_vha); |
| 4812 | qla2x00_free_queues(ha); |
| 4813 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 4814 | qla2x00_unmap_iobases(ha); |
| 4815 | |
| 4816 | pci_release_selected_regions(ha->pdev, ha->bars); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 4817 | pci_disable_pcie_error_reporting(pdev); |
| 4818 | pci_disable_device(pdev); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 4819 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 4820 | /* |
| 4821 | * Let qla2x00_remove_one cleanup qla_hw_data on device removal. |
| 4822 | */ |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 4823 | } |
| 4824 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4825 | /************************************************************************** |
| 4826 | * qla2x00_do_dpc |
| 4827 | * This kernel thread is a task that is schedule by the interrupt handler |
| 4828 | * to perform the background processing for interrupts. |
| 4829 | * |
| 4830 | * Notes: |
| 4831 | * This task always run in the context of a kernel thread. It |
| 4832 | * is kick-off by the driver's detect code and starts up |
| 4833 | * up one per adapter. It immediately goes to sleep and waits for |
| 4834 | * some fibre event. When either the interrupt handler or |
| 4835 | * the timer routine detects a event it will one of the task |
| 4836 | * bits then wake us up. |
| 4837 | **************************************************************************/ |
| 4838 | static int |
| 4839 | qla2x00_do_dpc(void *data) |
| 4840 | { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4841 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4842 | scsi_qla_host_t *base_vha; |
| 4843 | struct qla_hw_data *ha; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 4844 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4845 | ha = (struct qla_hw_data *)data; |
| 4846 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4847 | |
Dongsheng Yang | 8698a74 | 2014-03-11 18:09:12 +0800 | [diff] [blame] | 4848 | set_user_nice(current, MIN_NICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4849 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 4850 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4851 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4852 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 4853 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4854 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4855 | schedule(); |
| 4856 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4857 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4858 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 4859 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4860 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4861 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4862 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 4863 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4864 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4865 | } |
| 4866 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4867 | ha->dpc_active = 1; |
| 4868 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4869 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 4870 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 4871 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4872 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4873 | qla2x00_do_work(base_vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4874 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 4875 | if (IS_P3P_TYPE(ha)) { |
| 4876 | if (IS_QLA8044(ha)) { |
| 4877 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 4878 | &base_vha->dpc_flags)) { |
| 4879 | qla8044_idc_lock(ha); |
| 4880 | qla8044_wr_direct(base_vha, |
| 4881 | QLA8044_CRB_DEV_STATE_INDEX, |
| 4882 | QLA8XXX_DEV_FAILED); |
| 4883 | qla8044_idc_unlock(ha); |
| 4884 | ql_log(ql_log_info, base_vha, 0x4004, |
| 4885 | "HW State: FAILED.\n"); |
| 4886 | qla8044_device_state_handler(base_vha); |
| 4887 | continue; |
| 4888 | } |
| 4889 | |
| 4890 | } else { |
| 4891 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 4892 | &base_vha->dpc_flags)) { |
| 4893 | qla82xx_idc_lock(ha); |
| 4894 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
| 4895 | QLA8XXX_DEV_FAILED); |
| 4896 | qla82xx_idc_unlock(ha); |
| 4897 | ql_log(ql_log_info, base_vha, 0x0151, |
| 4898 | "HW State: FAILED.\n"); |
| 4899 | qla82xx_device_state_handler(base_vha); |
| 4900 | continue; |
| 4901 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4902 | } |
| 4903 | |
| 4904 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 4905 | &base_vha->dpc_flags)) { |
| 4906 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4907 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 4908 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4909 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 4910 | &base_vha->dpc_flags))) { |
| 4911 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 4912 | /* FCoE-ctx reset failed. |
| 4913 | * Escalate to chip-reset |
| 4914 | */ |
| 4915 | set_bit(ISP_ABORT_NEEDED, |
| 4916 | &base_vha->dpc_flags); |
| 4917 | } |
| 4918 | clear_bit(ABORT_ISP_ACTIVE, |
| 4919 | &base_vha->dpc_flags); |
| 4920 | } |
| 4921 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4922 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 4923 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4924 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4925 | } else if (IS_QLAFX00(ha)) { |
| 4926 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 4927 | &base_vha->dpc_flags)) { |
| 4928 | ql_dbg(ql_dbg_dpc, base_vha, 0x4020, |
| 4929 | "Firmware Reset Recovery\n"); |
| 4930 | if (qlafx00_reset_initialize(base_vha)) { |
| 4931 | /* Failed. Abort isp later. */ |
| 4932 | if (!test_bit(UNLOADING, |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 4933 | &base_vha->dpc_flags)) { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4934 | set_bit(ISP_UNRECOVERABLE, |
| 4935 | &base_vha->dpc_flags); |
| 4936 | ql_dbg(ql_dbg_dpc, base_vha, |
| 4937 | 0x4021, |
| 4938 | "Reset Recovery Failed\n"); |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 4939 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4940 | } |
| 4941 | } |
| 4942 | |
| 4943 | if (test_and_clear_bit(FX00_TARGET_SCAN, |
| 4944 | &base_vha->dpc_flags)) { |
| 4945 | ql_dbg(ql_dbg_dpc, base_vha, 0x4022, |
| 4946 | "ISPFx00 Target Scan scheduled\n"); |
| 4947 | if (qlafx00_rescan_isp(base_vha)) { |
| 4948 | if (!test_bit(UNLOADING, |
| 4949 | &base_vha->dpc_flags)) |
| 4950 | set_bit(ISP_UNRECOVERABLE, |
| 4951 | &base_vha->dpc_flags); |
| 4952 | ql_dbg(ql_dbg_dpc, base_vha, 0x401e, |
| 4953 | "ISPFx00 Target Scan Failed\n"); |
| 4954 | } |
| 4955 | ql_dbg(ql_dbg_dpc, base_vha, 0x401f, |
| 4956 | "ISPFx00 Target Scan End\n"); |
| 4957 | } |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 4958 | if (test_and_clear_bit(FX00_HOST_INFO_RESEND, |
| 4959 | &base_vha->dpc_flags)) { |
| 4960 | ql_dbg(ql_dbg_dpc, base_vha, 0x4023, |
| 4961 | "ISPFx00 Host Info resend scheduled\n"); |
| 4962 | qlafx00_fx_disc(base_vha, |
| 4963 | &base_vha->hw->mr.fcport, |
| 4964 | FXDISC_REG_HOST_INFO); |
| 4965 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4966 | } |
| 4967 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4968 | if (test_and_clear_bit(ISP_ABORT_NEEDED, |
| 4969 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4970 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4971 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 4972 | "ISP abort scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4973 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4974 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4975 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4976 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4977 | /* failed. retry later */ |
| 4978 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4979 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4980 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4981 | clear_bit(ABORT_ISP_ACTIVE, |
| 4982 | &base_vha->dpc_flags); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 4983 | } |
| 4984 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4985 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 4986 | "ISP abort end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4987 | } |
| 4988 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 4989 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 4990 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4991 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 4992 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 4993 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4994 | if (test_bit(SCR_PENDING, &base_vha->dpc_flags)) { |
| 4995 | int ret; |
| 4996 | ret = qla2x00_send_change_request(base_vha, 0x3, 0); |
| 4997 | if (ret != QLA_SUCCESS) |
| 4998 | ql_log(ql_log_warn, base_vha, 0x121, |
| 4999 | "Failed to enable receiving of RSCN " |
| 5000 | "requests: 0x%x.\n", ret); |
| 5001 | clear_bit(SCR_PENDING, &base_vha->dpc_flags); |
| 5002 | } |
| 5003 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5004 | if (IS_QLAFX00(ha)) |
| 5005 | goto loop_resync_check; |
| 5006 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5007 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5008 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 5009 | "Quiescence mode scheduled.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5010 | if (IS_P3P_TYPE(ha)) { |
| 5011 | if (IS_QLA82XX(ha)) |
| 5012 | qla82xx_device_state_handler(base_vha); |
| 5013 | if (IS_QLA8044(ha)) |
| 5014 | qla8044_device_state_handler(base_vha); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5015 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5016 | &base_vha->dpc_flags); |
| 5017 | if (!ha->flags.quiesce_owner) { |
| 5018 | qla2x00_perform_loop_resync(base_vha); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5019 | if (IS_QLA82XX(ha)) { |
| 5020 | qla82xx_idc_lock(ha); |
| 5021 | qla82xx_clear_qsnt_ready( |
| 5022 | base_vha); |
| 5023 | qla82xx_idc_unlock(ha); |
| 5024 | } else if (IS_QLA8044(ha)) { |
| 5025 | qla8044_idc_lock(ha); |
| 5026 | qla8044_clear_qsnt_ready( |
| 5027 | base_vha); |
| 5028 | qla8044_idc_unlock(ha); |
| 5029 | } |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5030 | } |
| 5031 | } else { |
| 5032 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5033 | &base_vha->dpc_flags); |
| 5034 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5035 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5036 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 5037 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5038 | } |
| 5039 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5040 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5041 | &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5042 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5043 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5044 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 5045 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5046 | qla2x00_rst_aen(base_vha); |
| 5047 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5048 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 5049 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5050 | } |
| 5051 | |
| 5052 | /* Retry each device up to login retry count */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5053 | if ((test_and_clear_bit(RELOGIN_NEEDED, |
| 5054 | &base_vha->dpc_flags)) && |
| 5055 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 5056 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5057 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5058 | ql_dbg(ql_dbg_dpc, base_vha, 0x400d, |
| 5059 | "Relogin scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5060 | qla2x00_relogin(base_vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5061 | ql_dbg(ql_dbg_dpc, base_vha, 0x400e, |
| 5062 | "Relogin end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5063 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5064 | loop_resync_check: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5065 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5066 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5067 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5068 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 5069 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5070 | |
| 5071 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5072 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5073 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5074 | rval = qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5075 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5076 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 5077 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5078 | } |
| 5079 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5080 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 5081 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5082 | } |
| 5083 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5084 | if (IS_QLAFX00(ha)) |
| 5085 | goto intr_on_check; |
| 5086 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5087 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 5088 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 5089 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 5090 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 5091 | } |
| 5092 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5093 | intr_on_check: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5094 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 5095 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5096 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5097 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
Himanshu Madani | 90b604f | 2014-04-11 16:54:40 -0400 | [diff] [blame] | 5098 | &base_vha->dpc_flags)) { |
| 5099 | if (ha->beacon_blink_led == 1) |
| 5100 | ha->isp_ops->beacon_blink(base_vha); |
| 5101 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5102 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5103 | if (!IS_QLAFX00(ha)) |
| 5104 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5105 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5106 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5107 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5108 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5109 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5110 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5111 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5112 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 5113 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5114 | |
| 5115 | /* |
| 5116 | * Make sure that nobody tries to wake us up again. |
| 5117 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5118 | ha->dpc_active = 0; |
| 5119 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5120 | /* Cleanup any residual CTX SRBs. */ |
| 5121 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5122 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5123 | return 0; |
| 5124 | } |
| 5125 | |
| 5126 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5127 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5128 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5129 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5130 | struct task_struct *t = ha->dpc_thread; |
| 5131 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5132 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5133 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5134 | } |
| 5135 | |
| 5136 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5137 | * qla2x00_rst_aen |
| 5138 | * Processes asynchronous reset. |
| 5139 | * |
| 5140 | * Input: |
| 5141 | * ha = adapter block pointer. |
| 5142 | */ |
| 5143 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5144 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5145 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5146 | if (vha->flags.online && !vha->flags.reset_active && |
| 5147 | !atomic_read(&vha->loop_down_timer) && |
| 5148 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5149 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5150 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5151 | |
| 5152 | /* |
| 5153 | * Issue marker command only when we are going to start |
| 5154 | * the I/O. |
| 5155 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5156 | vha->marker_needed = 1; |
| 5157 | } while (!atomic_read(&vha->loop_down_timer) && |
| 5158 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5159 | } |
| 5160 | } |
| 5161 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5162 | /************************************************************************** |
| 5163 | * qla2x00_timer |
| 5164 | * |
| 5165 | * Description: |
| 5166 | * One second timer |
| 5167 | * |
| 5168 | * Context: Interrupt |
| 5169 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5170 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5171 | qla2x00_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5172 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5173 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5174 | int start_dpc = 0; |
| 5175 | int index; |
| 5176 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5177 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5178 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5179 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5180 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5181 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5182 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 5183 | "EEH = %d, restarting timer.\n", |
| 5184 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5185 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 5186 | return; |
| 5187 | } |
| 5188 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5189 | /* |
| 5190 | * Hardware read to raise pending EEH errors during mailbox waits. If |
| 5191 | * the read returns -1 then disable the board. |
| 5192 | */ |
| 5193 | if (!pci_channel_offline(ha->pdev)) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5194 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Joe Lawrence | c821e0d | 2014-08-26 17:11:41 -0400 | [diff] [blame] | 5195 | qla2x00_check_reg16_for_disconnect(vha, w); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5196 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5197 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5198 | /* Make sure qla82xx_watchdog is run only for physical port */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5199 | if (!vha->vp_idx && IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5200 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 5201 | start_dpc++; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5202 | if (IS_QLA82XX(ha)) |
| 5203 | qla82xx_watchdog(vha); |
| 5204 | else if (IS_QLA8044(ha)) |
| 5205 | qla8044_watchdog(vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5206 | } |
| 5207 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5208 | if (!vha->vp_idx && IS_QLAFX00(ha)) |
| 5209 | qlafx00_timer_routine(vha); |
| 5210 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5211 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5212 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5213 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 5214 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5215 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5216 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5217 | if (atomic_read(&vha->loop_down_timer) == |
| 5218 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5219 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5220 | ql_log(ql_log_info, vha, 0x6008, |
| 5221 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5222 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5223 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 5224 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5225 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5226 | /* |
| 5227 | * Schedule an ISP abort to return any FCP2-device |
| 5228 | * commands. |
| 5229 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5230 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5231 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5232 | spin_lock_irqsave(&ha->hardware_lock, |
| 5233 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5234 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5235 | for (index = 1; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 5236 | index < req->num_outstanding_cmds; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5237 | index++) { |
| 5238 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 5239 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5240 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5241 | if (!sp) |
| 5242 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 5243 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 5244 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5245 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5246 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5247 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5248 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5249 | if (IS_QLA82XX(ha)) |
| 5250 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5251 | &vha->dpc_flags); |
| 5252 | else |
| 5253 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5254 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5255 | break; |
| 5256 | } |
| 5257 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5258 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5259 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5260 | start_dpc++; |
| 5261 | } |
| 5262 | |
| 5263 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5264 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 5265 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5266 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5267 | "Loop down - aborting ISP.\n"); |
| 5268 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5269 | if (IS_QLA82XX(ha)) |
| 5270 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5271 | &vha->dpc_flags); |
| 5272 | else |
| 5273 | set_bit(ISP_ABORT_NEEDED, |
| 5274 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5275 | } |
| 5276 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5277 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 5278 | "Loop down - seconds remaining %d.\n", |
| 5279 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5280 | } |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5281 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 5282 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5283 | /* There is no beacon_blink function for ISP82xx */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5284 | if (!IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5285 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 5286 | start_dpc++; |
| 5287 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5288 | } |
| 5289 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5290 | /* Process any deferred work. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5291 | if (!list_empty(&vha->work_list)) |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5292 | start_dpc++; |
| 5293 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5294 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5295 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 5296 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 5297 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5298 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5299 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 5300 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5301 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 5302 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5303 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5304 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5305 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 5306 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 5307 | "fcport_update_needed=%d start_dpc=%d " |
| 5308 | "reset_marker_needed=%d", |
| 5309 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 5310 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 5311 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 5312 | start_dpc, |
| 5313 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 5314 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 5315 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 5316 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5317 | "relogin_needed=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5318 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 5319 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 5320 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 5321 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5322 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5323 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5324 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5325 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5326 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5327 | } |
| 5328 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5329 | /* Firmware interface routines. */ |
| 5330 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5331 | #define FW_BLOBS 11 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5332 | #define FW_ISP21XX 0 |
| 5333 | #define FW_ISP22XX 1 |
| 5334 | #define FW_ISP2300 2 |
| 5335 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5336 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5337 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5338 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5339 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5340 | #define FW_ISP2031 8 |
| 5341 | #define FW_ISP8031 9 |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5342 | #define FW_ISP27XX 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5343 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5344 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 5345 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 5346 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 5347 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 5348 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5349 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5350 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5351 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5352 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 5353 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5354 | #define FW_FILE_ISP27XX "ql2700_fw.bin" |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5355 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5356 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5357 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5358 | |
| 5359 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5360 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 5361 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 5362 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 5363 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 5364 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5365 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5366 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5367 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5368 | { .name = FW_FILE_ISP2031, }, |
| 5369 | { .name = FW_FILE_ISP8031, }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5370 | { .name = FW_FILE_ISP27XX, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5371 | }; |
| 5372 | |
| 5373 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5374 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5375 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5376 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5377 | struct fw_blob *blob; |
| 5378 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5379 | if (IS_QLA2100(ha)) { |
| 5380 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 5381 | } else if (IS_QLA2200(ha)) { |
| 5382 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5383 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5384 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5385 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5386 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5387 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5388 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5389 | } else if (IS_QLA25XX(ha)) { |
| 5390 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5391 | } else if (IS_QLA81XX(ha)) { |
| 5392 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5393 | } else if (IS_QLA82XX(ha)) { |
| 5394 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5395 | } else if (IS_QLA2031(ha)) { |
| 5396 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 5397 | } else if (IS_QLA8031(ha)) { |
| 5398 | blob = &qla_fw_blobs[FW_ISP8031]; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5399 | } else if (IS_QLA27XX(ha)) { |
| 5400 | blob = &qla_fw_blobs[FW_ISP27XX]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 5401 | } else { |
| 5402 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5403 | } |
| 5404 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5405 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5406 | if (blob->fw) |
| 5407 | goto out; |
| 5408 | |
| 5409 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5410 | ql_log(ql_log_warn, vha, 0x0063, |
| 5411 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5412 | blob->fw = NULL; |
| 5413 | blob = NULL; |
| 5414 | goto out; |
| 5415 | } |
| 5416 | |
| 5417 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5418 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5419 | return blob; |
| 5420 | } |
| 5421 | |
| 5422 | static void |
| 5423 | qla2x00_release_firmware(void) |
| 5424 | { |
| 5425 | int idx; |
| 5426 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5427 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5428 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 5429 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5430 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5431 | } |
| 5432 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5433 | static pci_ers_result_t |
| 5434 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 5435 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5436 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 5437 | struct qla_hw_data *ha = vha->hw; |
| 5438 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5439 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 5440 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 5441 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5442 | switch (state) { |
| 5443 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5444 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5445 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 5446 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5447 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5448 | /* For ISP82XX complete any pending mailbox cmd */ |
| 5449 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5450 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 5451 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 5452 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5453 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5454 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5455 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 5456 | /* Return back all IOs */ |
| 5457 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5458 | return PCI_ERS_RESULT_NEED_RESET; |
| 5459 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5460 | ha->flags.pci_channel_io_perm_failure = 1; |
| 5461 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5462 | return PCI_ERS_RESULT_DISCONNECT; |
| 5463 | } |
| 5464 | return PCI_ERS_RESULT_NEED_RESET; |
| 5465 | } |
| 5466 | |
| 5467 | static pci_ers_result_t |
| 5468 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 5469 | { |
| 5470 | int risc_paused = 0; |
| 5471 | uint32_t stat; |
| 5472 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5473 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5474 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5475 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 5476 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 5477 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 5478 | if (IS_QLA82XX(ha)) |
| 5479 | return PCI_ERS_RESULT_RECOVERED; |
| 5480 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5481 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 5482 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 5483 | stat = RD_REG_DWORD(®->hccr); |
| 5484 | if (stat & HCCR_RISC_PAUSE) |
| 5485 | risc_paused = 1; |
| 5486 | } else if (IS_QLA23XX(ha)) { |
| 5487 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 5488 | if (stat & HSR_RISC_PAUSED) |
| 5489 | risc_paused = 1; |
| 5490 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 5491 | stat = RD_REG_DWORD(®24->host_status); |
| 5492 | if (stat & HSRX_RISC_PAUSED) |
| 5493 | risc_paused = 1; |
| 5494 | } |
| 5495 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 5496 | |
| 5497 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5498 | ql_log(ql_log_info, base_vha, 0x9003, |
| 5499 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5500 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5501 | |
| 5502 | return PCI_ERS_RESULT_NEED_RESET; |
| 5503 | } else |
| 5504 | return PCI_ERS_RESULT_RECOVERED; |
| 5505 | } |
| 5506 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5507 | static uint32_t |
| 5508 | qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5509 | { |
| 5510 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 5511 | uint32_t drv_active = 0; |
| 5512 | struct qla_hw_data *ha = base_vha->hw; |
| 5513 | int fn; |
| 5514 | struct pci_dev *other_pdev = NULL; |
| 5515 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5516 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 5517 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5518 | |
| 5519 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5520 | |
| 5521 | if (base_vha->flags.online) { |
| 5522 | /* Abort all outstanding commands, |
| 5523 | * so as to be requeued later */ |
| 5524 | qla2x00_abort_isp_cleanup(base_vha); |
| 5525 | } |
| 5526 | |
| 5527 | |
| 5528 | fn = PCI_FUNC(ha->pdev->devfn); |
| 5529 | while (fn > 0) { |
| 5530 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5531 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 5532 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5533 | other_pdev = |
| 5534 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 5535 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 5536 | fn)); |
| 5537 | |
| 5538 | if (!other_pdev) |
| 5539 | continue; |
| 5540 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5541 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 5542 | "Found PCI func available and enable at 0x%x.\n", |
| 5543 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5544 | pci_dev_put(other_pdev); |
| 5545 | break; |
| 5546 | } |
| 5547 | pci_dev_put(other_pdev); |
| 5548 | } |
| 5549 | |
| 5550 | if (!fn) { |
| 5551 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5552 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 5553 | "This devfn is reset owner = 0x%x.\n", |
| 5554 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5555 | qla82xx_idc_lock(ha); |
| 5556 | |
| 5557 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5558 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5559 | |
| 5560 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 5561 | QLA82XX_IDC_VERSION); |
| 5562 | |
| 5563 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5564 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 5565 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5566 | |
| 5567 | qla82xx_idc_unlock(ha); |
| 5568 | /* Reset if device is not already reset |
| 5569 | * drv_active would be 0 if a reset has already been done |
| 5570 | */ |
| 5571 | if (drv_active) |
| 5572 | rval = qla82xx_start_firmware(base_vha); |
| 5573 | else |
| 5574 | rval = QLA_SUCCESS; |
| 5575 | qla82xx_idc_lock(ha); |
| 5576 | |
| 5577 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5578 | ql_log(ql_log_info, base_vha, 0x900b, |
| 5579 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5580 | qla82xx_clear_drv_active(ha); |
| 5581 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5582 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5583 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5584 | ql_log(ql_log_info, base_vha, 0x900c, |
| 5585 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5586 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5587 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5588 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5589 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5590 | rval = qla82xx_restart_isp(base_vha); |
| 5591 | qla82xx_idc_lock(ha); |
| 5592 | /* Clear driver state register */ |
| 5593 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 5594 | qla82xx_set_drv_active(base_vha); |
| 5595 | } |
| 5596 | qla82xx_idc_unlock(ha); |
| 5597 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5598 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 5599 | "This devfn is not reset owner = 0x%x.\n", |
| 5600 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5601 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5602 | QLA8XXX_DEV_READY)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5603 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5604 | rval = qla82xx_restart_isp(base_vha); |
| 5605 | qla82xx_idc_lock(ha); |
| 5606 | qla82xx_set_drv_active(base_vha); |
| 5607 | qla82xx_idc_unlock(ha); |
| 5608 | } |
| 5609 | } |
| 5610 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5611 | |
| 5612 | return rval; |
| 5613 | } |
| 5614 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5615 | static pci_ers_result_t |
| 5616 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 5617 | { |
| 5618 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5619 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5620 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5621 | struct rsp_que *rsp; |
| 5622 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5623 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5624 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 5625 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5626 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5627 | /* Workaround: qla2xxx driver which access hardware earlier |
| 5628 | * needs error state to be pci_channel_io_online. |
| 5629 | * Otherwise mailbox command timesout. |
| 5630 | */ |
| 5631 | pdev->error_state = pci_channel_io_normal; |
| 5632 | |
| 5633 | pci_restore_state(pdev); |
| 5634 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 5635 | /* pci_restore_state() clears the saved_state flag of the device |
| 5636 | * save restored state which resets saved_state flag |
| 5637 | */ |
| 5638 | pci_save_state(pdev); |
| 5639 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 5640 | if (ha->mem_only) |
| 5641 | rc = pci_enable_device_mem(pdev); |
| 5642 | else |
| 5643 | rc = pci_enable_device(pdev); |
| 5644 | |
| 5645 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5646 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5647 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5648 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5649 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5650 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5651 | rsp = ha->rsp_q_map[0]; |
| 5652 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5653 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5654 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5655 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5656 | goto exit_slot_reset; |
| 5657 | |
| 5658 | if (IS_QLA82XX(ha)) { |
| 5659 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 5660 | ret = PCI_ERS_RESULT_RECOVERED; |
| 5661 | goto exit_slot_reset; |
| 5662 | } else |
| 5663 | goto exit_slot_reset; |
| 5664 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5665 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5666 | while (ha->flags.mbox_busy && retries--) |
| 5667 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5668 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5669 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5670 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5671 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5672 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5673 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5674 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5675 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5676 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 5677 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5678 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5679 | return ret; |
| 5680 | } |
| 5681 | |
| 5682 | static void |
| 5683 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 5684 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5685 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5686 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5687 | int ret; |
| 5688 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5689 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 5690 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5691 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5692 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5693 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5694 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 5695 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5696 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5697 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 5698 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 5699 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5700 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5701 | } |
| 5702 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 5703 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5704 | .error_detected = qla2xxx_pci_error_detected, |
| 5705 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 5706 | .slot_reset = qla2xxx_pci_slot_reset, |
| 5707 | .resume = qla2xxx_pci_resume, |
| 5708 | }; |
| 5709 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5710 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5711 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 5712 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 5713 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 5714 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 5715 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 5716 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 5717 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 5718 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 5719 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5720 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5721 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 5722 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5723 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5724 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5725 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5726 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 5727 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5728 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISPF001) }, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5729 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8044) }, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5730 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2071) }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5731 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2271) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5732 | { 0 }, |
| 5733 | }; |
| 5734 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 5735 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5736 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 5737 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 5738 | .driver = { |
| 5739 | .owner = THIS_MODULE, |
| 5740 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5741 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5742 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 5743 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 5744 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5745 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5746 | }; |
| 5747 | |
Al Viro | 75ef9de | 2013-04-04 19:09:41 -0400 | [diff] [blame] | 5748 | static const struct file_operations apidev_fops = { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5749 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 5750 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5751 | }; |
| 5752 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5753 | /** |
| 5754 | * qla2x00_module_init - Module initialization. |
| 5755 | **/ |
| 5756 | static int __init |
| 5757 | qla2x00_module_init(void) |
| 5758 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5759 | int ret = 0; |
| 5760 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5761 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 5762 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 5763 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5764 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5765 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 5766 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5767 | return -ENOMEM; |
| 5768 | } |
| 5769 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5770 | /* Initialize target kmem_cache and mem_pools */ |
| 5771 | ret = qlt_init(); |
| 5772 | if (ret < 0) { |
| 5773 | kmem_cache_destroy(srb_cachep); |
| 5774 | return ret; |
| 5775 | } else if (ret > 0) { |
| 5776 | /* |
| 5777 | * If initiator mode is explictly disabled by qlt_init(), |
| 5778 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 5779 | * performing scsi_scan_target() during LOOP UP event. |
| 5780 | */ |
| 5781 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 5782 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 5783 | } |
| 5784 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5785 | /* Derive version string. */ |
| 5786 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 5787 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 5788 | strcat(qla2x00_version_str, "-debug"); |
| 5789 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 5790 | qla2xxx_transport_template = |
| 5791 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5792 | if (!qla2xxx_transport_template) { |
| 5793 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5794 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 5795 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5796 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5797 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5798 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5799 | |
| 5800 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 5801 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5802 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 5803 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5804 | } |
| 5805 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5806 | qla2xxx_transport_vport_template = |
| 5807 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 5808 | if (!qla2xxx_transport_vport_template) { |
| 5809 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5810 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5811 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5812 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 5813 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5814 | return -ENODEV; |
| 5815 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5816 | ql_log(ql_log_info, NULL, 0x0005, |
| 5817 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 5818 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5819 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5820 | if (ret) { |
| 5821 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5822 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5823 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5824 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5825 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 5826 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 5827 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5828 | } |
| 5829 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5830 | } |
| 5831 | |
| 5832 | /** |
| 5833 | * qla2x00_module_exit - Module cleanup. |
| 5834 | **/ |
| 5835 | static void __exit |
| 5836 | qla2x00_module_exit(void) |
| 5837 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5838 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5839 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5840 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 5841 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5842 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5843 | if (ctx_cachep) |
| 5844 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5845 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5846 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5847 | } |
| 5848 | |
| 5849 | module_init(qla2x00_module_init); |
| 5850 | module_exit(qla2x00_module_exit); |
| 5851 | |
| 5852 | MODULE_AUTHOR("QLogic Corporation"); |
| 5853 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 5854 | MODULE_LICENSE("GPL"); |
| 5855 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5856 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 5857 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 5858 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 5859 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 5860 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 5861 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |