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); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 83 | module_param_named(logging, ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 84 | MODULE_PARM_DESC(ql2xextended_error_logging, |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 85 | "Option to enable extended error logging,\n" |
| 86 | "\t\tDefault is 0 - no logging. 0x40000000 - Module Init & Probe.\n" |
| 87 | "\t\t0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.\n" |
| 88 | "\t\t0x08000000 - IO tracing. 0x04000000 - DPC Thread.\n" |
| 89 | "\t\t0x02000000 - Async events. 0x01000000 - Timer routines.\n" |
| 90 | "\t\t0x00800000 - User space. 0x00400000 - Task Management.\n" |
| 91 | "\t\t0x00200000 - AER/EEH. 0x00100000 - Multi Q.\n" |
| 92 | "\t\t0x00080000 - P3P Specific. 0x00040000 - Virtual Port.\n" |
| 93 | "\t\t0x00020000 - Buffer Dump. 0x00010000 - Misc.\n" |
Chad Dupuis | 29f9f90 | 2012-11-21 02:40:41 -0500 | [diff] [blame] | 94 | "\t\t0x00008000 - Verbose. 0x00004000 - Target.\n" |
| 95 | "\t\t0x00002000 - Target Mgmt. 0x00001000 - Target TMF.\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 96 | "\t\t0x7fffffff - For enabling all logs, can be too many logs.\n" |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 97 | "\t\t0x1e400000 - Preferred value for capturing essential " |
| 98 | "debug information (equivalent to old " |
| 99 | "ql2xextended_error_logging=1).\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 100 | "\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] | 101 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 102 | int ql2xshiftctondsd = 6; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 103 | module_param(ql2xshiftctondsd, int, S_IRUGO); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 104 | MODULE_PARM_DESC(ql2xshiftctondsd, |
| 105 | "Set to control shifting of command type processing " |
| 106 | "based on total number of SG elements."); |
| 107 | |
Andrew Vasquez | 7e47e5c | 2008-04-24 15:21:26 -0700 | [diff] [blame] | 108 | int ql2xfdmienable=1; |
Himanshu Madhani | de187df | 2014-09-25 05:16:50 -0400 | [diff] [blame] | 109 | module_param(ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 110 | module_param_named(fdmi, ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 111 | MODULE_PARM_DESC(ql2xfdmienable, |
Ferenc Wagner | 7794a5a | 2010-03-23 18:14:59 +0100 | [diff] [blame] | 112 | "Enables FDMI registrations. " |
| 113 | "0 - no FDMI. Default is 1 - perform FDMI."); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 114 | |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 115 | #define MAX_Q_DEPTH 32 |
| 116 | static int ql2xmaxqdepth = MAX_Q_DEPTH; |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 117 | module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR); |
| 118 | MODULE_PARM_DESC(ql2xmaxqdepth, |
Chad Dupuis | e92e4a8 | 2012-08-22 14:21:23 -0400 | [diff] [blame] | 119 | "Maximum queue depth to set for each LUN. " |
| 120 | "Default is 32."); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 121 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 122 | int ql2xenabledif = 2; |
| 123 | module_param(ql2xenabledif, int, S_IRUGO); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 124 | MODULE_PARM_DESC(ql2xenabledif, |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 125 | " Enable T10-CRC-DIF:\n" |
| 126 | " Default is 2.\n" |
| 127 | " 0 -- No DIF Support\n" |
| 128 | " 1 -- Enable DIF for all types\n" |
| 129 | " 2 -- Enable DIF for all types, except Type 0.\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 130 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 131 | int ql2xenablehba_err_chk = 2; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 132 | module_param(ql2xenablehba_err_chk, int, S_IRUGO|S_IWUSR); |
| 133 | MODULE_PARM_DESC(ql2xenablehba_err_chk, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 134 | " Enable T10-CRC-DIF Error isolation by HBA:\n" |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 135 | " Default is 2.\n" |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 136 | " 0 -- Error isolation disabled\n" |
| 137 | " 1 -- Error isolation enabled only for DIX Type 0\n" |
| 138 | " 2 -- Error isolation enabled for all Types\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 139 | |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 140 | int ql2xiidmaenable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 141 | module_param(ql2xiidmaenable, int, S_IRUGO); |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 142 | MODULE_PARM_DESC(ql2xiidmaenable, |
| 143 | "Enables iIDMA settings " |
| 144 | "Default is 1 - perform iIDMA. 0 - no iIDMA."); |
| 145 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 146 | int ql2xmaxqueues = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 147 | module_param(ql2xmaxqueues, int, S_IRUGO); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 148 | MODULE_PARM_DESC(ql2xmaxqueues, |
| 149 | "Enables MQ settings " |
Joe Perches | ae68230 | 2010-08-10 18:01:21 -0700 | [diff] [blame] | 150 | "Default is 1 for single queue. Set it to number " |
| 151 | "of queues in MQ mode."); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 152 | |
| 153 | int ql2xmultique_tag; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 154 | module_param(ql2xmultique_tag, int, S_IRUGO); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 155 | MODULE_PARM_DESC(ql2xmultique_tag, |
| 156 | "Enables CPU affinity settings for the driver " |
| 157 | "Default is 0 for no affinity of request and response IO. " |
| 158 | "Set it to 1 to turn on the cpu affinity."); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 159 | |
| 160 | int ql2xfwloadbin; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 161 | module_param(ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 162 | module_param_named(fwload, ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 163 | MODULE_PARM_DESC(ql2xfwloadbin, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 164 | "Option to specify location from which to load ISP firmware:.\n" |
| 165 | " 2 -- load firmware via the request_firmware() (hotplug).\n" |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 166 | " interface.\n" |
| 167 | " 1 -- load firmware from flash.\n" |
| 168 | " 0 -- use default semantics.\n"); |
| 169 | |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 170 | int ql2xetsenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 171 | module_param(ql2xetsenable, int, S_IRUGO); |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 172 | MODULE_PARM_DESC(ql2xetsenable, |
| 173 | "Enables firmware ETS burst." |
| 174 | "Default is 0 - skip ETS enablement."); |
| 175 | |
Giridhar Malavali | 6907869 | 2010-05-28 15:08:28 -0700 | [diff] [blame] | 176 | int ql2xdbwr = 1; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 177 | module_param(ql2xdbwr, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 178 | MODULE_PARM_DESC(ql2xdbwr, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 179 | "Option to specify scheme for request queue posting.\n" |
| 180 | " 0 -- Regular doorbell.\n" |
| 181 | " 1 -- CAMRAM doorbell (faster).\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 182 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 183 | int ql2xtargetreset = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 184 | module_param(ql2xtargetreset, int, S_IRUGO); |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 185 | MODULE_PARM_DESC(ql2xtargetreset, |
| 186 | "Enable target reset." |
| 187 | "Default is 1 - use hw defaults."); |
| 188 | |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 189 | int ql2xgffidenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 190 | module_param(ql2xgffidenable, int, S_IRUGO); |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 191 | MODULE_PARM_DESC(ql2xgffidenable, |
| 192 | "Enables GFF_ID checks of port type. " |
| 193 | "Default is 0 - Do not use GFF_ID information."); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 194 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 195 | int ql2xasynctmfenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 196 | module_param(ql2xasynctmfenable, int, S_IRUGO); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 197 | MODULE_PARM_DESC(ql2xasynctmfenable, |
| 198 | "Enables issue of TM IOCBs asynchronously via IOCB mechanism" |
| 199 | "Default is 0 - Issue TM IOCBs via mailbox mechanism."); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 200 | |
| 201 | int ql2xdontresethba; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 202 | module_param(ql2xdontresethba, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 203 | MODULE_PARM_DESC(ql2xdontresethba, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 204 | "Option to specify reset behaviour.\n" |
| 205 | " 0 (Default) -- Reset on failure.\n" |
| 206 | " 1 -- Do not reset on failure.\n"); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 207 | |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 208 | uint64_t ql2xmaxlun = MAX_LUNS; |
| 209 | module_param(ql2xmaxlun, ullong, S_IRUGO); |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 210 | MODULE_PARM_DESC(ql2xmaxlun, |
| 211 | "Defines the maximum LU number to register with the SCSI " |
| 212 | "midlayer. Default is 65535."); |
| 213 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 214 | int ql2xmdcapmask = 0x1F; |
| 215 | module_param(ql2xmdcapmask, int, S_IRUGO); |
| 216 | MODULE_PARM_DESC(ql2xmdcapmask, |
| 217 | "Set the Minidump driver capture mask level. " |
Giridhar Malavali | 6e96fa7 | 2011-11-18 09:03:14 -0800 | [diff] [blame] | 218 | "Default is 0x1F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 219 | |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 220 | int ql2xmdenable = 1; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 221 | module_param(ql2xmdenable, int, S_IRUGO); |
| 222 | MODULE_PARM_DESC(ql2xmdenable, |
| 223 | "Enable/disable MiniDump. " |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 224 | "0 - MiniDump disabled. " |
| 225 | "1 (Default) - MiniDump enabled."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 226 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 227 | int ql2xexlogins = 0; |
| 228 | module_param(ql2xexlogins, uint, S_IRUGO|S_IWUSR); |
| 229 | MODULE_PARM_DESC(ql2xexlogins, |
| 230 | "Number of extended Logins. " |
| 231 | "0 (Default)- Disabled."); |
| 232 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 233 | int ql2xexchoffld = 0; |
| 234 | module_param(ql2xexchoffld, uint, S_IRUGO|S_IWUSR); |
| 235 | MODULE_PARM_DESC(ql2xexchoffld, |
| 236 | "Number of exchanges to offload. " |
| 237 | "0 (Default)- Disabled."); |
| 238 | |
Himanshu Madhani | f198caf | 2016-01-27 12:03:30 -0500 | [diff] [blame] | 239 | int ql2xfwholdabts = 0; |
| 240 | module_param(ql2xfwholdabts, int, S_IRUGO); |
| 241 | MODULE_PARM_DESC(ql2xfwholdabts, |
| 242 | "Allow FW to hold status IOCB until ABTS rsp received. " |
| 243 | "0 (Default) Do not set fw option. " |
| 244 | "1 - Set fw option to hold ABTS."); |
| 245 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 247 | * SCSI host template entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | */ |
| 249 | static int qla2xxx_slave_configure(struct scsi_device * device); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 250 | static int qla2xxx_slave_alloc(struct scsi_device *); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 251 | static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); |
| 252 | static void qla2xxx_scan_start(struct Scsi_Host *); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 253 | static void qla2xxx_slave_destroy(struct scsi_device *); |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 254 | static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | static int qla2xxx_eh_abort(struct scsi_cmnd *); |
| 256 | static int qla2xxx_eh_device_reset(struct scsi_cmnd *); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 257 | static int qla2xxx_eh_target_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); |
| 259 | static int qla2xxx_eh_host_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 261 | static void qla2x00_clear_drv_active(struct qla_hw_data *); |
Saurav Kashyap | 3491255 | 2013-06-25 11:27:18 -0400 | [diff] [blame] | 262 | static void qla2x00_free_device(scsi_qla_host_t *); |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 263 | static void qla83xx_disable_laser(scsi_qla_host_t *vha); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 264 | |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 265 | struct scsi_host_template qla2xxx_driver_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | .module = THIS_MODULE, |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 267 | .name = QLA2XXX_DRIVER_NAME, |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 268 | .queuecommand = qla2xxx_queuecommand, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 269 | |
| 270 | .eh_abort_handler = qla2xxx_eh_abort, |
| 271 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 272 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 273 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 274 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 275 | |
| 276 | .slave_configure = qla2xxx_slave_configure, |
| 277 | |
| 278 | .slave_alloc = qla2xxx_slave_alloc, |
| 279 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 280 | .scan_finished = qla2xxx_scan_finished, |
| 281 | .scan_start = qla2xxx_scan_start, |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 282 | .change_queue_depth = scsi_change_queue_depth, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 283 | .this_id = -1, |
| 284 | .cmd_per_lun = 3, |
| 285 | .use_clustering = ENABLE_CLUSTERING, |
| 286 | .sg_tablesize = SG_ALL, |
| 287 | |
| 288 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 289 | .shost_attrs = qla2x00_host_attrs, |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 290 | |
| 291 | .supported_mode = MODE_INITIATOR, |
Christoph Hellwig | c40ecc1 | 2014-11-13 14:25:11 +0100 | [diff] [blame] | 292 | .track_queue_depth = 1, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 293 | }; |
| 294 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 296 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | /* TODO Convert to inlines |
| 299 | * |
| 300 | * Timer routines |
| 301 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 303 | __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 304 | 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] | 305 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 306 | init_timer(&vha->timer); |
| 307 | vha->timer.expires = jiffies + interval * HZ; |
| 308 | vha->timer.data = (unsigned long)vha; |
| 309 | vha->timer.function = (void (*)(unsigned long))func; |
| 310 | add_timer(&vha->timer); |
| 311 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 315 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 317 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 318 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 319 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 320 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 321 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 322 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 323 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 324 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | } |
| 326 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 327 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 328 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 330 | del_timer_sync(&vha->timer); |
| 331 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | static int qla2x00_do_dpc(void *data); |
| 335 | |
| 336 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 337 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 338 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 339 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 340 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 341 | static void qla2x00_mem_free(struct qla_hw_data *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | /* -------------------------------------------------------------------------- */ |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 344 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 345 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 346 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 347 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 348 | 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] | 349 | GFP_KERNEL); |
| 350 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 351 | ql_log(ql_log_fatal, vha, 0x003b, |
| 352 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 353 | goto fail_req_map; |
| 354 | } |
| 355 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 356 | 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] | 357 | GFP_KERNEL); |
| 358 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 359 | ql_log(ql_log_fatal, vha, 0x003c, |
| 360 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 361 | goto fail_rsp_map; |
| 362 | } |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 363 | /* |
| 364 | * Make sure we record at least the request and response queue zero in |
| 365 | * case we need to free them if part of the probe fails. |
| 366 | */ |
| 367 | ha->rsp_q_map[0] = rsp; |
| 368 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 369 | set_bit(0, ha->rsp_qid_map); |
| 370 | set_bit(0, ha->req_qid_map); |
| 371 | return 1; |
| 372 | |
| 373 | fail_rsp_map: |
| 374 | kfree(ha->req_q_map); |
| 375 | ha->req_q_map = NULL; |
| 376 | fail_req_map: |
| 377 | return -ENOMEM; |
| 378 | } |
| 379 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 380 | 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] | 381 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 382 | if (IS_QLAFX00(ha)) { |
| 383 | if (req && req->ring_fx00) |
| 384 | dma_free_coherent(&ha->pdev->dev, |
| 385 | (req->length_fx00 + 1) * sizeof(request_t), |
| 386 | req->ring_fx00, req->dma_fx00); |
| 387 | } else if (req && req->ring) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 388 | dma_free_coherent(&ha->pdev->dev, |
| 389 | (req->length + 1) * sizeof(request_t), |
| 390 | req->ring, req->dma); |
| 391 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 392 | if (req) |
| 393 | kfree(req->outstanding_cmds); |
| 394 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 395 | kfree(req); |
| 396 | req = NULL; |
| 397 | } |
| 398 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 399 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 400 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 401 | if (IS_QLAFX00(ha)) { |
| 402 | if (rsp && rsp->ring) |
| 403 | dma_free_coherent(&ha->pdev->dev, |
| 404 | (rsp->length_fx00 + 1) * sizeof(request_t), |
| 405 | rsp->ring_fx00, rsp->dma_fx00); |
| 406 | } else if (rsp && rsp->ring) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 407 | dma_free_coherent(&ha->pdev->dev, |
| 408 | (rsp->length + 1) * sizeof(response_t), |
| 409 | rsp->ring, rsp->dma); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 410 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 411 | kfree(rsp); |
| 412 | rsp = NULL; |
| 413 | } |
| 414 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 415 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 416 | { |
| 417 | struct req_que *req; |
| 418 | struct rsp_que *rsp; |
| 419 | int cnt; |
| 420 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 421 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 422 | if (!test_bit(cnt, ha->req_qid_map)) |
| 423 | continue; |
| 424 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 425 | req = ha->req_q_map[cnt]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 426 | qla2x00_free_req_que(ha, req); |
| 427 | } |
| 428 | kfree(ha->req_q_map); |
| 429 | ha->req_q_map = NULL; |
| 430 | |
| 431 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 432 | if (!test_bit(cnt, ha->rsp_qid_map)) |
| 433 | continue; |
| 434 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 435 | rsp = ha->rsp_q_map[cnt]; |
| 436 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 437 | } |
| 438 | kfree(ha->rsp_q_map); |
| 439 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 440 | } |
| 441 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 442 | static int qla25xx_setup_mode(struct scsi_qla_host *vha) |
| 443 | { |
| 444 | uint16_t options = 0; |
| 445 | int ques, req, ret; |
| 446 | struct qla_hw_data *ha = vha->hw; |
| 447 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 448 | if (!(ha->fw_attributes & BIT_6)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 449 | ql_log(ql_log_warn, vha, 0x00d8, |
| 450 | "Firmware is not multi-queue capable.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 451 | goto fail; |
| 452 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 453 | if (ql2xmultique_tag) { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 454 | /* create a request queue for IO */ |
| 455 | options |= BIT_7; |
| 456 | req = qla25xx_create_req_que(ha, options, 0, 0, -1, |
| 457 | QLA_DEFAULT_QUE_QOS); |
| 458 | if (!req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 459 | ql_log(ql_log_warn, vha, 0x00e0, |
| 460 | "Failed to create request queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 461 | goto fail; |
| 462 | } |
Tejun Heo | 278274d | 2011-02-01 11:42:42 +0100 | [diff] [blame] | 463 | ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 464 | vha->req = ha->req_q_map[req]; |
| 465 | options |= BIT_1; |
| 466 | for (ques = 1; ques < ha->max_rsp_queues; ques++) { |
| 467 | ret = qla25xx_create_rsp_que(ha, options, 0, 0, req); |
| 468 | if (!ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 469 | ql_log(ql_log_warn, vha, 0x00e8, |
| 470 | "Failed to create response queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 471 | goto fail2; |
| 472 | } |
| 473 | } |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 474 | ha->flags.cpu_affinity_enabled = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 475 | ql_dbg(ql_dbg_multiq, vha, 0xc007, |
Yannick Guerrini | 6ef68da | 2015-02-23 23:26:50 +0100 | [diff] [blame] | 476 | "CPU affinity mode enabled, " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 477 | "no. of response queues:%d no. of request queues:%d.\n", |
| 478 | ha->max_rsp_queues, ha->max_req_queues); |
| 479 | ql_dbg(ql_dbg_init, vha, 0x00e9, |
Yannick Guerrini | 6ef68da | 2015-02-23 23:26:50 +0100 | [diff] [blame] | 480 | "CPU affinity mode enabled, " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 481 | "no. of response queues:%d no. of request queues:%d.\n", |
| 482 | ha->max_rsp_queues, ha->max_req_queues); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 483 | } |
| 484 | return 0; |
| 485 | fail2: |
| 486 | qla25xx_delete_queues(vha); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 487 | destroy_workqueue(ha->wq); |
| 488 | ha->wq = NULL; |
Giridhar Malavali | 0cd33fc | 2011-11-18 09:02:12 -0800 | [diff] [blame] | 489 | vha->req = ha->req_q_map[0]; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 490 | fail: |
| 491 | ha->mqenable = 0; |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 492 | kfree(ha->req_q_map); |
| 493 | kfree(ha->rsp_q_map); |
| 494 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 495 | return 1; |
| 496 | } |
| 497 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 499 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 501 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | static char *pci_bus_modes[] = { |
| 503 | "33", "66", "100", "133", |
| 504 | }; |
| 505 | uint16_t pci_bus; |
| 506 | |
| 507 | strcpy(str, "PCI"); |
| 508 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 509 | if (pci_bus) { |
| 510 | strcat(str, "-X ("); |
| 511 | strcat(str, pci_bus_modes[pci_bus]); |
| 512 | } else { |
| 513 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 514 | strcat(str, " ("); |
| 515 | strcat(str, pci_bus_modes[pci_bus]); |
| 516 | } |
| 517 | strcat(str, " MHz)"); |
| 518 | |
| 519 | return (str); |
| 520 | } |
| 521 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 522 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 523 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 524 | { |
| 525 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 526 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 527 | uint32_t pci_bus; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 528 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 529 | if (pci_is_pcie(ha->pdev)) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 530 | char lwstr[6]; |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 531 | uint32_t lstat, lspeed, lwidth; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 532 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 533 | pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); |
| 534 | lspeed = lstat & PCI_EXP_LNKCAP_SLS; |
| 535 | lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 536 | |
| 537 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 538 | switch (lspeed) { |
| 539 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 540 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 541 | break; |
| 542 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 543 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 544 | break; |
| 545 | case 3: |
| 546 | strcat(str, "8.0GT/s "); |
| 547 | break; |
| 548 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 549 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 550 | break; |
| 551 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 552 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 553 | strcat(str, lwstr); |
| 554 | |
| 555 | return str; |
| 556 | } |
| 557 | |
| 558 | strcpy(str, "PCI"); |
| 559 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 560 | if (pci_bus == 0 || pci_bus == 8) { |
| 561 | strcat(str, " ("); |
| 562 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 563 | } else { |
| 564 | strcat(str, "-X "); |
| 565 | if (pci_bus & BIT_2) |
| 566 | strcat(str, "Mode 2"); |
| 567 | else |
| 568 | strcat(str, "Mode 1"); |
| 569 | strcat(str, " ("); |
| 570 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 571 | } |
| 572 | strcat(str, " MHz)"); |
| 573 | |
| 574 | return str; |
| 575 | } |
| 576 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 577 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 578 | qla2x00_fw_version_str(struct scsi_qla_host *vha, char *str, size_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | { |
| 580 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 581 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 582 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 583 | snprintf(str, size, "%d.%02d.%02d ", ha->fw_major_version, |
| 584 | ha->fw_minor_version, ha->fw_subminor_version); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | |
| 586 | if (ha->fw_attributes & BIT_9) { |
| 587 | strcat(str, "FLX"); |
| 588 | return (str); |
| 589 | } |
| 590 | |
| 591 | switch (ha->fw_attributes & 0xFF) { |
| 592 | case 0x7: |
| 593 | strcat(str, "EF"); |
| 594 | break; |
| 595 | case 0x17: |
| 596 | strcat(str, "TP"); |
| 597 | break; |
| 598 | case 0x37: |
| 599 | strcat(str, "IP"); |
| 600 | break; |
| 601 | case 0x77: |
| 602 | strcat(str, "VI"); |
| 603 | break; |
| 604 | default: |
| 605 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 606 | strcat(str, un_str); |
| 607 | break; |
| 608 | } |
| 609 | if (ha->fw_attributes & 0x100) |
| 610 | strcat(str, "X"); |
| 611 | |
| 612 | return (str); |
| 613 | } |
| 614 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 615 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 616 | qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str, size_t size) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 617 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 618 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 619 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 620 | snprintf(str, size, "%d.%02d.%02d (%x)", ha->fw_major_version, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 621 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 622 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 623 | } |
| 624 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 625 | void |
| 626 | qla2x00_sp_free_dma(void *vha, void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 627 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 628 | srb_t *sp = (srb_t *)ptr; |
| 629 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 630 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 631 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 632 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 633 | if (sp->flags & SRB_DMA_VALID) { |
| 634 | scsi_dma_unmap(cmd); |
| 635 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 636 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 637 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 638 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 639 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 640 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 641 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 642 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 643 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 644 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 645 | /* List assured to be having elements */ |
Quinn Tran | f83adb6 | 2014-04-11 16:54:43 -0400 | [diff] [blame] | 646 | qla2x00_clean_dsd_pool(ha, sp, NULL); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 647 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 648 | } |
| 649 | |
| 650 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
| 651 | dma_pool_free(ha->dl_dma_pool, ctx, |
| 652 | ((struct crc_context *)ctx)->crc_ctx_dma); |
| 653 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 654 | } |
| 655 | |
| 656 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
| 657 | struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; |
| 658 | |
| 659 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 660 | ctx1->fcp_cmnd_dma); |
| 661 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 662 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 663 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 664 | mempool_free(ctx1, ha->ctx_mempool); |
| 665 | ctx1 = NULL; |
| 666 | } |
| 667 | |
| 668 | CMD_SP(cmd) = NULL; |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 669 | qla2x00_rel_sp(sp->fcport->vha, sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 670 | } |
| 671 | |
Fengguang Wu | 14b0680 | 2013-04-25 01:29:19 -0400 | [diff] [blame] | 672 | static void |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 673 | qla2x00_sp_compl(void *data, void *ptr, int res) |
| 674 | { |
| 675 | struct qla_hw_data *ha = (struct qla_hw_data *)data; |
| 676 | srb_t *sp = (srb_t *)ptr; |
| 677 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 678 | |
| 679 | cmd->result = res; |
| 680 | |
| 681 | if (atomic_read(&sp->ref_count) == 0) { |
| 682 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3015, |
| 683 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 684 | sp, GET_CMD_SP(sp)); |
| 685 | if (ql2xextended_error_logging & ql_dbg_io) |
Hiral Patel | 8fbdac8 | 2015-08-04 13:37:56 -0400 | [diff] [blame] | 686 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 687 | return; |
| 688 | } |
| 689 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 690 | return; |
| 691 | |
| 692 | qla2x00_sp_free_dma(ha, sp); |
| 693 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 694 | } |
| 695 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 696 | /* If we are SP1 here, we need to still take and release the host_lock as SP1 |
| 697 | * does not have the changes necessary to avoid taking host->host_lock. |
| 698 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 700 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 701 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 702 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 703 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 704 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 705 | struct qla_hw_data *ha = vha->hw; |
| 706 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 707 | srb_t *sp; |
| 708 | int rval; |
| 709 | |
Mauricio Faria de Oliveira | 04dfaa5 | 2016-11-07 17:53:30 -0200 | [diff] [blame] | 710 | if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { |
| 711 | cmd->result = DID_NO_CONNECT << 16; |
| 712 | goto qc24_fail_command; |
| 713 | } |
| 714 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 715 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 716 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 717 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 718 | "PCI Channel IO permanent failure, exiting " |
| 719 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 720 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 721 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 722 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 723 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 724 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 725 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 726 | goto qc24_fail_command; |
| 727 | } |
| 728 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 729 | rval = fc_remote_port_chkready(rport); |
| 730 | if (rval) { |
| 731 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 732 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 733 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 734 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 735 | goto qc24_fail_command; |
| 736 | } |
| 737 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 738 | if (!vha->flags.difdix_supported && |
| 739 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 740 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 741 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 742 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 743 | cmd->result = DID_NO_CONNECT << 16; |
| 744 | goto qc24_fail_command; |
| 745 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 746 | |
| 747 | if (!fcport) { |
| 748 | cmd->result = DID_NO_CONNECT << 16; |
| 749 | goto qc24_fail_command; |
| 750 | } |
| 751 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 752 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 753 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 754 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 755 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 756 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 757 | atomic_read(&fcport->state), |
| 758 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 759 | cmd->result = DID_NO_CONNECT << 16; |
| 760 | goto qc24_fail_command; |
| 761 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 762 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 763 | } |
| 764 | |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 765 | /* |
| 766 | * Return target busy if we've received a non-zero retry_delay_timer |
| 767 | * in a FCP_RSP. |
| 768 | */ |
Bruno Prémont | 975f7d4 | 2014-12-19 10:29:16 +0100 | [diff] [blame] | 769 | if (fcport->retry_delay_timestamp == 0) { |
| 770 | /* retry delay not set */ |
| 771 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 772 | fcport->retry_delay_timestamp = 0; |
| 773 | else |
| 774 | goto qc24_target_busy; |
| 775 | |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 776 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 777 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 778 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 779 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 780 | sp->u.scmd.cmd = cmd; |
| 781 | sp->type = SRB_SCSI_CMD; |
| 782 | atomic_set(&sp->ref_count, 1); |
| 783 | CMD_SP(cmd) = (void *)sp; |
| 784 | sp->free = qla2x00_sp_free_dma; |
| 785 | sp->done = qla2x00_sp_compl; |
| 786 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 787 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 788 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 789 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 790 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 791 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 792 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 793 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 794 | return 0; |
| 795 | |
| 796 | qc24_host_busy_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 797 | qla2x00_sp_free_dma(ha, sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 798 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 799 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 800 | return SCSI_MLQUEUE_HOST_BUSY; |
| 801 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 802 | qc24_target_busy: |
| 803 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 804 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 805 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 806 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 807 | |
| 808 | return 0; |
| 809 | } |
| 810 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | /* |
| 812 | * qla2x00_eh_wait_on_command |
| 813 | * Waits for the command to be returned by the Firmware for some |
| 814 | * max time. |
| 815 | * |
| 816 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | * |
| 819 | * Return: |
| 820 | * Not Found : 0 |
| 821 | * Found : 1 |
| 822 | */ |
| 823 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 824 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 826 | #define ABORT_POLLING_PERIOD 1000 |
Chad Dupuis | 478c3b0 | 2014-04-11 16:54:35 -0400 | [diff] [blame] | 827 | #define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 828 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 829 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 830 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 831 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 833 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 834 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 835 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 836 | return ret; |
| 837 | } |
| 838 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 839 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 840 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 841 | } |
| 842 | if (CMD_SP(cmd)) |
| 843 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 845 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | /* |
| 849 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 850 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 852 | * finally HBA is disabled ie marked offline |
| 853 | * |
| 854 | * Input: |
| 855 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 856 | * |
| 857 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | * Does context switching-Release SPIN_LOCK |
| 859 | * (if any) before calling this routine. |
| 860 | * |
| 861 | * Return: |
| 862 | * Success (Adapter is online) : 0 |
| 863 | * Failed (Adapter is offline/disabled) : 1 |
| 864 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 865 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 866 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 868 | int return_status; |
| 869 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 870 | struct qla_hw_data *ha = vha->hw; |
| 871 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 873 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 874 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 875 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 876 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 877 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | |
| 879 | msleep(1000); |
| 880 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 881 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 882 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | else |
| 884 | return_status = QLA_FUNCTION_FAILED; |
| 885 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | return (return_status); |
| 887 | } |
| 888 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 889 | /* |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 890 | * qla2x00_wait_for_hba_ready |
| 891 | * Wait till the HBA is ready before doing driver unload |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 892 | * |
| 893 | * Input: |
| 894 | * ha - pointer to host adapter structure |
| 895 | * |
| 896 | * Note: |
| 897 | * Does context switching-Release SPIN_LOCK |
| 898 | * (if any) before calling this routine. |
| 899 | * |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 900 | */ |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 901 | static void |
| 902 | qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 903 | { |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 904 | struct qla_hw_data *ha = vha->hw; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 905 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 906 | |
Dan Carpenter | 1d48390 | 2016-08-03 21:42:32 +0300 | [diff] [blame] | 907 | while ((qla2x00_reset_active(vha) || ha->dpc_active || |
| 908 | ha->flags.mbox_busy) || |
| 909 | test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags) || |
| 910 | test_bit(FX00_TARGET_SCAN, &vha->dpc_flags)) { |
| 911 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 912 | break; |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 913 | msleep(1000); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 914 | } |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 915 | } |
| 916 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 917 | int |
| 918 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 919 | { |
| 920 | int return_status; |
| 921 | unsigned long wait_reset; |
| 922 | struct qla_hw_data *ha = vha->hw; |
| 923 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 924 | |
| 925 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 926 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 927 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 928 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 929 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 930 | |
| 931 | msleep(1000); |
| 932 | |
| 933 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 934 | ha->flags.chip_reset_done) |
| 935 | break; |
| 936 | } |
| 937 | if (ha->flags.chip_reset_done) |
| 938 | return_status = QLA_SUCCESS; |
| 939 | else |
| 940 | return_status = QLA_FUNCTION_FAILED; |
| 941 | |
| 942 | return return_status; |
| 943 | } |
| 944 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 945 | static void |
| 946 | sp_get(struct srb *sp) |
| 947 | { |
| 948 | atomic_inc(&sp->ref_count); |
| 949 | } |
| 950 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 951 | #define ISP_REG_DISCONNECT 0xffffffffU |
| 952 | /************************************************************************** |
| 953 | * qla2x00_isp_reg_stat |
| 954 | * |
| 955 | * Description: |
| 956 | * Read the host status register of ISP before aborting the command. |
| 957 | * |
| 958 | * Input: |
| 959 | * ha = pointer to host adapter structure. |
| 960 | * |
| 961 | * |
| 962 | * Returns: |
| 963 | * Either true or false. |
| 964 | * |
| 965 | * Note: Return true if there is register disconnect. |
| 966 | **************************************************************************/ |
| 967 | static inline |
| 968 | uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) |
| 969 | { |
| 970 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
Sawan Chandak | 64e7469 | 2017-03-31 14:37:03 -0700 | [diff] [blame] | 971 | struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 972 | |
Sawan Chandak | 64e7469 | 2017-03-31 14:37:03 -0700 | [diff] [blame] | 973 | if (IS_P3P_TYPE(ha)) |
| 974 | return ((RD_REG_DWORD(®82->host_int)) == ISP_REG_DISCONNECT); |
| 975 | else |
| 976 | return ((RD_REG_DWORD(®->host_status)) == |
| 977 | ISP_REG_DISCONNECT); |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 978 | } |
| 979 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | /************************************************************************** |
| 981 | * qla2xxx_eh_abort |
| 982 | * |
| 983 | * Description: |
| 984 | * The abort function will abort the specified command. |
| 985 | * |
| 986 | * Input: |
| 987 | * cmd = Linux SCSI command packet to be aborted. |
| 988 | * |
| 989 | * Returns: |
| 990 | * Either SUCCESS or FAILED. |
| 991 | * |
| 992 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 993 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 995 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 996 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 997 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 998 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 999 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1000 | int ret; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1001 | unsigned int id; |
| 1002 | uint64_t lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1003 | unsigned long flags; |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1004 | int rval, wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1005 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1007 | if (qla2x00_isp_reg_stat(ha)) { |
| 1008 | ql_log(ql_log_info, vha, 0x8042, |
| 1009 | "PCI/Register disconnect, exiting.\n"); |
| 1010 | return FAILED; |
| 1011 | } |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1012 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1013 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1014 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1015 | ret = fc_block_scsi_eh(cmd); |
| 1016 | if (ret != 0) |
| 1017 | return ret; |
| 1018 | ret = SUCCESS; |
| 1019 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1020 | id = cmd->device->id; |
| 1021 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1022 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1023 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1024 | sp = (srb_t *) CMD_SP(cmd); |
| 1025 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1026 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1027 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1028 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1029 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1030 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | c7bc4ca | 2015-08-04 13:37:57 -0400 | [diff] [blame] | 1031 | "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n", |
| 1032 | vha->host_no, id, lun, sp, cmd, sp->handle); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1033 | |
| 1034 | /* Get a reference to the sp and drop the lock.*/ |
| 1035 | sp_get(sp); |
| 1036 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1037 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1038 | rval = ha->isp_ops->abort_command(sp); |
| 1039 | if (rval) { |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1040 | if (rval == QLA_FUNCTION_PARAMETER_ERROR) |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1041 | ret = SUCCESS; |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1042 | else |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1043 | ret = FAILED; |
| 1044 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1045 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1046 | "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1047 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1048 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1049 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1050 | wait = 1; |
| 1051 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1052 | |
| 1053 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1054 | sp->done(ha, sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1055 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1056 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 1057 | /* Did the command return during mailbox execution? */ |
| 1058 | if (ret == FAILED && !CMD_SP(cmd)) |
| 1059 | ret = SUCCESS; |
| 1060 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1061 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1062 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1063 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1064 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1065 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1066 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1067 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1070 | ql_log(ql_log_info, vha, 0x801c, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1071 | "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1072 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1074 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1075 | } |
| 1076 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1077 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1078 | 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] | 1079 | uint64_t l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1080 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1081 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1082 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1083 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1084 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1085 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1086 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1087 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1088 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1089 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1090 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1091 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1092 | for (cnt = 1; status == QLA_SUCCESS && |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1093 | cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1094 | sp = req->outstanding_cmds[cnt]; |
| 1095 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1096 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1097 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1098 | continue; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1099 | if (vha->vp_idx != sp->fcport->vha->vp_idx) |
| 1100 | continue; |
| 1101 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1102 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1103 | switch (type) { |
| 1104 | case WAIT_HOST: |
| 1105 | match = 1; |
| 1106 | break; |
| 1107 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1108 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1109 | break; |
| 1110 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1111 | match = (cmd->device->id == t && |
| 1112 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1113 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1115 | if (!match) |
| 1116 | continue; |
| 1117 | |
| 1118 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1119 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1120 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1122 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1123 | |
| 1124 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | } |
| 1126 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1127 | static char *reset_errors[] = { |
| 1128 | "HBA not online", |
| 1129 | "HBA not ready", |
| 1130 | "Task management failed", |
| 1131 | "Waiting for command completions", |
| 1132 | }; |
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 | static int |
| 1135 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1136 | 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] | 1137 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1138 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1139 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1140 | int err; |
| 1141 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1142 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1143 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1144 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1145 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1146 | err = fc_block_scsi_eh(cmd); |
| 1147 | if (err != 0) |
| 1148 | return err; |
| 1149 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1150 | ql_log(ql_log_info, vha, 0x8009, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1151 | "%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] | 1152 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1153 | |
| 1154 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1155 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1156 | ql_log(ql_log_warn, vha, 0x800a, |
| 1157 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1158 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1159 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1160 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1161 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1162 | != QLA_SUCCESS) { |
| 1163 | ql_log(ql_log_warn, vha, 0x800c, |
| 1164 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1165 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1166 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1167 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1168 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1169 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1170 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1171 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1172 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1173 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1174 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1175 | ql_log(ql_log_info, vha, 0x800e, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1176 | "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1177 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1178 | |
| 1179 | return SUCCESS; |
| 1180 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1181 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1182 | ql_log(ql_log_info, vha, 0x800f, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1183 | "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1184 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1185 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1186 | return FAILED; |
| 1187 | } |
| 1188 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1189 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1191 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1192 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1193 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1195 | if (qla2x00_isp_reg_stat(ha)) { |
| 1196 | ql_log(ql_log_info, vha, 0x803e, |
| 1197 | "PCI/Register disconnect, exiting.\n"); |
| 1198 | return FAILED; |
| 1199 | } |
| 1200 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1201 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1202 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1203 | } |
| 1204 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1205 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1206 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1208 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1209 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1211 | if (qla2x00_isp_reg_stat(ha)) { |
| 1212 | ql_log(ql_log_info, vha, 0x803f, |
| 1213 | "PCI/Register disconnect, exiting.\n"); |
| 1214 | return FAILED; |
| 1215 | } |
| 1216 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1217 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1218 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1219 | } |
| 1220 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | /************************************************************************** |
| 1222 | * qla2xxx_eh_bus_reset |
| 1223 | * |
| 1224 | * Description: |
| 1225 | * The bus reset function will reset the bus and abort any executing |
| 1226 | * commands. |
| 1227 | * |
| 1228 | * Input: |
| 1229 | * cmd = Linux SCSI command packet of the command that cause the |
| 1230 | * bus reset. |
| 1231 | * |
| 1232 | * Returns: |
| 1233 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1234 | * |
| 1235 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1236 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1237 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1238 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1239 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1240 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1241 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1242 | unsigned int id; |
| 1243 | uint64_t lun; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1244 | struct qla_hw_data *ha = vha->hw; |
| 1245 | |
| 1246 | if (qla2x00_isp_reg_stat(ha)) { |
| 1247 | ql_log(ql_log_info, vha, 0x8040, |
| 1248 | "PCI/Register disconnect, exiting.\n"); |
| 1249 | return FAILED; |
| 1250 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1252 | id = cmd->device->id; |
| 1253 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1254 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1255 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1256 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1257 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1258 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1259 | ret = fc_block_scsi_eh(cmd); |
| 1260 | if (ret != 0) |
| 1261 | return ret; |
| 1262 | ret = FAILED; |
| 1263 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1264 | ql_log(ql_log_info, vha, 0x8012, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1265 | "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] | 1266 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1267 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1268 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1269 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1270 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1271 | } |
| 1272 | |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1273 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1274 | ret = SUCCESS; |
| 1275 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1276 | if (ret == FAILED) |
| 1277 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1278 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1279 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1280 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1281 | QLA_SUCCESS) { |
| 1282 | ql_log(ql_log_warn, vha, 0x8014, |
| 1283 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1284 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1285 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1286 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1287 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1288 | ql_log(ql_log_warn, vha, 0x802b, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1289 | "BUS RESET %s nexus=%ld:%d:%llu.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1290 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1291 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1292 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1293 | } |
| 1294 | |
| 1295 | /************************************************************************** |
| 1296 | * qla2xxx_eh_host_reset |
| 1297 | * |
| 1298 | * Description: |
| 1299 | * The reset function will reset the Adapter. |
| 1300 | * |
| 1301 | * Input: |
| 1302 | * cmd = Linux SCSI command packet of the command that cause the |
| 1303 | * adapter reset. |
| 1304 | * |
| 1305 | * Returns: |
| 1306 | * Either SUCCESS or FAILED. |
| 1307 | * |
| 1308 | * Note: |
| 1309 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1310 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1311 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1312 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1313 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1314 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1315 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1316 | unsigned int id; |
| 1317 | uint64_t lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1318 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1319 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1320 | if (qla2x00_isp_reg_stat(ha)) { |
| 1321 | ql_log(ql_log_info, vha, 0x8041, |
| 1322 | "PCI/Register disconnect, exiting.\n"); |
| 1323 | schedule_work(&ha->board_disable); |
| 1324 | return SUCCESS; |
| 1325 | } |
| 1326 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1327 | id = cmd->device->id; |
| 1328 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1329 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1330 | ql_log(ql_log_info, vha, 0x8018, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1331 | "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] | 1332 | |
Chad Dupuis | 63ee707 | 2014-04-11 16:54:46 -0400 | [diff] [blame] | 1333 | /* |
| 1334 | * No point in issuing another reset if one is active. Also do not |
| 1335 | * attempt a reset if we are updating flash. |
| 1336 | */ |
| 1337 | if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1338 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1340 | if (vha != base_vha) { |
| 1341 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1342 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1343 | } else { |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1344 | if (IS_P3P_TYPE(vha->hw)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1345 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1346 | /* Ctx reset success */ |
| 1347 | ret = SUCCESS; |
| 1348 | goto eh_host_reset_lock; |
| 1349 | } |
| 1350 | /* fall thru if ctx reset failed */ |
| 1351 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1352 | if (ha->wq) |
| 1353 | flush_workqueue(ha->wq); |
| 1354 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1355 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1356 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1357 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1358 | /* failed. schedule dpc to try */ |
| 1359 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1360 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1361 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1362 | ql_log(ql_log_warn, vha, 0x802a, |
| 1363 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1364 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1365 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1366 | } |
| 1367 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1368 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1369 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1370 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1371 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1372 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1373 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1374 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1375 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1376 | ql_log(ql_log_info, vha, 0x8017, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1377 | "ADAPTER RESET %s nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1378 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1379 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1380 | return ret; |
| 1381 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1382 | |
| 1383 | /* |
| 1384 | * qla2x00_loop_reset |
| 1385 | * Issue loop reset. |
| 1386 | * |
| 1387 | * Input: |
| 1388 | * ha = adapter block pointer. |
| 1389 | * |
| 1390 | * Returns: |
| 1391 | * 0 = success |
| 1392 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1393 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1394 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1395 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1396 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1397 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1398 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1399 | |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1400 | if (IS_QLAFX00(ha)) { |
| 1401 | return qlafx00_loop_reset(vha); |
| 1402 | } |
| 1403 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1404 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1405 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1406 | if (fcport->port_type != FCT_TARGET) |
| 1407 | continue; |
| 1408 | |
| 1409 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1410 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1411 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1412 | "Bus Reset failed: Reset=%d " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1413 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1414 | } |
| 1415 | } |
| 1416 | } |
| 1417 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1418 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1419 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Andrew Vasquez | 0b7e7c5 | 2013-02-08 01:57:42 -0500 | [diff] [blame] | 1420 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1421 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1422 | qla2x00_mark_all_devices_lost(vha, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1423 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1424 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1425 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1426 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1427 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | } |
| 1429 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1430 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1431 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1432 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1433 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1434 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1435 | } |
| 1436 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1437 | /* 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] | 1438 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1440 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1441 | } |
| 1442 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1443 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1444 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1445 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1446 | int que, cnt; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1447 | unsigned long flags; |
| 1448 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1449 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1450 | struct req_que *req; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1451 | |
Arun Easi | c0cb449 | 2014-09-25 06:14:51 -0400 | [diff] [blame] | 1452 | qlt_host_reset_handler(ha); |
| 1453 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1454 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1455 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1456 | req = ha->req_q_map[que]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1457 | if (!req) |
| 1458 | continue; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1459 | if (!req->outstanding_cmds) |
| 1460 | continue; |
| 1461 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1462 | sp = req->outstanding_cmds[cnt]; |
Andrew Vasquez | e612d46 | 2009-03-24 09:08:04 -0700 | [diff] [blame] | 1463 | if (sp) { |
Mauricio Faria de Oliveira | c733ab3 | 2016-11-14 19:26:22 -0200 | [diff] [blame] | 1464 | /* Don't abort commands in adapter during EEH |
| 1465 | * recovery as it's not accessible/responding. |
Mauricio Faria de Oliveira | 1535aa7 | 2016-11-07 17:53:31 -0200 | [diff] [blame] | 1466 | */ |
Bill Kuzeja | 76aa65a | 2017-03-14 13:28:44 -0400 | [diff] [blame] | 1467 | if (GET_CMD_SP(sp) && !ha->flags.eeh_busy && |
| 1468 | (sp->type == SRB_SCSI_CMD)) { |
Mauricio Faria de Oliveira | c733ab3 | 2016-11-14 19:26:22 -0200 | [diff] [blame] | 1469 | /* Get a reference to the sp and drop the lock. |
| 1470 | * The reference ensures this sp->done() call |
| 1471 | * - and not the call in qla2xxx_eh_abort() - |
| 1472 | * ends the SCSI command (with result 'res'). |
| 1473 | */ |
| 1474 | sp_get(sp); |
| 1475 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1476 | qla2xxx_eh_abort(GET_CMD_SP(sp)); |
| 1477 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1478 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1479 | req->outstanding_cmds[cnt] = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1480 | sp->done(vha, sp, res); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1481 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1482 | } |
| 1483 | } |
| 1484 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1485 | } |
| 1486 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1487 | static int |
| 1488 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1490 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1491 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1492 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1493 | return -ENXIO; |
| 1494 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1495 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1496 | |
| 1497 | return 0; |
| 1498 | } |
| 1499 | |
| 1500 | static int |
| 1501 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1502 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1503 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1504 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1505 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1506 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1507 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1508 | |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 1509 | scsi_change_queue_depth(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1510 | return 0; |
| 1511 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1512 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1513 | static void |
| 1514 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1515 | { |
| 1516 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1517 | } |
| 1518 | |
| 1519 | /** |
| 1520 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1521 | * @ha: HA context |
| 1522 | * |
| 1523 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1524 | * supported addressing method. |
| 1525 | */ |
| 1526 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1527 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1529 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1531 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1532 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1533 | /* Any upper-dword bits set? */ |
| 1534 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1535 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1536 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1538 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1539 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1540 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1541 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1542 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1543 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1544 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1545 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1546 | } |
| 1547 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1548 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1549 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1550 | { |
| 1551 | unsigned long flags = 0; |
| 1552 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1553 | |
| 1554 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1555 | ha->interrupts_on = 1; |
| 1556 | /* enable risc and host interrupts */ |
| 1557 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1558 | RD_REG_WORD(®->ictrl); |
| 1559 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1560 | |
| 1561 | } |
| 1562 | |
| 1563 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1564 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1565 | { |
| 1566 | unsigned long flags = 0; |
| 1567 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1568 | |
| 1569 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1570 | ha->interrupts_on = 0; |
| 1571 | /* disable risc and host interrupts */ |
| 1572 | WRT_REG_WORD(®->ictrl, 0); |
| 1573 | RD_REG_WORD(®->ictrl); |
| 1574 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1575 | } |
| 1576 | |
| 1577 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1578 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1579 | { |
| 1580 | unsigned long flags = 0; |
| 1581 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1582 | |
| 1583 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1584 | ha->interrupts_on = 1; |
| 1585 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1586 | RD_REG_DWORD(®->ictrl); |
| 1587 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1588 | } |
| 1589 | |
| 1590 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1591 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1592 | { |
| 1593 | unsigned long flags = 0; |
| 1594 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1595 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1596 | if (IS_NOPOLLING_TYPE(ha)) |
| 1597 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1598 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1599 | ha->interrupts_on = 0; |
| 1600 | WRT_REG_DWORD(®->ictrl, 0); |
| 1601 | RD_REG_DWORD(®->ictrl); |
| 1602 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1603 | } |
| 1604 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1605 | static int |
| 1606 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1607 | { |
| 1608 | resource_size_t pio; |
| 1609 | uint16_t msix; |
| 1610 | int cpus; |
| 1611 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1612 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1613 | QLA2XXX_DRIVER_NAME)) { |
| 1614 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1615 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1616 | pci_name(ha->pdev)); |
| 1617 | goto iospace_error_exit; |
| 1618 | } |
| 1619 | if (!(ha->bars & 1)) |
| 1620 | goto skip_pio; |
| 1621 | |
| 1622 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1623 | pio = pci_resource_start(ha->pdev, 0); |
| 1624 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1625 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1626 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1627 | "Invalid pci I/O region size (%s).\n", |
| 1628 | pci_name(ha->pdev)); |
| 1629 | pio = 0; |
| 1630 | } |
| 1631 | } else { |
| 1632 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1633 | "Region #0 no a PIO resource (%s).\n", |
| 1634 | pci_name(ha->pdev)); |
| 1635 | pio = 0; |
| 1636 | } |
| 1637 | ha->pio_address = pio; |
| 1638 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1639 | "PIO address=%llu.\n", |
| 1640 | (unsigned long long)ha->pio_address); |
| 1641 | |
| 1642 | skip_pio: |
| 1643 | /* Use MMIO operations for all accesses. */ |
| 1644 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1645 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1646 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1647 | pci_name(ha->pdev)); |
| 1648 | goto iospace_error_exit; |
| 1649 | } |
| 1650 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1651 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1652 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1653 | pci_name(ha->pdev)); |
| 1654 | goto iospace_error_exit; |
| 1655 | } |
| 1656 | |
| 1657 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1658 | if (!ha->iobase) { |
| 1659 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1660 | "Cannot remap MMIO (%s), aborting.\n", |
| 1661 | pci_name(ha->pdev)); |
| 1662 | goto iospace_error_exit; |
| 1663 | } |
| 1664 | |
| 1665 | /* Determine queue resources */ |
| 1666 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1667 | if ((ql2xmaxqueues <= 1 && !ql2xmultique_tag) || |
| 1668 | (ql2xmaxqueues > 1 && ql2xmultique_tag) || |
| 1669 | (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
| 1670 | goto mqiobase_exit; |
| 1671 | |
| 1672 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1673 | pci_resource_len(ha->pdev, 3)); |
| 1674 | if (ha->mqiobase) { |
| 1675 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 1676 | "MQIO Base=%p.\n", ha->mqiobase); |
| 1677 | /* Read MSIX vector size of the board */ |
| 1678 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
| 1679 | ha->msix_count = msix; |
| 1680 | /* Max queues are bounded by available msix vectors */ |
| 1681 | /* queue 0 uses two msix vectors */ |
| 1682 | if (ql2xmultique_tag) { |
| 1683 | cpus = num_online_cpus(); |
| 1684 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1685 | (cpus + 1) : (ha->msix_count - 1); |
| 1686 | ha->max_req_queues = 2; |
| 1687 | } else if (ql2xmaxqueues > 1) { |
| 1688 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1689 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1690 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc008, |
| 1691 | "QoS mode set, max no of request queues:%d.\n", |
| 1692 | ha->max_req_queues); |
| 1693 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0019, |
| 1694 | "QoS mode set, max no of request queues:%d.\n", |
| 1695 | ha->max_req_queues); |
| 1696 | } |
| 1697 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
| 1698 | "MSI-X vector count: %d.\n", msix); |
| 1699 | } else |
| 1700 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 1701 | "BAR 3 not enabled.\n"); |
| 1702 | |
| 1703 | mqiobase_exit: |
| 1704 | ha->msix_count = ha->max_rsp_queues + 1; |
| 1705 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
| 1706 | "MSIX Count:%d.\n", ha->msix_count); |
| 1707 | return (0); |
| 1708 | |
| 1709 | iospace_error_exit: |
| 1710 | return (-ENOMEM); |
| 1711 | } |
| 1712 | |
| 1713 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1714 | static int |
| 1715 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 1716 | { |
| 1717 | uint16_t msix; |
| 1718 | int cpus; |
| 1719 | |
| 1720 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1721 | QLA2XXX_DRIVER_NAME)) { |
| 1722 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 1723 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1724 | pci_name(ha->pdev)); |
| 1725 | |
| 1726 | goto iospace_error_exit; |
| 1727 | } |
| 1728 | |
| 1729 | /* Use MMIO operations for all accesses. */ |
| 1730 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 1731 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 1732 | "Invalid pci I/O region size (%s).\n", |
| 1733 | pci_name(ha->pdev)); |
| 1734 | goto iospace_error_exit; |
| 1735 | } |
| 1736 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1737 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 1738 | "Invalid PCI mem region size (%s), aborting\n", |
| 1739 | pci_name(ha->pdev)); |
| 1740 | goto iospace_error_exit; |
| 1741 | } |
| 1742 | |
| 1743 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 1744 | if (!ha->iobase) { |
| 1745 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 1746 | "Cannot remap MMIO (%s), aborting.\n", |
| 1747 | pci_name(ha->pdev)); |
| 1748 | goto iospace_error_exit; |
| 1749 | } |
| 1750 | |
| 1751 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 1752 | /* 83XX 26XX always use MQ type access for queues |
| 1753 | * - mbar 2, a.k.a region 4 */ |
| 1754 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1755 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 1756 | pci_resource_len(ha->pdev, 4)); |
| 1757 | |
| 1758 | if (!ha->mqiobase) { |
| 1759 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 1760 | "BAR2/region4 not enabled\n"); |
| 1761 | goto mqiobase_exit; |
| 1762 | } |
| 1763 | |
| 1764 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 1765 | pci_resource_len(ha->pdev, 2)); |
| 1766 | if (ha->msixbase) { |
| 1767 | /* Read MSIX vector size of the board */ |
| 1768 | pci_read_config_word(ha->pdev, |
| 1769 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
| 1770 | ha->msix_count = msix; |
| 1771 | /* Max queues are bounded by available msix vectors */ |
| 1772 | /* queue 0 uses two msix vectors */ |
| 1773 | if (ql2xmultique_tag) { |
| 1774 | cpus = num_online_cpus(); |
| 1775 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1776 | (cpus + 1) : (ha->msix_count - 1); |
| 1777 | ha->max_req_queues = 2; |
| 1778 | } else if (ql2xmaxqueues > 1) { |
| 1779 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1780 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1781 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc00c, |
| 1782 | "QoS mode set, max no of request queues:%d.\n", |
| 1783 | ha->max_req_queues); |
| 1784 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b, |
| 1785 | "QoS mode set, max no of request queues:%d.\n", |
| 1786 | ha->max_req_queues); |
| 1787 | } |
| 1788 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
| 1789 | "MSI-X vector count: %d.\n", msix); |
| 1790 | } else |
| 1791 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 1792 | "BAR 1 not enabled.\n"); |
| 1793 | |
| 1794 | mqiobase_exit: |
| 1795 | ha->msix_count = ha->max_rsp_queues + 1; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 1796 | |
| 1797 | qlt_83xx_iospace_config(ha); |
| 1798 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1799 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
| 1800 | "MSIX Count:%d.\n", ha->msix_count); |
| 1801 | return 0; |
| 1802 | |
| 1803 | iospace_error_exit: |
| 1804 | return -ENOMEM; |
| 1805 | } |
| 1806 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1807 | static struct isp_operations qla2100_isp_ops = { |
| 1808 | .pci_config = qla2100_pci_config, |
| 1809 | .reset_chip = qla2x00_reset_chip, |
| 1810 | .chip_diag = qla2x00_chip_diag, |
| 1811 | .config_rings = qla2x00_config_rings, |
| 1812 | .reset_adapter = qla2x00_reset_adapter, |
| 1813 | .nvram_config = qla2x00_nvram_config, |
| 1814 | .update_fw_options = qla2x00_update_fw_options, |
| 1815 | .load_risc = qla2x00_load_risc, |
| 1816 | .pci_info_str = qla2x00_pci_info_str, |
| 1817 | .fw_version_str = qla2x00_fw_version_str, |
| 1818 | .intr_handler = qla2100_intr_handler, |
| 1819 | .enable_intrs = qla2x00_enable_intrs, |
| 1820 | .disable_intrs = qla2x00_disable_intrs, |
| 1821 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1822 | .target_reset = qla2x00_abort_target, |
| 1823 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1824 | .fabric_login = qla2x00_login_fabric, |
| 1825 | .fabric_logout = qla2x00_fabric_logout, |
| 1826 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1827 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1828 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1829 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1830 | .read_nvram = qla2x00_read_nvram_data, |
| 1831 | .write_nvram = qla2x00_write_nvram_data, |
| 1832 | .fw_dump = qla2100_fw_dump, |
| 1833 | .beacon_on = NULL, |
| 1834 | .beacon_off = NULL, |
| 1835 | .beacon_blink = NULL, |
| 1836 | .read_optrom = qla2x00_read_optrom_data, |
| 1837 | .write_optrom = qla2x00_write_optrom_data, |
| 1838 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1839 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1840 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1841 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1842 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1843 | }; |
| 1844 | |
| 1845 | static struct isp_operations qla2300_isp_ops = { |
| 1846 | .pci_config = qla2300_pci_config, |
| 1847 | .reset_chip = qla2x00_reset_chip, |
| 1848 | .chip_diag = qla2x00_chip_diag, |
| 1849 | .config_rings = qla2x00_config_rings, |
| 1850 | .reset_adapter = qla2x00_reset_adapter, |
| 1851 | .nvram_config = qla2x00_nvram_config, |
| 1852 | .update_fw_options = qla2x00_update_fw_options, |
| 1853 | .load_risc = qla2x00_load_risc, |
| 1854 | .pci_info_str = qla2x00_pci_info_str, |
| 1855 | .fw_version_str = qla2x00_fw_version_str, |
| 1856 | .intr_handler = qla2300_intr_handler, |
| 1857 | .enable_intrs = qla2x00_enable_intrs, |
| 1858 | .disable_intrs = qla2x00_disable_intrs, |
| 1859 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1860 | .target_reset = qla2x00_abort_target, |
| 1861 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1862 | .fabric_login = qla2x00_login_fabric, |
| 1863 | .fabric_logout = qla2x00_fabric_logout, |
| 1864 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1865 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1866 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1867 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1868 | .read_nvram = qla2x00_read_nvram_data, |
| 1869 | .write_nvram = qla2x00_write_nvram_data, |
| 1870 | .fw_dump = qla2300_fw_dump, |
| 1871 | .beacon_on = qla2x00_beacon_on, |
| 1872 | .beacon_off = qla2x00_beacon_off, |
| 1873 | .beacon_blink = qla2x00_beacon_blink, |
| 1874 | .read_optrom = qla2x00_read_optrom_data, |
| 1875 | .write_optrom = qla2x00_write_optrom_data, |
| 1876 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1877 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1878 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1879 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1880 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1881 | }; |
| 1882 | |
| 1883 | static struct isp_operations qla24xx_isp_ops = { |
| 1884 | .pci_config = qla24xx_pci_config, |
| 1885 | .reset_chip = qla24xx_reset_chip, |
| 1886 | .chip_diag = qla24xx_chip_diag, |
| 1887 | .config_rings = qla24xx_config_rings, |
| 1888 | .reset_adapter = qla24xx_reset_adapter, |
| 1889 | .nvram_config = qla24xx_nvram_config, |
| 1890 | .update_fw_options = qla24xx_update_fw_options, |
| 1891 | .load_risc = qla24xx_load_risc, |
| 1892 | .pci_info_str = qla24xx_pci_info_str, |
| 1893 | .fw_version_str = qla24xx_fw_version_str, |
| 1894 | .intr_handler = qla24xx_intr_handler, |
| 1895 | .enable_intrs = qla24xx_enable_intrs, |
| 1896 | .disable_intrs = qla24xx_disable_intrs, |
| 1897 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1898 | .target_reset = qla24xx_abort_target, |
| 1899 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1900 | .fabric_login = qla24xx_login_fabric, |
| 1901 | .fabric_logout = qla24xx_fabric_logout, |
| 1902 | .calc_req_entries = NULL, |
| 1903 | .build_iocbs = NULL, |
| 1904 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1905 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1906 | .read_nvram = qla24xx_read_nvram_data, |
| 1907 | .write_nvram = qla24xx_write_nvram_data, |
| 1908 | .fw_dump = qla24xx_fw_dump, |
| 1909 | .beacon_on = qla24xx_beacon_on, |
| 1910 | .beacon_off = qla24xx_beacon_off, |
| 1911 | .beacon_blink = qla24xx_beacon_blink, |
| 1912 | .read_optrom = qla24xx_read_optrom_data, |
| 1913 | .write_optrom = qla24xx_write_optrom_data, |
| 1914 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1915 | .start_scsi = qla24xx_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1916 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1917 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1918 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1919 | }; |
| 1920 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1921 | static struct isp_operations qla25xx_isp_ops = { |
| 1922 | .pci_config = qla25xx_pci_config, |
| 1923 | .reset_chip = qla24xx_reset_chip, |
| 1924 | .chip_diag = qla24xx_chip_diag, |
| 1925 | .config_rings = qla24xx_config_rings, |
| 1926 | .reset_adapter = qla24xx_reset_adapter, |
| 1927 | .nvram_config = qla24xx_nvram_config, |
| 1928 | .update_fw_options = qla24xx_update_fw_options, |
| 1929 | .load_risc = qla24xx_load_risc, |
| 1930 | .pci_info_str = qla24xx_pci_info_str, |
| 1931 | .fw_version_str = qla24xx_fw_version_str, |
| 1932 | .intr_handler = qla24xx_intr_handler, |
| 1933 | .enable_intrs = qla24xx_enable_intrs, |
| 1934 | .disable_intrs = qla24xx_disable_intrs, |
| 1935 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1936 | .target_reset = qla24xx_abort_target, |
| 1937 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1938 | .fabric_login = qla24xx_login_fabric, |
| 1939 | .fabric_logout = qla24xx_fabric_logout, |
| 1940 | .calc_req_entries = NULL, |
| 1941 | .build_iocbs = NULL, |
| 1942 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1943 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1944 | .read_nvram = qla25xx_read_nvram_data, |
| 1945 | .write_nvram = qla25xx_write_nvram_data, |
| 1946 | .fw_dump = qla25xx_fw_dump, |
| 1947 | .beacon_on = qla24xx_beacon_on, |
| 1948 | .beacon_off = qla24xx_beacon_off, |
| 1949 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 1950 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1951 | .write_optrom = qla24xx_write_optrom_data, |
| 1952 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1953 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1954 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1955 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1956 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1957 | }; |
| 1958 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1959 | static struct isp_operations qla81xx_isp_ops = { |
| 1960 | .pci_config = qla25xx_pci_config, |
| 1961 | .reset_chip = qla24xx_reset_chip, |
| 1962 | .chip_diag = qla24xx_chip_diag, |
| 1963 | .config_rings = qla24xx_config_rings, |
| 1964 | .reset_adapter = qla24xx_reset_adapter, |
| 1965 | .nvram_config = qla81xx_nvram_config, |
| 1966 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 1967 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1968 | .pci_info_str = qla24xx_pci_info_str, |
| 1969 | .fw_version_str = qla24xx_fw_version_str, |
| 1970 | .intr_handler = qla24xx_intr_handler, |
| 1971 | .enable_intrs = qla24xx_enable_intrs, |
| 1972 | .disable_intrs = qla24xx_disable_intrs, |
| 1973 | .abort_command = qla24xx_abort_command, |
| 1974 | .target_reset = qla24xx_abort_target, |
| 1975 | .lun_reset = qla24xx_lun_reset, |
| 1976 | .fabric_login = qla24xx_login_fabric, |
| 1977 | .fabric_logout = qla24xx_fabric_logout, |
| 1978 | .calc_req_entries = NULL, |
| 1979 | .build_iocbs = NULL, |
| 1980 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1981 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 1982 | .read_nvram = NULL, |
| 1983 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1984 | .fw_dump = qla81xx_fw_dump, |
| 1985 | .beacon_on = qla24xx_beacon_on, |
| 1986 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1987 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1988 | .read_optrom = qla25xx_read_optrom_data, |
| 1989 | .write_optrom = qla24xx_write_optrom_data, |
| 1990 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 1991 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1992 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1993 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1994 | .initialize_adapter = qla2x00_initialize_adapter, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1995 | }; |
| 1996 | |
| 1997 | static struct isp_operations qla82xx_isp_ops = { |
| 1998 | .pci_config = qla82xx_pci_config, |
| 1999 | .reset_chip = qla82xx_reset_chip, |
| 2000 | .chip_diag = qla24xx_chip_diag, |
| 2001 | .config_rings = qla82xx_config_rings, |
| 2002 | .reset_adapter = qla24xx_reset_adapter, |
| 2003 | .nvram_config = qla81xx_nvram_config, |
| 2004 | .update_fw_options = qla24xx_update_fw_options, |
| 2005 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 2006 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2007 | .fw_version_str = qla24xx_fw_version_str, |
| 2008 | .intr_handler = qla82xx_intr_handler, |
| 2009 | .enable_intrs = qla82xx_enable_intrs, |
| 2010 | .disable_intrs = qla82xx_disable_intrs, |
| 2011 | .abort_command = qla24xx_abort_command, |
| 2012 | .target_reset = qla24xx_abort_target, |
| 2013 | .lun_reset = qla24xx_lun_reset, |
| 2014 | .fabric_login = qla24xx_login_fabric, |
| 2015 | .fabric_logout = qla24xx_fabric_logout, |
| 2016 | .calc_req_entries = NULL, |
| 2017 | .build_iocbs = NULL, |
| 2018 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2019 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2020 | .read_nvram = qla24xx_read_nvram_data, |
| 2021 | .write_nvram = qla24xx_write_nvram_data, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2022 | .fw_dump = qla82xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 2023 | .beacon_on = qla82xx_beacon_on, |
| 2024 | .beacon_off = qla82xx_beacon_off, |
| 2025 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2026 | .read_optrom = qla82xx_read_optrom_data, |
| 2027 | .write_optrom = qla82xx_write_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2028 | .get_flash_version = qla82xx_get_flash_version, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2029 | .start_scsi = qla82xx_start_scsi, |
| 2030 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2031 | .iospace_config = qla82xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2032 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2033 | }; |
| 2034 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2035 | static struct isp_operations qla8044_isp_ops = { |
| 2036 | .pci_config = qla82xx_pci_config, |
| 2037 | .reset_chip = qla82xx_reset_chip, |
| 2038 | .chip_diag = qla24xx_chip_diag, |
| 2039 | .config_rings = qla82xx_config_rings, |
| 2040 | .reset_adapter = qla24xx_reset_adapter, |
| 2041 | .nvram_config = qla81xx_nvram_config, |
| 2042 | .update_fw_options = qla24xx_update_fw_options, |
| 2043 | .load_risc = qla82xx_load_risc, |
| 2044 | .pci_info_str = qla24xx_pci_info_str, |
| 2045 | .fw_version_str = qla24xx_fw_version_str, |
| 2046 | .intr_handler = qla8044_intr_handler, |
| 2047 | .enable_intrs = qla82xx_enable_intrs, |
| 2048 | .disable_intrs = qla82xx_disable_intrs, |
| 2049 | .abort_command = qla24xx_abort_command, |
| 2050 | .target_reset = qla24xx_abort_target, |
| 2051 | .lun_reset = qla24xx_lun_reset, |
| 2052 | .fabric_login = qla24xx_login_fabric, |
| 2053 | .fabric_logout = qla24xx_fabric_logout, |
| 2054 | .calc_req_entries = NULL, |
| 2055 | .build_iocbs = NULL, |
| 2056 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2057 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2058 | .read_nvram = NULL, |
| 2059 | .write_nvram = NULL, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2060 | .fw_dump = qla8044_fw_dump, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2061 | .beacon_on = qla82xx_beacon_on, |
| 2062 | .beacon_off = qla82xx_beacon_off, |
| 2063 | .beacon_blink = NULL, |
Saurav Kashyap | 888e639 | 2014-02-26 04:15:13 -0500 | [diff] [blame] | 2064 | .read_optrom = qla8044_read_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2065 | .write_optrom = qla8044_write_optrom_data, |
| 2066 | .get_flash_version = qla82xx_get_flash_version, |
| 2067 | .start_scsi = qla82xx_start_scsi, |
| 2068 | .abort_isp = qla8044_abort_isp, |
| 2069 | .iospace_config = qla82xx_iospace_config, |
| 2070 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2071 | }; |
| 2072 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2073 | static struct isp_operations qla83xx_isp_ops = { |
| 2074 | .pci_config = qla25xx_pci_config, |
| 2075 | .reset_chip = qla24xx_reset_chip, |
| 2076 | .chip_diag = qla24xx_chip_diag, |
| 2077 | .config_rings = qla24xx_config_rings, |
| 2078 | .reset_adapter = qla24xx_reset_adapter, |
| 2079 | .nvram_config = qla81xx_nvram_config, |
| 2080 | .update_fw_options = qla81xx_update_fw_options, |
| 2081 | .load_risc = qla81xx_load_risc, |
| 2082 | .pci_info_str = qla24xx_pci_info_str, |
| 2083 | .fw_version_str = qla24xx_fw_version_str, |
| 2084 | .intr_handler = qla24xx_intr_handler, |
| 2085 | .enable_intrs = qla24xx_enable_intrs, |
| 2086 | .disable_intrs = qla24xx_disable_intrs, |
| 2087 | .abort_command = qla24xx_abort_command, |
| 2088 | .target_reset = qla24xx_abort_target, |
| 2089 | .lun_reset = qla24xx_lun_reset, |
| 2090 | .fabric_login = qla24xx_login_fabric, |
| 2091 | .fabric_logout = qla24xx_fabric_logout, |
| 2092 | .calc_req_entries = NULL, |
| 2093 | .build_iocbs = NULL, |
| 2094 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2095 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2096 | .read_nvram = NULL, |
| 2097 | .write_nvram = NULL, |
| 2098 | .fw_dump = qla83xx_fw_dump, |
| 2099 | .beacon_on = qla24xx_beacon_on, |
| 2100 | .beacon_off = qla24xx_beacon_off, |
| 2101 | .beacon_blink = qla83xx_beacon_blink, |
| 2102 | .read_optrom = qla25xx_read_optrom_data, |
| 2103 | .write_optrom = qla24xx_write_optrom_data, |
| 2104 | .get_flash_version = qla24xx_get_flash_version, |
| 2105 | .start_scsi = qla24xx_dif_start_scsi, |
| 2106 | .abort_isp = qla2x00_abort_isp, |
| 2107 | .iospace_config = qla83xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2108 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2109 | }; |
| 2110 | |
| 2111 | static struct isp_operations qlafx00_isp_ops = { |
| 2112 | .pci_config = qlafx00_pci_config, |
| 2113 | .reset_chip = qlafx00_soft_reset, |
| 2114 | .chip_diag = qlafx00_chip_diag, |
| 2115 | .config_rings = qlafx00_config_rings, |
| 2116 | .reset_adapter = qlafx00_soft_reset, |
| 2117 | .nvram_config = NULL, |
| 2118 | .update_fw_options = NULL, |
| 2119 | .load_risc = NULL, |
| 2120 | .pci_info_str = qlafx00_pci_info_str, |
| 2121 | .fw_version_str = qlafx00_fw_version_str, |
| 2122 | .intr_handler = qlafx00_intr_handler, |
| 2123 | .enable_intrs = qlafx00_enable_intrs, |
| 2124 | .disable_intrs = qlafx00_disable_intrs, |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2125 | .abort_command = qla24xx_async_abort_command, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2126 | .target_reset = qlafx00_abort_target, |
| 2127 | .lun_reset = qlafx00_lun_reset, |
| 2128 | .fabric_login = NULL, |
| 2129 | .fabric_logout = NULL, |
| 2130 | .calc_req_entries = NULL, |
| 2131 | .build_iocbs = NULL, |
| 2132 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2133 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2134 | .read_nvram = qla24xx_read_nvram_data, |
| 2135 | .write_nvram = qla24xx_write_nvram_data, |
| 2136 | .fw_dump = NULL, |
| 2137 | .beacon_on = qla24xx_beacon_on, |
| 2138 | .beacon_off = qla24xx_beacon_off, |
| 2139 | .beacon_blink = NULL, |
| 2140 | .read_optrom = qla24xx_read_optrom_data, |
| 2141 | .write_optrom = qla24xx_write_optrom_data, |
| 2142 | .get_flash_version = qla24xx_get_flash_version, |
| 2143 | .start_scsi = qlafx00_start_scsi, |
| 2144 | .abort_isp = qlafx00_abort_isp, |
| 2145 | .iospace_config = qlafx00_iospace_config, |
| 2146 | .initialize_adapter = qlafx00_initialize_adapter, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2147 | }; |
| 2148 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2149 | static struct isp_operations qla27xx_isp_ops = { |
| 2150 | .pci_config = qla25xx_pci_config, |
| 2151 | .reset_chip = qla24xx_reset_chip, |
| 2152 | .chip_diag = qla24xx_chip_diag, |
| 2153 | .config_rings = qla24xx_config_rings, |
| 2154 | .reset_adapter = qla24xx_reset_adapter, |
| 2155 | .nvram_config = qla81xx_nvram_config, |
| 2156 | .update_fw_options = qla81xx_update_fw_options, |
| 2157 | .load_risc = qla81xx_load_risc, |
| 2158 | .pci_info_str = qla24xx_pci_info_str, |
| 2159 | .fw_version_str = qla24xx_fw_version_str, |
| 2160 | .intr_handler = qla24xx_intr_handler, |
| 2161 | .enable_intrs = qla24xx_enable_intrs, |
| 2162 | .disable_intrs = qla24xx_disable_intrs, |
| 2163 | .abort_command = qla24xx_abort_command, |
| 2164 | .target_reset = qla24xx_abort_target, |
| 2165 | .lun_reset = qla24xx_lun_reset, |
| 2166 | .fabric_login = qla24xx_login_fabric, |
| 2167 | .fabric_logout = qla24xx_fabric_logout, |
| 2168 | .calc_req_entries = NULL, |
| 2169 | .build_iocbs = NULL, |
| 2170 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2171 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2172 | .read_nvram = NULL, |
| 2173 | .write_nvram = NULL, |
| 2174 | .fw_dump = qla27xx_fwdump, |
| 2175 | .beacon_on = qla24xx_beacon_on, |
| 2176 | .beacon_off = qla24xx_beacon_off, |
| 2177 | .beacon_blink = qla83xx_beacon_blink, |
| 2178 | .read_optrom = qla25xx_read_optrom_data, |
| 2179 | .write_optrom = qla24xx_write_optrom_data, |
| 2180 | .get_flash_version = qla24xx_get_flash_version, |
| 2181 | .start_scsi = qla24xx_dif_start_scsi, |
| 2182 | .abort_isp = qla2x00_abort_isp, |
| 2183 | .iospace_config = qla83xx_iospace_config, |
| 2184 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2185 | }; |
| 2186 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2187 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2188 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2189 | { |
| 2190 | ha->device_type = DT_EXTENDED_IDS; |
| 2191 | switch (ha->pdev->device) { |
| 2192 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2193 | ha->isp_type |= DT_ISP2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2194 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2195 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2196 | break; |
| 2197 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2198 | ha->isp_type |= DT_ISP2200; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2199 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2200 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2201 | break; |
| 2202 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2203 | ha->isp_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2204 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2205 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2206 | break; |
| 2207 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2208 | ha->isp_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2209 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2210 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2211 | break; |
| 2212 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2213 | ha->isp_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2214 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2215 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2216 | ha->pdev->subsystem_device == 0x0170) |
| 2217 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2218 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2219 | break; |
| 2220 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2221 | ha->isp_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2222 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2223 | break; |
| 2224 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2225 | ha->isp_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2226 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2227 | break; |
| 2228 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2229 | ha->isp_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2230 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2231 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2232 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2233 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2234 | break; |
| 2235 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2236 | ha->isp_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2237 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2238 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2239 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2240 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2241 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2242 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2243 | ha->isp_type |= DT_ISP8432; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2244 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2245 | ha->device_type |= DT_FWI2; |
| 2246 | ha->device_type |= DT_IIDMA; |
| 2247 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2248 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2249 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2250 | ha->isp_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2251 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2252 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2253 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2254 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2255 | ha->isp_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2256 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2257 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2258 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2259 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2260 | ha->isp_type |= DT_ISP2532; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2261 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2262 | ha->device_type |= DT_FWI2; |
| 2263 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2264 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2265 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2266 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2267 | ha->isp_type |= DT_ISP8001; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2268 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2269 | ha->device_type |= DT_FWI2; |
| 2270 | ha->device_type |= DT_IIDMA; |
| 2271 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2272 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2273 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2274 | ha->isp_type |= DT_ISP8021; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2275 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2276 | ha->device_type |= DT_FWI2; |
| 2277 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2278 | /* Initialize 82XX ISP flags */ |
| 2279 | qla82xx_init_flags(ha); |
| 2280 | break; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2281 | case PCI_DEVICE_ID_QLOGIC_ISP8044: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2282 | ha->isp_type |= DT_ISP8044; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2283 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2284 | ha->device_type |= DT_FWI2; |
| 2285 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2286 | /* Initialize 82XX ISP flags */ |
| 2287 | qla82xx_init_flags(ha); |
| 2288 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2289 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2290 | ha->isp_type |= DT_ISP2031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2291 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2292 | ha->device_type |= DT_FWI2; |
| 2293 | ha->device_type |= DT_IIDMA; |
| 2294 | ha->device_type |= DT_T10_PI; |
| 2295 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2296 | break; |
| 2297 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2298 | ha->isp_type |= DT_ISP8031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2299 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2300 | ha->device_type |= DT_FWI2; |
| 2301 | ha->device_type |= DT_IIDMA; |
| 2302 | ha->device_type |= DT_T10_PI; |
| 2303 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2304 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2305 | case PCI_DEVICE_ID_QLOGIC_ISPF001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2306 | ha->isp_type |= DT_ISPFX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2307 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2308 | case PCI_DEVICE_ID_QLOGIC_ISP2071: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2309 | ha->isp_type |= DT_ISP2071; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2310 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2311 | ha->device_type |= DT_FWI2; |
| 2312 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2313 | ha->device_type |= DT_T10_PI; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2314 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2315 | break; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2316 | case PCI_DEVICE_ID_QLOGIC_ISP2271: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2317 | ha->isp_type |= DT_ISP2271; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2318 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2319 | ha->device_type |= DT_FWI2; |
| 2320 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2321 | ha->device_type |= DT_T10_PI; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2322 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2323 | break; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2324 | case PCI_DEVICE_ID_QLOGIC_ISP2261: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2325 | ha->isp_type |= DT_ISP2261; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2326 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2327 | ha->device_type |= DT_FWI2; |
| 2328 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2329 | ha->device_type |= DT_T10_PI; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2330 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2331 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2332 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2333 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2334 | if (IS_QLA82XX(ha)) |
Saurav Kashyap | 43a9c38 | 2014-02-26 04:15:16 -0500 | [diff] [blame] | 2335 | ha->port_no = ha->portnum & 1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2336 | else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2337 | /* Get adapter physical port no from interrupt pin register. */ |
| 2338 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2339 | if (IS_QLA27XX(ha)) |
| 2340 | ha->port_no--; |
| 2341 | else |
| 2342 | ha->port_no = !(ha->port_no & 1); |
| 2343 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2344 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2345 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2346 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2347 | ha->device_type, ha->port_no, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2348 | } |
| 2349 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2350 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2351 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2352 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2353 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2354 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2355 | if (vha->hw->flags.running_gold_fw) |
| 2356 | return; |
| 2357 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2358 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2359 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2360 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2361 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2362 | } |
| 2363 | |
| 2364 | static int |
| 2365 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2366 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2367 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2368 | |
Bill Kuzeja | a5dd506e | 2016-10-21 16:45:27 -0400 | [diff] [blame] | 2369 | if (test_bit(UNLOADING, &vha->dpc_flags)) |
| 2370 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2371 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2372 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2373 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2374 | return 1; |
| 2375 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2376 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2377 | } |
| 2378 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2379 | /* |
| 2380 | * PCI driver interface |
| 2381 | */ |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 2382 | static int |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2383 | 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] | 2384 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2385 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2386 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2387 | scsi_qla_host_t *base_vha = NULL; |
| 2388 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2389 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2390 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2391 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2392 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2393 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2394 | struct req_que *req = NULL; |
| 2395 | struct rsp_que *rsp = NULL; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2396 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2397 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2398 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2399 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2400 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2401 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2402 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2403 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2404 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2405 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2406 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2407 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031 || |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2408 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISPF001 || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2409 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8044 || |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2410 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2071 || |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2411 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271 || |
| 2412 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2261) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2413 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2414 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2415 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2416 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2417 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2418 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2419 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2420 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2421 | if (mem_only) { |
| 2422 | if (pci_enable_device_mem(pdev)) |
Johannes Thumshirn | fe42472 | 2017-05-23 16:50:47 +0200 | [diff] [blame^] | 2423 | return ret; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2424 | } else { |
| 2425 | if (pci_enable_device(pdev)) |
Johannes Thumshirn | fe42472 | 2017-05-23 16:50:47 +0200 | [diff] [blame^] | 2426 | return ret; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2427 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2428 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2429 | /* This may fail but that's ok */ |
| 2430 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2431 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2432 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2433 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2434 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2435 | "Unable to allocate memory for ha.\n"); |
Johannes Thumshirn | fe42472 | 2017-05-23 16:50:47 +0200 | [diff] [blame^] | 2436 | goto disable_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2437 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2438 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2439 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2440 | ha->pdev = pdev; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2441 | ha->tgt.enable_class_2 = ql2xenableclass2; |
Quinn Tran | 33e7997 | 2014-09-25 06:14:55 -0400 | [diff] [blame] | 2442 | INIT_LIST_HEAD(&ha->tgt.q_full_list); |
| 2443 | spin_lock_init(&ha->tgt.q_full_lock); |
Quinn Tran | 7560151 | 2015-12-17 14:57:04 -0500 | [diff] [blame] | 2444 | spin_lock_init(&ha->tgt.sess_lock); |
Quinn Tran | 2f424b9 | 2015-12-17 14:57:07 -0500 | [diff] [blame] | 2445 | spin_lock_init(&ha->tgt.atio_lock); |
| 2446 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2447 | |
| 2448 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2449 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2450 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2451 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2452 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f722 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2453 | mutex_init(&ha->selflogin_lock); |
Chad Dupuis | 7a8ab9c | 2014-02-26 04:14:56 -0500 | [diff] [blame] | 2454 | mutex_init(&ha->optrom_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2455 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2456 | /* Set ISP-type information. */ |
| 2457 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2458 | |
| 2459 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2460 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2461 | IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2462 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2463 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2464 | ha->prev_topology = 0; |
| 2465 | ha->init_cb_size = sizeof(init_cb_t); |
| 2466 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2467 | ha->optrom_size = OPTROM_SIZE_2300; |
| 2468 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2469 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2470 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2471 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2472 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2473 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2474 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2475 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2476 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2477 | ha->flash_conf_off = ~0; |
| 2478 | ha->flash_data_off = ~0; |
| 2479 | ha->nvram_conf_off = ~0; |
| 2480 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2481 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2482 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2483 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2484 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2485 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2486 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2487 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2488 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2489 | ha->flash_conf_off = ~0; |
| 2490 | ha->flash_data_off = ~0; |
| 2491 | ha->nvram_conf_off = ~0; |
| 2492 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2493 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2494 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2495 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2496 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2497 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2498 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2499 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2500 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2501 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2502 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2503 | ha->flash_conf_off = ~0; |
| 2504 | ha->flash_data_off = ~0; |
| 2505 | ha->nvram_conf_off = ~0; |
| 2506 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2507 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2508 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2509 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2510 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2511 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2512 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2513 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2514 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2515 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2516 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2517 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2518 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2519 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2520 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2521 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2522 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2523 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2524 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2525 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2526 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2527 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2528 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2529 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2530 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2531 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2532 | ha->gid_list_info_size = 8; |
| 2533 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2534 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2535 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2536 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2537 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2538 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2539 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2540 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2541 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2542 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2543 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2544 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 2545 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2546 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2547 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2548 | ha->gid_list_info_size = 8; |
| 2549 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2550 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2551 | ha->isp_ops = &qla81xx_isp_ops; |
| 2552 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2553 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2554 | ha->nvram_conf_off = ~0; |
| 2555 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2556 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2557 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2558 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2559 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2560 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2561 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2562 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2563 | ha->gid_list_info_size = 8; |
| 2564 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2565 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2566 | ha->isp_ops = &qla82xx_isp_ops; |
| 2567 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2568 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2569 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2570 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2571 | } else if (IS_QLA8044(ha)) { |
| 2572 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2573 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2574 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2575 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2576 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2577 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2578 | ha->gid_list_info_size = 8; |
| 2579 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2580 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2581 | ha->isp_ops = &qla8044_isp_ops; |
| 2582 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2583 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2584 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2585 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2586 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2587 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2588 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2589 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Saurav Kashyap | f2ea653 | 2014-09-25 06:14:54 -0400 | [diff] [blame] | 2590 | req_length = REQUEST_ENTRY_CNT_83XX; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2591 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Arun Easi | b8aa4bd | 2013-01-30 03:34:40 -0500 | [diff] [blame] | 2592 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2593 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2594 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2595 | ha->gid_list_info_size = 8; |
| 2596 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2597 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2598 | ha->isp_ops = &qla83xx_isp_ops; |
| 2599 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2600 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2601 | ha->nvram_conf_off = ~0; |
| 2602 | ha->nvram_data_off = ~0; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2603 | } else if (IS_QLAFX00(ha)) { |
| 2604 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_FX00; |
| 2605 | ha->mbx_count = MAILBOX_REGISTER_COUNT_FX00; |
| 2606 | ha->aen_mbx_count = AEN_MAILBOX_REGISTER_COUNT_FX00; |
| 2607 | req_length = REQUEST_ENTRY_CNT_FX00; |
| 2608 | rsp_length = RESPONSE_ENTRY_CNT_FX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2609 | ha->isp_ops = &qlafx00_isp_ops; |
| 2610 | ha->port_down_retry_count = 30; /* default value */ |
| 2611 | ha->mr.fw_hbt_cnt = QLAFX00_HEARTBEAT_INTERVAL; |
| 2612 | ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; |
Armen Baloyan | 71e5600 | 2013-08-27 01:37:38 -0400 | [diff] [blame] | 2613 | ha->mr.fw_critemp_timer_tick = QLAFX00_CRITEMP_INTERVAL; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2614 | ha->mr.fw_hbt_en = 1; |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 2615 | ha->mr.host_info_resend = false; |
| 2616 | ha->mr.hinfo_resend_timer_tick = QLAFX00_HINFO_RESEND_INTERVAL; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2617 | } else if (IS_QLA27XX(ha)) { |
| 2618 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
| 2619 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2620 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2621 | req_length = REQUEST_ENTRY_CNT_83XX; |
| 2622 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 2623 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2624 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2625 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2626 | ha->gid_list_info_size = 8; |
| 2627 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2628 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2629 | ha->isp_ops = &qla27xx_isp_ops; |
| 2630 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2631 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2632 | ha->nvram_conf_off = ~0; |
| 2633 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2634 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2635 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2636 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 2637 | "mbx_count=%d, req_length=%d, " |
| 2638 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2639 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 2640 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2641 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 2642 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2643 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2644 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 2645 | "isp_ops=%p, flash_conf_off=%d, " |
| 2646 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 2647 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 2648 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2649 | |
| 2650 | /* Configure PCI I/O space */ |
| 2651 | ret = ha->isp_ops->iospace_config(ha); |
| 2652 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2653 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2654 | |
| 2655 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 2656 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 2657 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 2658 | mutex_init(&ha->vport_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2659 | init_completion(&ha->mbx_cmd_comp); |
| 2660 | complete(&ha->mbx_cmd_comp); |
| 2661 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 2662 | init_completion(&ha->dcbx_comp); |
Chad Dupuis | f356bef | 2013-02-08 01:58:04 -0500 | [diff] [blame] | 2663 | init_completion(&ha->lb_portup_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2664 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2665 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2666 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 2667 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2668 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 2669 | "64 Bit addressing is %s.\n", |
| 2670 | ha->flags.enable_64bit_addressing ? "enable" : |
| 2671 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2672 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 2673 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2674 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 2675 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2676 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2677 | goto probe_hw_failed; |
| 2678 | } |
| 2679 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2680 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2681 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2682 | req->max_q_depth = ql2xmaxqdepth; |
| 2683 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2684 | |
| 2685 | base_vha = qla2x00_create_host(sht, ha); |
| 2686 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2687 | ret = -ENOMEM; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2688 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2689 | qla2x00_free_req_que(ha, req); |
| 2690 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2691 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2692 | } |
| 2693 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2694 | pci_set_drvdata(pdev, base_vha); |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 2695 | set_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2696 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2697 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2698 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2699 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2700 | base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2701 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2702 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 2703 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2704 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2705 | /* Setup fcport template structure. */ |
| 2706 | ha->mr.fcport.vha = base_vha; |
| 2707 | ha->mr.fcport.port_type = FCT_UNKNOWN; |
| 2708 | ha->mr.fcport.loop_id = FC_NO_LOOP_ID; |
| 2709 | qla2x00_set_fcport_state(&ha->mr.fcport, FCS_UNCONFIGURED); |
| 2710 | ha->mr.fcport.supported_classes = FC_COS_UNSPECIFIED; |
| 2711 | ha->mr.fcport.scan_state = 1; |
| 2712 | |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2713 | /* Set the SG table size based on ISP type */ |
| 2714 | if (!IS_FWI2_CAPABLE(ha)) { |
| 2715 | if (IS_QLA2100(ha)) |
| 2716 | host->sg_tablesize = 32; |
| 2717 | } else { |
| 2718 | if (!IS_QLA82XX(ha)) |
| 2719 | host->sg_tablesize = QLA_SG_ALL; |
| 2720 | } |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2721 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2722 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 2723 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2724 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2725 | host->max_cmd_len = 32; |
| 2726 | else |
| 2727 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 2728 | host->max_channel = MAX_BUSES - 1; |
Hannes Reinecke | 755f516 | 2014-06-03 10:58:54 +0200 | [diff] [blame] | 2729 | /* Older HBAs support only 16-bit LUNs */ |
| 2730 | if (!IS_QLAFX00(ha) && !IS_FWI2_CAPABLE(ha) && |
| 2731 | ql2xmaxlun > 0xffff) |
| 2732 | host->max_lun = 0xffff; |
| 2733 | else |
| 2734 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2735 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2736 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2737 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2738 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 2739 | "max_id=%d this_id=%d " |
| 2740 | "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] | 2741 | "max_lun=%llu transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2742 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 2743 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 2744 | host->transportt, sht->vendor_id); |
| 2745 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2746 | que_init: |
| 2747 | /* Alloc arrays of request and response ring ptrs */ |
| 2748 | if (!qla2x00_alloc_queues(ha, req, rsp)) { |
| 2749 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 2750 | "Failed to allocate memory for queue pointers..." |
| 2751 | "aborting.\n"); |
| 2752 | goto probe_init_failed; |
| 2753 | } |
| 2754 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2755 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2756 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2757 | /* Set up the irqs */ |
| 2758 | ret = qla2x00_request_irqs(ha, rsp); |
| 2759 | if (ret) |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2760 | goto probe_init_failed; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2761 | |
| 2762 | pci_save_state(pdev); |
| 2763 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2764 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2765 | rsp->req = req; |
| 2766 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2767 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2768 | if (IS_QLAFX00(ha)) { |
| 2769 | ha->rsp_q_map[0] = rsp; |
| 2770 | ha->req_q_map[0] = req; |
| 2771 | set_bit(0, ha->req_qid_map); |
| 2772 | set_bit(0, ha->rsp_qid_map); |
| 2773 | } |
| 2774 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2775 | /* FWI2-capable only. */ |
| 2776 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 2777 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 2778 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 2779 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2780 | if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2781 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 2782 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 2783 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 2784 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 2785 | } |
| 2786 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2787 | if (IS_QLAFX00(ha)) { |
| 2788 | req->req_q_in = &ha->iobase->ispfx00.req_q_in; |
| 2789 | req->req_q_out = &ha->iobase->ispfx00.req_q_out; |
| 2790 | rsp->rsp_q_in = &ha->iobase->ispfx00.rsp_q_in; |
| 2791 | rsp->rsp_q_out = &ha->iobase->ispfx00.rsp_q_out; |
| 2792 | } |
| 2793 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2794 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2795 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 2796 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 2797 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 2798 | } |
| 2799 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2800 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 2801 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2802 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2803 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 2804 | "req->req_q_in=%p req->req_q_out=%p " |
| 2805 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2806 | req->req_q_in, req->req_q_out, |
| 2807 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 2808 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 2809 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2810 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2811 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 2812 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2813 | 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] | 2814 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2815 | if (ha->isp_ops->initialize_adapter(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2816 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 2817 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 2818 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2819 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2820 | if (IS_QLA82XX(ha)) { |
| 2821 | qla82xx_idc_lock(ha); |
| 2822 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2823 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2824 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2825 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 2826 | "HW State: FAILED.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2827 | } else if (IS_QLA8044(ha)) { |
| 2828 | qla8044_idc_lock(ha); |
| 2829 | qla8044_wr_direct(base_vha, |
| 2830 | QLA8044_CRB_DEV_STATE_INDEX, |
| 2831 | QLA8XXX_DEV_FAILED); |
| 2832 | qla8044_idc_unlock(ha); |
| 2833 | ql_log(ql_log_fatal, base_vha, 0x0150, |
| 2834 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2835 | } |
| 2836 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2837 | ret = -ENODEV; |
| 2838 | goto probe_failed; |
| 2839 | } |
| 2840 | |
Chad Dupuis | 3b1bef6 | 2014-02-26 04:15:04 -0500 | [diff] [blame] | 2841 | if (IS_QLAFX00(ha)) |
| 2842 | host->can_queue = QLAFX00_MAX_CANQUEUE; |
| 2843 | else |
| 2844 | host->can_queue = req->num_outstanding_cmds - 10; |
| 2845 | |
| 2846 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 2847 | "can_queue=%d, req=%p, mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 2848 | host->can_queue, base_vha->req, |
| 2849 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
| 2850 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2851 | if (ha->mqenable) { |
| 2852 | if (qla25xx_setup_mode(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2853 | ql_log(ql_log_warn, base_vha, 0x00ec, |
| 2854 | "Failed to create queues, falling back to single queue mode.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2855 | goto que_init; |
| 2856 | } |
| 2857 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2858 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2859 | if (ha->flags.running_gold_fw) |
| 2860 | goto skip_dpc; |
| 2861 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2862 | /* |
| 2863 | * Startup the kernel thread for this host adapter |
| 2864 | */ |
| 2865 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2866 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2867 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2868 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 2869 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2870 | ret = PTR_ERR(ha->dpc_thread); |
| 2871 | goto probe_failed; |
| 2872 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2873 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 2874 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2875 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2876 | /* |
| 2877 | * If we're not coming up in initiator mode, we might sit for |
| 2878 | * a while without waking up the dpc thread, which leads to a |
| 2879 | * stuck process warning. So just kick the dpc once here and |
| 2880 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 2881 | */ |
| 2882 | qla2xxx_wake_dpc(base_vha); |
| 2883 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 2884 | INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); |
| 2885 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 2886 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 2887 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 2888 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 2889 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 2890 | |
| 2891 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 2892 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 2893 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 2894 | INIT_WORK(&ha->idc_state_handler, |
| 2895 | qla83xx_idc_state_handler_work); |
| 2896 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 2897 | qla83xx_nic_core_unrecoverable_work); |
| 2898 | } |
| 2899 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2900 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2901 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 2902 | base_vha->host->irq = ha->pdev->irq; |
| 2903 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2904 | /* Initialized the timer */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2905 | qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2906 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 2907 | "Started qla2x00_timer with " |
| 2908 | "interval=%d.\n", WATCH_INTERVAL); |
| 2909 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 2910 | "Detected hba at address=%p.\n", |
| 2911 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2912 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2913 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2914 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2915 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2916 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2917 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 2918 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2919 | if (ql2xenabledif == 1) |
| 2920 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2921 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2922 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2923 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2924 | | SHOST_DIF_TYPE3_PROTECTION |
| 2925 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2926 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2927 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2928 | |
| 2929 | guard = SHOST_DIX_GUARD_CRC; |
| 2930 | |
| 2931 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 2932 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 2933 | guard |= SHOST_DIX_GUARD_IP; |
| 2934 | |
| 2935 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2936 | } else |
| 2937 | base_vha->flags.difdix_supported = 0; |
| 2938 | } |
| 2939 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2940 | ha->isp_ops->enable_intrs(ha); |
| 2941 | |
Armen Baloyan | 1fe19ee | 2013-08-27 01:37:41 -0400 | [diff] [blame] | 2942 | if (IS_QLAFX00(ha)) { |
| 2943 | ret = qlafx00_fx_disc(base_vha, |
| 2944 | &base_vha->hw->mr.fcport, FXDISC_GET_CONFIG_INFO); |
| 2945 | host->sg_tablesize = (ha->mr.extended_io_enabled) ? |
| 2946 | QLA_SG_ALL : 128; |
| 2947 | } |
| 2948 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2949 | ret = scsi_add_host(host, &pdev->dev); |
| 2950 | if (ret) |
| 2951 | goto probe_failed; |
| 2952 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 2953 | base_vha->flags.init_done = 1; |
| 2954 | base_vha->flags.online = 1; |
Saurav Kashyap | edaa5c7 | 2014-04-11 16:54:14 -0400 | [diff] [blame] | 2955 | ha->prev_minidump_failed = 0; |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 2956 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2957 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 2958 | "Init done and hba is online.\n"); |
| 2959 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2960 | if (qla_ini_mode_enabled(base_vha)) |
| 2961 | scsi_scan_host(host); |
| 2962 | else |
| 2963 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 2964 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2965 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2966 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2967 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2968 | if (IS_QLAFX00(ha)) { |
| 2969 | ret = qlafx00_fx_disc(base_vha, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2970 | &base_vha->hw->mr.fcport, FXDISC_GET_PORT_INFO); |
| 2971 | |
| 2972 | /* Register system information */ |
| 2973 | ret = qlafx00_fx_disc(base_vha, |
| 2974 | &base_vha->hw->mr.fcport, FXDISC_REG_HOST_INFO); |
| 2975 | } |
| 2976 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2977 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2978 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2979 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2980 | |
Armen Baloyan | 03eb912 | 2013-10-30 03:38:22 -0400 | [diff] [blame] | 2981 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 2982 | "QLogic %s - %s.\n", ha->model_number, ha->model_desc); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2983 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 2984 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 2985 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 2986 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 2987 | base_vha->host_no, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2988 | ha->isp_ops->fw_version_str(base_vha, fw_str, sizeof(fw_str))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2989 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2990 | qlt_add_target(ha, base_vha); |
| 2991 | |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 2992 | clear_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 2993 | |
| 2994 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 2995 | return -ENODEV; |
| 2996 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2997 | return 0; |
| 2998 | |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2999 | probe_init_failed: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3000 | qla2x00_free_req_que(ha, req); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3001 | ha->req_q_map[0] = NULL; |
| 3002 | clear_bit(0, ha->req_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3003 | qla2x00_free_rsp_que(ha, rsp); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3004 | ha->rsp_q_map[0] = NULL; |
| 3005 | clear_bit(0, ha->rsp_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3006 | ha->max_req_queues = ha->max_rsp_queues = 0; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 3007 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3008 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3009 | if (base_vha->timer_active) |
| 3010 | qla2x00_stop_timer(base_vha); |
| 3011 | base_vha->flags.online = 0; |
| 3012 | if (ha->dpc_thread) { |
| 3013 | struct task_struct *t = ha->dpc_thread; |
| 3014 | |
| 3015 | ha->dpc_thread = NULL; |
| 3016 | kthread_stop(t); |
| 3017 | } |
| 3018 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3019 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3020 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3021 | scsi_host_put(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3022 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3023 | probe_hw_failed: |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 3024 | qla2x00_clear_drv_active(ha); |
| 3025 | |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3026 | iospace_config_failed: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3027 | if (IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3028 | if (!ha->nx_pcibase) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3029 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3030 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3031 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3032 | } else { |
| 3033 | if (ha->iobase) |
| 3034 | iounmap(ha->iobase); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3035 | if (ha->cregbase) |
| 3036 | iounmap(ha->cregbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3037 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3038 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3039 | kfree(ha); |
| 3040 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3041 | |
Johannes Thumshirn | fe42472 | 2017-05-23 16:50:47 +0200 | [diff] [blame^] | 3042 | disable_device: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3043 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3044 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3045 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3046 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 3047 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3048 | qla2x00_shutdown(struct pci_dev *pdev) |
| 3049 | { |
| 3050 | scsi_qla_host_t *vha; |
| 3051 | struct qla_hw_data *ha; |
| 3052 | |
Masanari Iida | 552f3f9 | 2013-02-08 01:57:44 -0500 | [diff] [blame] | 3053 | if (!atomic_read(&pdev->enable_cnt)) |
| 3054 | return; |
| 3055 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3056 | vha = pci_get_drvdata(pdev); |
| 3057 | ha = vha->hw; |
| 3058 | |
Armen Baloyan | 4247934 | 2013-08-27 01:37:37 -0400 | [diff] [blame] | 3059 | /* Notify ISPFX00 firmware */ |
| 3060 | if (IS_QLAFX00(ha)) |
| 3061 | qlafx00_driver_shutdown(vha, 20); |
| 3062 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3063 | /* Turn-off FCE trace */ |
| 3064 | if (ha->flags.fce_enabled) { |
| 3065 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 3066 | ha->flags.fce_enabled = 0; |
| 3067 | } |
| 3068 | |
| 3069 | /* Turn-off EFT trace */ |
| 3070 | if (ha->eft) |
| 3071 | qla2x00_disable_eft_trace(vha); |
| 3072 | |
| 3073 | /* Stop currently executing firmware. */ |
| 3074 | qla2x00_try_to_stop_firmware(vha); |
| 3075 | |
| 3076 | /* Turn adapter off line */ |
| 3077 | vha->flags.online = 0; |
| 3078 | |
| 3079 | /* turn-off interrupts on the card */ |
| 3080 | if (ha->interrupts_on) { |
| 3081 | vha->flags.init_done = 0; |
| 3082 | ha->isp_ops->disable_intrs(ha); |
| 3083 | } |
| 3084 | |
| 3085 | qla2x00_free_irqs(vha); |
| 3086 | |
| 3087 | qla2x00_free_fw_dump(ha); |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3088 | |
| 3089 | pci_disable_pcie_error_reporting(pdev); |
| 3090 | pci_disable_device(pdev); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3091 | } |
| 3092 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3093 | /* Deletes all the virtual ports for a given ha */ |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3094 | static void |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3095 | 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] | 3096 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3097 | scsi_qla_host_t *vha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3098 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3099 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3100 | mutex_lock(&ha->vport_lock); |
| 3101 | while (ha->cur_vport_count) { |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3102 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3103 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3104 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 3105 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 3106 | vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list); |
Bart Van Assche | 52c8282 | 2015-07-09 07:23:26 -0700 | [diff] [blame] | 3107 | scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3108 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3109 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3110 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3111 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3112 | fc_vport_terminate(vha->fc_vport); |
| 3113 | scsi_host_put(vha->host); |
| 3114 | |
| 3115 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3116 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3117 | mutex_unlock(&ha->vport_lock); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3118 | } |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3119 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3120 | /* Stops all deferred work threads */ |
| 3121 | static void |
| 3122 | qla2x00_destroy_deferred_work(struct qla_hw_data *ha) |
| 3123 | { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3124 | /* Flush the work queue and remove it */ |
| 3125 | if (ha->wq) { |
| 3126 | flush_workqueue(ha->wq); |
| 3127 | destroy_workqueue(ha->wq); |
| 3128 | ha->wq = NULL; |
| 3129 | } |
| 3130 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3131 | /* Cancel all work and destroy DPC workqueues */ |
| 3132 | if (ha->dpc_lp_wq) { |
| 3133 | cancel_work_sync(&ha->idc_aen); |
| 3134 | destroy_workqueue(ha->dpc_lp_wq); |
| 3135 | ha->dpc_lp_wq = NULL; |
| 3136 | } |
| 3137 | |
| 3138 | if (ha->dpc_hp_wq) { |
| 3139 | cancel_work_sync(&ha->nic_core_reset); |
| 3140 | cancel_work_sync(&ha->idc_state_handler); |
| 3141 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 3142 | destroy_workqueue(ha->dpc_hp_wq); |
| 3143 | ha->dpc_hp_wq = NULL; |
| 3144 | } |
| 3145 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3146 | /* Kill the kernel thread for this host */ |
| 3147 | if (ha->dpc_thread) { |
| 3148 | struct task_struct *t = ha->dpc_thread; |
| 3149 | |
| 3150 | /* |
| 3151 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 3152 | * so we need to zero it out. |
| 3153 | */ |
| 3154 | ha->dpc_thread = NULL; |
| 3155 | kthread_stop(t); |
| 3156 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3157 | } |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3158 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3159 | static void |
| 3160 | qla2x00_unmap_iobases(struct qla_hw_data *ha) |
| 3161 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3162 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 3163 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3164 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3165 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3166 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3167 | } else { |
| 3168 | if (ha->iobase) |
| 3169 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3170 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3171 | if (ha->cregbase) |
| 3172 | iounmap(ha->cregbase); |
| 3173 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3174 | if (ha->mqiobase) |
| 3175 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3176 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3177 | if ((IS_QLA83XX(ha) || IS_QLA27XX(ha)) && ha->msixbase) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3178 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3179 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3180 | } |
| 3181 | |
| 3182 | static void |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3183 | qla2x00_clear_drv_active(struct qla_hw_data *ha) |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3184 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3185 | if (IS_QLA8044(ha)) { |
| 3186 | qla8044_idc_lock(ha); |
Saurav Kashyap | c41afc9 | 2013-11-07 02:54:56 -0500 | [diff] [blame] | 3187 | qla8044_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3188 | qla8044_idc_unlock(ha); |
| 3189 | } else if (IS_QLA82XX(ha)) { |
| 3190 | qla82xx_idc_lock(ha); |
| 3191 | qla82xx_clear_drv_active(ha); |
| 3192 | qla82xx_idc_unlock(ha); |
| 3193 | } |
| 3194 | } |
| 3195 | |
| 3196 | static void |
| 3197 | qla2x00_remove_one(struct pci_dev *pdev) |
| 3198 | { |
| 3199 | scsi_qla_host_t *base_vha; |
| 3200 | struct qla_hw_data *ha; |
| 3201 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3202 | base_vha = pci_get_drvdata(pdev); |
| 3203 | ha = base_vha->hw; |
| 3204 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3205 | /* Indicate device removal to prevent future board_disable and wait |
| 3206 | * until any pending board_disable has completed. */ |
| 3207 | set_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags); |
| 3208 | cancel_work_sync(&ha->board_disable); |
| 3209 | |
| 3210 | /* |
| 3211 | * If the PCI device is disabled then there was a PCI-disconnect and |
| 3212 | * qla2x00_disable_board_on_pci_error has taken care of most of the |
| 3213 | * resources. |
| 3214 | */ |
| 3215 | if (!atomic_read(&pdev->enable_cnt)) { |
| 3216 | scsi_host_put(base_vha->host); |
| 3217 | kfree(ha); |
| 3218 | pci_set_drvdata(pdev, NULL); |
| 3219 | return; |
| 3220 | } |
| 3221 | |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 3222 | qla2x00_wait_for_hba_ready(base_vha); |
| 3223 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 3224 | /* if UNLOAD flag is already set, then continue unload, |
| 3225 | * where it was set first. |
| 3226 | */ |
| 3227 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3228 | return; |
| 3229 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3230 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 3231 | |
| 3232 | if (IS_QLAFX00(ha)) |
| 3233 | qlafx00_driver_shutdown(base_vha, 20); |
| 3234 | |
| 3235 | qla2x00_delete_all_vps(ha, base_vha); |
| 3236 | |
| 3237 | if (IS_QLA8031(ha)) { |
| 3238 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 3239 | "Clearing fcoe driver presence.\n"); |
| 3240 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 3241 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 3242 | "Error while clearing DRV-Presence.\n"); |
| 3243 | } |
| 3244 | |
| 3245 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 3246 | |
| 3247 | qla2x00_dfs_remove(base_vha); |
| 3248 | |
| 3249 | qla84xx_put_chip(base_vha); |
| 3250 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 3251 | /* Laser should be disabled only for ISP2031 */ |
| 3252 | if (IS_QLA2031(ha)) |
| 3253 | qla83xx_disable_laser(base_vha); |
| 3254 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3255 | /* Disable timer */ |
| 3256 | if (base_vha->timer_active) |
| 3257 | qla2x00_stop_timer(base_vha); |
| 3258 | |
| 3259 | base_vha->flags.online = 0; |
| 3260 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3261 | /* free DMA memory */ |
| 3262 | if (ha->exlogin_buf) |
| 3263 | qla2x00_free_exlogin_buffer(ha); |
| 3264 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3265 | /* free DMA memory */ |
| 3266 | if (ha->exchoffld_buf) |
| 3267 | qla2x00_free_exchoffld_buffer(ha); |
| 3268 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3269 | qla2x00_destroy_deferred_work(ha); |
| 3270 | |
| 3271 | qlt_remove_target(ha, base_vha); |
| 3272 | |
| 3273 | qla2x00_free_sysfs_attr(base_vha, true); |
| 3274 | |
| 3275 | fc_remove_host(base_vha->host); |
| 3276 | |
| 3277 | scsi_remove_host(base_vha->host); |
| 3278 | |
| 3279 | qla2x00_free_device(base_vha); |
| 3280 | |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3281 | qla2x00_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3282 | |
Arun Easi | d2749ff | 2014-09-25 05:16:51 -0400 | [diff] [blame] | 3283 | scsi_host_put(base_vha->host); |
| 3284 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3285 | qla2x00_unmap_iobases(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3286 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3287 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3288 | kfree(ha); |
| 3289 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3290 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3291 | pci_disable_pcie_error_reporting(pdev); |
| 3292 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 3293 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3294 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3295 | |
| 3296 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3297 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3298 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3299 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3300 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3301 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 3302 | |
| 3303 | /* Disable timer */ |
| 3304 | if (vha->timer_active) |
| 3305 | qla2x00_stop_timer(vha); |
| 3306 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3307 | qla25xx_delete_queues(vha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3308 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3309 | if (ha->flags.fce_enabled) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3310 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3311 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3312 | if (ha->eft) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3313 | qla2x00_disable_eft_trace(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3314 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3315 | /* Stop currently executing firmware. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3316 | qla2x00_try_to_stop_firmware(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3317 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3318 | vha->flags.online = 0; |
| 3319 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3320 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3321 | if (ha->interrupts_on) { |
| 3322 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 3323 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3324 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3325 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3326 | qla2x00_free_irqs(vha); |
| 3327 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3328 | qla2x00_free_fcports(vha); |
| 3329 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3330 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3331 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 3332 | qla82xx_md_free(vha); |
| 3333 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3334 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3335 | } |
| 3336 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3337 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 3338 | { |
| 3339 | fc_port_t *fcport, *tfcport; |
| 3340 | |
| 3341 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 3342 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3343 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3344 | kfree(fcport); |
| 3345 | fcport = NULL; |
| 3346 | } |
| 3347 | } |
| 3348 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3349 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3350 | 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] | 3351 | int defer) |
| 3352 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3353 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3354 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3355 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3356 | |
| 3357 | if (!fcport->rport) |
| 3358 | return; |
| 3359 | |
| 3360 | rport = fcport->rport; |
| 3361 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3362 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3363 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3364 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3365 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3366 | qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3367 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 3368 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3369 | } else { |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3370 | int now; |
Alexei Potashnik | d20ed91 | 2015-07-14 16:00:47 -0400 | [diff] [blame] | 3371 | if (rport) |
| 3372 | fc_remote_port_delete(rport); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3373 | qlt_do_generation_tick(vha, &now); |
| 3374 | qlt_fc_port_deleted(vha, fcport, now); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3375 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3376 | } |
| 3377 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3378 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3379 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 3380 | * |
| 3381 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 3382 | * |
| 3383 | * Return: None. |
| 3384 | * |
| 3385 | * Context: |
| 3386 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3387 | 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] | 3388 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3389 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3390 | if (IS_QLAFX00(vha->hw)) { |
| 3391 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
| 3392 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3393 | return; |
| 3394 | } |
| 3395 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3396 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3397 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3398 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3399 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3400 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3401 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3402 | * We may need to retry the login, so don't change the state of the |
| 3403 | * port but do the retries. |
| 3404 | */ |
| 3405 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3406 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3407 | |
| 3408 | if (!do_login) |
| 3409 | return; |
| 3410 | |
Arun Easi | a1d0285 | 2015-08-04 13:38:02 -0400 | [diff] [blame] | 3411 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 3412 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3413 | if (fcport->login_retry == 0) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3414 | fcport->login_retry = vha->hw->login_retry_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3415 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3416 | ql_dbg(ql_dbg_disc, vha, 0x2067, |
Oleksandr Khoshaba | 7b83355 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 3417 | "Port login retry %8phN, id = 0x%04x retry cnt=%d.\n", |
| 3418 | fcport->port_name, fcport->loop_id, fcport->login_retry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3419 | } |
| 3420 | } |
| 3421 | |
| 3422 | /* |
| 3423 | * qla2x00_mark_all_devices_lost |
| 3424 | * Updates fcport state when device goes offline. |
| 3425 | * |
| 3426 | * Input: |
| 3427 | * ha = adapter block pointer. |
| 3428 | * fcport = port structure pointer. |
| 3429 | * |
| 3430 | * Return: |
| 3431 | * None. |
| 3432 | * |
| 3433 | * Context: |
| 3434 | */ |
| 3435 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3436 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3437 | { |
| 3438 | fc_port_t *fcport; |
| 3439 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3440 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3441 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3442 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3443 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3444 | /* |
| 3445 | * No point in marking the device as lost, if the device is |
| 3446 | * already DEAD. |
| 3447 | */ |
| 3448 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3449 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3450 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3451 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3452 | if (defer) |
| 3453 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3454 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3455 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3456 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3457 | } |
| 3458 | } |
| 3459 | |
| 3460 | /* |
| 3461 | * qla2x00_mem_alloc |
| 3462 | * Allocates adapter memory. |
| 3463 | * |
| 3464 | * Returns: |
| 3465 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3466 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3467 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3468 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3469 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3470 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3471 | { |
| 3472 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3473 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3474 | 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] | 3475 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3476 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3477 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3478 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3479 | if (qlt_mem_alloc(ha) < 0) |
| 3480 | goto fail_free_init_cb; |
| 3481 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3482 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3483 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3484 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3485 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3486 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3487 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3488 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3489 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3490 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3491 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3492 | /* Allocate cache for CT6 Ctx. */ |
| 3493 | if (!ctx_cachep) { |
| 3494 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3495 | sizeof(struct ct6_dsd), 0, |
| 3496 | SLAB_HWCACHE_ALIGN, NULL); |
| 3497 | if (!ctx_cachep) |
Quinn Tran | beecb1e | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3498 | goto fail_free_srb_mempool; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3499 | } |
| 3500 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3501 | ctx_cachep); |
| 3502 | if (!ha->ctx_mempool) |
| 3503 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3504 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3505 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3506 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3507 | } |
| 3508 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3509 | /* Get memory for cached NVRAM */ |
| 3510 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3511 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3512 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3513 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3514 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3515 | ha->pdev->device); |
| 3516 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3517 | DMA_POOL_SIZE, 8, 0); |
| 3518 | if (!ha->s_dma_pool) |
| 3519 | goto fail_free_nvram; |
| 3520 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3521 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3522 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3523 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3524 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3525 | if (IS_P3P_TYPE(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3526 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3527 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3528 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3529 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3530 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3531 | goto fail_s_dma_pool; |
| 3532 | } |
| 3533 | |
| 3534 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3535 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3536 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3537 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3538 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3539 | goto fail_dl_dma_pool; |
| 3540 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3541 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3542 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3543 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3544 | } |
| 3545 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3546 | /* Allocate memory for SNS commands */ |
| 3547 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3548 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3549 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3550 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3551 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3552 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3553 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 3554 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3555 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3556 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3557 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3558 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3559 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3560 | goto fail_dma_pool; |
| 3561 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3562 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3563 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3564 | if (!ha->ct_sns) |
| 3565 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3566 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 3567 | "ms_iocb=%p ct_sns=%p.\n", |
| 3568 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3569 | } |
| 3570 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3571 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3572 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 3573 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3574 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 3575 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3576 | goto fail_req; |
| 3577 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3578 | (*req)->length = req_len; |
| 3579 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3580 | ((*req)->length + 1) * sizeof(request_t), |
| 3581 | &(*req)->dma, GFP_KERNEL); |
| 3582 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3583 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 3584 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3585 | goto fail_req_ring; |
| 3586 | } |
| 3587 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3588 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 3589 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3590 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 3591 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3592 | goto fail_rsp; |
| 3593 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3594 | (*rsp)->hw = ha; |
| 3595 | (*rsp)->length = rsp_len; |
| 3596 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3597 | ((*rsp)->length + 1) * sizeof(response_t), |
| 3598 | &(*rsp)->dma, GFP_KERNEL); |
| 3599 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3600 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 3601 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3602 | goto fail_rsp_ring; |
| 3603 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3604 | (*req)->rsp = *rsp; |
| 3605 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3606 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 3607 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 3608 | "rsp->length=%d rsp->ring=%p.\n", |
| 3609 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 3610 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3611 | /* Allocate memory for NVRAM data for vports */ |
| 3612 | if (ha->nvram_npiv_size) { |
| 3613 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3614 | ha->nvram_npiv_size, GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3615 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3616 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 3617 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3618 | goto fail_npiv_info; |
| 3619 | } |
| 3620 | } else |
| 3621 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3622 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3623 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3624 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3625 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3626 | &ha->ex_init_cb_dma); |
| 3627 | if (!ha->ex_init_cb) |
| 3628 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3629 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 3630 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3631 | } |
| 3632 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3633 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 3634 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3635 | /* Get consistent memory allocated for Async Port-Database. */ |
| 3636 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3637 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3638 | &ha->async_pd_dma); |
| 3639 | if (!ha->async_pd) |
| 3640 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3641 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 3642 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3643 | } |
| 3644 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3645 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3646 | |
| 3647 | /* Allocate memory for our loop_id bitmap */ |
| 3648 | ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), |
| 3649 | GFP_KERNEL); |
| 3650 | if (!ha->loop_id_map) |
Quinn Tran | beecb1e | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3651 | goto fail_loop_id_map; |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3652 | else { |
| 3653 | qla2x00_set_reserved_loop_ids(ha); |
| 3654 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3655 | "loop_id_map=%p.\n", ha->loop_id_map); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3656 | } |
| 3657 | |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3658 | return 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3659 | |
Quinn Tran | beecb1e | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3660 | fail_loop_id_map: |
| 3661 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3662 | fail_async_pd: |
| 3663 | 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] | 3664 | fail_ex_init_cb: |
| 3665 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3666 | fail_npiv_info: |
| 3667 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 3668 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 3669 | (*rsp)->ring = NULL; |
| 3670 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3671 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3672 | kfree(*rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3673 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3674 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 3675 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 3676 | (*req)->ring = NULL; |
| 3677 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3678 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3679 | kfree(*req); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3680 | fail_req: |
| 3681 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 3682 | ha->ct_sns, ha->ct_sns_dma); |
| 3683 | ha->ct_sns = NULL; |
| 3684 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3685 | fail_free_ms_iocb: |
| 3686 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3687 | ha->ms_iocb = NULL; |
| 3688 | ha->ms_iocb_dma = 0; |
Quinn Tran | beecb1e | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3689 | |
| 3690 | if (ha->sns_cmd) |
| 3691 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
| 3692 | ha->sns_cmd, ha->sns_cmd_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3693 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3694 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3695 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3696 | ha->fcp_cmnd_dma_pool = NULL; |
| 3697 | } |
| 3698 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3699 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3700 | dma_pool_destroy(ha->dl_dma_pool); |
| 3701 | ha->dl_dma_pool = NULL; |
| 3702 | } |
| 3703 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3704 | dma_pool_destroy(ha->s_dma_pool); |
| 3705 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3706 | fail_free_nvram: |
| 3707 | kfree(ha->nvram); |
| 3708 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3709 | fail_free_ctx_mempool: |
Quinn Tran | beecb1e | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3710 | if (ha->ctx_mempool) |
| 3711 | mempool_destroy(ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3712 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3713 | fail_free_srb_mempool: |
Quinn Tran | beecb1e | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3714 | if (ha->srb_mempool) |
| 3715 | mempool_destroy(ha->srb_mempool); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3716 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3717 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3718 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3719 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3720 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3721 | ha->gid_list = NULL; |
| 3722 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3723 | fail_free_tgt_mem: |
| 3724 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3725 | fail_free_init_cb: |
| 3726 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 3727 | ha->init_cb_dma); |
| 3728 | ha->init_cb = NULL; |
| 3729 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3730 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3731 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 3732 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3733 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3734 | } |
| 3735 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3736 | int |
| 3737 | qla2x00_set_exlogins_buffer(scsi_qla_host_t *vha) |
| 3738 | { |
| 3739 | int rval; |
| 3740 | uint16_t size, max_cnt, temp; |
| 3741 | struct qla_hw_data *ha = vha->hw; |
| 3742 | |
| 3743 | /* Return if we don't need to alloacate any extended logins */ |
| 3744 | if (!ql2xexlogins) |
| 3745 | return QLA_SUCCESS; |
| 3746 | |
| 3747 | ql_log(ql_log_info, vha, 0xd021, "EXLOGIN count: %d.\n", ql2xexlogins); |
| 3748 | max_cnt = 0; |
| 3749 | rval = qla_get_exlogin_status(vha, &size, &max_cnt); |
| 3750 | if (rval != QLA_SUCCESS) { |
| 3751 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd029, |
| 3752 | "Failed to get exlogin status.\n"); |
| 3753 | return rval; |
| 3754 | } |
| 3755 | |
| 3756 | temp = (ql2xexlogins > max_cnt) ? max_cnt : ql2xexlogins; |
| 3757 | ha->exlogin_size = (size * temp); |
| 3758 | ql_log(ql_log_info, vha, 0xd024, |
| 3759 | "EXLOGIN: max_logins=%d, portdb=0x%x, total=%d.\n", |
| 3760 | max_cnt, size, temp); |
| 3761 | |
| 3762 | ql_log(ql_log_info, vha, 0xd025, "EXLOGIN: requested size=0x%x\n", |
| 3763 | ha->exlogin_size); |
| 3764 | |
| 3765 | /* Get consistent memory for extended logins */ |
| 3766 | ha->exlogin_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 3767 | ha->exlogin_size, &ha->exlogin_buf_dma, GFP_KERNEL); |
| 3768 | if (!ha->exlogin_buf) { |
| 3769 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd02a, |
| 3770 | "Failed to allocate memory for exlogin_buf_dma.\n"); |
| 3771 | return -ENOMEM; |
| 3772 | } |
| 3773 | |
| 3774 | /* Now configure the dma buffer */ |
| 3775 | rval = qla_set_exlogin_mem_cfg(vha, ha->exlogin_buf_dma); |
| 3776 | if (rval) { |
| 3777 | ql_log(ql_log_fatal, vha, 0x00cf, |
| 3778 | "Setup extended login buffer ****FAILED****.\n"); |
| 3779 | qla2x00_free_exlogin_buffer(ha); |
| 3780 | } |
| 3781 | |
| 3782 | return rval; |
| 3783 | } |
| 3784 | |
| 3785 | /* |
| 3786 | * qla2x00_free_exlogin_buffer |
| 3787 | * |
| 3788 | * Input: |
| 3789 | * ha = adapter block pointer |
| 3790 | */ |
| 3791 | void |
| 3792 | qla2x00_free_exlogin_buffer(struct qla_hw_data *ha) |
| 3793 | { |
| 3794 | if (ha->exlogin_buf) { |
| 3795 | dma_free_coherent(&ha->pdev->dev, ha->exlogin_size, |
| 3796 | ha->exlogin_buf, ha->exlogin_buf_dma); |
| 3797 | ha->exlogin_buf = NULL; |
| 3798 | ha->exlogin_size = 0; |
| 3799 | } |
| 3800 | } |
| 3801 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3802 | int |
| 3803 | qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) |
| 3804 | { |
| 3805 | int rval; |
| 3806 | uint16_t size, max_cnt, temp; |
| 3807 | struct qla_hw_data *ha = vha->hw; |
| 3808 | |
| 3809 | /* Return if we don't need to alloacate any extended logins */ |
| 3810 | if (!ql2xexchoffld) |
| 3811 | return QLA_SUCCESS; |
| 3812 | |
| 3813 | ql_log(ql_log_info, vha, 0xd014, |
| 3814 | "Exchange offload count: %d.\n", ql2xexlogins); |
| 3815 | |
| 3816 | max_cnt = 0; |
| 3817 | rval = qla_get_exchoffld_status(vha, &size, &max_cnt); |
| 3818 | if (rval != QLA_SUCCESS) { |
| 3819 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd012, |
| 3820 | "Failed to get exlogin status.\n"); |
| 3821 | return rval; |
| 3822 | } |
| 3823 | |
| 3824 | temp = (ql2xexchoffld > max_cnt) ? max_cnt : ql2xexchoffld; |
| 3825 | ha->exchoffld_size = (size * temp); |
| 3826 | ql_log(ql_log_info, vha, 0xd016, |
| 3827 | "Exchange offload: max_count=%d, buffers=0x%x, total=%d.\n", |
| 3828 | max_cnt, size, temp); |
| 3829 | |
| 3830 | ql_log(ql_log_info, vha, 0xd017, |
| 3831 | "Exchange Buffers requested size = 0x%x\n", ha->exchoffld_size); |
| 3832 | |
| 3833 | /* Get consistent memory for extended logins */ |
| 3834 | ha->exchoffld_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 3835 | ha->exchoffld_size, &ha->exchoffld_buf_dma, GFP_KERNEL); |
| 3836 | if (!ha->exchoffld_buf) { |
| 3837 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
| 3838 | "Failed to allocate memory for exchoffld_buf_dma.\n"); |
| 3839 | return -ENOMEM; |
| 3840 | } |
| 3841 | |
| 3842 | /* Now configure the dma buffer */ |
| 3843 | rval = qla_set_exchoffld_mem_cfg(vha, ha->exchoffld_buf_dma); |
| 3844 | if (rval) { |
| 3845 | ql_log(ql_log_fatal, vha, 0xd02e, |
| 3846 | "Setup exchange offload buffer ****FAILED****.\n"); |
| 3847 | qla2x00_free_exchoffld_buffer(ha); |
| 3848 | } |
| 3849 | |
| 3850 | return rval; |
| 3851 | } |
| 3852 | |
| 3853 | /* |
| 3854 | * qla2x00_free_exchoffld_buffer |
| 3855 | * |
| 3856 | * Input: |
| 3857 | * ha = adapter block pointer |
| 3858 | */ |
| 3859 | void |
| 3860 | qla2x00_free_exchoffld_buffer(struct qla_hw_data *ha) |
| 3861 | { |
| 3862 | if (ha->exchoffld_buf) { |
| 3863 | dma_free_coherent(&ha->pdev->dev, ha->exchoffld_size, |
| 3864 | ha->exchoffld_buf, ha->exchoffld_buf_dma); |
| 3865 | ha->exchoffld_buf = NULL; |
| 3866 | ha->exchoffld_size = 0; |
| 3867 | } |
| 3868 | } |
| 3869 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3870 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3871 | * qla2x00_free_fw_dump |
| 3872 | * Frees fw dump stuff. |
| 3873 | * |
| 3874 | * Input: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3875 | * ha = adapter block pointer |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3876 | */ |
| 3877 | static void |
| 3878 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 3879 | { |
| 3880 | if (ha->fce) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3881 | dma_free_coherent(&ha->pdev->dev, |
| 3882 | FCE_SIZE, ha->fce, ha->fce_dma); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3883 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3884 | if (ha->eft) |
| 3885 | dma_free_coherent(&ha->pdev->dev, |
| 3886 | EFT_SIZE, ha->eft, ha->eft_dma); |
| 3887 | |
| 3888 | if (ha->fw_dump) |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3889 | vfree(ha->fw_dump); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3890 | if (ha->fw_dump_template) |
| 3891 | vfree(ha->fw_dump_template); |
| 3892 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3893 | ha->fce = NULL; |
| 3894 | ha->fce_dma = 0; |
| 3895 | ha->eft = NULL; |
| 3896 | ha->eft_dma = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3897 | ha->fw_dumped = 0; |
Hiral Patel | 61f098d | 2014-04-11 16:54:21 -0400 | [diff] [blame] | 3898 | ha->fw_dump_cap_flags = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3899 | ha->fw_dump_reading = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3900 | ha->fw_dump = NULL; |
| 3901 | ha->fw_dump_len = 0; |
| 3902 | ha->fw_dump_template = NULL; |
| 3903 | ha->fw_dump_template_len = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3904 | } |
| 3905 | |
| 3906 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3907 | * qla2x00_mem_free |
| 3908 | * Frees all adapter allocated memory. |
| 3909 | * |
| 3910 | * Input: |
| 3911 | * ha = adapter block pointer. |
| 3912 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 3913 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3914 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3915 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3916 | qla2x00_free_fw_dump(ha); |
| 3917 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3918 | if (ha->mctp_dump) |
| 3919 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 3920 | ha->mctp_dump_dma); |
| 3921 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3922 | if (ha->srb_mempool) |
| 3923 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3924 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 3925 | if (ha->dcbx_tlv) |
| 3926 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 3927 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 3928 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 3929 | if (ha->xgmac_data) |
| 3930 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 3931 | ha->xgmac_data, ha->xgmac_data_dma); |
| 3932 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3933 | if (ha->sns_cmd) |
| 3934 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3935 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3936 | |
| 3937 | if (ha->ct_sns) |
| 3938 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3939 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3940 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3941 | if (ha->sfp_data) |
| 3942 | dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); |
| 3943 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3944 | if (ha->ms_iocb) |
| 3945 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3946 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3947 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3948 | dma_pool_free(ha->s_dma_pool, |
| 3949 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3950 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3951 | if (ha->async_pd) |
| 3952 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 3953 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3954 | if (ha->s_dma_pool) |
| 3955 | dma_pool_destroy(ha->s_dma_pool); |
| 3956 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3957 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3958 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3959 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3960 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3961 | if (IS_QLA82XX(ha)) { |
| 3962 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 3963 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 3964 | |
| 3965 | /* clean up allocated prev pool */ |
| 3966 | list_for_each_entry_safe(dsd_ptr, |
| 3967 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 3968 | dma_pool_free(ha->dl_dma_pool, |
| 3969 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 3970 | list_del(&dsd_ptr->list); |
| 3971 | kfree(dsd_ptr); |
| 3972 | } |
| 3973 | } |
| 3974 | } |
| 3975 | |
| 3976 | if (ha->dl_dma_pool) |
| 3977 | dma_pool_destroy(ha->dl_dma_pool); |
| 3978 | |
| 3979 | if (ha->fcp_cmnd_dma_pool) |
| 3980 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3981 | |
| 3982 | if (ha->ctx_mempool) |
| 3983 | mempool_destroy(ha->ctx_mempool); |
| 3984 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3985 | qlt_mem_free(ha); |
| 3986 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3987 | if (ha->init_cb) |
| 3988 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3989 | ha->init_cb, ha->init_cb_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3990 | vfree(ha->optrom_buffer); |
| 3991 | kfree(ha->nvram); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3992 | kfree(ha->npiv_info); |
Andrew Vasquez | 7a67735 | 2012-02-09 11:15:56 -0800 | [diff] [blame] | 3993 | kfree(ha->swl); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3994 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3995 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3996 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3997 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3998 | ha->sns_cmd = NULL; |
| 3999 | ha->sns_cmd_dma = 0; |
| 4000 | ha->ct_sns = NULL; |
| 4001 | ha->ct_sns_dma = 0; |
| 4002 | ha->ms_iocb = NULL; |
| 4003 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4004 | ha->init_cb = NULL; |
| 4005 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4006 | ha->ex_init_cb = NULL; |
| 4007 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4008 | ha->async_pd = NULL; |
| 4009 | ha->async_pd_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4010 | |
| 4011 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4012 | ha->dl_dma_pool = NULL; |
| 4013 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4014 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4015 | ha->gid_list = NULL; |
| 4016 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4017 | |
| 4018 | ha->tgt.atio_ring = NULL; |
| 4019 | ha->tgt.atio_dma = 0; |
| 4020 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4021 | } |
| 4022 | |
| 4023 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 4024 | struct qla_hw_data *ha) |
| 4025 | { |
| 4026 | struct Scsi_Host *host; |
| 4027 | struct scsi_qla_host *vha = NULL; |
| 4028 | |
| 4029 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
| 4030 | if (host == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4031 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 4032 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4033 | goto fail; |
| 4034 | } |
| 4035 | |
| 4036 | /* Clear our data area */ |
| 4037 | vha = shost_priv(host); |
| 4038 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 4039 | |
| 4040 | vha->host = host; |
| 4041 | vha->host_no = host->host_no; |
| 4042 | vha->hw = ha; |
| 4043 | |
| 4044 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 4045 | INIT_LIST_HEAD(&vha->work_list); |
| 4046 | INIT_LIST_HEAD(&vha->list); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4047 | INIT_LIST_HEAD(&vha->qla_cmd_list); |
| 4048 | INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list); |
Alexei Potashnik | 71cdc07 | 2015-12-17 14:57:01 -0500 | [diff] [blame] | 4049 | INIT_LIST_HEAD(&vha->logo_list); |
Alexei Potashnik | b7bd104 | 2015-12-17 14:57:02 -0500 | [diff] [blame] | 4050 | INIT_LIST_HEAD(&vha->plogi_ack_list); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4051 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4052 | spin_lock_init(&vha->work_lock); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4053 | spin_lock_init(&vha->cmd_list_lock); |
Joe Carnuccio | c1716f0 | 2017-03-15 09:48:43 -0700 | [diff] [blame] | 4054 | init_waitqueue_head(&vha->vref_waitq); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4055 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4056 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4057 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 4058 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 4059 | vha->host, vha->hw, vha, |
| 4060 | dev_name(&(ha->pdev->dev))); |
| 4061 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4062 | return vha; |
| 4063 | |
| 4064 | fail: |
| 4065 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4066 | } |
| 4067 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 4068 | static struct qla_work_evt * |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4069 | 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] | 4070 | { |
| 4071 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4072 | uint8_t bail; |
| 4073 | |
| 4074 | QLA_VHA_MARK_BUSY(vha, bail); |
| 4075 | if (bail) |
| 4076 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4077 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4078 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4079 | if (!e) { |
| 4080 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4081 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4082 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4083 | |
| 4084 | INIT_LIST_HEAD(&e->list); |
| 4085 | e->type = type; |
| 4086 | e->flags = QLA_EVT_FLAG_FREE; |
| 4087 | return e; |
| 4088 | } |
| 4089 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 4090 | static int |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4091 | 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] | 4092 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4093 | unsigned long flags; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4094 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4095 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4096 | list_add_tail(&e->list, &vha->work_list); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4097 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4098 | qla2xxx_wake_dpc(vha); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4099 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4100 | return QLA_SUCCESS; |
| 4101 | } |
| 4102 | |
| 4103 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4104 | 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] | 4105 | u32 data) |
| 4106 | { |
| 4107 | struct qla_work_evt *e; |
| 4108 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4109 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4110 | if (!e) |
| 4111 | return QLA_FUNCTION_FAILED; |
| 4112 | |
| 4113 | e->u.aen.code = code; |
| 4114 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4115 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4116 | } |
| 4117 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4118 | int |
| 4119 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 4120 | { |
| 4121 | struct qla_work_evt *e; |
| 4122 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4123 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4124 | if (!e) |
| 4125 | return QLA_FUNCTION_FAILED; |
| 4126 | |
| 4127 | memcpy(e->u.idc_ack.mb, mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4128 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4129 | } |
| 4130 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4131 | #define qla2x00_post_async_work(name, type) \ |
| 4132 | int qla2x00_post_async_##name##_work( \ |
| 4133 | struct scsi_qla_host *vha, \ |
| 4134 | fc_port_t *fcport, uint16_t *data) \ |
| 4135 | { \ |
| 4136 | struct qla_work_evt *e; \ |
| 4137 | \ |
| 4138 | e = qla2x00_alloc_work(vha, type); \ |
| 4139 | if (!e) \ |
| 4140 | return QLA_FUNCTION_FAILED; \ |
| 4141 | \ |
| 4142 | e->u.logio.fcport = fcport; \ |
| 4143 | if (data) { \ |
| 4144 | e->u.logio.data[0] = data[0]; \ |
| 4145 | e->u.logio.data[1] = data[1]; \ |
| 4146 | } \ |
| 4147 | return qla2x00_post_work(vha, e); \ |
| 4148 | } |
| 4149 | |
| 4150 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
| 4151 | qla2x00_post_async_work(login_done, QLA_EVT_ASYNC_LOGIN_DONE); |
| 4152 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 4153 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4154 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 4155 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4156 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4157 | int |
| 4158 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 4159 | { |
| 4160 | struct qla_work_evt *e; |
| 4161 | |
| 4162 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 4163 | if (!e) |
| 4164 | return QLA_FUNCTION_FAILED; |
| 4165 | |
| 4166 | e->u.uevent.code = code; |
| 4167 | return qla2x00_post_work(vha, e); |
| 4168 | } |
| 4169 | |
| 4170 | static void |
| 4171 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 4172 | { |
| 4173 | char event_string[40]; |
| 4174 | char *envp[] = { event_string, NULL }; |
| 4175 | |
| 4176 | switch (code) { |
| 4177 | case QLA_UEVENT_CODE_FW_DUMP: |
| 4178 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 4179 | vha->host_no); |
| 4180 | break; |
| 4181 | default: |
| 4182 | /* do nothing */ |
| 4183 | break; |
| 4184 | } |
| 4185 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 4186 | } |
| 4187 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4188 | int |
| 4189 | qlafx00_post_aenfx_work(struct scsi_qla_host *vha, uint32_t evtcode, |
| 4190 | uint32_t *data, int cnt) |
| 4191 | { |
| 4192 | struct qla_work_evt *e; |
| 4193 | |
| 4194 | e = qla2x00_alloc_work(vha, QLA_EVT_AENFX); |
| 4195 | if (!e) |
| 4196 | return QLA_FUNCTION_FAILED; |
| 4197 | |
| 4198 | e->u.aenfx.evtcode = evtcode; |
| 4199 | e->u.aenfx.count = cnt; |
| 4200 | memcpy(e->u.aenfx.mbx, data, sizeof(*data) * cnt); |
| 4201 | return qla2x00_post_work(vha, e); |
| 4202 | } |
| 4203 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4204 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4205 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4206 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4207 | struct qla_work_evt *e, *tmp; |
| 4208 | unsigned long flags; |
| 4209 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4210 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4211 | spin_lock_irqsave(&vha->work_lock, flags); |
| 4212 | list_splice_init(&vha->work_list, &work); |
| 4213 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 4214 | |
| 4215 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4216 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4217 | |
| 4218 | switch (e->type) { |
| 4219 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4220 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4221 | e->u.aen.code, e->u.aen.data); |
| 4222 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4223 | case QLA_EVT_IDC_ACK: |
| 4224 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 4225 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4226 | case QLA_EVT_ASYNC_LOGIN: |
| 4227 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 4228 | e->u.logio.data); |
| 4229 | break; |
| 4230 | case QLA_EVT_ASYNC_LOGIN_DONE: |
| 4231 | qla2x00_async_login_done(vha, e->u.logio.fcport, |
| 4232 | e->u.logio.data); |
| 4233 | break; |
| 4234 | case QLA_EVT_ASYNC_LOGOUT: |
| 4235 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 4236 | break; |
| 4237 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 4238 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 4239 | e->u.logio.data); |
| 4240 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4241 | case QLA_EVT_ASYNC_ADISC: |
| 4242 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 4243 | e->u.logio.data); |
| 4244 | break; |
| 4245 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 4246 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 4247 | e->u.logio.data); |
| 4248 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4249 | case QLA_EVT_UEVENT: |
| 4250 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 4251 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4252 | case QLA_EVT_AENFX: |
| 4253 | qlafx00_process_aen(vha, e); |
| 4254 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4255 | } |
| 4256 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 4257 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4258 | |
| 4259 | /* For each work completed decrement vha ref count */ |
| 4260 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4261 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4262 | } |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4263 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4264 | /* Relogins all the fcports of a vport |
| 4265 | * Context: dpc thread |
| 4266 | */ |
| 4267 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 4268 | { |
| 4269 | fc_port_t *fcport; |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 4270 | int status; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4271 | uint16_t next_loopid = 0; |
| 4272 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4273 | uint16_t data[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4274 | |
| 4275 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 4276 | /* |
| 4277 | * If the port is not ONLINE then try to login |
| 4278 | * to it if we haven't run out of retries. |
| 4279 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4280 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
| 4281 | fcport->login_retry && !(fcport->flags & FCF_ASYNC_SENT)) { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4282 | fcport->login_retry--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4283 | if (fcport->flags & FCF_FABRIC_DEVICE) { |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 4284 | if (fcport->flags & FCF_FCP2_DEVICE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4285 | ha->isp_ops->fabric_logout(vha, |
| 4286 | fcport->loop_id, |
| 4287 | fcport->d_id.b.domain, |
| 4288 | fcport->d_id.b.area, |
| 4289 | fcport->d_id.b.al_pa); |
| 4290 | |
Joe Carnuccio | 03bcfb5 | 2011-03-30 11:46:27 -0700 | [diff] [blame] | 4291 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
| 4292 | fcport->loop_id = next_loopid = |
| 4293 | ha->min_external_loopid; |
| 4294 | status = qla2x00_find_new_loop_id( |
| 4295 | vha, fcport); |
| 4296 | if (status != QLA_SUCCESS) { |
| 4297 | /* Ran out of IDs to use */ |
| 4298 | break; |
| 4299 | } |
| 4300 | } |
| 4301 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4302 | if (IS_ALOGIO_CAPABLE(ha)) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4303 | fcport->flags |= FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4304 | data[0] = 0; |
| 4305 | data[1] = QLA_LOGIO_LOGIN_RETRIED; |
| 4306 | status = qla2x00_post_async_login_work( |
| 4307 | vha, fcport, data); |
| 4308 | if (status == QLA_SUCCESS) |
| 4309 | continue; |
| 4310 | /* Attempt a retry. */ |
| 4311 | status = 1; |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4312 | } else { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4313 | status = qla2x00_fabric_login(vha, |
| 4314 | fcport, &next_loopid); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4315 | if (status == QLA_SUCCESS) { |
| 4316 | int status2; |
| 4317 | uint8_t opts; |
| 4318 | |
| 4319 | opts = 0; |
| 4320 | if (fcport->flags & |
| 4321 | FCF_FCP2_DEVICE) |
| 4322 | opts |= BIT_1; |
Saurav Kashyap | 0300396 | 2012-11-21 02:40:31 -0500 | [diff] [blame] | 4323 | status2 = |
| 4324 | qla2x00_get_port_database( |
| 4325 | vha, fcport, opts); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4326 | if (status2 != QLA_SUCCESS) |
| 4327 | status = 1; |
| 4328 | } |
| 4329 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4330 | } else |
| 4331 | status = qla2x00_local_device_login(vha, |
| 4332 | fcport); |
| 4333 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4334 | if (status == QLA_SUCCESS) { |
| 4335 | fcport->old_loop_id = fcport->loop_id; |
| 4336 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4337 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 4338 | "Port login OK: logged in ID 0x%x.\n", |
| 4339 | fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4340 | |
| 4341 | qla2x00_update_fcport(vha, fcport); |
| 4342 | |
| 4343 | } else if (status == 1) { |
| 4344 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 4345 | /* retry the login again */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4346 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 4347 | "Retrying %d login again loop_id 0x%x.\n", |
| 4348 | fcport->login_retry, fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4349 | } else { |
| 4350 | fcport->login_retry = 0; |
| 4351 | } |
| 4352 | |
| 4353 | if (fcport->login_retry == 0 && status != QLA_SUCCESS) |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4354 | qla2x00_clear_loop_id(fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4355 | } |
| 4356 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 4357 | break; |
| 4358 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4359 | } |
| 4360 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4361 | /* Schedule work on any of the dpc-workqueues */ |
| 4362 | void |
| 4363 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 4364 | { |
| 4365 | struct qla_hw_data *ha = base_vha->hw; |
| 4366 | |
| 4367 | switch (work_code) { |
| 4368 | case MBA_IDC_AEN: /* 0x8200 */ |
| 4369 | if (ha->dpc_lp_wq) |
| 4370 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 4371 | break; |
| 4372 | |
| 4373 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 4374 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4375 | if (ha->dpc_hp_wq) |
| 4376 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 4377 | } else |
| 4378 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 4379 | "NIC Core reset is already active. Skip " |
| 4380 | "scheduling it again.\n"); |
| 4381 | break; |
| 4382 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 4383 | if (ha->dpc_hp_wq) |
| 4384 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 4385 | break; |
| 4386 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 4387 | if (ha->dpc_hp_wq) |
| 4388 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 4389 | break; |
| 4390 | default: |
| 4391 | ql_log(ql_log_warn, base_vha, 0xb05f, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 4392 | "Unknown work-code=0x%x.\n", work_code); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4393 | } |
| 4394 | |
| 4395 | return; |
| 4396 | } |
| 4397 | |
| 4398 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 4399 | void |
| 4400 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 4401 | { |
| 4402 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4403 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4404 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4405 | uint32_t dev_state = 0; |
| 4406 | |
| 4407 | qla83xx_idc_lock(base_vha, 0); |
| 4408 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4409 | qla83xx_reset_ownership(base_vha); |
| 4410 | if (ha->flags.nic_core_reset_owner) { |
| 4411 | ha->flags.nic_core_reset_owner = 0; |
| 4412 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4413 | QLA8XXX_DEV_FAILED); |
| 4414 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 4415 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4416 | } |
| 4417 | qla83xx_idc_unlock(base_vha, 0); |
| 4418 | } |
| 4419 | |
| 4420 | /* Work: Execute IDC state handler */ |
| 4421 | void |
| 4422 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 4423 | { |
| 4424 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4425 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4426 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4427 | uint32_t dev_state = 0; |
| 4428 | |
| 4429 | qla83xx_idc_lock(base_vha, 0); |
| 4430 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4431 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 4432 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 4433 | qla83xx_idc_state_handler(base_vha); |
| 4434 | qla83xx_idc_unlock(base_vha, 0); |
| 4435 | } |
| 4436 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4437 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4438 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 4439 | { |
| 4440 | int rval = QLA_SUCCESS; |
| 4441 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 4442 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 4443 | |
| 4444 | do { |
| 4445 | if (time_after(jiffies, heart_beat_wait)) { |
| 4446 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 4447 | "Nic Core f/w is not alive.\n"); |
| 4448 | rval = QLA_FUNCTION_FAILED; |
| 4449 | break; |
| 4450 | } |
| 4451 | |
| 4452 | qla83xx_idc_lock(base_vha, 0); |
| 4453 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4454 | &heart_beat_counter1); |
| 4455 | qla83xx_idc_unlock(base_vha, 0); |
| 4456 | msleep(100); |
| 4457 | qla83xx_idc_lock(base_vha, 0); |
| 4458 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4459 | &heart_beat_counter2); |
| 4460 | qla83xx_idc_unlock(base_vha, 0); |
| 4461 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 4462 | |
| 4463 | return rval; |
| 4464 | } |
| 4465 | |
| 4466 | /* Work: Perform NIC Core Reset handling */ |
| 4467 | void |
| 4468 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 4469 | { |
| 4470 | struct qla_hw_data *ha = |
| 4471 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 4472 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4473 | uint32_t dev_state = 0; |
| 4474 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4475 | if (IS_QLA2031(ha)) { |
| 4476 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 4477 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 4478 | "Failed to dump mctp\n"); |
| 4479 | return; |
| 4480 | } |
| 4481 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4482 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4483 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 4484 | qla83xx_idc_lock(base_vha, 0); |
| 4485 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4486 | &dev_state); |
| 4487 | qla83xx_idc_unlock(base_vha, 0); |
| 4488 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 4489 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 4490 | "Nic Core f/w is alive.\n"); |
| 4491 | return; |
| 4492 | } |
| 4493 | } |
| 4494 | |
| 4495 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 4496 | if (qla83xx_nic_core_reset(base_vha)) { |
| 4497 | /* NIC Core reset failed. */ |
| 4498 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 4499 | "NIC Core reset failed.\n"); |
| 4500 | } |
| 4501 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 4502 | } |
| 4503 | } |
| 4504 | |
| 4505 | /* Work: Handle 8200 IDC aens */ |
| 4506 | void |
| 4507 | qla83xx_service_idc_aen(struct work_struct *work) |
| 4508 | { |
| 4509 | struct qla_hw_data *ha = |
| 4510 | container_of(work, struct qla_hw_data, idc_aen); |
| 4511 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4512 | uint32_t dev_state, idc_control; |
| 4513 | |
| 4514 | qla83xx_idc_lock(base_vha, 0); |
| 4515 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4516 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 4517 | qla83xx_idc_unlock(base_vha, 0); |
| 4518 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 4519 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 4520 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 4521 | "Application requested NIC Core Reset.\n"); |
| 4522 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4523 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 4524 | QLA_SUCCESS) { |
| 4525 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 4526 | "Other protocol driver requested NIC Core Reset.\n"); |
| 4527 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4528 | } |
| 4529 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 4530 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 4531 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4532 | } |
| 4533 | } |
| 4534 | |
| 4535 | static void |
| 4536 | qla83xx_wait_logic(void) |
| 4537 | { |
| 4538 | int i; |
| 4539 | |
| 4540 | /* Yield CPU */ |
| 4541 | if (!in_interrupt()) { |
| 4542 | /* |
| 4543 | * Wait about 200ms before retrying again. |
| 4544 | * This controls the number of retries for single |
| 4545 | * lock operation. |
| 4546 | */ |
| 4547 | msleep(100); |
| 4548 | schedule(); |
| 4549 | } else { |
| 4550 | for (i = 0; i < 20; i++) |
| 4551 | cpu_relax(); /* This a nop instr on i386 */ |
| 4552 | } |
| 4553 | } |
| 4554 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4555 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4556 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 4557 | { |
| 4558 | int rval; |
| 4559 | uint32_t data; |
| 4560 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 4561 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 4562 | struct qla_hw_data *ha = base_vha->hw; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4563 | ql_dbg(ql_dbg_p3p, base_vha, 0xb086, |
| 4564 | "Trying force recovery of the IDC lock.\n"); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4565 | |
| 4566 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 4567 | if (rval) |
| 4568 | return rval; |
| 4569 | |
| 4570 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 4571 | return QLA_SUCCESS; |
| 4572 | } else { |
| 4573 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 4574 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4575 | data); |
| 4576 | if (rval) |
| 4577 | return rval; |
| 4578 | |
| 4579 | msleep(200); |
| 4580 | |
| 4581 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4582 | &data); |
| 4583 | if (rval) |
| 4584 | return rval; |
| 4585 | |
| 4586 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 4587 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 4588 | ~(idc_lck_rcvry_stage_mask)); |
| 4589 | rval = qla83xx_wr_reg(base_vha, |
| 4590 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 4591 | if (rval) |
| 4592 | return rval; |
| 4593 | |
| 4594 | /* Forcefully perform IDC UnLock */ |
| 4595 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 4596 | &data); |
| 4597 | if (rval) |
| 4598 | return rval; |
| 4599 | /* Clear lock-id by setting 0xff */ |
| 4600 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4601 | 0xff); |
| 4602 | if (rval) |
| 4603 | return rval; |
| 4604 | /* Clear lock-recovery by setting 0x0 */ |
| 4605 | rval = qla83xx_wr_reg(base_vha, |
| 4606 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 4607 | if (rval) |
| 4608 | return rval; |
| 4609 | } else |
| 4610 | return QLA_SUCCESS; |
| 4611 | } |
| 4612 | |
| 4613 | return rval; |
| 4614 | } |
| 4615 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4616 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4617 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 4618 | { |
| 4619 | int rval = QLA_SUCCESS; |
| 4620 | uint32_t o_drv_lockid, n_drv_lockid; |
| 4621 | unsigned long lock_recovery_timeout; |
| 4622 | |
| 4623 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 4624 | retry_lockid: |
| 4625 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 4626 | if (rval) |
| 4627 | goto exit; |
| 4628 | |
| 4629 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 4630 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 4631 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 4632 | return QLA_SUCCESS; |
| 4633 | else |
| 4634 | return QLA_FUNCTION_FAILED; |
| 4635 | } |
| 4636 | |
| 4637 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 4638 | if (rval) |
| 4639 | goto exit; |
| 4640 | |
| 4641 | if (o_drv_lockid == n_drv_lockid) { |
| 4642 | qla83xx_wait_logic(); |
| 4643 | goto retry_lockid; |
| 4644 | } else |
| 4645 | return QLA_SUCCESS; |
| 4646 | |
| 4647 | exit: |
| 4648 | return rval; |
| 4649 | } |
| 4650 | |
| 4651 | void |
| 4652 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4653 | { |
| 4654 | uint16_t options = (requester_id << 15) | BIT_6; |
| 4655 | uint32_t data; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4656 | uint32_t lock_owner; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4657 | struct qla_hw_data *ha = base_vha->hw; |
| 4658 | |
| 4659 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 4660 | retry_lock: |
| 4661 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 4662 | == QLA_SUCCESS) { |
| 4663 | if (data) { |
| 4664 | /* Setting lock-id to our function-number */ |
| 4665 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4666 | ha->portnum); |
| 4667 | } else { |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4668 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4669 | &lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4670 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4671 | "Failed to acquire IDC lock, acquired by %d, " |
| 4672 | "retrying...\n", lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4673 | |
| 4674 | /* Retry/Perform IDC-Lock recovery */ |
| 4675 | if (qla83xx_idc_lock_recovery(base_vha) |
| 4676 | == QLA_SUCCESS) { |
| 4677 | qla83xx_wait_logic(); |
| 4678 | goto retry_lock; |
| 4679 | } else |
| 4680 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 4681 | "IDC Lock recovery FAILED.\n"); |
| 4682 | } |
| 4683 | |
| 4684 | } |
| 4685 | |
| 4686 | return; |
| 4687 | |
| 4688 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 4689 | retry_lock2: |
| 4690 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4691 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 4692 | "Failed to acquire IDC lock. retrying...\n"); |
| 4693 | /* Retry/Perform IDC-Lock recovery */ |
| 4694 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 4695 | qla83xx_wait_logic(); |
| 4696 | goto retry_lock2; |
| 4697 | } else |
| 4698 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 4699 | "IDC Lock recovery FAILED.\n"); |
| 4700 | } |
| 4701 | |
| 4702 | return; |
| 4703 | } |
| 4704 | |
| 4705 | void |
| 4706 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4707 | { |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4708 | #if 0 |
| 4709 | uint16_t options = (requester_id << 15) | BIT_7; |
| 4710 | #endif |
| 4711 | uint16_t retry; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4712 | uint32_t data; |
| 4713 | struct qla_hw_data *ha = base_vha->hw; |
| 4714 | |
| 4715 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 4716 | * remote registers |
| 4717 | */ |
| 4718 | retry = 0; |
| 4719 | retry_unlock: |
| 4720 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 4721 | == QLA_SUCCESS) { |
| 4722 | if (data == ha->portnum) { |
| 4723 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 4724 | /* Clearing lock-id by setting 0xff */ |
| 4725 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 4726 | } else if (retry < 10) { |
| 4727 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 4728 | |
| 4729 | /* Retry for IDC-unlock */ |
| 4730 | qla83xx_wait_logic(); |
| 4731 | retry++; |
| 4732 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 4733 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4734 | goto retry_unlock; |
| 4735 | } |
| 4736 | } else if (retry < 10) { |
| 4737 | /* Retry for IDC-unlock */ |
| 4738 | qla83xx_wait_logic(); |
| 4739 | retry++; |
| 4740 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 4741 | "Failed to read drv-lockid, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4742 | goto retry_unlock; |
| 4743 | } |
| 4744 | |
| 4745 | return; |
| 4746 | |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4747 | #if 0 |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4748 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 4749 | retry = 0; |
| 4750 | retry_unlock2: |
| 4751 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4752 | if (retry < 10) { |
| 4753 | /* Retry for IDC-unlock */ |
| 4754 | qla83xx_wait_logic(); |
| 4755 | retry++; |
| 4756 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 4757 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4758 | goto retry_unlock2; |
| 4759 | } |
| 4760 | } |
| 4761 | |
| 4762 | return; |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4763 | #endif |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4764 | } |
| 4765 | |
| 4766 | int |
| 4767 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4768 | { |
| 4769 | int rval = QLA_SUCCESS; |
| 4770 | struct qla_hw_data *ha = vha->hw; |
| 4771 | uint32_t drv_presence; |
| 4772 | |
| 4773 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4774 | if (rval == QLA_SUCCESS) { |
| 4775 | drv_presence |= (1 << ha->portnum); |
| 4776 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4777 | drv_presence); |
| 4778 | } |
| 4779 | |
| 4780 | return rval; |
| 4781 | } |
| 4782 | |
| 4783 | int |
| 4784 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4785 | { |
| 4786 | int rval = QLA_SUCCESS; |
| 4787 | |
| 4788 | qla83xx_idc_lock(vha, 0); |
| 4789 | rval = __qla83xx_set_drv_presence(vha); |
| 4790 | qla83xx_idc_unlock(vha, 0); |
| 4791 | |
| 4792 | return rval; |
| 4793 | } |
| 4794 | |
| 4795 | int |
| 4796 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4797 | { |
| 4798 | int rval = QLA_SUCCESS; |
| 4799 | struct qla_hw_data *ha = vha->hw; |
| 4800 | uint32_t drv_presence; |
| 4801 | |
| 4802 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4803 | if (rval == QLA_SUCCESS) { |
| 4804 | drv_presence &= ~(1 << ha->portnum); |
| 4805 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4806 | drv_presence); |
| 4807 | } |
| 4808 | |
| 4809 | return rval; |
| 4810 | } |
| 4811 | |
| 4812 | int |
| 4813 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4814 | { |
| 4815 | int rval = QLA_SUCCESS; |
| 4816 | |
| 4817 | qla83xx_idc_lock(vha, 0); |
| 4818 | rval = __qla83xx_clear_drv_presence(vha); |
| 4819 | qla83xx_idc_unlock(vha, 0); |
| 4820 | |
| 4821 | return rval; |
| 4822 | } |
| 4823 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4824 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4825 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 4826 | { |
| 4827 | struct qla_hw_data *ha = vha->hw; |
| 4828 | uint32_t drv_ack, drv_presence; |
| 4829 | unsigned long ack_timeout; |
| 4830 | |
| 4831 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 4832 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 4833 | while (1) { |
| 4834 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 4835 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 4836 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4837 | break; |
| 4838 | |
| 4839 | if (time_after_eq(jiffies, ack_timeout)) { |
| 4840 | ql_log(ql_log_warn, vha, 0xb067, |
| 4841 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 4842 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 4843 | /* |
| 4844 | * The function(s) which did not ack in time are forced |
| 4845 | * to withdraw any further participation in the IDC |
| 4846 | * reset. |
| 4847 | */ |
| 4848 | if (drv_ack != drv_presence) |
| 4849 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4850 | drv_ack); |
| 4851 | break; |
| 4852 | } |
| 4853 | |
| 4854 | qla83xx_idc_unlock(vha, 0); |
| 4855 | msleep(1000); |
| 4856 | qla83xx_idc_lock(vha, 0); |
| 4857 | } |
| 4858 | |
| 4859 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 4860 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 4861 | } |
| 4862 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4863 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4864 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 4865 | { |
| 4866 | int rval = QLA_SUCCESS; |
| 4867 | uint32_t idc_control; |
| 4868 | |
| 4869 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 4870 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 4871 | |
| 4872 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 4873 | __qla83xx_get_idc_control(vha, &idc_control); |
| 4874 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 4875 | __qla83xx_set_idc_control(vha, 0); |
| 4876 | |
| 4877 | qla83xx_idc_unlock(vha, 0); |
| 4878 | rval = qla83xx_restart_nic_firmware(vha); |
| 4879 | qla83xx_idc_lock(vha, 0); |
| 4880 | |
| 4881 | if (rval != QLA_SUCCESS) { |
| 4882 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 4883 | "Failed to restart NIC f/w.\n"); |
| 4884 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 4885 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 4886 | } else { |
| 4887 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 4888 | "Success in restarting nic f/w.\n"); |
| 4889 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 4890 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 4891 | } |
| 4892 | |
| 4893 | return rval; |
| 4894 | } |
| 4895 | |
| 4896 | /* Assumes idc_lock always held on entry */ |
| 4897 | int |
| 4898 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 4899 | { |
| 4900 | struct qla_hw_data *ha = base_vha->hw; |
| 4901 | int rval = QLA_SUCCESS; |
| 4902 | unsigned long dev_init_timeout; |
| 4903 | uint32_t dev_state; |
| 4904 | |
| 4905 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 4906 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 4907 | |
| 4908 | while (1) { |
| 4909 | |
| 4910 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 4911 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 4912 | "Initialization TIMEOUT!\n"); |
| 4913 | /* Init timeout. Disable further NIC Core |
| 4914 | * communication. |
| 4915 | */ |
| 4916 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4917 | QLA8XXX_DEV_FAILED); |
| 4918 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 4919 | "HW State: FAILED.\n"); |
| 4920 | } |
| 4921 | |
| 4922 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4923 | switch (dev_state) { |
| 4924 | case QLA8XXX_DEV_READY: |
| 4925 | if (ha->flags.nic_core_reset_owner) |
| 4926 | qla83xx_idc_audit(base_vha, |
| 4927 | IDC_AUDIT_COMPLETION); |
| 4928 | ha->flags.nic_core_reset_owner = 0; |
| 4929 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 4930 | "Reset_owner reset by 0x%x.\n", |
| 4931 | ha->portnum); |
| 4932 | goto exit; |
| 4933 | case QLA8XXX_DEV_COLD: |
| 4934 | if (ha->flags.nic_core_reset_owner) |
| 4935 | rval = qla83xx_device_bootstrap(base_vha); |
| 4936 | else { |
| 4937 | /* Wait for AEN to change device-state */ |
| 4938 | qla83xx_idc_unlock(base_vha, 0); |
| 4939 | msleep(1000); |
| 4940 | qla83xx_idc_lock(base_vha, 0); |
| 4941 | } |
| 4942 | break; |
| 4943 | case QLA8XXX_DEV_INITIALIZING: |
| 4944 | /* Wait for AEN to change device-state */ |
| 4945 | qla83xx_idc_unlock(base_vha, 0); |
| 4946 | msleep(1000); |
| 4947 | qla83xx_idc_lock(base_vha, 0); |
| 4948 | break; |
| 4949 | case QLA8XXX_DEV_NEED_RESET: |
| 4950 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 4951 | qla83xx_need_reset_handler(base_vha); |
| 4952 | else { |
| 4953 | /* Wait for AEN to change device-state */ |
| 4954 | qla83xx_idc_unlock(base_vha, 0); |
| 4955 | msleep(1000); |
| 4956 | qla83xx_idc_lock(base_vha, 0); |
| 4957 | } |
| 4958 | /* reset timeout value after need reset handler */ |
| 4959 | dev_init_timeout = jiffies + |
| 4960 | (ha->fcoe_dev_init_timeout * HZ); |
| 4961 | break; |
| 4962 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 4963 | /* XXX: DEBUG for now */ |
| 4964 | qla83xx_idc_unlock(base_vha, 0); |
| 4965 | msleep(1000); |
| 4966 | qla83xx_idc_lock(base_vha, 0); |
| 4967 | break; |
| 4968 | case QLA8XXX_DEV_QUIESCENT: |
| 4969 | /* XXX: DEBUG for now */ |
| 4970 | if (ha->flags.quiesce_owner) |
| 4971 | goto exit; |
| 4972 | |
| 4973 | qla83xx_idc_unlock(base_vha, 0); |
| 4974 | msleep(1000); |
| 4975 | qla83xx_idc_lock(base_vha, 0); |
| 4976 | dev_init_timeout = jiffies + |
| 4977 | (ha->fcoe_dev_init_timeout * HZ); |
| 4978 | break; |
| 4979 | case QLA8XXX_DEV_FAILED: |
| 4980 | if (ha->flags.nic_core_reset_owner) |
| 4981 | qla83xx_idc_audit(base_vha, |
| 4982 | IDC_AUDIT_COMPLETION); |
| 4983 | ha->flags.nic_core_reset_owner = 0; |
| 4984 | __qla83xx_clear_drv_presence(base_vha); |
| 4985 | qla83xx_idc_unlock(base_vha, 0); |
| 4986 | qla8xxx_dev_failed_handler(base_vha); |
| 4987 | rval = QLA_FUNCTION_FAILED; |
| 4988 | qla83xx_idc_lock(base_vha, 0); |
| 4989 | goto exit; |
| 4990 | case QLA8XXX_BAD_VALUE: |
| 4991 | qla83xx_idc_unlock(base_vha, 0); |
| 4992 | msleep(1000); |
| 4993 | qla83xx_idc_lock(base_vha, 0); |
| 4994 | break; |
| 4995 | default: |
| 4996 | ql_log(ql_log_warn, base_vha, 0xb071, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 4997 | "Unknown Device State: %x.\n", dev_state); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4998 | qla83xx_idc_unlock(base_vha, 0); |
| 4999 | qla8xxx_dev_failed_handler(base_vha); |
| 5000 | rval = QLA_FUNCTION_FAILED; |
| 5001 | qla83xx_idc_lock(base_vha, 0); |
| 5002 | goto exit; |
| 5003 | } |
| 5004 | } |
| 5005 | |
| 5006 | exit: |
| 5007 | return rval; |
| 5008 | } |
| 5009 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5010 | void |
| 5011 | qla2x00_disable_board_on_pci_error(struct work_struct *work) |
| 5012 | { |
| 5013 | struct qla_hw_data *ha = container_of(work, struct qla_hw_data, |
| 5014 | board_disable); |
| 5015 | struct pci_dev *pdev = ha->pdev; |
| 5016 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5017 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 5018 | /* if UNLOAD flag is already set, then continue unload, |
| 5019 | * where it was set first. |
| 5020 | */ |
| 5021 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5022 | return; |
| 5023 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5024 | ql_log(ql_log_warn, base_vha, 0x015b, |
| 5025 | "Disabling adapter.\n"); |
| 5026 | |
| 5027 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 5028 | |
| 5029 | qla2x00_delete_all_vps(ha, base_vha); |
| 5030 | |
| 5031 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5032 | |
| 5033 | qla2x00_dfs_remove(base_vha); |
| 5034 | |
| 5035 | qla84xx_put_chip(base_vha); |
| 5036 | |
| 5037 | if (base_vha->timer_active) |
| 5038 | qla2x00_stop_timer(base_vha); |
| 5039 | |
| 5040 | base_vha->flags.online = 0; |
| 5041 | |
| 5042 | qla2x00_destroy_deferred_work(ha); |
| 5043 | |
| 5044 | /* |
| 5045 | * Do not try to stop beacon blink as it will issue a mailbox |
| 5046 | * command. |
| 5047 | */ |
| 5048 | qla2x00_free_sysfs_attr(base_vha, false); |
| 5049 | |
| 5050 | fc_remove_host(base_vha->host); |
| 5051 | |
| 5052 | scsi_remove_host(base_vha->host); |
| 5053 | |
| 5054 | base_vha->flags.init_done = 0; |
| 5055 | qla25xx_delete_queues(base_vha); |
| 5056 | qla2x00_free_irqs(base_vha); |
| 5057 | qla2x00_free_fcports(base_vha); |
| 5058 | qla2x00_mem_free(ha); |
| 5059 | qla82xx_md_free(base_vha); |
| 5060 | qla2x00_free_queues(ha); |
| 5061 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5062 | qla2x00_unmap_iobases(ha); |
| 5063 | |
| 5064 | pci_release_selected_regions(ha->pdev, ha->bars); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5065 | pci_disable_pcie_error_reporting(pdev); |
| 5066 | pci_disable_device(pdev); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5067 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 5068 | /* |
| 5069 | * Let qla2x00_remove_one cleanup qla_hw_data on device removal. |
| 5070 | */ |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5071 | } |
| 5072 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5073 | /************************************************************************** |
| 5074 | * qla2x00_do_dpc |
| 5075 | * This kernel thread is a task that is schedule by the interrupt handler |
| 5076 | * to perform the background processing for interrupts. |
| 5077 | * |
| 5078 | * Notes: |
| 5079 | * This task always run in the context of a kernel thread. It |
| 5080 | * is kick-off by the driver's detect code and starts up |
| 5081 | * up one per adapter. It immediately goes to sleep and waits for |
| 5082 | * some fibre event. When either the interrupt handler or |
| 5083 | * the timer routine detects a event it will one of the task |
| 5084 | * bits then wake us up. |
| 5085 | **************************************************************************/ |
| 5086 | static int |
| 5087 | qla2x00_do_dpc(void *data) |
| 5088 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5089 | scsi_qla_host_t *base_vha; |
| 5090 | struct qla_hw_data *ha; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5091 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5092 | ha = (struct qla_hw_data *)data; |
| 5093 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5094 | |
Dongsheng Yang | 8698a74 | 2014-03-11 18:09:12 +0800 | [diff] [blame] | 5095 | set_user_nice(current, MIN_NICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5096 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5097 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5098 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5099 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 5100 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5101 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5102 | schedule(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5103 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5104 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 5105 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5106 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5107 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5108 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 5109 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5110 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5111 | } |
| 5112 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5113 | ha->dpc_active = 1; |
| 5114 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5115 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 5116 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 5117 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5118 | |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 5119 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5120 | break; |
| 5121 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5122 | qla2x00_do_work(base_vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5123 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5124 | if (IS_P3P_TYPE(ha)) { |
| 5125 | if (IS_QLA8044(ha)) { |
| 5126 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5127 | &base_vha->dpc_flags)) { |
| 5128 | qla8044_idc_lock(ha); |
| 5129 | qla8044_wr_direct(base_vha, |
| 5130 | QLA8044_CRB_DEV_STATE_INDEX, |
| 5131 | QLA8XXX_DEV_FAILED); |
| 5132 | qla8044_idc_unlock(ha); |
| 5133 | ql_log(ql_log_info, base_vha, 0x4004, |
| 5134 | "HW State: FAILED.\n"); |
| 5135 | qla8044_device_state_handler(base_vha); |
| 5136 | continue; |
| 5137 | } |
| 5138 | |
| 5139 | } else { |
| 5140 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5141 | &base_vha->dpc_flags)) { |
| 5142 | qla82xx_idc_lock(ha); |
| 5143 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
| 5144 | QLA8XXX_DEV_FAILED); |
| 5145 | qla82xx_idc_unlock(ha); |
| 5146 | ql_log(ql_log_info, base_vha, 0x0151, |
| 5147 | "HW State: FAILED.\n"); |
| 5148 | qla82xx_device_state_handler(base_vha); |
| 5149 | continue; |
| 5150 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5151 | } |
| 5152 | |
| 5153 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 5154 | &base_vha->dpc_flags)) { |
| 5155 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5156 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 5157 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5158 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 5159 | &base_vha->dpc_flags))) { |
| 5160 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 5161 | /* FCoE-ctx reset failed. |
| 5162 | * Escalate to chip-reset |
| 5163 | */ |
| 5164 | set_bit(ISP_ABORT_NEEDED, |
| 5165 | &base_vha->dpc_flags); |
| 5166 | } |
| 5167 | clear_bit(ABORT_ISP_ACTIVE, |
| 5168 | &base_vha->dpc_flags); |
| 5169 | } |
| 5170 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5171 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 5172 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5173 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5174 | } else if (IS_QLAFX00(ha)) { |
| 5175 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5176 | &base_vha->dpc_flags)) { |
| 5177 | ql_dbg(ql_dbg_dpc, base_vha, 0x4020, |
| 5178 | "Firmware Reset Recovery\n"); |
| 5179 | if (qlafx00_reset_initialize(base_vha)) { |
| 5180 | /* Failed. Abort isp later. */ |
| 5181 | if (!test_bit(UNLOADING, |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5182 | &base_vha->dpc_flags)) { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5183 | set_bit(ISP_UNRECOVERABLE, |
| 5184 | &base_vha->dpc_flags); |
| 5185 | ql_dbg(ql_dbg_dpc, base_vha, |
| 5186 | 0x4021, |
| 5187 | "Reset Recovery Failed\n"); |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5188 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5189 | } |
| 5190 | } |
| 5191 | |
| 5192 | if (test_and_clear_bit(FX00_TARGET_SCAN, |
| 5193 | &base_vha->dpc_flags)) { |
| 5194 | ql_dbg(ql_dbg_dpc, base_vha, 0x4022, |
| 5195 | "ISPFx00 Target Scan scheduled\n"); |
| 5196 | if (qlafx00_rescan_isp(base_vha)) { |
| 5197 | if (!test_bit(UNLOADING, |
| 5198 | &base_vha->dpc_flags)) |
| 5199 | set_bit(ISP_UNRECOVERABLE, |
| 5200 | &base_vha->dpc_flags); |
| 5201 | ql_dbg(ql_dbg_dpc, base_vha, 0x401e, |
| 5202 | "ISPFx00 Target Scan Failed\n"); |
| 5203 | } |
| 5204 | ql_dbg(ql_dbg_dpc, base_vha, 0x401f, |
| 5205 | "ISPFx00 Target Scan End\n"); |
| 5206 | } |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 5207 | if (test_and_clear_bit(FX00_HOST_INFO_RESEND, |
| 5208 | &base_vha->dpc_flags)) { |
| 5209 | ql_dbg(ql_dbg_dpc, base_vha, 0x4023, |
| 5210 | "ISPFx00 Host Info resend scheduled\n"); |
| 5211 | qlafx00_fx_disc(base_vha, |
| 5212 | &base_vha->hw->mr.fcport, |
| 5213 | FXDISC_REG_HOST_INFO); |
| 5214 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5215 | } |
| 5216 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5217 | if (test_and_clear_bit(ISP_ABORT_NEEDED, |
| 5218 | &base_vha->dpc_flags)) { |
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_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 5221 | "ISP abort scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5222 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5223 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5224 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5225 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5226 | /* failed. retry later */ |
| 5227 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5228 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5229 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5230 | clear_bit(ABORT_ISP_ACTIVE, |
| 5231 | &base_vha->dpc_flags); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5232 | } |
| 5233 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5234 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 5235 | "ISP abort end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5236 | } |
| 5237 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 5238 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 5239 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5240 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 5241 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 5242 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5243 | if (test_bit(SCR_PENDING, &base_vha->dpc_flags)) { |
| 5244 | int ret; |
| 5245 | ret = qla2x00_send_change_request(base_vha, 0x3, 0); |
| 5246 | if (ret != QLA_SUCCESS) |
| 5247 | ql_log(ql_log_warn, base_vha, 0x121, |
| 5248 | "Failed to enable receiving of RSCN " |
| 5249 | "requests: 0x%x.\n", ret); |
| 5250 | clear_bit(SCR_PENDING, &base_vha->dpc_flags); |
| 5251 | } |
| 5252 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5253 | if (IS_QLAFX00(ha)) |
| 5254 | goto loop_resync_check; |
| 5255 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5256 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5257 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 5258 | "Quiescence mode scheduled.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5259 | if (IS_P3P_TYPE(ha)) { |
| 5260 | if (IS_QLA82XX(ha)) |
| 5261 | qla82xx_device_state_handler(base_vha); |
| 5262 | if (IS_QLA8044(ha)) |
| 5263 | qla8044_device_state_handler(base_vha); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5264 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5265 | &base_vha->dpc_flags); |
| 5266 | if (!ha->flags.quiesce_owner) { |
| 5267 | qla2x00_perform_loop_resync(base_vha); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5268 | if (IS_QLA82XX(ha)) { |
| 5269 | qla82xx_idc_lock(ha); |
| 5270 | qla82xx_clear_qsnt_ready( |
| 5271 | base_vha); |
| 5272 | qla82xx_idc_unlock(ha); |
| 5273 | } else if (IS_QLA8044(ha)) { |
| 5274 | qla8044_idc_lock(ha); |
| 5275 | qla8044_clear_qsnt_ready( |
| 5276 | base_vha); |
| 5277 | qla8044_idc_unlock(ha); |
| 5278 | } |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5279 | } |
| 5280 | } else { |
| 5281 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5282 | &base_vha->dpc_flags); |
| 5283 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5284 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5285 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 5286 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5287 | } |
| 5288 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5289 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5290 | &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5291 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5292 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5293 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 5294 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5295 | qla2x00_rst_aen(base_vha); |
| 5296 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5297 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 5298 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5299 | } |
| 5300 | |
| 5301 | /* Retry each device up to login retry count */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5302 | if ((test_and_clear_bit(RELOGIN_NEEDED, |
| 5303 | &base_vha->dpc_flags)) && |
| 5304 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 5305 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5306 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5307 | ql_dbg(ql_dbg_dpc, base_vha, 0x400d, |
| 5308 | "Relogin scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5309 | qla2x00_relogin(base_vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5310 | ql_dbg(ql_dbg_dpc, base_vha, 0x400e, |
| 5311 | "Relogin end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5312 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5313 | loop_resync_check: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5314 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5315 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5316 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5317 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 5318 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5319 | |
| 5320 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5321 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5322 | |
Bart Van Assche | 52c8282 | 2015-07-09 07:23:26 -0700 | [diff] [blame] | 5323 | qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5324 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5325 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 5326 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5327 | } |
| 5328 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5329 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 5330 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5331 | } |
| 5332 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5333 | if (IS_QLAFX00(ha)) |
| 5334 | goto intr_on_check; |
| 5335 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5336 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 5337 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 5338 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 5339 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 5340 | } |
| 5341 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5342 | intr_on_check: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5343 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 5344 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5345 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5346 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
Himanshu Madani | 90b604f | 2014-04-11 16:54:40 -0400 | [diff] [blame] | 5347 | &base_vha->dpc_flags)) { |
| 5348 | if (ha->beacon_blink_led == 1) |
| 5349 | ha->isp_ops->beacon_blink(base_vha); |
| 5350 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5351 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5352 | if (!IS_QLAFX00(ha)) |
| 5353 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5354 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5355 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5356 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5357 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5358 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5359 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5360 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5361 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 5362 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5363 | |
| 5364 | /* |
| 5365 | * Make sure that nobody tries to wake us up again. |
| 5366 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5367 | ha->dpc_active = 0; |
| 5368 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5369 | /* Cleanup any residual CTX SRBs. */ |
| 5370 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5371 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5372 | return 0; |
| 5373 | } |
| 5374 | |
| 5375 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5376 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5377 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5378 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5379 | struct task_struct *t = ha->dpc_thread; |
| 5380 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5381 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5382 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5383 | } |
| 5384 | |
| 5385 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5386 | * qla2x00_rst_aen |
| 5387 | * Processes asynchronous reset. |
| 5388 | * |
| 5389 | * Input: |
| 5390 | * ha = adapter block pointer. |
| 5391 | */ |
| 5392 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5393 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5394 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5395 | if (vha->flags.online && !vha->flags.reset_active && |
| 5396 | !atomic_read(&vha->loop_down_timer) && |
| 5397 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5398 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5399 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5400 | |
| 5401 | /* |
| 5402 | * Issue marker command only when we are going to start |
| 5403 | * the I/O. |
| 5404 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5405 | vha->marker_needed = 1; |
| 5406 | } while (!atomic_read(&vha->loop_down_timer) && |
| 5407 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5408 | } |
| 5409 | } |
| 5410 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5411 | /************************************************************************** |
| 5412 | * qla2x00_timer |
| 5413 | * |
| 5414 | * Description: |
| 5415 | * One second timer |
| 5416 | * |
| 5417 | * Context: Interrupt |
| 5418 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5419 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5420 | qla2x00_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5421 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5422 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5423 | int start_dpc = 0; |
| 5424 | int index; |
| 5425 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5426 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5427 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5428 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5429 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5430 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5431 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 5432 | "EEH = %d, restarting timer.\n", |
| 5433 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5434 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 5435 | return; |
| 5436 | } |
| 5437 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5438 | /* |
| 5439 | * Hardware read to raise pending EEH errors during mailbox waits. If |
| 5440 | * the read returns -1 then disable the board. |
| 5441 | */ |
| 5442 | if (!pci_channel_offline(ha->pdev)) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5443 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Joe Lawrence | c821e0d | 2014-08-26 17:11:41 -0400 | [diff] [blame] | 5444 | qla2x00_check_reg16_for_disconnect(vha, w); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5445 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5446 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5447 | /* Make sure qla82xx_watchdog is run only for physical port */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5448 | if (!vha->vp_idx && IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5449 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 5450 | start_dpc++; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5451 | if (IS_QLA82XX(ha)) |
| 5452 | qla82xx_watchdog(vha); |
| 5453 | else if (IS_QLA8044(ha)) |
| 5454 | qla8044_watchdog(vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5455 | } |
| 5456 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5457 | if (!vha->vp_idx && IS_QLAFX00(ha)) |
| 5458 | qlafx00_timer_routine(vha); |
| 5459 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5460 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5461 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5462 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 5463 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5464 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5465 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5466 | if (atomic_read(&vha->loop_down_timer) == |
| 5467 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5468 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5469 | ql_log(ql_log_info, vha, 0x6008, |
| 5470 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5471 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5472 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 5473 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5474 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5475 | /* |
| 5476 | * Schedule an ISP abort to return any FCP2-device |
| 5477 | * commands. |
| 5478 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5479 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5480 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5481 | spin_lock_irqsave(&ha->hardware_lock, |
| 5482 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5483 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5484 | for (index = 1; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 5485 | index < req->num_outstanding_cmds; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5486 | index++) { |
| 5487 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 5488 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5489 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5490 | if (!sp) |
| 5491 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 5492 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 5493 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5494 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5495 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5496 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5497 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5498 | if (IS_QLA82XX(ha)) |
| 5499 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5500 | &vha->dpc_flags); |
| 5501 | else |
| 5502 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5503 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5504 | break; |
| 5505 | } |
| 5506 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5507 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5508 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5509 | start_dpc++; |
| 5510 | } |
| 5511 | |
| 5512 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5513 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 5514 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5515 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5516 | "Loop down - aborting ISP.\n"); |
| 5517 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5518 | if (IS_QLA82XX(ha)) |
| 5519 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5520 | &vha->dpc_flags); |
| 5521 | else |
| 5522 | set_bit(ISP_ABORT_NEEDED, |
| 5523 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5524 | } |
| 5525 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5526 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 5527 | "Loop down - seconds remaining %d.\n", |
| 5528 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5529 | } |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5530 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 5531 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5532 | /* There is no beacon_blink function for ISP82xx */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5533 | if (!IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5534 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 5535 | start_dpc++; |
| 5536 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5537 | } |
| 5538 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5539 | /* Process any deferred work. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5540 | if (!list_empty(&vha->work_list)) |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5541 | start_dpc++; |
| 5542 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5543 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5544 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 5545 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 5546 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5547 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5548 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 5549 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5550 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 5551 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5552 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5553 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5554 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 5555 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 5556 | "fcport_update_needed=%d start_dpc=%d " |
| 5557 | "reset_marker_needed=%d", |
| 5558 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 5559 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 5560 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 5561 | start_dpc, |
| 5562 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 5563 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 5564 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 5565 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5566 | "relogin_needed=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5567 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 5568 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 5569 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 5570 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5571 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5572 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5573 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5574 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5575 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5576 | } |
| 5577 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5578 | /* Firmware interface routines. */ |
| 5579 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5580 | #define FW_BLOBS 11 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5581 | #define FW_ISP21XX 0 |
| 5582 | #define FW_ISP22XX 1 |
| 5583 | #define FW_ISP2300 2 |
| 5584 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5585 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5586 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5587 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5588 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5589 | #define FW_ISP2031 8 |
| 5590 | #define FW_ISP8031 9 |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5591 | #define FW_ISP27XX 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5592 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5593 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 5594 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 5595 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 5596 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 5597 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5598 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5599 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5600 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5601 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 5602 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5603 | #define FW_FILE_ISP27XX "ql2700_fw.bin" |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5604 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5605 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5606 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5607 | |
| 5608 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5609 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 5610 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 5611 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 5612 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 5613 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5614 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5615 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5616 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5617 | { .name = FW_FILE_ISP2031, }, |
| 5618 | { .name = FW_FILE_ISP8031, }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5619 | { .name = FW_FILE_ISP27XX, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5620 | }; |
| 5621 | |
| 5622 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5623 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5624 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5625 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5626 | struct fw_blob *blob; |
| 5627 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5628 | if (IS_QLA2100(ha)) { |
| 5629 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 5630 | } else if (IS_QLA2200(ha)) { |
| 5631 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5632 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5633 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5634 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5635 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5636 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5637 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5638 | } else if (IS_QLA25XX(ha)) { |
| 5639 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5640 | } else if (IS_QLA81XX(ha)) { |
| 5641 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5642 | } else if (IS_QLA82XX(ha)) { |
| 5643 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5644 | } else if (IS_QLA2031(ha)) { |
| 5645 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 5646 | } else if (IS_QLA8031(ha)) { |
| 5647 | blob = &qla_fw_blobs[FW_ISP8031]; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5648 | } else if (IS_QLA27XX(ha)) { |
| 5649 | blob = &qla_fw_blobs[FW_ISP27XX]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 5650 | } else { |
| 5651 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5652 | } |
| 5653 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5654 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5655 | if (blob->fw) |
| 5656 | goto out; |
| 5657 | |
| 5658 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5659 | ql_log(ql_log_warn, vha, 0x0063, |
| 5660 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5661 | blob->fw = NULL; |
| 5662 | blob = NULL; |
| 5663 | goto out; |
| 5664 | } |
| 5665 | |
| 5666 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5667 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5668 | return blob; |
| 5669 | } |
| 5670 | |
| 5671 | static void |
| 5672 | qla2x00_release_firmware(void) |
| 5673 | { |
| 5674 | int idx; |
| 5675 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5676 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5677 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 5678 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5679 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5680 | } |
| 5681 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5682 | static pci_ers_result_t |
| 5683 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 5684 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5685 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 5686 | struct qla_hw_data *ha = vha->hw; |
| 5687 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5688 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 5689 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 5690 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5691 | switch (state) { |
| 5692 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5693 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5694 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 5695 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5696 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5697 | /* For ISP82XX complete any pending mailbox cmd */ |
| 5698 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5699 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 5700 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 5701 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5702 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5703 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5704 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 5705 | /* Return back all IOs */ |
| 5706 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5707 | return PCI_ERS_RESULT_NEED_RESET; |
| 5708 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5709 | ha->flags.pci_channel_io_perm_failure = 1; |
| 5710 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5711 | return PCI_ERS_RESULT_DISCONNECT; |
| 5712 | } |
| 5713 | return PCI_ERS_RESULT_NEED_RESET; |
| 5714 | } |
| 5715 | |
| 5716 | static pci_ers_result_t |
| 5717 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 5718 | { |
| 5719 | int risc_paused = 0; |
| 5720 | uint32_t stat; |
| 5721 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5722 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5723 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5724 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 5725 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 5726 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 5727 | if (IS_QLA82XX(ha)) |
| 5728 | return PCI_ERS_RESULT_RECOVERED; |
| 5729 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5730 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 5731 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 5732 | stat = RD_REG_DWORD(®->hccr); |
| 5733 | if (stat & HCCR_RISC_PAUSE) |
| 5734 | risc_paused = 1; |
| 5735 | } else if (IS_QLA23XX(ha)) { |
| 5736 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 5737 | if (stat & HSR_RISC_PAUSED) |
| 5738 | risc_paused = 1; |
| 5739 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 5740 | stat = RD_REG_DWORD(®24->host_status); |
| 5741 | if (stat & HSRX_RISC_PAUSED) |
| 5742 | risc_paused = 1; |
| 5743 | } |
| 5744 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 5745 | |
| 5746 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5747 | ql_log(ql_log_info, base_vha, 0x9003, |
| 5748 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5749 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5750 | |
| 5751 | return PCI_ERS_RESULT_NEED_RESET; |
| 5752 | } else |
| 5753 | return PCI_ERS_RESULT_RECOVERED; |
| 5754 | } |
| 5755 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5756 | static uint32_t |
| 5757 | qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5758 | { |
| 5759 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 5760 | uint32_t drv_active = 0; |
| 5761 | struct qla_hw_data *ha = base_vha->hw; |
| 5762 | int fn; |
| 5763 | struct pci_dev *other_pdev = NULL; |
| 5764 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5765 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 5766 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5767 | |
| 5768 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5769 | |
| 5770 | if (base_vha->flags.online) { |
| 5771 | /* Abort all outstanding commands, |
| 5772 | * so as to be requeued later */ |
| 5773 | qla2x00_abort_isp_cleanup(base_vha); |
| 5774 | } |
| 5775 | |
| 5776 | |
| 5777 | fn = PCI_FUNC(ha->pdev->devfn); |
| 5778 | while (fn > 0) { |
| 5779 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5780 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 5781 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5782 | other_pdev = |
| 5783 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 5784 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 5785 | fn)); |
| 5786 | |
| 5787 | if (!other_pdev) |
| 5788 | continue; |
| 5789 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5790 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 5791 | "Found PCI func available and enable at 0x%x.\n", |
| 5792 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5793 | pci_dev_put(other_pdev); |
| 5794 | break; |
| 5795 | } |
| 5796 | pci_dev_put(other_pdev); |
| 5797 | } |
| 5798 | |
| 5799 | if (!fn) { |
| 5800 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5801 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 5802 | "This devfn is reset owner = 0x%x.\n", |
| 5803 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5804 | qla82xx_idc_lock(ha); |
| 5805 | |
| 5806 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5807 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5808 | |
| 5809 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 5810 | QLA82XX_IDC_VERSION); |
| 5811 | |
| 5812 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5813 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 5814 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5815 | |
| 5816 | qla82xx_idc_unlock(ha); |
| 5817 | /* Reset if device is not already reset |
| 5818 | * drv_active would be 0 if a reset has already been done |
| 5819 | */ |
| 5820 | if (drv_active) |
| 5821 | rval = qla82xx_start_firmware(base_vha); |
| 5822 | else |
| 5823 | rval = QLA_SUCCESS; |
| 5824 | qla82xx_idc_lock(ha); |
| 5825 | |
| 5826 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5827 | ql_log(ql_log_info, base_vha, 0x900b, |
| 5828 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5829 | qla82xx_clear_drv_active(ha); |
| 5830 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5831 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5832 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5833 | ql_log(ql_log_info, base_vha, 0x900c, |
| 5834 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5835 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5836 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5837 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5838 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5839 | rval = qla82xx_restart_isp(base_vha); |
| 5840 | qla82xx_idc_lock(ha); |
| 5841 | /* Clear driver state register */ |
| 5842 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 5843 | qla82xx_set_drv_active(base_vha); |
| 5844 | } |
| 5845 | qla82xx_idc_unlock(ha); |
| 5846 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5847 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 5848 | "This devfn is not reset owner = 0x%x.\n", |
| 5849 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5850 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5851 | QLA8XXX_DEV_READY)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5852 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5853 | rval = qla82xx_restart_isp(base_vha); |
| 5854 | qla82xx_idc_lock(ha); |
| 5855 | qla82xx_set_drv_active(base_vha); |
| 5856 | qla82xx_idc_unlock(ha); |
| 5857 | } |
| 5858 | } |
| 5859 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5860 | |
| 5861 | return rval; |
| 5862 | } |
| 5863 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5864 | static pci_ers_result_t |
| 5865 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 5866 | { |
| 5867 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5868 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5869 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5870 | struct rsp_que *rsp; |
| 5871 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5872 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5873 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 5874 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5875 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5876 | /* Workaround: qla2xxx driver which access hardware earlier |
| 5877 | * needs error state to be pci_channel_io_online. |
| 5878 | * Otherwise mailbox command timesout. |
| 5879 | */ |
| 5880 | pdev->error_state = pci_channel_io_normal; |
| 5881 | |
| 5882 | pci_restore_state(pdev); |
| 5883 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 5884 | /* pci_restore_state() clears the saved_state flag of the device |
| 5885 | * save restored state which resets saved_state flag |
| 5886 | */ |
| 5887 | pci_save_state(pdev); |
| 5888 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 5889 | if (ha->mem_only) |
| 5890 | rc = pci_enable_device_mem(pdev); |
| 5891 | else |
| 5892 | rc = pci_enable_device(pdev); |
| 5893 | |
| 5894 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5895 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5896 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5897 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5898 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5899 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5900 | rsp = ha->rsp_q_map[0]; |
| 5901 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5902 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5903 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5904 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5905 | goto exit_slot_reset; |
| 5906 | |
| 5907 | if (IS_QLA82XX(ha)) { |
| 5908 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 5909 | ret = PCI_ERS_RESULT_RECOVERED; |
| 5910 | goto exit_slot_reset; |
| 5911 | } else |
| 5912 | goto exit_slot_reset; |
| 5913 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5914 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5915 | while (ha->flags.mbox_busy && retries--) |
| 5916 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5917 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5918 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5919 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5920 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5921 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5922 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5923 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5924 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5925 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 5926 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5927 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5928 | return ret; |
| 5929 | } |
| 5930 | |
| 5931 | static void |
| 5932 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 5933 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5934 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5935 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5936 | int ret; |
| 5937 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5938 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 5939 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5940 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5941 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5942 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5943 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 5944 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5945 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5946 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 5947 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 5948 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5949 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5950 | } |
| 5951 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 5952 | static void |
| 5953 | qla83xx_disable_laser(scsi_qla_host_t *vha) |
| 5954 | { |
| 5955 | uint32_t reg, data, fn; |
| 5956 | struct qla_hw_data *ha = vha->hw; |
| 5957 | struct device_reg_24xx __iomem *isp_reg = &ha->iobase->isp24; |
| 5958 | |
| 5959 | /* pci func #/port # */ |
| 5960 | ql_dbg(ql_dbg_init, vha, 0x004b, |
| 5961 | "Disabling Laser for hba: %p\n", vha); |
| 5962 | |
| 5963 | fn = (RD_REG_DWORD(&isp_reg->ctrl_status) & |
| 5964 | (BIT_15|BIT_14|BIT_13|BIT_12)); |
| 5965 | |
| 5966 | fn = (fn >> 12); |
| 5967 | |
| 5968 | if (fn & 1) |
| 5969 | reg = PORT_1_2031; |
| 5970 | else |
| 5971 | reg = PORT_0_2031; |
| 5972 | |
| 5973 | data = LASER_OFF_2031; |
| 5974 | |
| 5975 | qla83xx_wr_reg(vha, reg, data); |
| 5976 | } |
| 5977 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 5978 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5979 | .error_detected = qla2xxx_pci_error_detected, |
| 5980 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 5981 | .slot_reset = qla2xxx_pci_slot_reset, |
| 5982 | .resume = qla2xxx_pci_resume, |
| 5983 | }; |
| 5984 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5985 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5986 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 5987 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 5988 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 5989 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 5990 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 5991 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 5992 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 5993 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 5994 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5995 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5996 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 5997 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5998 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5999 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6000 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6001 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 6002 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6003 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISPF001) }, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6004 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8044) }, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6005 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2071) }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6006 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2271) }, |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 6007 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2261) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6008 | { 0 }, |
| 6009 | }; |
| 6010 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 6011 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6012 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 6013 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 6014 | .driver = { |
| 6015 | .owner = THIS_MODULE, |
| 6016 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6017 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6018 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 6019 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 6020 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6021 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6022 | }; |
| 6023 | |
Al Viro | 75ef9de | 2013-04-04 19:09:41 -0400 | [diff] [blame] | 6024 | static const struct file_operations apidev_fops = { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6025 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 6026 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6027 | }; |
| 6028 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6029 | /** |
| 6030 | * qla2x00_module_init - Module initialization. |
| 6031 | **/ |
| 6032 | static int __init |
| 6033 | qla2x00_module_init(void) |
| 6034 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6035 | int ret = 0; |
| 6036 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6037 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6038 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 6039 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6040 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6041 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 6042 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6043 | return -ENOMEM; |
| 6044 | } |
| 6045 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6046 | /* Initialize target kmem_cache and mem_pools */ |
| 6047 | ret = qlt_init(); |
| 6048 | if (ret < 0) { |
| 6049 | kmem_cache_destroy(srb_cachep); |
| 6050 | return ret; |
| 6051 | } else if (ret > 0) { |
| 6052 | /* |
| 6053 | * If initiator mode is explictly disabled by qlt_init(), |
| 6054 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 6055 | * performing scsi_scan_target() during LOOP UP event. |
| 6056 | */ |
| 6057 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 6058 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 6059 | } |
| 6060 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6061 | /* Derive version string. */ |
| 6062 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 6063 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 6064 | strcat(qla2x00_version_str, "-debug"); |
| 6065 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 6066 | qla2xxx_transport_template = |
| 6067 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6068 | if (!qla2xxx_transport_template) { |
| 6069 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6070 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 6071 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6072 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6073 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6074 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6075 | |
| 6076 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 6077 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6078 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 6079 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6080 | } |
| 6081 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6082 | qla2xxx_transport_vport_template = |
| 6083 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 6084 | if (!qla2xxx_transport_vport_template) { |
| 6085 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6086 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6087 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6088 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 6089 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6090 | return -ENODEV; |
| 6091 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6092 | ql_log(ql_log_info, NULL, 0x0005, |
| 6093 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 6094 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6095 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6096 | if (ret) { |
| 6097 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6098 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6099 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6100 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6101 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 6102 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 6103 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6104 | } |
| 6105 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6106 | } |
| 6107 | |
| 6108 | /** |
| 6109 | * qla2x00_module_exit - Module cleanup. |
| 6110 | **/ |
| 6111 | static void __exit |
| 6112 | qla2x00_module_exit(void) |
| 6113 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6114 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6115 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6116 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6117 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6118 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6119 | if (ctx_cachep) |
| 6120 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6121 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6122 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6123 | } |
| 6124 | |
| 6125 | module_init(qla2x00_module_init); |
| 6126 | module_exit(qla2x00_module_exit); |
| 6127 | |
| 6128 | MODULE_AUTHOR("QLogic Corporation"); |
| 6129 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 6130 | MODULE_LICENSE("GPL"); |
| 6131 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6132 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 6133 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 6134 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 6135 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 6136 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 6137 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |