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> |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 16 | #include <linux/blk-mq-pci.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <scsi/scsi_tcq.h> |
| 18 | #include <scsi/scsicam.h> |
| 19 | #include <scsi/scsi_transport.h> |
| 20 | #include <scsi/scsi_transport_fc.h> |
| 21 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 22 | #include "qla_target.h" |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | /* |
| 25 | * Driver version |
| 26 | */ |
| 27 | char qla2x00_version_str[40]; |
| 28 | |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 29 | static int apidev_major; |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | /* |
| 32 | * SRB allocation cache |
| 33 | */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 34 | struct kmem_cache *srb_cachep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 36 | /* |
| 37 | * CT6 CTX allocation cache |
| 38 | */ |
| 39 | static struct kmem_cache *ctx_cachep; |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 40 | /* |
| 41 | * error level for logging |
| 42 | */ |
| 43 | int ql_errlev = ql_log_all; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 44 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 45 | static int ql2xenableclass2; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 46 | module_param(ql2xenableclass2, int, S_IRUGO|S_IRUSR); |
| 47 | MODULE_PARM_DESC(ql2xenableclass2, |
| 48 | "Specify if Class 2 operations are supported from the very " |
| 49 | "beginning. Default is 0 - class 2 not supported."); |
| 50 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | int ql2xlogintimeout = 20; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 53 | module_param(ql2xlogintimeout, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | MODULE_PARM_DESC(ql2xlogintimeout, |
| 55 | "Login timeout value in seconds."); |
| 56 | |
Andrew Vasquez | a7b6184 | 2007-05-07 07:42:59 -0700 | [diff] [blame] | 57 | int qlport_down_retry; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 58 | module_param(qlport_down_retry, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | MODULE_PARM_DESC(qlport_down_retry, |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 60 | "Maximum number of command retries to a port that returns " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | "a PORT-DOWN status."); |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | int ql2xplogiabsentdevice; |
| 64 | module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); |
| 65 | MODULE_PARM_DESC(ql2xplogiabsentdevice, |
| 66 | "Option to enable PLOGI to devices that are not present after " |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 67 | "a Fabric scan. This is needed for several broken switches. " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | "Default is 0 - no PLOGI. 1 - perfom PLOGI."); |
| 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | int ql2xloginretrycount = 0; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 71 | module_param(ql2xloginretrycount, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | MODULE_PARM_DESC(ql2xloginretrycount, |
| 73 | "Specify an alternate value for the NVRAM login retry count."); |
| 74 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 75 | int ql2xallocfwdump = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 76 | module_param(ql2xallocfwdump, int, S_IRUGO); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 77 | MODULE_PARM_DESC(ql2xallocfwdump, |
| 78 | "Option to enable allocation of memory for a firmware dump " |
| 79 | "during HBA initialization. Memory allocation requirements " |
| 80 | "vary by ISP type. Default is 1 - allocate memory."); |
| 81 | |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 82 | int ql2xextended_error_logging; |
Andrew Vasquez | 27d9403 | 2007-03-12 10:41:30 -0700 | [diff] [blame] | 83 | module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 84 | module_param_named(logging, ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 85 | MODULE_PARM_DESC(ql2xextended_error_logging, |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 86 | "Option to enable extended error logging,\n" |
| 87 | "\t\tDefault is 0 - no logging. 0x40000000 - Module Init & Probe.\n" |
| 88 | "\t\t0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.\n" |
| 89 | "\t\t0x08000000 - IO tracing. 0x04000000 - DPC Thread.\n" |
| 90 | "\t\t0x02000000 - Async events. 0x01000000 - Timer routines.\n" |
| 91 | "\t\t0x00800000 - User space. 0x00400000 - Task Management.\n" |
| 92 | "\t\t0x00200000 - AER/EEH. 0x00100000 - Multi Q.\n" |
| 93 | "\t\t0x00080000 - P3P Specific. 0x00040000 - Virtual Port.\n" |
| 94 | "\t\t0x00020000 - Buffer Dump. 0x00010000 - Misc.\n" |
Chad Dupuis | 29f9f90 | 2012-11-21 02:40:41 -0500 | [diff] [blame] | 95 | "\t\t0x00008000 - Verbose. 0x00004000 - Target.\n" |
| 96 | "\t\t0x00002000 - Target Mgmt. 0x00001000 - Target TMF.\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 97 | "\t\t0x7fffffff - For enabling all logs, can be too many logs.\n" |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 98 | "\t\t0x1e400000 - Preferred value for capturing essential " |
| 99 | "debug information (equivalent to old " |
| 100 | "ql2xextended_error_logging=1).\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 101 | "\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] | 102 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 103 | int ql2xshiftctondsd = 6; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 104 | module_param(ql2xshiftctondsd, int, S_IRUGO); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 105 | MODULE_PARM_DESC(ql2xshiftctondsd, |
| 106 | "Set to control shifting of command type processing " |
| 107 | "based on total number of SG elements."); |
| 108 | |
Andrew Vasquez | 7e47e5c | 2008-04-24 15:21:26 -0700 | [diff] [blame] | 109 | int ql2xfdmienable=1; |
Himanshu Madhani | de187df | 2014-09-25 05:16:50 -0400 | [diff] [blame] | 110 | module_param(ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 111 | module_param_named(fdmi, ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 112 | MODULE_PARM_DESC(ql2xfdmienable, |
Ferenc Wagner | 7794a5a | 2010-03-23 18:14:59 +0100 | [diff] [blame] | 113 | "Enables FDMI registrations. " |
| 114 | "0 - no FDMI. Default is 1 - perform FDMI."); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 115 | |
Michael Hernandez | d213a4b | 2017-08-23 15:05:20 -0700 | [diff] [blame] | 116 | #define MAX_Q_DEPTH 64 |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 117 | static int ql2xmaxqdepth = MAX_Q_DEPTH; |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 118 | module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR); |
| 119 | MODULE_PARM_DESC(ql2xmaxqdepth, |
Chad Dupuis | e92e4a8 | 2012-08-22 14:21:23 -0400 | [diff] [blame] | 120 | "Maximum queue depth to set for each LUN. " |
Michael Hernandez | d213a4b | 2017-08-23 15:05:20 -0700 | [diff] [blame] | 121 | "Default is 64."); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 122 | |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 123 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 124 | int ql2xenabledif; |
| 125 | #else |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 126 | int ql2xenabledif = 2; |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 127 | #endif |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 128 | module_param(ql2xenabledif, int, S_IRUGO); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 129 | MODULE_PARM_DESC(ql2xenabledif, |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 130 | " Enable T10-CRC-DIF:\n" |
| 131 | " Default is 2.\n" |
| 132 | " 0 -- No DIF Support\n" |
| 133 | " 1 -- Enable DIF for all types\n" |
| 134 | " 2 -- Enable DIF for all types, except Type 0.\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 135 | |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 136 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 137 | int ql2xnvmeenable = 1; |
| 138 | #else |
| 139 | int ql2xnvmeenable; |
| 140 | #endif |
| 141 | module_param(ql2xnvmeenable, int, 0644); |
| 142 | MODULE_PARM_DESC(ql2xnvmeenable, |
| 143 | "Enables NVME support. " |
| 144 | "0 - no NVMe. Default is Y"); |
| 145 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 146 | int ql2xenablehba_err_chk = 2; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 147 | module_param(ql2xenablehba_err_chk, int, S_IRUGO|S_IWUSR); |
| 148 | MODULE_PARM_DESC(ql2xenablehba_err_chk, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 149 | " Enable T10-CRC-DIF Error isolation by HBA:\n" |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 150 | " Default is 2.\n" |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 151 | " 0 -- Error isolation disabled\n" |
| 152 | " 1 -- Error isolation enabled only for DIX Type 0\n" |
| 153 | " 2 -- Error isolation enabled for all Types\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 154 | |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 155 | int ql2xiidmaenable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 156 | module_param(ql2xiidmaenable, int, S_IRUGO); |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 157 | MODULE_PARM_DESC(ql2xiidmaenable, |
| 158 | "Enables iIDMA settings " |
| 159 | "Default is 1 - perform iIDMA. 0 - no iIDMA."); |
| 160 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 161 | int ql2xmqsupport = 1; |
| 162 | module_param(ql2xmqsupport, int, S_IRUGO); |
| 163 | MODULE_PARM_DESC(ql2xmqsupport, |
| 164 | "Enable on demand multiple queue pairs support " |
| 165 | "Default is 1 for supported. " |
| 166 | "Set it to 0 to turn off mq qpair support."); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 167 | |
| 168 | int ql2xfwloadbin; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 169 | module_param(ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 170 | module_param_named(fwload, ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 171 | MODULE_PARM_DESC(ql2xfwloadbin, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 172 | "Option to specify location from which to load ISP firmware:.\n" |
| 173 | " 2 -- load firmware via the request_firmware() (hotplug).\n" |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 174 | " interface.\n" |
| 175 | " 1 -- load firmware from flash.\n" |
| 176 | " 0 -- use default semantics.\n"); |
| 177 | |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 178 | int ql2xetsenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 179 | module_param(ql2xetsenable, int, S_IRUGO); |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 180 | MODULE_PARM_DESC(ql2xetsenable, |
| 181 | "Enables firmware ETS burst." |
| 182 | "Default is 0 - skip ETS enablement."); |
| 183 | |
Giridhar Malavali | 6907869 | 2010-05-28 15:08:28 -0700 | [diff] [blame] | 184 | int ql2xdbwr = 1; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 185 | module_param(ql2xdbwr, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 186 | MODULE_PARM_DESC(ql2xdbwr, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 187 | "Option to specify scheme for request queue posting.\n" |
| 188 | " 0 -- Regular doorbell.\n" |
| 189 | " 1 -- CAMRAM doorbell (faster).\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 190 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 191 | int ql2xtargetreset = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 192 | module_param(ql2xtargetreset, int, S_IRUGO); |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 193 | MODULE_PARM_DESC(ql2xtargetreset, |
| 194 | "Enable target reset." |
| 195 | "Default is 1 - use hw defaults."); |
| 196 | |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 197 | int ql2xgffidenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 198 | module_param(ql2xgffidenable, int, S_IRUGO); |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 199 | MODULE_PARM_DESC(ql2xgffidenable, |
| 200 | "Enables GFF_ID checks of port type. " |
| 201 | "Default is 0 - Do not use GFF_ID information."); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 202 | |
himanshu.madhani@cavium.com | 043dc1d | 2017-08-23 15:05:19 -0700 | [diff] [blame] | 203 | int ql2xasynctmfenable = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 204 | module_param(ql2xasynctmfenable, int, S_IRUGO); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 205 | MODULE_PARM_DESC(ql2xasynctmfenable, |
| 206 | "Enables issue of TM IOCBs asynchronously via IOCB mechanism" |
| 207 | "Default is 0 - Issue TM IOCBs via mailbox mechanism."); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 208 | |
| 209 | int ql2xdontresethba; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 210 | module_param(ql2xdontresethba, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 211 | MODULE_PARM_DESC(ql2xdontresethba, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 212 | "Option to specify reset behaviour.\n" |
| 213 | " 0 (Default) -- Reset on failure.\n" |
| 214 | " 1 -- Do not reset on failure.\n"); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 215 | |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 216 | uint64_t ql2xmaxlun = MAX_LUNS; |
| 217 | module_param(ql2xmaxlun, ullong, S_IRUGO); |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 218 | MODULE_PARM_DESC(ql2xmaxlun, |
| 219 | "Defines the maximum LU number to register with the SCSI " |
| 220 | "midlayer. Default is 65535."); |
| 221 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 222 | int ql2xmdcapmask = 0x1F; |
| 223 | module_param(ql2xmdcapmask, int, S_IRUGO); |
| 224 | MODULE_PARM_DESC(ql2xmdcapmask, |
| 225 | "Set the Minidump driver capture mask level. " |
Giridhar Malavali | 6e96fa7 | 2011-11-18 09:03:14 -0800 | [diff] [blame] | 226 | "Default is 0x1F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 227 | |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 228 | int ql2xmdenable = 1; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 229 | module_param(ql2xmdenable, int, S_IRUGO); |
| 230 | MODULE_PARM_DESC(ql2xmdenable, |
| 231 | "Enable/disable MiniDump. " |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 232 | "0 - MiniDump disabled. " |
| 233 | "1 (Default) - MiniDump enabled."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 234 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 235 | int ql2xexlogins = 0; |
| 236 | module_param(ql2xexlogins, uint, S_IRUGO|S_IWUSR); |
| 237 | MODULE_PARM_DESC(ql2xexlogins, |
| 238 | "Number of extended Logins. " |
| 239 | "0 (Default)- Disabled."); |
| 240 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 241 | int ql2xexchoffld = 1024; |
| 242 | module_param(ql2xexchoffld, uint, 0644); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 243 | MODULE_PARM_DESC(ql2xexchoffld, |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 244 | "Number of target exchanges."); |
| 245 | |
| 246 | int ql2xiniexchg = 1024; |
| 247 | module_param(ql2xiniexchg, uint, 0644); |
| 248 | MODULE_PARM_DESC(ql2xiniexchg, |
| 249 | "Number of initiator exchanges."); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 250 | |
Himanshu Madhani | f198caf | 2016-01-27 12:03:30 -0500 | [diff] [blame] | 251 | int ql2xfwholdabts = 0; |
| 252 | module_param(ql2xfwholdabts, int, S_IRUGO); |
| 253 | MODULE_PARM_DESC(ql2xfwholdabts, |
| 254 | "Allow FW to hold status IOCB until ABTS rsp received. " |
| 255 | "0 (Default) Do not set fw option. " |
| 256 | "1 - Set fw option to hold ABTS."); |
| 257 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 258 | int ql2xmvasynctoatio = 1; |
| 259 | module_param(ql2xmvasynctoatio, int, S_IRUGO|S_IWUSR); |
| 260 | MODULE_PARM_DESC(ql2xmvasynctoatio, |
| 261 | "Move PUREX, ABTS RX and RIDA IOCBs to ATIOQ" |
| 262 | "0 (Default). Do not move IOCBs" |
| 263 | "1 - Move IOCBs."); |
| 264 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 265 | int ql2xautodetectsfp = 1; |
| 266 | module_param(ql2xautodetectsfp, int, 0444); |
| 267 | MODULE_PARM_DESC(ql2xautodetectsfp, |
| 268 | "Detect SFP range and set appropriate distance.\n" |
| 269 | "1 (Default): Enable\n"); |
| 270 | |
Himanshu Madhani | e7240af | 2017-10-13 09:34:03 -0700 | [diff] [blame] | 271 | int ql2xenablemsix = 1; |
| 272 | module_param(ql2xenablemsix, int, 0444); |
| 273 | MODULE_PARM_DESC(ql2xenablemsix, |
| 274 | "Set to enable MSI or MSI-X interrupt mechanism.\n" |
| 275 | " Default is 1, enable MSI-X interrupt mechanism.\n" |
| 276 | " 0 -- enable traditional pin-based mechanism.\n" |
| 277 | " 1 -- enable MSI-X interrupt mechanism.\n" |
| 278 | " 2 -- enable MSI interrupt mechanism.\n"); |
| 279 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 281 | * SCSI host template entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | */ |
| 283 | static int qla2xxx_slave_configure(struct scsi_device * device); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 284 | static int qla2xxx_slave_alloc(struct scsi_device *); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 285 | static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); |
| 286 | static void qla2xxx_scan_start(struct Scsi_Host *); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 287 | static void qla2xxx_slave_destroy(struct scsi_device *); |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 288 | static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | static int qla2xxx_eh_abort(struct scsi_cmnd *); |
| 290 | static int qla2xxx_eh_device_reset(struct scsi_cmnd *); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 291 | static int qla2xxx_eh_target_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); |
| 293 | static int qla2xxx_eh_host_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 295 | static void qla2x00_clear_drv_active(struct qla_hw_data *); |
Saurav Kashyap | 3491255 | 2013-06-25 11:27:18 -0400 | [diff] [blame] | 296 | static void qla2x00_free_device(scsi_qla_host_t *); |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 297 | static void qla83xx_disable_laser(scsi_qla_host_t *vha); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 298 | static int qla2xxx_map_queues(struct Scsi_Host *shost); |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 299 | static void qla2x00_destroy_deferred_work(struct qla_hw_data *); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 300 | |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 301 | struct scsi_host_template qla2xxx_driver_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | .module = THIS_MODULE, |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 303 | .name = QLA2XXX_DRIVER_NAME, |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 304 | .queuecommand = qla2xxx_queuecommand, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 305 | |
Christoph Hellwig | b6a05c8 | 2017-01-30 13:18:58 +0100 | [diff] [blame] | 306 | .eh_timed_out = fc_eh_timed_out, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 307 | .eh_abort_handler = qla2xxx_eh_abort, |
| 308 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 309 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 310 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 311 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 312 | |
| 313 | .slave_configure = qla2xxx_slave_configure, |
| 314 | |
| 315 | .slave_alloc = qla2xxx_slave_alloc, |
| 316 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 317 | .scan_finished = qla2xxx_scan_finished, |
| 318 | .scan_start = qla2xxx_scan_start, |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 319 | .change_queue_depth = scsi_change_queue_depth, |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 320 | .map_queues = qla2xxx_map_queues, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 321 | .this_id = -1, |
| 322 | .cmd_per_lun = 3, |
| 323 | .use_clustering = ENABLE_CLUSTERING, |
| 324 | .sg_tablesize = SG_ALL, |
| 325 | |
| 326 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 327 | .shost_attrs = qla2x00_host_attrs, |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 328 | |
| 329 | .supported_mode = MODE_INITIATOR, |
Christoph Hellwig | c40ecc1 | 2014-11-13 14:25:11 +0100 | [diff] [blame] | 330 | .track_queue_depth = 1, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 331 | }; |
| 332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 334 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | /* TODO Convert to inlines |
| 337 | * |
| 338 | * Timer routines |
| 339 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 341 | __inline__ void |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 342 | qla2x00_start_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | { |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 344 | timer_setup(&vha->timer, qla2x00_timer, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 345 | vha->timer.expires = jiffies + interval * HZ; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 346 | add_timer(&vha->timer); |
| 347 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 351 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 353 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 354 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 355 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 356 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 357 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 358 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 359 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 360 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | } |
| 362 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 363 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 364 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 366 | del_timer_sync(&vha->timer); |
| 367 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | static int qla2x00_do_dpc(void *data); |
| 371 | |
| 372 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 373 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 374 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 375 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 376 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 377 | static void qla2x00_mem_free(struct qla_hw_data *); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 378 | int qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 379 | struct qla_qpair *qpair); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | /* -------------------------------------------------------------------------- */ |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 382 | static void qla_init_base_qpair(struct scsi_qla_host *vha, struct req_que *req, |
| 383 | struct rsp_que *rsp) |
| 384 | { |
| 385 | struct qla_hw_data *ha = vha->hw; |
| 386 | rsp->qpair = ha->base_qpair; |
| 387 | rsp->req = req; |
| 388 | ha->base_qpair->req = req; |
| 389 | ha->base_qpair->rsp = rsp; |
| 390 | ha->base_qpair->vha = vha; |
| 391 | ha->base_qpair->qp_lock_ptr = &ha->hardware_lock; |
| 392 | ha->base_qpair->use_shadow_reg = IS_SHADOW_REG_CAPABLE(ha) ? 1 : 0; |
| 393 | ha->base_qpair->msix = &ha->msix_entries[QLA_MSIX_RSP_Q]; |
| 394 | INIT_LIST_HEAD(&ha->base_qpair->hints_list); |
Duane Grigsby | cf19c45 | 2017-08-23 15:04:58 -0700 | [diff] [blame] | 395 | INIT_LIST_HEAD(&ha->base_qpair->nvme_done_list); |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 396 | ha->base_qpair->enable_class_2 = ql2xenableclass2; |
| 397 | /* init qpair to this cpu. Will adjust at run time. */ |
Bart Van Assche | 8653188 | 2017-11-06 11:59:05 -0800 | [diff] [blame] | 398 | qla_cpu_update(rsp->qpair, raw_smp_processor_id()); |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 399 | ha->base_qpair->pdev = ha->pdev; |
| 400 | |
| 401 | if (IS_QLA27XX(ha) || IS_QLA83XX(ha)) |
| 402 | ha->base_qpair->reqq_start_iocbs = qla_83xx_start_iocbs; |
| 403 | } |
| 404 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 405 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 406 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 407 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 408 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 409 | 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] | 410 | GFP_KERNEL); |
| 411 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 412 | ql_log(ql_log_fatal, vha, 0x003b, |
| 413 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 414 | goto fail_req_map; |
| 415 | } |
| 416 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 417 | 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] | 418 | GFP_KERNEL); |
| 419 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 420 | ql_log(ql_log_fatal, vha, 0x003c, |
| 421 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 422 | goto fail_rsp_map; |
| 423 | } |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 424 | |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 425 | ha->base_qpair = kzalloc(sizeof(struct qla_qpair), GFP_KERNEL); |
| 426 | if (ha->base_qpair == NULL) { |
| 427 | ql_log(ql_log_warn, vha, 0x00e0, |
| 428 | "Failed to allocate base queue pair memory.\n"); |
| 429 | goto fail_base_qpair; |
| 430 | } |
| 431 | |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 432 | qla_init_base_qpair(vha, req, rsp); |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 433 | |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 434 | if ((ql2xmqsupport || ql2xnvmeenable) && ha->max_qpairs) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 435 | ha->queue_pair_map = kcalloc(ha->max_qpairs, sizeof(struct qla_qpair *), |
| 436 | GFP_KERNEL); |
| 437 | if (!ha->queue_pair_map) { |
| 438 | ql_log(ql_log_fatal, vha, 0x0180, |
| 439 | "Unable to allocate memory for queue pair ptrs.\n"); |
| 440 | goto fail_qpair_map; |
| 441 | } |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 442 | } |
| 443 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 444 | /* |
| 445 | * Make sure we record at least the request and response queue zero in |
| 446 | * case we need to free them if part of the probe fails. |
| 447 | */ |
| 448 | ha->rsp_q_map[0] = rsp; |
| 449 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 450 | set_bit(0, ha->rsp_qid_map); |
| 451 | set_bit(0, ha->req_qid_map); |
| 452 | return 1; |
| 453 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 454 | fail_qpair_map: |
Quinn Tran | 82de802 | 2017-06-13 20:47:17 -0700 | [diff] [blame] | 455 | kfree(ha->base_qpair); |
| 456 | ha->base_qpair = NULL; |
| 457 | fail_base_qpair: |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 458 | kfree(ha->rsp_q_map); |
| 459 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 460 | fail_rsp_map: |
| 461 | kfree(ha->req_q_map); |
| 462 | ha->req_q_map = NULL; |
| 463 | fail_req_map: |
| 464 | return -ENOMEM; |
| 465 | } |
| 466 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 467 | 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] | 468 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 469 | if (IS_QLAFX00(ha)) { |
| 470 | if (req && req->ring_fx00) |
| 471 | dma_free_coherent(&ha->pdev->dev, |
| 472 | (req->length_fx00 + 1) * sizeof(request_t), |
| 473 | req->ring_fx00, req->dma_fx00); |
| 474 | } else if (req && req->ring) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 475 | dma_free_coherent(&ha->pdev->dev, |
| 476 | (req->length + 1) * sizeof(request_t), |
| 477 | req->ring, req->dma); |
| 478 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 479 | if (req) |
| 480 | kfree(req->outstanding_cmds); |
| 481 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 482 | kfree(req); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 483 | } |
| 484 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 485 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 486 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 487 | if (IS_QLAFX00(ha)) { |
| 488 | if (rsp && rsp->ring) |
| 489 | dma_free_coherent(&ha->pdev->dev, |
| 490 | (rsp->length_fx00 + 1) * sizeof(request_t), |
| 491 | rsp->ring_fx00, rsp->dma_fx00); |
| 492 | } else if (rsp && rsp->ring) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 493 | dma_free_coherent(&ha->pdev->dev, |
| 494 | (rsp->length + 1) * sizeof(response_t), |
| 495 | rsp->ring, rsp->dma); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 496 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 497 | kfree(rsp); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 498 | } |
| 499 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 500 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 501 | { |
| 502 | struct req_que *req; |
| 503 | struct rsp_que *rsp; |
| 504 | int cnt; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 505 | unsigned long flags; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 506 | |
Quinn Tran | 82de802 | 2017-06-13 20:47:17 -0700 | [diff] [blame] | 507 | if (ha->queue_pair_map) { |
| 508 | kfree(ha->queue_pair_map); |
| 509 | ha->queue_pair_map = NULL; |
| 510 | } |
| 511 | if (ha->base_qpair) { |
| 512 | kfree(ha->base_qpair); |
| 513 | ha->base_qpair = NULL; |
| 514 | } |
| 515 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 516 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 517 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 518 | if (!test_bit(cnt, ha->req_qid_map)) |
| 519 | continue; |
| 520 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 521 | req = ha->req_q_map[cnt]; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 522 | clear_bit(cnt, ha->req_qid_map); |
| 523 | ha->req_q_map[cnt] = NULL; |
| 524 | |
| 525 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 526 | qla2x00_free_req_que(ha, req); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 527 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 528 | } |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 529 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 530 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 531 | kfree(ha->req_q_map); |
| 532 | ha->req_q_map = NULL; |
| 533 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 534 | |
| 535 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 536 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 537 | if (!test_bit(cnt, ha->rsp_qid_map)) |
| 538 | continue; |
| 539 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 540 | rsp = ha->rsp_q_map[cnt]; |
Dave Jones | c3c4239 | 2016-12-27 13:13:21 -0500 | [diff] [blame] | 541 | clear_bit(cnt, ha->rsp_qid_map); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 542 | ha->rsp_q_map[cnt] = NULL; |
| 543 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 544 | qla2x00_free_rsp_que(ha, rsp); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 545 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 546 | } |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 547 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 548 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 549 | kfree(ha->rsp_q_map); |
| 550 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 551 | } |
| 552 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 554 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 556 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | static char *pci_bus_modes[] = { |
| 558 | "33", "66", "100", "133", |
| 559 | }; |
| 560 | uint16_t pci_bus; |
| 561 | |
| 562 | strcpy(str, "PCI"); |
| 563 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 564 | if (pci_bus) { |
| 565 | strcat(str, "-X ("); |
| 566 | strcat(str, pci_bus_modes[pci_bus]); |
| 567 | } else { |
| 568 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 569 | strcat(str, " ("); |
| 570 | strcat(str, pci_bus_modes[pci_bus]); |
| 571 | } |
| 572 | strcat(str, " MHz)"); |
| 573 | |
| 574 | return (str); |
| 575 | } |
| 576 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 577 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 578 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 579 | { |
| 580 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 581 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 582 | uint32_t pci_bus; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 583 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 584 | if (pci_is_pcie(ha->pdev)) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 585 | char lwstr[6]; |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 586 | uint32_t lstat, lspeed, lwidth; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 587 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 588 | pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); |
| 589 | lspeed = lstat & PCI_EXP_LNKCAP_SLS; |
| 590 | lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 591 | |
| 592 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 593 | switch (lspeed) { |
| 594 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 595 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 596 | break; |
| 597 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 598 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 599 | break; |
| 600 | case 3: |
| 601 | strcat(str, "8.0GT/s "); |
| 602 | break; |
| 603 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 604 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 605 | break; |
| 606 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 607 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 608 | strcat(str, lwstr); |
| 609 | |
| 610 | return str; |
| 611 | } |
| 612 | |
| 613 | strcpy(str, "PCI"); |
| 614 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 615 | if (pci_bus == 0 || pci_bus == 8) { |
| 616 | strcat(str, " ("); |
| 617 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 618 | } else { |
| 619 | strcat(str, "-X "); |
| 620 | if (pci_bus & BIT_2) |
| 621 | strcat(str, "Mode 2"); |
| 622 | else |
| 623 | strcat(str, "Mode 1"); |
| 624 | strcat(str, " ("); |
| 625 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 626 | } |
| 627 | strcat(str, " MHz)"); |
| 628 | |
| 629 | return str; |
| 630 | } |
| 631 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 632 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 633 | 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] | 634 | { |
| 635 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 636 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 637 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 638 | snprintf(str, size, "%d.%02d.%02d ", ha->fw_major_version, |
| 639 | ha->fw_minor_version, ha->fw_subminor_version); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | |
| 641 | if (ha->fw_attributes & BIT_9) { |
| 642 | strcat(str, "FLX"); |
| 643 | return (str); |
| 644 | } |
| 645 | |
| 646 | switch (ha->fw_attributes & 0xFF) { |
| 647 | case 0x7: |
| 648 | strcat(str, "EF"); |
| 649 | break; |
| 650 | case 0x17: |
| 651 | strcat(str, "TP"); |
| 652 | break; |
| 653 | case 0x37: |
| 654 | strcat(str, "IP"); |
| 655 | break; |
| 656 | case 0x77: |
| 657 | strcat(str, "VI"); |
| 658 | break; |
| 659 | default: |
| 660 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 661 | strcat(str, un_str); |
| 662 | break; |
| 663 | } |
| 664 | if (ha->fw_attributes & 0x100) |
| 665 | strcat(str, "X"); |
| 666 | |
| 667 | return (str); |
| 668 | } |
| 669 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 670 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 671 | 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] | 672 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 673 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 674 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 675 | snprintf(str, size, "%d.%02d.%02d (%x)", ha->fw_major_version, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 676 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 677 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 678 | } |
| 679 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 680 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 681 | qla2x00_sp_free_dma(void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 682 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 683 | srb_t *sp = ptr; |
| 684 | struct qla_hw_data *ha = sp->vha->hw; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 685 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 686 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 687 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 688 | if (sp->flags & SRB_DMA_VALID) { |
| 689 | scsi_dma_unmap(cmd); |
| 690 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 691 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 692 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 693 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 694 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 695 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 696 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 697 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 698 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 699 | if (!ctx) |
| 700 | goto end; |
| 701 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 702 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 703 | /* List assured to be having elements */ |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 704 | qla2x00_clean_dsd_pool(ha, ctx); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 705 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 706 | } |
| 707 | |
| 708 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 709 | struct crc_context *ctx0 = ctx; |
| 710 | |
| 711 | dma_pool_free(ha->dl_dma_pool, ctx0, ctx0->crc_ctx_dma); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 712 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 713 | } |
| 714 | |
| 715 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 716 | struct ct6_dsd *ctx1 = ctx; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 717 | |
| 718 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 719 | ctx1->fcp_cmnd_dma); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 720 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 721 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 722 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 723 | mempool_free(ctx1, ha->ctx_mempool); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 724 | } |
| 725 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 726 | end: |
himanshu.madhani@cavium.com | 6fcd98f | 2017-07-21 09:32:23 -0700 | [diff] [blame] | 727 | if (sp->type != SRB_NVME_CMD && sp->type != SRB_NVME_LS) { |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 728 | CMD_SP(cmd) = NULL; |
| 729 | qla2x00_rel_sp(sp); |
| 730 | } |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 731 | } |
| 732 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 733 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 734 | qla2x00_sp_compl(void *ptr, int res) |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 735 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 736 | srb_t *sp = ptr; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 737 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 738 | |
| 739 | cmd->result = res; |
| 740 | |
| 741 | if (atomic_read(&sp->ref_count) == 0) { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 742 | ql_dbg(ql_dbg_io, sp->vha, 0x3015, |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 743 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 744 | sp, GET_CMD_SP(sp)); |
| 745 | if (ql2xextended_error_logging & ql_dbg_io) |
Hiral Patel | 8fbdac8 | 2015-08-04 13:37:56 -0400 | [diff] [blame] | 746 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 747 | return; |
| 748 | } |
| 749 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 750 | return; |
| 751 | |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 752 | sp->free(sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 753 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 754 | } |
| 755 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 756 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 757 | qla2xxx_qpair_sp_free_dma(void *ptr) |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 758 | { |
| 759 | srb_t *sp = (srb_t *)ptr; |
| 760 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 761 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 762 | void *ctx = GET_CMD_CTX_SP(sp); |
| 763 | |
| 764 | if (sp->flags & SRB_DMA_VALID) { |
| 765 | scsi_dma_unmap(cmd); |
| 766 | sp->flags &= ~SRB_DMA_VALID; |
| 767 | } |
| 768 | |
| 769 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 770 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 771 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 772 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 773 | } |
| 774 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 775 | if (!ctx) |
| 776 | goto end; |
| 777 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 778 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 779 | /* List assured to be having elements */ |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 780 | qla2x00_clean_dsd_pool(ha, ctx); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 781 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 782 | } |
| 783 | |
| 784 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 785 | struct crc_context *ctx0 = ctx; |
| 786 | |
| 787 | dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 788 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 789 | } |
| 790 | |
| 791 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 792 | struct ct6_dsd *ctx1 = ctx; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 793 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 794 | ctx1->fcp_cmnd_dma); |
| 795 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 796 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 797 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 798 | mempool_free(ctx1, ha->ctx_mempool); |
| 799 | } |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 800 | end: |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 801 | CMD_SP(cmd) = NULL; |
| 802 | qla2xxx_rel_qpair_sp(sp->qpair, sp); |
| 803 | } |
| 804 | |
| 805 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 806 | qla2xxx_qpair_sp_compl(void *ptr, int res) |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 807 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 808 | srb_t *sp = ptr; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 809 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 810 | |
| 811 | cmd->result = res; |
| 812 | |
| 813 | if (atomic_read(&sp->ref_count) == 0) { |
| 814 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079, |
| 815 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 816 | sp, GET_CMD_SP(sp)); |
| 817 | if (ql2xextended_error_logging & ql_dbg_io) |
| 818 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
| 819 | return; |
| 820 | } |
| 821 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 822 | return; |
| 823 | |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 824 | sp->free(sp); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 825 | cmd->scsi_done(cmd); |
| 826 | } |
| 827 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 828 | /* If we are SP1 here, we need to still take and release the host_lock as SP1 |
| 829 | * does not have the changes necessary to avoid taking host->host_lock. |
| 830 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 832 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 833 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 834 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 835 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 836 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 837 | struct qla_hw_data *ha = vha->hw; |
| 838 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 839 | srb_t *sp; |
| 840 | int rval; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 841 | struct qla_qpair *qpair = NULL; |
| 842 | uint32_t tag; |
| 843 | uint16_t hwq; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 844 | |
Mauricio Faria de Oliveira | 04dfaa5 | 2016-11-07 17:53:30 -0200 | [diff] [blame] | 845 | if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { |
| 846 | cmd->result = DID_NO_CONNECT << 16; |
| 847 | goto qc24_fail_command; |
| 848 | } |
| 849 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 850 | if (ha->mqenable) { |
| 851 | if (shost_use_blk_mq(vha->host)) { |
| 852 | tag = blk_mq_unique_tag(cmd->request); |
| 853 | hwq = blk_mq_unique_tag_to_hwq(tag); |
| 854 | qpair = ha->queue_pair_map[hwq]; |
| 855 | } else if (vha->vp_idx && vha->qpair) { |
| 856 | qpair = vha->qpair; |
| 857 | } |
| 858 | |
| 859 | if (qpair) |
| 860 | return qla2xxx_mqueuecommand(host, cmd, qpair); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 861 | } |
| 862 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 863 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 864 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 865 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 866 | "PCI Channel IO permanent failure, exiting " |
| 867 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 868 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 869 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 870 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 871 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 872 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 873 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 874 | goto qc24_fail_command; |
| 875 | } |
| 876 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 877 | rval = fc_remote_port_chkready(rport); |
| 878 | if (rval) { |
| 879 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 880 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 881 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 882 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 883 | goto qc24_fail_command; |
| 884 | } |
| 885 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 886 | if (!vha->flags.difdix_supported && |
| 887 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 888 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 889 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 890 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 891 | cmd->result = DID_NO_CONNECT << 16; |
| 892 | goto qc24_fail_command; |
| 893 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 894 | |
| 895 | if (!fcport) { |
| 896 | cmd->result = DID_NO_CONNECT << 16; |
| 897 | goto qc24_fail_command; |
| 898 | } |
| 899 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 900 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 901 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 902 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 903 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 904 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 905 | atomic_read(&fcport->state), |
| 906 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 907 | cmd->result = DID_NO_CONNECT << 16; |
| 908 | goto qc24_fail_command; |
| 909 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 910 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 911 | } |
| 912 | |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 913 | /* |
| 914 | * Return target busy if we've received a non-zero retry_delay_timer |
| 915 | * in a FCP_RSP. |
| 916 | */ |
Bruno Prémont | 975f7d4 | 2014-12-19 10:29:16 +0100 | [diff] [blame] | 917 | if (fcport->retry_delay_timestamp == 0) { |
| 918 | /* retry delay not set */ |
| 919 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 920 | fcport->retry_delay_timestamp = 0; |
| 921 | else |
| 922 | goto qc24_target_busy; |
| 923 | |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 924 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 925 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 926 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 927 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 928 | sp->u.scmd.cmd = cmd; |
| 929 | sp->type = SRB_SCSI_CMD; |
| 930 | atomic_set(&sp->ref_count, 1); |
| 931 | CMD_SP(cmd) = (void *)sp; |
| 932 | sp->free = qla2x00_sp_free_dma; |
| 933 | sp->done = qla2x00_sp_compl; |
| 934 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 935 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 936 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 937 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 938 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 939 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 940 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 941 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 942 | return 0; |
| 943 | |
| 944 | qc24_host_busy_free_sp: |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 945 | sp->free(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 946 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 947 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 948 | return SCSI_MLQUEUE_HOST_BUSY; |
| 949 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 950 | qc24_target_busy: |
| 951 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 952 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 953 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 954 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 955 | |
| 956 | return 0; |
| 957 | } |
| 958 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 959 | /* For MQ supported I/O */ |
| 960 | int |
| 961 | qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 962 | struct qla_qpair *qpair) |
| 963 | { |
| 964 | scsi_qla_host_t *vha = shost_priv(host); |
| 965 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 966 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
| 967 | struct qla_hw_data *ha = vha->hw; |
| 968 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
| 969 | srb_t *sp; |
| 970 | int rval; |
| 971 | |
| 972 | rval = fc_remote_port_chkready(rport); |
| 973 | if (rval) { |
| 974 | cmd->result = rval; |
| 975 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3076, |
| 976 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 977 | cmd, rval); |
| 978 | goto qc24_fail_command; |
| 979 | } |
| 980 | |
| 981 | if (!fcport) { |
| 982 | cmd->result = DID_NO_CONNECT << 16; |
| 983 | goto qc24_fail_command; |
| 984 | } |
| 985 | |
| 986 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 987 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
| 988 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
| 989 | ql_dbg(ql_dbg_io, vha, 0x3077, |
| 990 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 991 | atomic_read(&fcport->state), |
| 992 | atomic_read(&base_vha->loop_state)); |
| 993 | cmd->result = DID_NO_CONNECT << 16; |
| 994 | goto qc24_fail_command; |
| 995 | } |
| 996 | goto qc24_target_busy; |
| 997 | } |
| 998 | |
| 999 | /* |
| 1000 | * Return target busy if we've received a non-zero retry_delay_timer |
| 1001 | * in a FCP_RSP. |
| 1002 | */ |
| 1003 | if (fcport->retry_delay_timestamp == 0) { |
| 1004 | /* retry delay not set */ |
| 1005 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
| 1006 | fcport->retry_delay_timestamp = 0; |
| 1007 | else |
| 1008 | goto qc24_target_busy; |
| 1009 | |
| 1010 | sp = qla2xxx_get_qpair_sp(qpair, fcport, GFP_ATOMIC); |
| 1011 | if (!sp) |
| 1012 | goto qc24_host_busy; |
| 1013 | |
| 1014 | sp->u.scmd.cmd = cmd; |
| 1015 | sp->type = SRB_SCSI_CMD; |
| 1016 | atomic_set(&sp->ref_count, 1); |
| 1017 | CMD_SP(cmd) = (void *)sp; |
| 1018 | sp->free = qla2xxx_qpair_sp_free_dma; |
| 1019 | sp->done = qla2xxx_qpair_sp_compl; |
| 1020 | sp->qpair = qpair; |
| 1021 | |
| 1022 | rval = ha->isp_ops->start_scsi_mq(sp); |
| 1023 | if (rval != QLA_SUCCESS) { |
| 1024 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3078, |
| 1025 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
| 1026 | if (rval == QLA_INTERFACE_ERROR) |
| 1027 | goto qc24_fail_command; |
| 1028 | goto qc24_host_busy_free_sp; |
| 1029 | } |
| 1030 | |
| 1031 | return 0; |
| 1032 | |
| 1033 | qc24_host_busy_free_sp: |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 1034 | sp->free(sp); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1035 | |
| 1036 | qc24_host_busy: |
| 1037 | return SCSI_MLQUEUE_HOST_BUSY; |
| 1038 | |
| 1039 | qc24_target_busy: |
| 1040 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 1041 | |
| 1042 | qc24_fail_command: |
| 1043 | cmd->scsi_done(cmd); |
| 1044 | |
| 1045 | return 0; |
| 1046 | } |
| 1047 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | /* |
| 1049 | * qla2x00_eh_wait_on_command |
| 1050 | * Waits for the command to be returned by the Firmware for some |
| 1051 | * max time. |
| 1052 | * |
| 1053 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | * |
| 1056 | * Return: |
| 1057 | * Not Found : 0 |
| 1058 | * Found : 1 |
| 1059 | */ |
| 1060 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1061 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 1063 | #define ABORT_POLLING_PERIOD 1000 |
Chad Dupuis | 478c3b0 | 2014-04-11 16:54:35 -0400 | [diff] [blame] | 1064 | #define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1065 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1066 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1067 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1068 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1070 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1071 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 1072 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1073 | return ret; |
| 1074 | } |
| 1075 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 1076 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 1077 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1078 | } |
| 1079 | if (CMD_SP(cmd)) |
| 1080 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1082 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | /* |
| 1086 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1087 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 1089 | * finally HBA is disabled ie marked offline |
| 1090 | * |
| 1091 | * Input: |
| 1092 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1093 | * |
| 1094 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 | * Does context switching-Release SPIN_LOCK |
| 1096 | * (if any) before calling this routine. |
| 1097 | * |
| 1098 | * Return: |
| 1099 | * Success (Adapter is online) : 0 |
| 1100 | * Failed (Adapter is offline/disabled) : 1 |
| 1101 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 1102 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1103 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1104 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 1105 | int return_status; |
| 1106 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1107 | struct qla_hw_data *ha = vha->hw; |
| 1108 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1110 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1111 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1112 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1113 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1114 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1115 | |
| 1116 | msleep(1000); |
| 1117 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1118 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1119 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | else |
| 1121 | return_status = QLA_FUNCTION_FAILED; |
| 1122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1123 | return (return_status); |
| 1124 | } |
| 1125 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1126 | static inline int test_fcport_count(scsi_qla_host_t *vha) |
| 1127 | { |
| 1128 | struct qla_hw_data *ha = vha->hw; |
| 1129 | unsigned long flags; |
| 1130 | int res; |
| 1131 | |
| 1132 | spin_lock_irqsave(&ha->tgt.sess_lock, flags); |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 1133 | ql_dbg(ql_dbg_init, vha, 0x00ec, |
| 1134 | "tgt %p, fcport_count=%d\n", |
| 1135 | vha, vha->fcport_count); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1136 | res = (vha->fcport_count == 0); |
| 1137 | spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); |
| 1138 | |
| 1139 | return res; |
| 1140 | } |
| 1141 | |
| 1142 | /* |
| 1143 | * qla2x00_wait_for_sess_deletion can only be called from remove_one. |
| 1144 | * it has dependency on UNLOADING flag to stop device discovery |
| 1145 | */ |
| 1146 | static void |
| 1147 | qla2x00_wait_for_sess_deletion(scsi_qla_host_t *vha) |
| 1148 | { |
| 1149 | qla2x00_mark_all_devices_lost(vha, 0); |
| 1150 | |
Joe Carnuccio | b85e095 | 2017-08-23 15:05:11 -0700 | [diff] [blame] | 1151 | wait_event_timeout(vha->fcport_waitQ, test_fcport_count(vha), 10*HZ); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1152 | } |
| 1153 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1154 | /* |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1155 | * qla2x00_wait_for_hba_ready |
| 1156 | * Wait till the HBA is ready before doing driver unload |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1157 | * |
| 1158 | * Input: |
| 1159 | * ha - pointer to host adapter structure |
| 1160 | * |
| 1161 | * Note: |
| 1162 | * Does context switching-Release SPIN_LOCK |
| 1163 | * (if any) before calling this routine. |
| 1164 | * |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1165 | */ |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1166 | static void |
| 1167 | qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1168 | { |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1169 | struct qla_hw_data *ha = vha->hw; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1170 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1171 | |
Dan Carpenter | 1d48390 | 2016-08-03 21:42:32 +0300 | [diff] [blame] | 1172 | while ((qla2x00_reset_active(vha) || ha->dpc_active || |
| 1173 | ha->flags.mbox_busy) || |
| 1174 | test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags) || |
| 1175 | test_bit(FX00_TARGET_SCAN, &vha->dpc_flags)) { |
| 1176 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 1177 | break; |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1178 | msleep(1000); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1179 | } |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1180 | } |
| 1181 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 1182 | int |
| 1183 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 1184 | { |
| 1185 | int return_status; |
| 1186 | unsigned long wait_reset; |
| 1187 | struct qla_hw_data *ha = vha->hw; |
| 1188 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 1189 | |
| 1190 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 1191 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1192 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1193 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1194 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 1195 | |
| 1196 | msleep(1000); |
| 1197 | |
| 1198 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 1199 | ha->flags.chip_reset_done) |
| 1200 | break; |
| 1201 | } |
| 1202 | if (ha->flags.chip_reset_done) |
| 1203 | return_status = QLA_SUCCESS; |
| 1204 | else |
| 1205 | return_status = QLA_FUNCTION_FAILED; |
| 1206 | |
| 1207 | return return_status; |
| 1208 | } |
| 1209 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 1210 | static void |
| 1211 | sp_get(struct srb *sp) |
| 1212 | { |
| 1213 | atomic_inc(&sp->ref_count); |
| 1214 | } |
| 1215 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1216 | #define ISP_REG_DISCONNECT 0xffffffffU |
| 1217 | /************************************************************************** |
| 1218 | * qla2x00_isp_reg_stat |
| 1219 | * |
| 1220 | * Description: |
| 1221 | * Read the host status register of ISP before aborting the command. |
| 1222 | * |
| 1223 | * Input: |
| 1224 | * ha = pointer to host adapter structure. |
| 1225 | * |
| 1226 | * |
| 1227 | * Returns: |
| 1228 | * Either true or false. |
| 1229 | * |
| 1230 | * Note: Return true if there is register disconnect. |
| 1231 | **************************************************************************/ |
| 1232 | static inline |
| 1233 | uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) |
| 1234 | { |
| 1235 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
Sawan Chandak | bf6061b1 | 2017-03-31 14:37:03 -0700 | [diff] [blame] | 1236 | struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1237 | |
Sawan Chandak | bf6061b1 | 2017-03-31 14:37:03 -0700 | [diff] [blame] | 1238 | if (IS_P3P_TYPE(ha)) |
| 1239 | return ((RD_REG_DWORD(®82->host_int)) == ISP_REG_DISCONNECT); |
| 1240 | else |
| 1241 | return ((RD_REG_DWORD(®->host_status)) == |
| 1242 | ISP_REG_DISCONNECT); |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1243 | } |
| 1244 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1245 | /************************************************************************** |
| 1246 | * qla2xxx_eh_abort |
| 1247 | * |
| 1248 | * Description: |
| 1249 | * The abort function will abort the specified command. |
| 1250 | * |
| 1251 | * Input: |
| 1252 | * cmd = Linux SCSI command packet to be aborted. |
| 1253 | * |
| 1254 | * Returns: |
| 1255 | * Either SUCCESS or FAILED. |
| 1256 | * |
| 1257 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1258 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1259 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1260 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1261 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 1262 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1263 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1264 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1265 | int ret; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1266 | unsigned int id; |
| 1267 | uint64_t lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1268 | unsigned long flags; |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1269 | int rval, wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1270 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1271 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1272 | if (qla2x00_isp_reg_stat(ha)) { |
| 1273 | ql_log(ql_log_info, vha, 0x8042, |
| 1274 | "PCI/Register disconnect, exiting.\n"); |
| 1275 | return FAILED; |
| 1276 | } |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1277 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1278 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1279 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1280 | ret = fc_block_scsi_eh(cmd); |
| 1281 | if (ret != 0) |
| 1282 | return ret; |
| 1283 | ret = SUCCESS; |
| 1284 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1285 | id = cmd->device->id; |
| 1286 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1287 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1288 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1289 | sp = (srb_t *) CMD_SP(cmd); |
| 1290 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1291 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1292 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1293 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1294 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1295 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | c7bc4ca | 2015-08-04 13:37:57 -0400 | [diff] [blame] | 1296 | "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n", |
| 1297 | vha->host_no, id, lun, sp, cmd, sp->handle); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1298 | |
| 1299 | /* Get a reference to the sp and drop the lock.*/ |
| 1300 | sp_get(sp); |
| 1301 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1302 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1303 | rval = ha->isp_ops->abort_command(sp); |
| 1304 | if (rval) { |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1305 | if (rval == QLA_FUNCTION_PARAMETER_ERROR) |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1306 | ret = SUCCESS; |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1307 | else |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1308 | ret = FAILED; |
| 1309 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1310 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1311 | "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1312 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1313 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1314 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1315 | wait = 1; |
| 1316 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1317 | |
| 1318 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 1319 | sp->done(sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1320 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1321 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 1322 | /* Did the command return during mailbox execution? */ |
| 1323 | if (ret == FAILED && !CMD_SP(cmd)) |
| 1324 | ret = SUCCESS; |
| 1325 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1326 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1327 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1328 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1329 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1330 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1331 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1332 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1333 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1335 | ql_log(ql_log_info, vha, 0x801c, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1336 | "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1337 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1338 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1339 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | } |
| 1341 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1342 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1343 | 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] | 1344 | uint64_t l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1346 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1347 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1348 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1349 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1350 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1351 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1352 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1353 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1354 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1355 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1356 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1357 | for (cnt = 1; status == QLA_SUCCESS && |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1358 | cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1359 | sp = req->outstanding_cmds[cnt]; |
| 1360 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1361 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1362 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1363 | continue; |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 1364 | if (vha->vp_idx != sp->vha->vp_idx) |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1365 | continue; |
| 1366 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1367 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1368 | switch (type) { |
| 1369 | case WAIT_HOST: |
| 1370 | match = 1; |
| 1371 | break; |
| 1372 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1373 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1374 | break; |
| 1375 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1376 | match = (cmd->device->id == t && |
| 1377 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1378 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1379 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1380 | if (!match) |
| 1381 | continue; |
| 1382 | |
| 1383 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1384 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1385 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1386 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1387 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1388 | |
| 1389 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1390 | } |
| 1391 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1392 | static char *reset_errors[] = { |
| 1393 | "HBA not online", |
| 1394 | "HBA not ready", |
| 1395 | "Task management failed", |
| 1396 | "Waiting for command completions", |
| 1397 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1398 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1399 | static int |
| 1400 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1401 | 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] | 1402 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1403 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1404 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1405 | int err; |
| 1406 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1407 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1408 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1409 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1410 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1411 | err = fc_block_scsi_eh(cmd); |
| 1412 | if (err != 0) |
| 1413 | return err; |
| 1414 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1415 | ql_log(ql_log_info, vha, 0x8009, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1416 | "%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] | 1417 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1418 | |
| 1419 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1420 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1421 | ql_log(ql_log_warn, vha, 0x800a, |
| 1422 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1423 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1424 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1425 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1426 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1427 | != QLA_SUCCESS) { |
| 1428 | ql_log(ql_log_warn, vha, 0x800c, |
| 1429 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1430 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1431 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1432 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1433 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1434 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1435 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1436 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1437 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1438 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1439 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1440 | ql_log(ql_log_info, vha, 0x800e, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1441 | "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1442 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1443 | |
| 1444 | return SUCCESS; |
| 1445 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1446 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1447 | ql_log(ql_log_info, vha, 0x800f, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1448 | "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1449 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1450 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1451 | return FAILED; |
| 1452 | } |
| 1453 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1454 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1455 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1456 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1457 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1458 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1459 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1460 | if (qla2x00_isp_reg_stat(ha)) { |
| 1461 | ql_log(ql_log_info, vha, 0x803e, |
| 1462 | "PCI/Register disconnect, exiting.\n"); |
| 1463 | return FAILED; |
| 1464 | } |
| 1465 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1466 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1467 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | } |
| 1469 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1470 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1471 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1472 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1473 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1474 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1476 | if (qla2x00_isp_reg_stat(ha)) { |
| 1477 | ql_log(ql_log_info, vha, 0x803f, |
| 1478 | "PCI/Register disconnect, exiting.\n"); |
| 1479 | return FAILED; |
| 1480 | } |
| 1481 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1482 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1483 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1484 | } |
| 1485 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | /************************************************************************** |
| 1487 | * qla2xxx_eh_bus_reset |
| 1488 | * |
| 1489 | * Description: |
| 1490 | * The bus reset function will reset the bus and abort any executing |
| 1491 | * commands. |
| 1492 | * |
| 1493 | * Input: |
| 1494 | * cmd = Linux SCSI command packet of the command that cause the |
| 1495 | * bus reset. |
| 1496 | * |
| 1497 | * Returns: |
| 1498 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1499 | * |
| 1500 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1501 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1502 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1503 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1504 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1505 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1506 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1507 | unsigned int id; |
| 1508 | uint64_t lun; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1509 | struct qla_hw_data *ha = vha->hw; |
| 1510 | |
| 1511 | if (qla2x00_isp_reg_stat(ha)) { |
| 1512 | ql_log(ql_log_info, vha, 0x8040, |
| 1513 | "PCI/Register disconnect, exiting.\n"); |
| 1514 | return FAILED; |
| 1515 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1516 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1517 | id = cmd->device->id; |
| 1518 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1519 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1520 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1521 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1522 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1523 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1524 | ret = fc_block_scsi_eh(cmd); |
| 1525 | if (ret != 0) |
| 1526 | return ret; |
| 1527 | ret = FAILED; |
| 1528 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1529 | ql_log(ql_log_info, vha, 0x8012, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1530 | "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] | 1531 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1532 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1533 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1534 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1535 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1536 | } |
| 1537 | |
Saurav Kashyap | ad537689 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1538 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1539 | ret = SUCCESS; |
| 1540 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1541 | if (ret == FAILED) |
| 1542 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1543 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1544 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1545 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1546 | QLA_SUCCESS) { |
| 1547 | ql_log(ql_log_warn, vha, 0x8014, |
| 1548 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1549 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1550 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1551 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1552 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1553 | ql_log(ql_log_warn, vha, 0x802b, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1554 | "BUS RESET %s nexus=%ld:%d:%llu.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1555 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1556 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1557 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1558 | } |
| 1559 | |
| 1560 | /************************************************************************** |
| 1561 | * qla2xxx_eh_host_reset |
| 1562 | * |
| 1563 | * Description: |
| 1564 | * The reset function will reset the Adapter. |
| 1565 | * |
| 1566 | * Input: |
| 1567 | * cmd = Linux SCSI command packet of the command that cause the |
| 1568 | * adapter reset. |
| 1569 | * |
| 1570 | * Returns: |
| 1571 | * Either SUCCESS or FAILED. |
| 1572 | * |
| 1573 | * Note: |
| 1574 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1575 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1576 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1577 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1578 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1579 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1580 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1581 | unsigned int id; |
| 1582 | uint64_t lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1583 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1584 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1585 | if (qla2x00_isp_reg_stat(ha)) { |
| 1586 | ql_log(ql_log_info, vha, 0x8041, |
| 1587 | "PCI/Register disconnect, exiting.\n"); |
| 1588 | schedule_work(&ha->board_disable); |
| 1589 | return SUCCESS; |
| 1590 | } |
| 1591 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1592 | id = cmd->device->id; |
| 1593 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1594 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1595 | ql_log(ql_log_info, vha, 0x8018, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1596 | "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] | 1597 | |
Chad Dupuis | 63ee707 | 2014-04-11 16:54:46 -0400 | [diff] [blame] | 1598 | /* |
| 1599 | * No point in issuing another reset if one is active. Also do not |
| 1600 | * attempt a reset if we are updating flash. |
| 1601 | */ |
| 1602 | if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1603 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1604 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1605 | if (vha != base_vha) { |
| 1606 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1607 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1608 | } else { |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1609 | if (IS_P3P_TYPE(vha->hw)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1610 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1611 | /* Ctx reset success */ |
| 1612 | ret = SUCCESS; |
| 1613 | goto eh_host_reset_lock; |
| 1614 | } |
| 1615 | /* fall thru if ctx reset failed */ |
| 1616 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1617 | if (ha->wq) |
| 1618 | flush_workqueue(ha->wq); |
| 1619 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1620 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1621 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1622 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1623 | /* failed. schedule dpc to try */ |
| 1624 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1625 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1626 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1627 | ql_log(ql_log_warn, vha, 0x802a, |
| 1628 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1629 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1630 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1631 | } |
| 1632 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1633 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1634 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1635 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1636 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1637 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1638 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1639 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1640 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1641 | ql_log(ql_log_info, vha, 0x8017, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1642 | "ADAPTER RESET %s nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1643 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1644 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1645 | return ret; |
| 1646 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1647 | |
| 1648 | /* |
| 1649 | * qla2x00_loop_reset |
| 1650 | * Issue loop reset. |
| 1651 | * |
| 1652 | * Input: |
| 1653 | * ha = adapter block pointer. |
| 1654 | * |
| 1655 | * Returns: |
| 1656 | * 0 = success |
| 1657 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1658 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1659 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1660 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1661 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1662 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1663 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1664 | |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1665 | if (IS_QLAFX00(ha)) { |
| 1666 | return qlafx00_loop_reset(vha); |
| 1667 | } |
| 1668 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1669 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1670 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1671 | if (fcport->port_type != FCT_TARGET) |
| 1672 | continue; |
| 1673 | |
| 1674 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1675 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1676 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1677 | "Bus Reset failed: Reset=%d " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1678 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1679 | } |
| 1680 | } |
| 1681 | } |
| 1682 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1683 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1684 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Andrew Vasquez | 0b7e7c5 | 2013-02-08 01:57:42 -0500 | [diff] [blame] | 1685 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1686 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1687 | qla2x00_mark_all_devices_lost(vha, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1688 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1689 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1690 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1691 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1692 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | } |
| 1694 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1695 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1696 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad537689 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1697 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1698 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1699 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1700 | } |
| 1701 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1702 | /* 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] | 1703 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1704 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1705 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1706 | } |
| 1707 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1708 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1709 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1710 | { |
Bill Kuzeja | 4cd3b6e | 2017-05-25 15:26:31 -0400 | [diff] [blame] | 1711 | int que, cnt, status; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1712 | unsigned long flags; |
| 1713 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1714 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1715 | struct req_que *req; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 1716 | struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; |
| 1717 | struct qla_tgt_cmd *cmd; |
| 1718 | uint8_t trace = 0; |
Arun Easi | c0cb449 | 2014-09-25 06:14:51 -0400 | [diff] [blame] | 1719 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1720 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1721 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1722 | req = ha->req_q_map[que]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1723 | if (!req) |
| 1724 | continue; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1725 | if (!req->outstanding_cmds) |
| 1726 | continue; |
| 1727 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1728 | sp = req->outstanding_cmds[cnt]; |
Andrew Vasquez | e612d46 | 2009-03-24 09:08:04 -0700 | [diff] [blame] | 1729 | if (sp) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1730 | req->outstanding_cmds[cnt] = NULL; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 1731 | if (sp->cmd_type == TYPE_SRB) { |
himanshu.madhani@cavium.com | 6fcd98f | 2017-07-21 09:32:23 -0700 | [diff] [blame] | 1732 | if (sp->type == SRB_NVME_CMD || |
| 1733 | sp->type == SRB_NVME_LS) { |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 1734 | sp_get(sp); |
| 1735 | spin_unlock_irqrestore( |
| 1736 | &ha->hardware_lock, flags); |
| 1737 | qla_nvme_abort(ha, sp); |
| 1738 | spin_lock_irqsave( |
| 1739 | &ha->hardware_lock, flags); |
| 1740 | } else if (GET_CMD_SP(sp) && |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 1741 | !ha->flags.eeh_busy && |
Sawan Chandak | d61cca6 | 2017-08-23 15:05:24 -0700 | [diff] [blame] | 1742 | (!test_bit(ABORT_ISP_ACTIVE, |
| 1743 | &vha->dpc_flags)) && |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 1744 | (sp->type == SRB_SCSI_CMD)) { |
| 1745 | /* |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 1746 | * Don't abort commands in |
| 1747 | * adapter during EEH |
| 1748 | * recovery as it's not |
| 1749 | * accessible/responding. |
| 1750 | * |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 1751 | * Get a reference to the sp |
| 1752 | * and drop the lock. The |
| 1753 | * reference ensures this |
| 1754 | * sp->done() call and not the |
| 1755 | * call in qla2xxx_eh_abort() |
| 1756 | * ends the SCSI command (with |
| 1757 | * result 'res'). |
| 1758 | */ |
| 1759 | sp_get(sp); |
| 1760 | spin_unlock_irqrestore( |
| 1761 | &ha->hardware_lock, flags); |
| 1762 | status = qla2xxx_eh_abort( |
| 1763 | GET_CMD_SP(sp)); |
| 1764 | spin_lock_irqsave( |
| 1765 | &ha->hardware_lock, flags); |
| 1766 | /* |
| 1767 | * Get rid of extra reference |
| 1768 | * if immediate exit from |
| 1769 | * ql2xxx_eh_abort |
| 1770 | */ |
| 1771 | if (status == FAILED && |
| 1772 | (qla2x00_isp_reg_stat(ha))) |
| 1773 | atomic_dec( |
| 1774 | &sp->ref_count); |
| 1775 | } |
| 1776 | sp->done(sp, res); |
| 1777 | } else { |
| 1778 | if (!vha->hw->tgt.tgt_ops || !tgt || |
| 1779 | qla_ini_mode_enabled(vha)) { |
| 1780 | if (!trace) |
| 1781 | ql_dbg(ql_dbg_tgt_mgt, |
| 1782 | vha, 0xf003, |
| 1783 | "HOST-ABORT-HNDLR: dpc_flags=%lx. Target mode disabled\n", |
| 1784 | vha->dpc_flags); |
| 1785 | continue; |
| 1786 | } |
| 1787 | cmd = (struct qla_tgt_cmd *)sp; |
| 1788 | qlt_abort_cmd_on_host_reset(cmd->vha, |
| 1789 | cmd); |
| 1790 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1791 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1792 | } |
| 1793 | } |
| 1794 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1795 | } |
| 1796 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1797 | static int |
| 1798 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1799 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1800 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1801 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1802 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1803 | return -ENXIO; |
| 1804 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1805 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1806 | |
| 1807 | return 0; |
| 1808 | } |
| 1809 | |
| 1810 | static int |
| 1811 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1812 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1813 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1814 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1815 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1816 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1817 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1818 | |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 1819 | scsi_change_queue_depth(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1820 | return 0; |
| 1821 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1822 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1823 | static void |
| 1824 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1825 | { |
| 1826 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1827 | } |
| 1828 | |
| 1829 | /** |
| 1830 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1831 | * @ha: HA context |
| 1832 | * |
| 1833 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1834 | * supported addressing method. |
| 1835 | */ |
| 1836 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1837 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1838 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1839 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1840 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1841 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1842 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1843 | /* Any upper-dword bits set? */ |
| 1844 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1845 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1846 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1847 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1848 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1849 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1850 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1851 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1852 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1853 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1854 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1855 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1856 | } |
| 1857 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1858 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1859 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1860 | { |
| 1861 | unsigned long flags = 0; |
| 1862 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1863 | |
| 1864 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1865 | ha->interrupts_on = 1; |
| 1866 | /* enable risc and host interrupts */ |
| 1867 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1868 | RD_REG_WORD(®->ictrl); |
| 1869 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1870 | |
| 1871 | } |
| 1872 | |
| 1873 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1874 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1875 | { |
| 1876 | unsigned long flags = 0; |
| 1877 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1878 | |
| 1879 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1880 | ha->interrupts_on = 0; |
| 1881 | /* disable risc and host interrupts */ |
| 1882 | WRT_REG_WORD(®->ictrl, 0); |
| 1883 | RD_REG_WORD(®->ictrl); |
| 1884 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1885 | } |
| 1886 | |
| 1887 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1888 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1889 | { |
| 1890 | unsigned long flags = 0; |
| 1891 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1892 | |
| 1893 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1894 | ha->interrupts_on = 1; |
| 1895 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1896 | RD_REG_DWORD(®->ictrl); |
| 1897 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1898 | } |
| 1899 | |
| 1900 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1901 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1902 | { |
| 1903 | unsigned long flags = 0; |
| 1904 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1905 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1906 | if (IS_NOPOLLING_TYPE(ha)) |
| 1907 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1908 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1909 | ha->interrupts_on = 0; |
| 1910 | WRT_REG_DWORD(®->ictrl, 0); |
| 1911 | RD_REG_DWORD(®->ictrl); |
| 1912 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1913 | } |
| 1914 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1915 | static int |
| 1916 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1917 | { |
| 1918 | resource_size_t pio; |
| 1919 | uint16_t msix; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1920 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1921 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1922 | QLA2XXX_DRIVER_NAME)) { |
| 1923 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1924 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1925 | pci_name(ha->pdev)); |
| 1926 | goto iospace_error_exit; |
| 1927 | } |
| 1928 | if (!(ha->bars & 1)) |
| 1929 | goto skip_pio; |
| 1930 | |
| 1931 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1932 | pio = pci_resource_start(ha->pdev, 0); |
| 1933 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1934 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1935 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1936 | "Invalid pci I/O region size (%s).\n", |
| 1937 | pci_name(ha->pdev)); |
| 1938 | pio = 0; |
| 1939 | } |
| 1940 | } else { |
| 1941 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1942 | "Region #0 no a PIO resource (%s).\n", |
| 1943 | pci_name(ha->pdev)); |
| 1944 | pio = 0; |
| 1945 | } |
| 1946 | ha->pio_address = pio; |
| 1947 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1948 | "PIO address=%llu.\n", |
| 1949 | (unsigned long long)ha->pio_address); |
| 1950 | |
| 1951 | skip_pio: |
| 1952 | /* Use MMIO operations for all accesses. */ |
| 1953 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1954 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1955 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1956 | pci_name(ha->pdev)); |
| 1957 | goto iospace_error_exit; |
| 1958 | } |
| 1959 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1960 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1961 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1962 | pci_name(ha->pdev)); |
| 1963 | goto iospace_error_exit; |
| 1964 | } |
| 1965 | |
| 1966 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1967 | if (!ha->iobase) { |
| 1968 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1969 | "Cannot remap MMIO (%s), aborting.\n", |
| 1970 | pci_name(ha->pdev)); |
| 1971 | goto iospace_error_exit; |
| 1972 | } |
| 1973 | |
| 1974 | /* Determine queue resources */ |
| 1975 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 1976 | ha->msix_count = QLA_BASE_VECTORS; |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 1977 | if (!ql2xmqsupport || !ql2xnvmeenable || |
| 1978 | (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1979 | goto mqiobase_exit; |
| 1980 | |
| 1981 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1982 | pci_resource_len(ha->pdev, 3)); |
| 1983 | if (ha->mqiobase) { |
| 1984 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 1985 | "MQIO Base=%p.\n", ha->mqiobase); |
| 1986 | /* Read MSIX vector size of the board */ |
| 1987 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1988 | ha->msix_count = msix + 1; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1989 | /* Max queues are bounded by available msix vectors */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1990 | /* MB interrupt uses 1 vector */ |
| 1991 | ha->max_req_queues = ha->msix_count - 1; |
| 1992 | ha->max_rsp_queues = ha->max_req_queues; |
| 1993 | /* Queue pairs is the max value minus the base queue pair */ |
| 1994 | ha->max_qpairs = ha->max_rsp_queues - 1; |
| 1995 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0188, |
| 1996 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
| 1997 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1998 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1999 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2000 | } else |
| 2001 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 2002 | "BAR 3 not enabled.\n"); |
| 2003 | |
| 2004 | mqiobase_exit: |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2005 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2006 | "MSIX Count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2007 | return (0); |
| 2008 | |
| 2009 | iospace_error_exit: |
| 2010 | return (-ENOMEM); |
| 2011 | } |
| 2012 | |
| 2013 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2014 | static int |
| 2015 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 2016 | { |
| 2017 | uint16_t msix; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2018 | |
| 2019 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 2020 | QLA2XXX_DRIVER_NAME)) { |
| 2021 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 2022 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 2023 | pci_name(ha->pdev)); |
| 2024 | |
| 2025 | goto iospace_error_exit; |
| 2026 | } |
| 2027 | |
| 2028 | /* Use MMIO operations for all accesses. */ |
| 2029 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 2030 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 2031 | "Invalid pci I/O region size (%s).\n", |
| 2032 | pci_name(ha->pdev)); |
| 2033 | goto iospace_error_exit; |
| 2034 | } |
| 2035 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 2036 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 2037 | "Invalid PCI mem region size (%s), aborting\n", |
| 2038 | pci_name(ha->pdev)); |
| 2039 | goto iospace_error_exit; |
| 2040 | } |
| 2041 | |
| 2042 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 2043 | if (!ha->iobase) { |
| 2044 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 2045 | "Cannot remap MMIO (%s), aborting.\n", |
| 2046 | pci_name(ha->pdev)); |
| 2047 | goto iospace_error_exit; |
| 2048 | } |
| 2049 | |
| 2050 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 2051 | /* 83XX 26XX always use MQ type access for queues |
| 2052 | * - mbar 2, a.k.a region 4 */ |
| 2053 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2054 | ha->msix_count = QLA_BASE_VECTORS; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2055 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 2056 | pci_resource_len(ha->pdev, 4)); |
| 2057 | |
| 2058 | if (!ha->mqiobase) { |
| 2059 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 2060 | "BAR2/region4 not enabled\n"); |
| 2061 | goto mqiobase_exit; |
| 2062 | } |
| 2063 | |
| 2064 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 2065 | pci_resource_len(ha->pdev, 2)); |
| 2066 | if (ha->msixbase) { |
| 2067 | /* Read MSIX vector size of the board */ |
| 2068 | pci_read_config_word(ha->pdev, |
| 2069 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 2070 | ha->msix_count = (msix & PCI_MSIX_FLAGS_QSIZE) + 1; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 2071 | /* |
| 2072 | * By default, driver uses at least two msix vectors |
| 2073 | * (default & rspq) |
| 2074 | */ |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 2075 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2076 | /* MB interrupt uses 1 vector */ |
| 2077 | ha->max_req_queues = ha->msix_count - 1; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 2078 | |
| 2079 | /* ATIOQ needs 1 vector. That's 1 less QPair */ |
| 2080 | if (QLA_TGT_MODE_ENABLED()) |
| 2081 | ha->max_req_queues--; |
| 2082 | |
Michael Hernandez | d0d2c68 | 2017-02-15 15:37:20 -0800 | [diff] [blame] | 2083 | ha->max_rsp_queues = ha->max_req_queues; |
| 2084 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2085 | /* Queue pairs is the max value minus |
| 2086 | * the base queue pair */ |
| 2087 | ha->max_qpairs = ha->max_req_queues - 1; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2088 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x00e3, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2089 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2090 | } |
| 2091 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2092 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2093 | } else |
| 2094 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 2095 | "BAR 1 not enabled.\n"); |
| 2096 | |
| 2097 | mqiobase_exit: |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2098 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2099 | "MSIX Count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2100 | return 0; |
| 2101 | |
| 2102 | iospace_error_exit: |
| 2103 | return -ENOMEM; |
| 2104 | } |
| 2105 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2106 | static struct isp_operations qla2100_isp_ops = { |
| 2107 | .pci_config = qla2100_pci_config, |
| 2108 | .reset_chip = qla2x00_reset_chip, |
| 2109 | .chip_diag = qla2x00_chip_diag, |
| 2110 | .config_rings = qla2x00_config_rings, |
| 2111 | .reset_adapter = qla2x00_reset_adapter, |
| 2112 | .nvram_config = qla2x00_nvram_config, |
| 2113 | .update_fw_options = qla2x00_update_fw_options, |
| 2114 | .load_risc = qla2x00_load_risc, |
| 2115 | .pci_info_str = qla2x00_pci_info_str, |
| 2116 | .fw_version_str = qla2x00_fw_version_str, |
| 2117 | .intr_handler = qla2100_intr_handler, |
| 2118 | .enable_intrs = qla2x00_enable_intrs, |
| 2119 | .disable_intrs = qla2x00_disable_intrs, |
| 2120 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2121 | .target_reset = qla2x00_abort_target, |
| 2122 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2123 | .fabric_login = qla2x00_login_fabric, |
| 2124 | .fabric_logout = qla2x00_fabric_logout, |
| 2125 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 2126 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 2127 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 2128 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 2129 | .read_nvram = qla2x00_read_nvram_data, |
| 2130 | .write_nvram = qla2x00_write_nvram_data, |
| 2131 | .fw_dump = qla2100_fw_dump, |
| 2132 | .beacon_on = NULL, |
| 2133 | .beacon_off = NULL, |
| 2134 | .beacon_blink = NULL, |
| 2135 | .read_optrom = qla2x00_read_optrom_data, |
| 2136 | .write_optrom = qla2x00_write_optrom_data, |
| 2137 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2138 | .start_scsi = qla2x00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2139 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2140 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2141 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2142 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2143 | }; |
| 2144 | |
| 2145 | static struct isp_operations qla2300_isp_ops = { |
| 2146 | .pci_config = qla2300_pci_config, |
| 2147 | .reset_chip = qla2x00_reset_chip, |
| 2148 | .chip_diag = qla2x00_chip_diag, |
| 2149 | .config_rings = qla2x00_config_rings, |
| 2150 | .reset_adapter = qla2x00_reset_adapter, |
| 2151 | .nvram_config = qla2x00_nvram_config, |
| 2152 | .update_fw_options = qla2x00_update_fw_options, |
| 2153 | .load_risc = qla2x00_load_risc, |
| 2154 | .pci_info_str = qla2x00_pci_info_str, |
| 2155 | .fw_version_str = qla2x00_fw_version_str, |
| 2156 | .intr_handler = qla2300_intr_handler, |
| 2157 | .enable_intrs = qla2x00_enable_intrs, |
| 2158 | .disable_intrs = qla2x00_disable_intrs, |
| 2159 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2160 | .target_reset = qla2x00_abort_target, |
| 2161 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2162 | .fabric_login = qla2x00_login_fabric, |
| 2163 | .fabric_logout = qla2x00_fabric_logout, |
| 2164 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 2165 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 2166 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 2167 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 2168 | .read_nvram = qla2x00_read_nvram_data, |
| 2169 | .write_nvram = qla2x00_write_nvram_data, |
| 2170 | .fw_dump = qla2300_fw_dump, |
| 2171 | .beacon_on = qla2x00_beacon_on, |
| 2172 | .beacon_off = qla2x00_beacon_off, |
| 2173 | .beacon_blink = qla2x00_beacon_blink, |
| 2174 | .read_optrom = qla2x00_read_optrom_data, |
| 2175 | .write_optrom = qla2x00_write_optrom_data, |
| 2176 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2177 | .start_scsi = qla2x00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2178 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2179 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2180 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2181 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2182 | }; |
| 2183 | |
| 2184 | static struct isp_operations qla24xx_isp_ops = { |
| 2185 | .pci_config = qla24xx_pci_config, |
| 2186 | .reset_chip = qla24xx_reset_chip, |
| 2187 | .chip_diag = qla24xx_chip_diag, |
| 2188 | .config_rings = qla24xx_config_rings, |
| 2189 | .reset_adapter = qla24xx_reset_adapter, |
| 2190 | .nvram_config = qla24xx_nvram_config, |
| 2191 | .update_fw_options = qla24xx_update_fw_options, |
| 2192 | .load_risc = qla24xx_load_risc, |
| 2193 | .pci_info_str = qla24xx_pci_info_str, |
| 2194 | .fw_version_str = qla24xx_fw_version_str, |
| 2195 | .intr_handler = qla24xx_intr_handler, |
| 2196 | .enable_intrs = qla24xx_enable_intrs, |
| 2197 | .disable_intrs = qla24xx_disable_intrs, |
| 2198 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2199 | .target_reset = qla24xx_abort_target, |
| 2200 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2201 | .fabric_login = qla24xx_login_fabric, |
| 2202 | .fabric_logout = qla24xx_fabric_logout, |
| 2203 | .calc_req_entries = NULL, |
| 2204 | .build_iocbs = NULL, |
| 2205 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2206 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2207 | .read_nvram = qla24xx_read_nvram_data, |
| 2208 | .write_nvram = qla24xx_write_nvram_data, |
| 2209 | .fw_dump = qla24xx_fw_dump, |
| 2210 | .beacon_on = qla24xx_beacon_on, |
| 2211 | .beacon_off = qla24xx_beacon_off, |
| 2212 | .beacon_blink = qla24xx_beacon_blink, |
| 2213 | .read_optrom = qla24xx_read_optrom_data, |
| 2214 | .write_optrom = qla24xx_write_optrom_data, |
| 2215 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2216 | .start_scsi = qla24xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2217 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2218 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2219 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2220 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2221 | }; |
| 2222 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2223 | static struct isp_operations qla25xx_isp_ops = { |
| 2224 | .pci_config = qla25xx_pci_config, |
| 2225 | .reset_chip = qla24xx_reset_chip, |
| 2226 | .chip_diag = qla24xx_chip_diag, |
| 2227 | .config_rings = qla24xx_config_rings, |
| 2228 | .reset_adapter = qla24xx_reset_adapter, |
| 2229 | .nvram_config = qla24xx_nvram_config, |
| 2230 | .update_fw_options = qla24xx_update_fw_options, |
| 2231 | .load_risc = qla24xx_load_risc, |
| 2232 | .pci_info_str = qla24xx_pci_info_str, |
| 2233 | .fw_version_str = qla24xx_fw_version_str, |
| 2234 | .intr_handler = qla24xx_intr_handler, |
| 2235 | .enable_intrs = qla24xx_enable_intrs, |
| 2236 | .disable_intrs = qla24xx_disable_intrs, |
| 2237 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2238 | .target_reset = qla24xx_abort_target, |
| 2239 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2240 | .fabric_login = qla24xx_login_fabric, |
| 2241 | .fabric_logout = qla24xx_fabric_logout, |
| 2242 | .calc_req_entries = NULL, |
| 2243 | .build_iocbs = NULL, |
| 2244 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2245 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2246 | .read_nvram = qla25xx_read_nvram_data, |
| 2247 | .write_nvram = qla25xx_write_nvram_data, |
| 2248 | .fw_dump = qla25xx_fw_dump, |
| 2249 | .beacon_on = qla24xx_beacon_on, |
| 2250 | .beacon_off = qla24xx_beacon_off, |
| 2251 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 2252 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2253 | .write_optrom = qla24xx_write_optrom_data, |
| 2254 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2255 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2256 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2257 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2258 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2259 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2260 | }; |
| 2261 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2262 | static struct isp_operations qla81xx_isp_ops = { |
| 2263 | .pci_config = qla25xx_pci_config, |
| 2264 | .reset_chip = qla24xx_reset_chip, |
| 2265 | .chip_diag = qla24xx_chip_diag, |
| 2266 | .config_rings = qla24xx_config_rings, |
| 2267 | .reset_adapter = qla24xx_reset_adapter, |
| 2268 | .nvram_config = qla81xx_nvram_config, |
| 2269 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 2270 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2271 | .pci_info_str = qla24xx_pci_info_str, |
| 2272 | .fw_version_str = qla24xx_fw_version_str, |
| 2273 | .intr_handler = qla24xx_intr_handler, |
| 2274 | .enable_intrs = qla24xx_enable_intrs, |
| 2275 | .disable_intrs = qla24xx_disable_intrs, |
| 2276 | .abort_command = qla24xx_abort_command, |
| 2277 | .target_reset = qla24xx_abort_target, |
| 2278 | .lun_reset = qla24xx_lun_reset, |
| 2279 | .fabric_login = qla24xx_login_fabric, |
| 2280 | .fabric_logout = qla24xx_fabric_logout, |
| 2281 | .calc_req_entries = NULL, |
| 2282 | .build_iocbs = NULL, |
| 2283 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2284 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 2285 | .read_nvram = NULL, |
| 2286 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2287 | .fw_dump = qla81xx_fw_dump, |
| 2288 | .beacon_on = qla24xx_beacon_on, |
| 2289 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2290 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2291 | .read_optrom = qla25xx_read_optrom_data, |
| 2292 | .write_optrom = qla24xx_write_optrom_data, |
| 2293 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 2294 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2295 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2296 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2297 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2298 | .initialize_adapter = qla2x00_initialize_adapter, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2299 | }; |
| 2300 | |
| 2301 | static struct isp_operations qla82xx_isp_ops = { |
| 2302 | .pci_config = qla82xx_pci_config, |
| 2303 | .reset_chip = qla82xx_reset_chip, |
| 2304 | .chip_diag = qla24xx_chip_diag, |
| 2305 | .config_rings = qla82xx_config_rings, |
| 2306 | .reset_adapter = qla24xx_reset_adapter, |
| 2307 | .nvram_config = qla81xx_nvram_config, |
| 2308 | .update_fw_options = qla24xx_update_fw_options, |
| 2309 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 2310 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2311 | .fw_version_str = qla24xx_fw_version_str, |
| 2312 | .intr_handler = qla82xx_intr_handler, |
| 2313 | .enable_intrs = qla82xx_enable_intrs, |
| 2314 | .disable_intrs = qla82xx_disable_intrs, |
| 2315 | .abort_command = qla24xx_abort_command, |
| 2316 | .target_reset = qla24xx_abort_target, |
| 2317 | .lun_reset = qla24xx_lun_reset, |
| 2318 | .fabric_login = qla24xx_login_fabric, |
| 2319 | .fabric_logout = qla24xx_fabric_logout, |
| 2320 | .calc_req_entries = NULL, |
| 2321 | .build_iocbs = NULL, |
| 2322 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2323 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2324 | .read_nvram = qla24xx_read_nvram_data, |
| 2325 | .write_nvram = qla24xx_write_nvram_data, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2326 | .fw_dump = qla82xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 2327 | .beacon_on = qla82xx_beacon_on, |
| 2328 | .beacon_off = qla82xx_beacon_off, |
| 2329 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2330 | .read_optrom = qla82xx_read_optrom_data, |
| 2331 | .write_optrom = qla82xx_write_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2332 | .get_flash_version = qla82xx_get_flash_version, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2333 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2334 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2335 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2336 | .iospace_config = qla82xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2337 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2338 | }; |
| 2339 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2340 | static struct isp_operations qla8044_isp_ops = { |
| 2341 | .pci_config = qla82xx_pci_config, |
| 2342 | .reset_chip = qla82xx_reset_chip, |
| 2343 | .chip_diag = qla24xx_chip_diag, |
| 2344 | .config_rings = qla82xx_config_rings, |
| 2345 | .reset_adapter = qla24xx_reset_adapter, |
| 2346 | .nvram_config = qla81xx_nvram_config, |
| 2347 | .update_fw_options = qla24xx_update_fw_options, |
| 2348 | .load_risc = qla82xx_load_risc, |
| 2349 | .pci_info_str = qla24xx_pci_info_str, |
| 2350 | .fw_version_str = qla24xx_fw_version_str, |
| 2351 | .intr_handler = qla8044_intr_handler, |
| 2352 | .enable_intrs = qla82xx_enable_intrs, |
| 2353 | .disable_intrs = qla82xx_disable_intrs, |
| 2354 | .abort_command = qla24xx_abort_command, |
| 2355 | .target_reset = qla24xx_abort_target, |
| 2356 | .lun_reset = qla24xx_lun_reset, |
| 2357 | .fabric_login = qla24xx_login_fabric, |
| 2358 | .fabric_logout = qla24xx_fabric_logout, |
| 2359 | .calc_req_entries = NULL, |
| 2360 | .build_iocbs = NULL, |
| 2361 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2362 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2363 | .read_nvram = NULL, |
| 2364 | .write_nvram = NULL, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2365 | .fw_dump = qla8044_fw_dump, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2366 | .beacon_on = qla82xx_beacon_on, |
| 2367 | .beacon_off = qla82xx_beacon_off, |
| 2368 | .beacon_blink = NULL, |
Saurav Kashyap | 888e639 | 2014-02-26 04:15:13 -0500 | [diff] [blame] | 2369 | .read_optrom = qla8044_read_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2370 | .write_optrom = qla8044_write_optrom_data, |
| 2371 | .get_flash_version = qla82xx_get_flash_version, |
| 2372 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2373 | .start_scsi_mq = NULL, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2374 | .abort_isp = qla8044_abort_isp, |
| 2375 | .iospace_config = qla82xx_iospace_config, |
| 2376 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2377 | }; |
| 2378 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2379 | static struct isp_operations qla83xx_isp_ops = { |
| 2380 | .pci_config = qla25xx_pci_config, |
| 2381 | .reset_chip = qla24xx_reset_chip, |
| 2382 | .chip_diag = qla24xx_chip_diag, |
| 2383 | .config_rings = qla24xx_config_rings, |
| 2384 | .reset_adapter = qla24xx_reset_adapter, |
| 2385 | .nvram_config = qla81xx_nvram_config, |
| 2386 | .update_fw_options = qla81xx_update_fw_options, |
| 2387 | .load_risc = qla81xx_load_risc, |
| 2388 | .pci_info_str = qla24xx_pci_info_str, |
| 2389 | .fw_version_str = qla24xx_fw_version_str, |
| 2390 | .intr_handler = qla24xx_intr_handler, |
| 2391 | .enable_intrs = qla24xx_enable_intrs, |
| 2392 | .disable_intrs = qla24xx_disable_intrs, |
| 2393 | .abort_command = qla24xx_abort_command, |
| 2394 | .target_reset = qla24xx_abort_target, |
| 2395 | .lun_reset = qla24xx_lun_reset, |
| 2396 | .fabric_login = qla24xx_login_fabric, |
| 2397 | .fabric_logout = qla24xx_fabric_logout, |
| 2398 | .calc_req_entries = NULL, |
| 2399 | .build_iocbs = NULL, |
| 2400 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2401 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2402 | .read_nvram = NULL, |
| 2403 | .write_nvram = NULL, |
| 2404 | .fw_dump = qla83xx_fw_dump, |
| 2405 | .beacon_on = qla24xx_beacon_on, |
| 2406 | .beacon_off = qla24xx_beacon_off, |
| 2407 | .beacon_blink = qla83xx_beacon_blink, |
| 2408 | .read_optrom = qla25xx_read_optrom_data, |
| 2409 | .write_optrom = qla24xx_write_optrom_data, |
| 2410 | .get_flash_version = qla24xx_get_flash_version, |
| 2411 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2412 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2413 | .abort_isp = qla2x00_abort_isp, |
| 2414 | .iospace_config = qla83xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2415 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2416 | }; |
| 2417 | |
| 2418 | static struct isp_operations qlafx00_isp_ops = { |
| 2419 | .pci_config = qlafx00_pci_config, |
| 2420 | .reset_chip = qlafx00_soft_reset, |
| 2421 | .chip_diag = qlafx00_chip_diag, |
| 2422 | .config_rings = qlafx00_config_rings, |
| 2423 | .reset_adapter = qlafx00_soft_reset, |
| 2424 | .nvram_config = NULL, |
| 2425 | .update_fw_options = NULL, |
| 2426 | .load_risc = NULL, |
| 2427 | .pci_info_str = qlafx00_pci_info_str, |
| 2428 | .fw_version_str = qlafx00_fw_version_str, |
| 2429 | .intr_handler = qlafx00_intr_handler, |
| 2430 | .enable_intrs = qlafx00_enable_intrs, |
| 2431 | .disable_intrs = qlafx00_disable_intrs, |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2432 | .abort_command = qla24xx_async_abort_command, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2433 | .target_reset = qlafx00_abort_target, |
| 2434 | .lun_reset = qlafx00_lun_reset, |
| 2435 | .fabric_login = NULL, |
| 2436 | .fabric_logout = NULL, |
| 2437 | .calc_req_entries = NULL, |
| 2438 | .build_iocbs = NULL, |
| 2439 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2440 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2441 | .read_nvram = qla24xx_read_nvram_data, |
| 2442 | .write_nvram = qla24xx_write_nvram_data, |
| 2443 | .fw_dump = NULL, |
| 2444 | .beacon_on = qla24xx_beacon_on, |
| 2445 | .beacon_off = qla24xx_beacon_off, |
| 2446 | .beacon_blink = NULL, |
| 2447 | .read_optrom = qla24xx_read_optrom_data, |
| 2448 | .write_optrom = qla24xx_write_optrom_data, |
| 2449 | .get_flash_version = qla24xx_get_flash_version, |
| 2450 | .start_scsi = qlafx00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2451 | .start_scsi_mq = NULL, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2452 | .abort_isp = qlafx00_abort_isp, |
| 2453 | .iospace_config = qlafx00_iospace_config, |
| 2454 | .initialize_adapter = qlafx00_initialize_adapter, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2455 | }; |
| 2456 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2457 | static struct isp_operations qla27xx_isp_ops = { |
| 2458 | .pci_config = qla25xx_pci_config, |
| 2459 | .reset_chip = qla24xx_reset_chip, |
| 2460 | .chip_diag = qla24xx_chip_diag, |
| 2461 | .config_rings = qla24xx_config_rings, |
| 2462 | .reset_adapter = qla24xx_reset_adapter, |
| 2463 | .nvram_config = qla81xx_nvram_config, |
| 2464 | .update_fw_options = qla81xx_update_fw_options, |
| 2465 | .load_risc = qla81xx_load_risc, |
| 2466 | .pci_info_str = qla24xx_pci_info_str, |
| 2467 | .fw_version_str = qla24xx_fw_version_str, |
| 2468 | .intr_handler = qla24xx_intr_handler, |
| 2469 | .enable_intrs = qla24xx_enable_intrs, |
| 2470 | .disable_intrs = qla24xx_disable_intrs, |
| 2471 | .abort_command = qla24xx_abort_command, |
| 2472 | .target_reset = qla24xx_abort_target, |
| 2473 | .lun_reset = qla24xx_lun_reset, |
| 2474 | .fabric_login = qla24xx_login_fabric, |
| 2475 | .fabric_logout = qla24xx_fabric_logout, |
| 2476 | .calc_req_entries = NULL, |
| 2477 | .build_iocbs = NULL, |
| 2478 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2479 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2480 | .read_nvram = NULL, |
| 2481 | .write_nvram = NULL, |
| 2482 | .fw_dump = qla27xx_fwdump, |
| 2483 | .beacon_on = qla24xx_beacon_on, |
| 2484 | .beacon_off = qla24xx_beacon_off, |
| 2485 | .beacon_blink = qla83xx_beacon_blink, |
| 2486 | .read_optrom = qla25xx_read_optrom_data, |
| 2487 | .write_optrom = qla24xx_write_optrom_data, |
| 2488 | .get_flash_version = qla24xx_get_flash_version, |
| 2489 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2490 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2491 | .abort_isp = qla2x00_abort_isp, |
| 2492 | .iospace_config = qla83xx_iospace_config, |
| 2493 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2494 | }; |
| 2495 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2496 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2497 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2498 | { |
| 2499 | ha->device_type = DT_EXTENDED_IDS; |
| 2500 | switch (ha->pdev->device) { |
| 2501 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2502 | ha->isp_type |= DT_ISP2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2503 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2504 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2505 | break; |
| 2506 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2507 | ha->isp_type |= DT_ISP2200; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2508 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2509 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2510 | break; |
| 2511 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2512 | ha->isp_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2513 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2514 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2515 | break; |
| 2516 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2517 | ha->isp_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2518 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2519 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2520 | break; |
| 2521 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2522 | ha->isp_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2523 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2524 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2525 | ha->pdev->subsystem_device == 0x0170) |
| 2526 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2527 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2528 | break; |
| 2529 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2530 | ha->isp_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2531 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2532 | break; |
| 2533 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2534 | ha->isp_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2535 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2536 | break; |
| 2537 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2538 | ha->isp_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2539 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2540 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2541 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2542 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2543 | break; |
| 2544 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2545 | ha->isp_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2546 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2547 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2548 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2549 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2550 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2551 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2552 | ha->isp_type |= DT_ISP8432; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2553 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2554 | ha->device_type |= DT_FWI2; |
| 2555 | ha->device_type |= DT_IIDMA; |
| 2556 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2557 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2558 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2559 | ha->isp_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2560 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2561 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2562 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2563 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2564 | ha->isp_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2565 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2566 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2567 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2568 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2569 | ha->isp_type |= DT_ISP2532; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2570 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2571 | ha->device_type |= DT_FWI2; |
| 2572 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2573 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2574 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2575 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2576 | ha->isp_type |= DT_ISP8001; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2577 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2578 | ha->device_type |= DT_FWI2; |
| 2579 | ha->device_type |= DT_IIDMA; |
| 2580 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2581 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2582 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2583 | ha->isp_type |= DT_ISP8021; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2584 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2585 | ha->device_type |= DT_FWI2; |
| 2586 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2587 | /* Initialize 82XX ISP flags */ |
| 2588 | qla82xx_init_flags(ha); |
| 2589 | break; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2590 | case PCI_DEVICE_ID_QLOGIC_ISP8044: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2591 | ha->isp_type |= DT_ISP8044; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2592 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2593 | ha->device_type |= DT_FWI2; |
| 2594 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2595 | /* Initialize 82XX ISP flags */ |
| 2596 | qla82xx_init_flags(ha); |
| 2597 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2598 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2599 | ha->isp_type |= DT_ISP2031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2600 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2601 | ha->device_type |= DT_FWI2; |
| 2602 | ha->device_type |= DT_IIDMA; |
| 2603 | ha->device_type |= DT_T10_PI; |
| 2604 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2605 | break; |
| 2606 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2607 | ha->isp_type |= DT_ISP8031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2608 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2609 | ha->device_type |= DT_FWI2; |
| 2610 | ha->device_type |= DT_IIDMA; |
| 2611 | ha->device_type |= DT_T10_PI; |
| 2612 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2613 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2614 | case PCI_DEVICE_ID_QLOGIC_ISPF001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2615 | ha->isp_type |= DT_ISPFX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2616 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2617 | case PCI_DEVICE_ID_QLOGIC_ISP2071: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2618 | ha->isp_type |= DT_ISP2071; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2619 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2620 | ha->device_type |= DT_FWI2; |
| 2621 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2622 | ha->device_type |= DT_T10_PI; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2623 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2624 | break; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2625 | case PCI_DEVICE_ID_QLOGIC_ISP2271: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2626 | ha->isp_type |= DT_ISP2271; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2627 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2628 | ha->device_type |= DT_FWI2; |
| 2629 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2630 | ha->device_type |= DT_T10_PI; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2631 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2632 | break; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2633 | case PCI_DEVICE_ID_QLOGIC_ISP2261: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2634 | ha->isp_type |= DT_ISP2261; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2635 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2636 | ha->device_type |= DT_FWI2; |
| 2637 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2638 | ha->device_type |= DT_T10_PI; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2639 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2640 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2641 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2642 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2643 | if (IS_QLA82XX(ha)) |
Saurav Kashyap | 43a9c38 | 2014-02-26 04:15:16 -0500 | [diff] [blame] | 2644 | ha->port_no = ha->portnum & 1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2645 | else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2646 | /* Get adapter physical port no from interrupt pin register. */ |
| 2647 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2648 | if (IS_QLA27XX(ha)) |
| 2649 | ha->port_no--; |
| 2650 | else |
| 2651 | ha->port_no = !(ha->port_no & 1); |
| 2652 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2653 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2654 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2655 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2656 | ha->device_type, ha->port_no, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2657 | } |
| 2658 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2659 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2660 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2661 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2662 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2663 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2664 | if (vha->hw->flags.running_gold_fw) |
| 2665 | return; |
| 2666 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2667 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2668 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2669 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2670 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2671 | } |
| 2672 | |
| 2673 | static int |
| 2674 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2675 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2676 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2677 | |
Bill Kuzeja | a5dd506e | 2016-10-21 16:45:27 -0400 | [diff] [blame] | 2678 | if (test_bit(UNLOADING, &vha->dpc_flags)) |
| 2679 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2680 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2681 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2682 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2683 | return 1; |
| 2684 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2685 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2686 | } |
| 2687 | |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2688 | static void qla2x00_iocb_work_fn(struct work_struct *work) |
| 2689 | { |
| 2690 | struct scsi_qla_host *vha = container_of(work, |
| 2691 | struct scsi_qla_host, iocb_work); |
| 2692 | int cnt = 0; |
| 2693 | |
| 2694 | while (!list_empty(&vha->work_list)) { |
| 2695 | qla2x00_do_work(vha); |
| 2696 | cnt++; |
| 2697 | if (cnt > 10) |
| 2698 | break; |
| 2699 | } |
| 2700 | } |
| 2701 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2702 | /* |
| 2703 | * PCI driver interface |
| 2704 | */ |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 2705 | static int |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2706 | 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] | 2707 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2708 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2709 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2710 | scsi_qla_host_t *base_vha = NULL; |
| 2711 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2712 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2713 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2714 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2715 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2716 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2717 | struct req_que *req = NULL; |
| 2718 | struct rsp_que *rsp = NULL; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 2719 | int i; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2720 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2721 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2722 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2723 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2724 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2725 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2726 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2727 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2728 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2729 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2730 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2731 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2732 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031 || |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2733 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISPF001 || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2734 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8044 || |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2735 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2071 || |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2736 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271 || |
| 2737 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2261) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2738 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2739 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2740 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2741 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2742 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2743 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2744 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2745 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2746 | if (mem_only) { |
| 2747 | if (pci_enable_device_mem(pdev)) |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2748 | return ret; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2749 | } else { |
| 2750 | if (pci_enable_device(pdev)) |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2751 | return ret; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2752 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2753 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2754 | /* This may fail but that's ok */ |
| 2755 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2756 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2757 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2758 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2759 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2760 | "Unable to allocate memory for ha.\n"); |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2761 | goto disable_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2762 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2763 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2764 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2765 | ha->pdev = pdev; |
Quinn Tran | 33e7997 | 2014-09-25 06:14:55 -0400 | [diff] [blame] | 2766 | INIT_LIST_HEAD(&ha->tgt.q_full_list); |
| 2767 | spin_lock_init(&ha->tgt.q_full_lock); |
Quinn Tran | 7560151 | 2015-12-17 14:57:04 -0500 | [diff] [blame] | 2768 | spin_lock_init(&ha->tgt.sess_lock); |
Quinn Tran | 2f424b9 | 2015-12-17 14:57:07 -0500 | [diff] [blame] | 2769 | spin_lock_init(&ha->tgt.atio_lock); |
| 2770 | |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 2771 | atomic_set(&ha->nvme_active_aen_cnt, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2772 | |
| 2773 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2774 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2775 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2776 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2777 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2778 | mutex_init(&ha->selflogin_lock); |
Chad Dupuis | 7a8ab9c | 2014-02-26 04:14:56 -0500 | [diff] [blame] | 2779 | mutex_init(&ha->optrom_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2780 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2781 | /* Set ISP-type information. */ |
| 2782 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2783 | |
| 2784 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2785 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2786 | IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2787 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2788 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2789 | ha->prev_topology = 0; |
| 2790 | ha->init_cb_size = sizeof(init_cb_t); |
| 2791 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2792 | ha->optrom_size = OPTROM_SIZE_2300; |
| 2793 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2794 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2795 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2796 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2797 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2798 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2799 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2800 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2801 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2802 | ha->flash_conf_off = ~0; |
| 2803 | ha->flash_data_off = ~0; |
| 2804 | ha->nvram_conf_off = ~0; |
| 2805 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2806 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2807 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2808 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2809 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2810 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2811 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2812 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2813 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2814 | ha->flash_conf_off = ~0; |
| 2815 | ha->flash_data_off = ~0; |
| 2816 | ha->nvram_conf_off = ~0; |
| 2817 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2818 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2819 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2820 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2821 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2822 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2823 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2824 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2825 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2826 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2827 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2828 | ha->flash_conf_off = ~0; |
| 2829 | ha->flash_data_off = ~0; |
| 2830 | ha->nvram_conf_off = ~0; |
| 2831 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2832 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2833 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2834 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2835 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2836 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2837 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2838 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2839 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2840 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2841 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2842 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2843 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2844 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2845 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2846 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2847 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2848 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2849 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2850 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2851 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2852 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2853 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2854 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2855 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2856 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2857 | ha->gid_list_info_size = 8; |
| 2858 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2859 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2860 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2861 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2862 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2863 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2864 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2865 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2866 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2867 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2868 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2869 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 2870 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2871 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2872 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2873 | ha->gid_list_info_size = 8; |
| 2874 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2875 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2876 | ha->isp_ops = &qla81xx_isp_ops; |
| 2877 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2878 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2879 | ha->nvram_conf_off = ~0; |
| 2880 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2881 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2882 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2883 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2884 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2885 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2886 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2887 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2888 | ha->gid_list_info_size = 8; |
| 2889 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2890 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2891 | ha->isp_ops = &qla82xx_isp_ops; |
| 2892 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2893 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2894 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2895 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2896 | } else if (IS_QLA8044(ha)) { |
| 2897 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2898 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2899 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2900 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2901 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2902 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2903 | ha->gid_list_info_size = 8; |
| 2904 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2905 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2906 | ha->isp_ops = &qla8044_isp_ops; |
| 2907 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2908 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2909 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2910 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2911 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2912 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2913 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2914 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Saurav Kashyap | f2ea653 | 2014-09-25 06:14:54 -0400 | [diff] [blame] | 2915 | req_length = REQUEST_ENTRY_CNT_83XX; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2916 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Arun Easi | b8aa4bd | 2013-01-30 03:34:40 -0500 | [diff] [blame] | 2917 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2918 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2919 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2920 | ha->gid_list_info_size = 8; |
| 2921 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2922 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2923 | ha->isp_ops = &qla83xx_isp_ops; |
| 2924 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2925 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2926 | ha->nvram_conf_off = ~0; |
| 2927 | ha->nvram_data_off = ~0; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2928 | } else if (IS_QLAFX00(ha)) { |
| 2929 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_FX00; |
| 2930 | ha->mbx_count = MAILBOX_REGISTER_COUNT_FX00; |
| 2931 | ha->aen_mbx_count = AEN_MAILBOX_REGISTER_COUNT_FX00; |
| 2932 | req_length = REQUEST_ENTRY_CNT_FX00; |
| 2933 | rsp_length = RESPONSE_ENTRY_CNT_FX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2934 | ha->isp_ops = &qlafx00_isp_ops; |
| 2935 | ha->port_down_retry_count = 30; /* default value */ |
| 2936 | ha->mr.fw_hbt_cnt = QLAFX00_HEARTBEAT_INTERVAL; |
| 2937 | ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; |
Armen Baloyan | 71e5600 | 2013-08-27 01:37:38 -0400 | [diff] [blame] | 2938 | ha->mr.fw_critemp_timer_tick = QLAFX00_CRITEMP_INTERVAL; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2939 | ha->mr.fw_hbt_en = 1; |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 2940 | ha->mr.host_info_resend = false; |
| 2941 | ha->mr.hinfo_resend_timer_tick = QLAFX00_HINFO_RESEND_INTERVAL; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2942 | } else if (IS_QLA27XX(ha)) { |
| 2943 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
| 2944 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2945 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2946 | req_length = REQUEST_ENTRY_CNT_83XX; |
| 2947 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 2948 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2949 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2950 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2951 | ha->gid_list_info_size = 8; |
| 2952 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2953 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2954 | ha->isp_ops = &qla27xx_isp_ops; |
| 2955 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2956 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2957 | ha->nvram_conf_off = ~0; |
| 2958 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2959 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2960 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2961 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 2962 | "mbx_count=%d, req_length=%d, " |
| 2963 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2964 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 2965 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2966 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 2967 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2968 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2969 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 2970 | "isp_ops=%p, flash_conf_off=%d, " |
| 2971 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 2972 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 2973 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2974 | |
| 2975 | /* Configure PCI I/O space */ |
| 2976 | ret = ha->isp_ops->iospace_config(ha); |
| 2977 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2978 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2979 | |
| 2980 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 2981 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 2982 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 2983 | mutex_init(&ha->vport_lock); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2984 | mutex_init(&ha->mq_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2985 | init_completion(&ha->mbx_cmd_comp); |
| 2986 | complete(&ha->mbx_cmd_comp); |
| 2987 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 2988 | init_completion(&ha->dcbx_comp); |
Chad Dupuis | f356bef | 2013-02-08 01:58:04 -0500 | [diff] [blame] | 2989 | init_completion(&ha->lb_portup_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2990 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2991 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2992 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 2993 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2994 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 2995 | "64 Bit addressing is %s.\n", |
| 2996 | ha->flags.enable_64bit_addressing ? "enable" : |
| 2997 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2998 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 2999 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3000 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 3001 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3002 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3003 | goto probe_hw_failed; |
| 3004 | } |
| 3005 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3006 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3007 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3008 | req->max_q_depth = ql2xmaxqdepth; |
| 3009 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3010 | |
| 3011 | base_vha = qla2x00_create_host(sht, ha); |
| 3012 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3013 | ret = -ENOMEM; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 3014 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3015 | qla2x00_free_req_que(ha, req); |
| 3016 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3017 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3018 | } |
| 3019 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3020 | pci_set_drvdata(pdev, base_vha); |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 3021 | set_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
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 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3024 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3025 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3026 | base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3027 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3028 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 3029 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 3030 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3031 | /* Setup fcport template structure. */ |
| 3032 | ha->mr.fcport.vha = base_vha; |
| 3033 | ha->mr.fcport.port_type = FCT_UNKNOWN; |
| 3034 | ha->mr.fcport.loop_id = FC_NO_LOOP_ID; |
| 3035 | qla2x00_set_fcport_state(&ha->mr.fcport, FCS_UNCONFIGURED); |
| 3036 | ha->mr.fcport.supported_classes = FC_COS_UNSPECIFIED; |
| 3037 | ha->mr.fcport.scan_state = 1; |
| 3038 | |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 3039 | /* Set the SG table size based on ISP type */ |
| 3040 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3041 | if (IS_QLA2100(ha)) |
| 3042 | host->sg_tablesize = 32; |
| 3043 | } else { |
| 3044 | if (!IS_QLA82XX(ha)) |
| 3045 | host->sg_tablesize = QLA_SG_ALL; |
| 3046 | } |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3047 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3048 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 3049 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 3050 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3051 | host->max_cmd_len = 32; |
| 3052 | else |
| 3053 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 3054 | host->max_channel = MAX_BUSES - 1; |
Hannes Reinecke | 755f516 | 2014-06-03 10:58:54 +0200 | [diff] [blame] | 3055 | /* Older HBAs support only 16-bit LUNs */ |
| 3056 | if (!IS_QLAFX00(ha) && !IS_FWI2_CAPABLE(ha) && |
| 3057 | ql2xmaxlun > 0xffff) |
| 3058 | host->max_lun = 0xffff; |
| 3059 | else |
| 3060 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3061 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3062 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3063 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3064 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 3065 | "max_id=%d this_id=%d " |
| 3066 | "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] | 3067 | "max_lun=%llu transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3068 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 3069 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 3070 | host->transportt, sht->vendor_id); |
| 3071 | |
Himanshu Madhani | 1010f21 | 2017-10-16 11:26:05 -0700 | [diff] [blame] | 3072 | INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn); |
| 3073 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3074 | /* Set up the irqs */ |
| 3075 | ret = qla2x00_request_irqs(ha, rsp); |
| 3076 | if (ret) |
| 3077 | goto probe_init_failed; |
| 3078 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3079 | /* Alloc arrays of request and response ring ptrs */ |
| 3080 | if (!qla2x00_alloc_queues(ha, req, rsp)) { |
| 3081 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 3082 | "Failed to allocate memory for queue pointers..." |
| 3083 | "aborting.\n"); |
| 3084 | goto probe_init_failed; |
| 3085 | } |
| 3086 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3087 | if (ha->mqenable && shost_use_blk_mq(host)) { |
| 3088 | /* number of hardware queues supported by blk/scsi-mq*/ |
| 3089 | host->nr_hw_queues = ha->max_qpairs; |
| 3090 | |
| 3091 | ql_dbg(ql_dbg_init, base_vha, 0x0192, |
| 3092 | "blk/scsi-mq enabled, HW queues = %d.\n", host->nr_hw_queues); |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 3093 | } else { |
| 3094 | if (ql2xnvmeenable) { |
| 3095 | host->nr_hw_queues = ha->max_qpairs; |
| 3096 | ql_dbg(ql_dbg_init, base_vha, 0x0194, |
| 3097 | "FC-NVMe support is enabled, HW queues=%d\n", |
| 3098 | host->nr_hw_queues); |
| 3099 | } else { |
| 3100 | ql_dbg(ql_dbg_init, base_vha, 0x0193, |
| 3101 | "blk/scsi-mq disabled.\n"); |
| 3102 | } |
| 3103 | } |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3104 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3105 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3106 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3107 | pci_save_state(pdev); |
| 3108 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3109 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3110 | rsp->req = req; |
| 3111 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3112 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3113 | if (IS_QLAFX00(ha)) { |
| 3114 | ha->rsp_q_map[0] = rsp; |
| 3115 | ha->req_q_map[0] = req; |
| 3116 | set_bit(0, ha->req_qid_map); |
| 3117 | set_bit(0, ha->rsp_qid_map); |
| 3118 | } |
| 3119 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 3120 | /* FWI2-capable only. */ |
| 3121 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 3122 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 3123 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 3124 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3125 | if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 3126 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 3127 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 3128 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 3129 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 3130 | } |
| 3131 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3132 | if (IS_QLAFX00(ha)) { |
| 3133 | req->req_q_in = &ha->iobase->ispfx00.req_q_in; |
| 3134 | req->req_q_out = &ha->iobase->ispfx00.req_q_out; |
| 3135 | rsp->rsp_q_in = &ha->iobase->ispfx00.rsp_q_in; |
| 3136 | rsp->rsp_q_out = &ha->iobase->ispfx00.rsp_q_out; |
| 3137 | } |
| 3138 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3139 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3140 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 3141 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 3142 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 3143 | } |
| 3144 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3145 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 3146 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 3147 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 3148 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 3149 | "req->req_q_in=%p req->req_q_out=%p " |
| 3150 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 3151 | req->req_q_in, req->req_q_out, |
| 3152 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 3153 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 3154 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 3155 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 3156 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 3157 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 3158 | 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] | 3159 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3160 | if (ha->isp_ops->initialize_adapter(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3161 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 3162 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 3163 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3164 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3165 | if (IS_QLA82XX(ha)) { |
| 3166 | qla82xx_idc_lock(ha); |
| 3167 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3168 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3169 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3170 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 3171 | "HW State: FAILED.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3172 | } else if (IS_QLA8044(ha)) { |
| 3173 | qla8044_idc_lock(ha); |
| 3174 | qla8044_wr_direct(base_vha, |
| 3175 | QLA8044_CRB_DEV_STATE_INDEX, |
| 3176 | QLA8XXX_DEV_FAILED); |
| 3177 | qla8044_idc_unlock(ha); |
| 3178 | ql_log(ql_log_fatal, base_vha, 0x0150, |
| 3179 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3180 | } |
| 3181 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3182 | ret = -ENODEV; |
| 3183 | goto probe_failed; |
| 3184 | } |
| 3185 | |
Chad Dupuis | 3b1bef6 | 2014-02-26 04:15:04 -0500 | [diff] [blame] | 3186 | if (IS_QLAFX00(ha)) |
| 3187 | host->can_queue = QLAFX00_MAX_CANQUEUE; |
| 3188 | else |
| 3189 | host->can_queue = req->num_outstanding_cmds - 10; |
| 3190 | |
| 3191 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 3192 | "can_queue=%d, req=%p, mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 3193 | host->can_queue, base_vha->req, |
| 3194 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
| 3195 | |
Quinn Tran | a01c77d | 2017-12-04 14:44:58 -0800 | [diff] [blame] | 3196 | ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 0); |
| 3197 | |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3198 | if (ha->mqenable) { |
| 3199 | bool mq = false; |
| 3200 | bool startit = false; |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3201 | |
| 3202 | if (QLA_TGT_MODE_ENABLED()) { |
| 3203 | mq = true; |
| 3204 | startit = false; |
| 3205 | } |
| 3206 | |
| 3207 | if ((ql2x_ini_mode == QLA2XXX_INI_MODE_ENABLED) && |
| 3208 | shost_use_blk_mq(host)) { |
| 3209 | mq = true; |
| 3210 | startit = true; |
| 3211 | } |
| 3212 | |
| 3213 | if (mq) { |
| 3214 | /* Create start of day qpairs for Block MQ */ |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3215 | for (i = 0; i < ha->max_qpairs; i++) |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3216 | qla2xxx_create_qpair(base_vha, 5, 0, startit); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3217 | } |
| 3218 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3219 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3220 | if (ha->flags.running_gold_fw) |
| 3221 | goto skip_dpc; |
| 3222 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3223 | /* |
| 3224 | * Startup the kernel thread for this host adapter |
| 3225 | */ |
| 3226 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3227 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3228 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3229 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 3230 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3231 | ret = PTR_ERR(ha->dpc_thread); |
Douglas Miller | e2532b4 | 2017-10-20 08:17:22 -0500 | [diff] [blame] | 3232 | ha->dpc_thread = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3233 | goto probe_failed; |
| 3234 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3235 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 3236 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3237 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3238 | /* |
| 3239 | * If we're not coming up in initiator mode, we might sit for |
| 3240 | * a while without waking up the dpc thread, which leads to a |
| 3241 | * stuck process warning. So just kick the dpc once here and |
| 3242 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 3243 | */ |
| 3244 | qla2xxx_wake_dpc(base_vha); |
| 3245 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 3246 | INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); |
| 3247 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3248 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 3249 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 3250 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 3251 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 3252 | |
| 3253 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 3254 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 3255 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 3256 | INIT_WORK(&ha->idc_state_handler, |
| 3257 | qla83xx_idc_state_handler_work); |
| 3258 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 3259 | qla83xx_nic_core_unrecoverable_work); |
| 3260 | } |
| 3261 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3262 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3263 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 3264 | base_vha->host->irq = ha->pdev->irq; |
| 3265 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3266 | /* Initialized the timer */ |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 3267 | qla2x00_start_timer(base_vha, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3268 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 3269 | "Started qla2x00_timer with " |
| 3270 | "interval=%d.\n", WATCH_INTERVAL); |
| 3271 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 3272 | "Detected hba at address=%p.\n", |
| 3273 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3274 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 3275 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3276 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3277 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3278 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3279 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 3280 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3281 | if (ql2xenabledif == 1) |
| 3282 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3283 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3284 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3285 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3286 | | SHOST_DIF_TYPE3_PROTECTION |
| 3287 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3288 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3289 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3290 | |
| 3291 | guard = SHOST_DIX_GUARD_CRC; |
| 3292 | |
| 3293 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 3294 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 3295 | guard |= SHOST_DIX_GUARD_IP; |
| 3296 | |
| 3297 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3298 | } else |
| 3299 | base_vha->flags.difdix_supported = 0; |
| 3300 | } |
| 3301 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3302 | ha->isp_ops->enable_intrs(ha); |
| 3303 | |
Armen Baloyan | 1fe19ee | 2013-08-27 01:37:41 -0400 | [diff] [blame] | 3304 | if (IS_QLAFX00(ha)) { |
| 3305 | ret = qlafx00_fx_disc(base_vha, |
| 3306 | &base_vha->hw->mr.fcport, FXDISC_GET_CONFIG_INFO); |
| 3307 | host->sg_tablesize = (ha->mr.extended_io_enabled) ? |
| 3308 | QLA_SG_ALL : 128; |
| 3309 | } |
| 3310 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3311 | ret = scsi_add_host(host, &pdev->dev); |
| 3312 | if (ret) |
| 3313 | goto probe_failed; |
| 3314 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3315 | base_vha->flags.init_done = 1; |
| 3316 | base_vha->flags.online = 1; |
Saurav Kashyap | edaa5c7 | 2014-04-11 16:54:14 -0400 | [diff] [blame] | 3317 | ha->prev_minidump_failed = 0; |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3318 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3319 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 3320 | "Init done and hba is online.\n"); |
| 3321 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3322 | if (qla_ini_mode_enabled(base_vha) || |
| 3323 | qla_dual_mode_enabled(base_vha)) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3324 | scsi_scan_host(host); |
| 3325 | else |
| 3326 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 3327 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 3328 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3329 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3330 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3331 | if (IS_QLAFX00(ha)) { |
| 3332 | ret = qlafx00_fx_disc(base_vha, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3333 | &base_vha->hw->mr.fcport, FXDISC_GET_PORT_INFO); |
| 3334 | |
| 3335 | /* Register system information */ |
| 3336 | ret = qlafx00_fx_disc(base_vha, |
| 3337 | &base_vha->hw->mr.fcport, FXDISC_REG_HOST_INFO); |
| 3338 | } |
| 3339 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3340 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3341 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3342 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3343 | |
Armen Baloyan | 03eb912 | 2013-10-30 03:38:22 -0400 | [diff] [blame] | 3344 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 3345 | "QLogic %s - %s.\n", ha->model_number, ha->model_desc); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3346 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 3347 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 3348 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 3349 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 3350 | base_vha->host_no, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 3351 | 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] | 3352 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3353 | qlt_add_target(ha, base_vha); |
| 3354 | |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 3355 | clear_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 3356 | |
| 3357 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3358 | return -ENODEV; |
| 3359 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 3360 | if (ha->flags.detected_lr_sfp) { |
| 3361 | ql_log(ql_log_info, base_vha, 0xffff, |
| 3362 | "Reset chip to pick up LR SFP setting\n"); |
| 3363 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 3364 | qla2xxx_wake_dpc(base_vha); |
| 3365 | } |
| 3366 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3367 | return 0; |
| 3368 | |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 3369 | probe_init_failed: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3370 | qla2x00_free_req_que(ha, req); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3371 | ha->req_q_map[0] = NULL; |
| 3372 | clear_bit(0, ha->req_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3373 | qla2x00_free_rsp_que(ha, rsp); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3374 | ha->rsp_q_map[0] = NULL; |
| 3375 | clear_bit(0, ha->rsp_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3376 | ha->max_req_queues = ha->max_rsp_queues = 0; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 3377 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3378 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3379 | if (base_vha->timer_active) |
| 3380 | qla2x00_stop_timer(base_vha); |
| 3381 | base_vha->flags.online = 0; |
| 3382 | if (ha->dpc_thread) { |
| 3383 | struct task_struct *t = ha->dpc_thread; |
| 3384 | |
| 3385 | ha->dpc_thread = NULL; |
| 3386 | kthread_stop(t); |
| 3387 | } |
| 3388 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3389 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3390 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3391 | scsi_host_put(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3392 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3393 | probe_hw_failed: |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 3394 | qla2x00_clear_drv_active(ha); |
| 3395 | |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3396 | iospace_config_failed: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3397 | if (IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3398 | if (!ha->nx_pcibase) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3399 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3400 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3401 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3402 | } else { |
| 3403 | if (ha->iobase) |
| 3404 | iounmap(ha->iobase); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3405 | if (ha->cregbase) |
| 3406 | iounmap(ha->cregbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3407 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3408 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3409 | kfree(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3410 | |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 3411 | disable_device: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3412 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3413 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3414 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3415 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 3416 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3417 | qla2x00_shutdown(struct pci_dev *pdev) |
| 3418 | { |
| 3419 | scsi_qla_host_t *vha; |
| 3420 | struct qla_hw_data *ha; |
| 3421 | |
| 3422 | vha = pci_get_drvdata(pdev); |
| 3423 | ha = vha->hw; |
| 3424 | |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 3425 | ql_log(ql_log_info, vha, 0xfffa, |
| 3426 | "Adapter shutdown\n"); |
| 3427 | |
| 3428 | /* |
| 3429 | * Prevent future board_disable and wait |
| 3430 | * until any pending board_disable has completed. |
| 3431 | */ |
| 3432 | set_bit(PFLG_DRIVER_REMOVING, &vha->pci_flags); |
| 3433 | cancel_work_sync(&ha->board_disable); |
| 3434 | |
| 3435 | if (!atomic_read(&pdev->enable_cnt)) |
| 3436 | return; |
| 3437 | |
Armen Baloyan | 4247934 | 2013-08-27 01:37:37 -0400 | [diff] [blame] | 3438 | /* Notify ISPFX00 firmware */ |
| 3439 | if (IS_QLAFX00(ha)) |
| 3440 | qlafx00_driver_shutdown(vha, 20); |
| 3441 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3442 | /* Turn-off FCE trace */ |
| 3443 | if (ha->flags.fce_enabled) { |
| 3444 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 3445 | ha->flags.fce_enabled = 0; |
| 3446 | } |
| 3447 | |
| 3448 | /* Turn-off EFT trace */ |
| 3449 | if (ha->eft) |
| 3450 | qla2x00_disable_eft_trace(vha); |
| 3451 | |
| 3452 | /* Stop currently executing firmware. */ |
| 3453 | qla2x00_try_to_stop_firmware(vha); |
| 3454 | |
| 3455 | /* Turn adapter off line */ |
| 3456 | vha->flags.online = 0; |
| 3457 | |
| 3458 | /* turn-off interrupts on the card */ |
| 3459 | if (ha->interrupts_on) { |
| 3460 | vha->flags.init_done = 0; |
| 3461 | ha->isp_ops->disable_intrs(ha); |
| 3462 | } |
| 3463 | |
| 3464 | qla2x00_free_irqs(vha); |
| 3465 | |
| 3466 | qla2x00_free_fw_dump(ha); |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3467 | |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3468 | pci_disable_device(pdev); |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 3469 | ql_log(ql_log_info, vha, 0xfffe, |
| 3470 | "Adapter shutdown successfully.\n"); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3471 | } |
| 3472 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3473 | /* Deletes all the virtual ports for a given ha */ |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3474 | static void |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3475 | 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] | 3476 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3477 | scsi_qla_host_t *vha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3478 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3479 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3480 | mutex_lock(&ha->vport_lock); |
| 3481 | while (ha->cur_vport_count) { |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3482 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3483 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3484 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 3485 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 3486 | 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] | 3487 | scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3488 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3489 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3490 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3491 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3492 | fc_vport_terminate(vha->fc_vport); |
| 3493 | scsi_host_put(vha->host); |
| 3494 | |
| 3495 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3496 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3497 | mutex_unlock(&ha->vport_lock); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3498 | } |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3499 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3500 | /* Stops all deferred work threads */ |
| 3501 | static void |
| 3502 | qla2x00_destroy_deferred_work(struct qla_hw_data *ha) |
| 3503 | { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3504 | /* Cancel all work and destroy DPC workqueues */ |
| 3505 | if (ha->dpc_lp_wq) { |
| 3506 | cancel_work_sync(&ha->idc_aen); |
| 3507 | destroy_workqueue(ha->dpc_lp_wq); |
| 3508 | ha->dpc_lp_wq = NULL; |
| 3509 | } |
| 3510 | |
| 3511 | if (ha->dpc_hp_wq) { |
| 3512 | cancel_work_sync(&ha->nic_core_reset); |
| 3513 | cancel_work_sync(&ha->idc_state_handler); |
| 3514 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 3515 | destroy_workqueue(ha->dpc_hp_wq); |
| 3516 | ha->dpc_hp_wq = NULL; |
| 3517 | } |
| 3518 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3519 | /* Kill the kernel thread for this host */ |
| 3520 | if (ha->dpc_thread) { |
| 3521 | struct task_struct *t = ha->dpc_thread; |
| 3522 | |
| 3523 | /* |
| 3524 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 3525 | * so we need to zero it out. |
| 3526 | */ |
| 3527 | ha->dpc_thread = NULL; |
| 3528 | kthread_stop(t); |
| 3529 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3530 | } |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3531 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3532 | static void |
| 3533 | qla2x00_unmap_iobases(struct qla_hw_data *ha) |
| 3534 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3535 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 3536 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3537 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3538 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3539 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3540 | } else { |
| 3541 | if (ha->iobase) |
| 3542 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3543 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3544 | if (ha->cregbase) |
| 3545 | iounmap(ha->cregbase); |
| 3546 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3547 | if (ha->mqiobase) |
| 3548 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3549 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3550 | if ((IS_QLA83XX(ha) || IS_QLA27XX(ha)) && ha->msixbase) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3551 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3552 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3553 | } |
| 3554 | |
| 3555 | static void |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3556 | qla2x00_clear_drv_active(struct qla_hw_data *ha) |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3557 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3558 | if (IS_QLA8044(ha)) { |
| 3559 | qla8044_idc_lock(ha); |
Saurav Kashyap | c41afc9 | 2013-11-07 02:54:56 -0500 | [diff] [blame] | 3560 | qla8044_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3561 | qla8044_idc_unlock(ha); |
| 3562 | } else if (IS_QLA82XX(ha)) { |
| 3563 | qla82xx_idc_lock(ha); |
| 3564 | qla82xx_clear_drv_active(ha); |
| 3565 | qla82xx_idc_unlock(ha); |
| 3566 | } |
| 3567 | } |
| 3568 | |
| 3569 | static void |
| 3570 | qla2x00_remove_one(struct pci_dev *pdev) |
| 3571 | { |
| 3572 | scsi_qla_host_t *base_vha; |
| 3573 | struct qla_hw_data *ha; |
| 3574 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3575 | base_vha = pci_get_drvdata(pdev); |
| 3576 | ha = base_vha->hw; |
| 3577 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3578 | /* Indicate device removal to prevent future board_disable and wait |
| 3579 | * until any pending board_disable has completed. */ |
| 3580 | set_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags); |
| 3581 | cancel_work_sync(&ha->board_disable); |
| 3582 | |
| 3583 | /* |
| 3584 | * If the PCI device is disabled then there was a PCI-disconnect and |
| 3585 | * qla2x00_disable_board_on_pci_error has taken care of most of the |
| 3586 | * resources. |
| 3587 | */ |
| 3588 | if (!atomic_read(&pdev->enable_cnt)) { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3589 | dma_free_coherent(&ha->pdev->dev, base_vha->gnl.size, |
| 3590 | base_vha->gnl.l, base_vha->gnl.ldma); |
| 3591 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3592 | scsi_host_put(base_vha->host); |
| 3593 | kfree(ha); |
| 3594 | pci_set_drvdata(pdev, NULL); |
| 3595 | return; |
| 3596 | } |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 3597 | qla2x00_wait_for_hba_ready(base_vha); |
| 3598 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3599 | /* |
| 3600 | * if UNLOAD flag is already set, then continue unload, |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 3601 | * where it was set first. |
| 3602 | */ |
| 3603 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3604 | return; |
| 3605 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3606 | set_bit(UNLOADING, &base_vha->dpc_flags); |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 3607 | |
| 3608 | qla_nvme_delete(base_vha); |
| 3609 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3610 | dma_free_coherent(&ha->pdev->dev, |
| 3611 | base_vha->gnl.size, base_vha->gnl.l, base_vha->gnl.ldma); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3612 | |
| 3613 | if (IS_QLAFX00(ha)) |
| 3614 | qlafx00_driver_shutdown(base_vha, 20); |
| 3615 | |
| 3616 | qla2x00_delete_all_vps(ha, base_vha); |
| 3617 | |
| 3618 | if (IS_QLA8031(ha)) { |
| 3619 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 3620 | "Clearing fcoe driver presence.\n"); |
| 3621 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 3622 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 3623 | "Error while clearing DRV-Presence.\n"); |
| 3624 | } |
| 3625 | |
| 3626 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 3627 | |
| 3628 | qla2x00_dfs_remove(base_vha); |
| 3629 | |
| 3630 | qla84xx_put_chip(base_vha); |
| 3631 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 3632 | /* Laser should be disabled only for ISP2031 */ |
| 3633 | if (IS_QLA2031(ha)) |
| 3634 | qla83xx_disable_laser(base_vha); |
| 3635 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3636 | /* Disable timer */ |
| 3637 | if (base_vha->timer_active) |
| 3638 | qla2x00_stop_timer(base_vha); |
| 3639 | |
| 3640 | base_vha->flags.online = 0; |
| 3641 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3642 | /* free DMA memory */ |
| 3643 | if (ha->exlogin_buf) |
| 3644 | qla2x00_free_exlogin_buffer(ha); |
| 3645 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3646 | /* free DMA memory */ |
| 3647 | if (ha->exchoffld_buf) |
| 3648 | qla2x00_free_exchoffld_buffer(ha); |
| 3649 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3650 | qla2x00_destroy_deferred_work(ha); |
| 3651 | |
| 3652 | qlt_remove_target(ha, base_vha); |
| 3653 | |
| 3654 | qla2x00_free_sysfs_attr(base_vha, true); |
| 3655 | |
| 3656 | fc_remove_host(base_vha->host); |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3657 | qlt_remove_target_resources(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3658 | |
| 3659 | scsi_remove_host(base_vha->host); |
| 3660 | |
| 3661 | qla2x00_free_device(base_vha); |
| 3662 | |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3663 | qla2x00_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3664 | |
Arun Easi | d2749ff | 2014-09-25 05:16:51 -0400 | [diff] [blame] | 3665 | scsi_host_put(base_vha->host); |
| 3666 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3667 | qla2x00_unmap_iobases(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3668 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3669 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3670 | kfree(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3671 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3672 | pci_disable_pcie_error_reporting(pdev); |
| 3673 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 3674 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3675 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3676 | |
| 3677 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3678 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3679 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3680 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3681 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3682 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 3683 | |
| 3684 | /* Disable timer */ |
| 3685 | if (vha->timer_active) |
| 3686 | qla2x00_stop_timer(vha); |
| 3687 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3688 | qla25xx_delete_queues(vha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3689 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3690 | if (ha->flags.fce_enabled) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3691 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3692 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3693 | if (ha->eft) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3694 | qla2x00_disable_eft_trace(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3695 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3696 | /* Stop currently executing firmware. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3697 | qla2x00_try_to_stop_firmware(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3698 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3699 | vha->flags.online = 0; |
| 3700 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3701 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3702 | if (ha->interrupts_on) { |
| 3703 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 3704 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3705 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3706 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3707 | qla2x00_free_fcports(vha); |
| 3708 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3709 | qla2x00_free_irqs(vha); |
| 3710 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3711 | /* Flush the work queue and remove it */ |
| 3712 | if (ha->wq) { |
| 3713 | flush_workqueue(ha->wq); |
| 3714 | destroy_workqueue(ha->wq); |
| 3715 | ha->wq = NULL; |
| 3716 | } |
| 3717 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3718 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3719 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3720 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 3721 | qla82xx_md_free(vha); |
| 3722 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3723 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3724 | } |
| 3725 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3726 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 3727 | { |
| 3728 | fc_port_t *fcport, *tfcport; |
| 3729 | |
| 3730 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 3731 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3732 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3733 | kfree(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3734 | } |
| 3735 | } |
| 3736 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3737 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3738 | 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] | 3739 | int defer) |
| 3740 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3741 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3742 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3743 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3744 | |
| 3745 | if (!fcport->rport) |
| 3746 | return; |
| 3747 | |
| 3748 | rport = fcport->rport; |
| 3749 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3750 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3751 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3752 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3753 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3754 | qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3755 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 3756 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3757 | } else { |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3758 | int now; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3759 | if (rport) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3760 | ql_dbg(ql_dbg_disc, fcport->vha, 0x2109, |
| 3761 | "%s %8phN. rport %p roles %x\n", |
| 3762 | __func__, fcport->port_name, rport, |
| 3763 | rport->roles); |
Alexei Potashnik | d20ed91 | 2015-07-14 16:00:47 -0400 | [diff] [blame] | 3764 | fc_remote_port_delete(rport); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3765 | } |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3766 | qlt_do_generation_tick(vha, &now); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3767 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3768 | } |
| 3769 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3770 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3771 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 3772 | * |
| 3773 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 3774 | * |
| 3775 | * Return: None. |
| 3776 | * |
| 3777 | * Context: |
| 3778 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3779 | 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] | 3780 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3781 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3782 | if (IS_QLAFX00(vha->hw)) { |
| 3783 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
| 3784 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3785 | return; |
| 3786 | } |
| 3787 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3788 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3789 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3790 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3791 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3792 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3793 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3794 | * We may need to retry the login, so don't change the state of the |
| 3795 | * port but do the retries. |
| 3796 | */ |
| 3797 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3798 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3799 | |
| 3800 | if (!do_login) |
| 3801 | return; |
| 3802 | |
Arun Easi | a1d0285 | 2015-08-04 13:38:02 -0400 | [diff] [blame] | 3803 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 3804 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3805 | if (fcport->login_retry == 0) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3806 | fcport->login_retry = vha->hw->login_retry_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3807 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3808 | ql_dbg(ql_dbg_disc, vha, 0x20a3, |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3809 | "Port login retry %8phN, lid 0x%04x retry cnt=%d.\n", |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 3810 | fcport->port_name, fcport->loop_id, fcport->login_retry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3811 | } |
| 3812 | } |
| 3813 | |
| 3814 | /* |
| 3815 | * qla2x00_mark_all_devices_lost |
| 3816 | * Updates fcport state when device goes offline. |
| 3817 | * |
| 3818 | * Input: |
| 3819 | * ha = adapter block pointer. |
| 3820 | * fcport = port structure pointer. |
| 3821 | * |
| 3822 | * Return: |
| 3823 | * None. |
| 3824 | * |
| 3825 | * Context: |
| 3826 | */ |
| 3827 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3828 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3829 | { |
| 3830 | fc_port_t *fcport; |
| 3831 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3832 | ql_dbg(ql_dbg_disc, vha, 0x20f1, |
| 3833 | "Mark all dev lost\n"); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3834 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3835 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3836 | fcport->scan_state = 0; |
| 3837 | qlt_schedule_sess_for_deletion_lock(fcport); |
| 3838 | |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3839 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3840 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3841 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3842 | /* |
| 3843 | * No point in marking the device as lost, if the device is |
| 3844 | * already DEAD. |
| 3845 | */ |
| 3846 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3847 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3848 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3849 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3850 | if (defer) |
| 3851 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3852 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3853 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3854 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3855 | } |
| 3856 | } |
| 3857 | |
| 3858 | /* |
| 3859 | * qla2x00_mem_alloc |
| 3860 | * Allocates adapter memory. |
| 3861 | * |
| 3862 | * Returns: |
| 3863 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3864 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3865 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3866 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3867 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3868 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3869 | { |
| 3870 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3871 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3872 | 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] | 3873 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3874 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3875 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3876 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3877 | if (qlt_mem_alloc(ha) < 0) |
| 3878 | goto fail_free_init_cb; |
| 3879 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3880 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3881 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3882 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3883 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3884 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3885 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3886 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3887 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3888 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3889 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3890 | /* Allocate cache for CT6 Ctx. */ |
| 3891 | if (!ctx_cachep) { |
| 3892 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3893 | sizeof(struct ct6_dsd), 0, |
| 3894 | SLAB_HWCACHE_ALIGN, NULL); |
| 3895 | if (!ctx_cachep) |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3896 | goto fail_free_srb_mempool; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3897 | } |
| 3898 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3899 | ctx_cachep); |
| 3900 | if (!ha->ctx_mempool) |
| 3901 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3902 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3903 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3904 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3905 | } |
| 3906 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3907 | /* Get memory for cached NVRAM */ |
| 3908 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3909 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3910 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3911 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3912 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3913 | ha->pdev->device); |
| 3914 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3915 | DMA_POOL_SIZE, 8, 0); |
| 3916 | if (!ha->s_dma_pool) |
| 3917 | goto fail_free_nvram; |
| 3918 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3919 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3920 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3921 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3922 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3923 | if (IS_P3P_TYPE(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3924 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3925 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3926 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3927 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3928 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3929 | goto fail_s_dma_pool; |
| 3930 | } |
| 3931 | |
| 3932 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3933 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3934 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3935 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3936 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3937 | goto fail_dl_dma_pool; |
| 3938 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3939 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3940 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3941 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3942 | } |
| 3943 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3944 | /* Allocate memory for SNS commands */ |
| 3945 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3946 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3947 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3948 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3949 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3950 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3951 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 3952 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3953 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3954 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3955 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3956 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3957 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3958 | goto fail_dma_pool; |
| 3959 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3960 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3961 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3962 | if (!ha->ct_sns) |
| 3963 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3964 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 3965 | "ms_iocb=%p ct_sns=%p.\n", |
| 3966 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3967 | } |
| 3968 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3969 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3970 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 3971 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3972 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 3973 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3974 | goto fail_req; |
| 3975 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3976 | (*req)->length = req_len; |
| 3977 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3978 | ((*req)->length + 1) * sizeof(request_t), |
| 3979 | &(*req)->dma, GFP_KERNEL); |
| 3980 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3981 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 3982 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3983 | goto fail_req_ring; |
| 3984 | } |
| 3985 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3986 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 3987 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3988 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 3989 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3990 | goto fail_rsp; |
| 3991 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3992 | (*rsp)->hw = ha; |
| 3993 | (*rsp)->length = rsp_len; |
| 3994 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3995 | ((*rsp)->length + 1) * sizeof(response_t), |
| 3996 | &(*rsp)->dma, GFP_KERNEL); |
| 3997 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3998 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 3999 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4000 | goto fail_rsp_ring; |
| 4001 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4002 | (*req)->rsp = *rsp; |
| 4003 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4004 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 4005 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 4006 | "rsp->length=%d rsp->ring=%p.\n", |
| 4007 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 4008 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4009 | /* Allocate memory for NVRAM data for vports */ |
| 4010 | if (ha->nvram_npiv_size) { |
| 4011 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4012 | ha->nvram_npiv_size, GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4013 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4014 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 4015 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4016 | goto fail_npiv_info; |
| 4017 | } |
| 4018 | } else |
| 4019 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4020 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4021 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4022 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4023 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 4024 | &ha->ex_init_cb_dma); |
| 4025 | if (!ha->ex_init_cb) |
| 4026 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4027 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 4028 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4029 | } |
| 4030 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4031 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 4032 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4033 | /* Get consistent memory allocated for Async Port-Database. */ |
| 4034 | if (!IS_FWI2_CAPABLE(ha)) { |
| 4035 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 4036 | &ha->async_pd_dma); |
| 4037 | if (!ha->async_pd) |
| 4038 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4039 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 4040 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4041 | } |
| 4042 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4043 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4044 | |
| 4045 | /* Allocate memory for our loop_id bitmap */ |
| 4046 | ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), |
| 4047 | GFP_KERNEL); |
| 4048 | if (!ha->loop_id_map) |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4049 | goto fail_loop_id_map; |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4050 | else { |
| 4051 | qla2x00_set_reserved_loop_ids(ha); |
| 4052 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 4053 | "loop_id_map=%p.\n", ha->loop_id_map); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4054 | } |
| 4055 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4056 | ha->sfp_data = dma_alloc_coherent(&ha->pdev->dev, |
| 4057 | SFP_DEV_SIZE, &ha->sfp_data_dma, GFP_KERNEL); |
| 4058 | if (!ha->sfp_data) { |
| 4059 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b, |
| 4060 | "Unable to allocate memory for SFP read-data.\n"); |
| 4061 | goto fail_sfp_data; |
| 4062 | } |
| 4063 | |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 4064 | return 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4065 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4066 | fail_sfp_data: |
| 4067 | kfree(ha->loop_id_map); |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4068 | fail_loop_id_map: |
| 4069 | 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] | 4070 | fail_async_pd: |
| 4071 | 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] | 4072 | fail_ex_init_cb: |
| 4073 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4074 | fail_npiv_info: |
| 4075 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 4076 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 4077 | (*rsp)->ring = NULL; |
| 4078 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4079 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4080 | kfree(*rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4081 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4082 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 4083 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 4084 | (*req)->ring = NULL; |
| 4085 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4086 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4087 | kfree(*req); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4088 | fail_req: |
| 4089 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 4090 | ha->ct_sns, ha->ct_sns_dma); |
| 4091 | ha->ct_sns = NULL; |
| 4092 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4093 | fail_free_ms_iocb: |
| 4094 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 4095 | ha->ms_iocb = NULL; |
| 4096 | ha->ms_iocb_dma = 0; |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4097 | |
| 4098 | if (ha->sns_cmd) |
| 4099 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
| 4100 | ha->sns_cmd, ha->sns_cmd_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4101 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 4102 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4103 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 4104 | ha->fcp_cmnd_dma_pool = NULL; |
| 4105 | } |
| 4106 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 4107 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4108 | dma_pool_destroy(ha->dl_dma_pool); |
| 4109 | ha->dl_dma_pool = NULL; |
| 4110 | } |
| 4111 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4112 | dma_pool_destroy(ha->s_dma_pool); |
| 4113 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4114 | fail_free_nvram: |
| 4115 | kfree(ha->nvram); |
| 4116 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4117 | fail_free_ctx_mempool: |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4118 | if (ha->ctx_mempool) |
| 4119 | mempool_destroy(ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4120 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4121 | fail_free_srb_mempool: |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4122 | if (ha->srb_mempool) |
| 4123 | mempool_destroy(ha->srb_mempool); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4124 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4125 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 4126 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 4127 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4128 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4129 | ha->gid_list = NULL; |
| 4130 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4131 | fail_free_tgt_mem: |
| 4132 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4133 | fail_free_init_cb: |
| 4134 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 4135 | ha->init_cb_dma); |
| 4136 | ha->init_cb = NULL; |
| 4137 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4138 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4139 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 4140 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4141 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4142 | } |
| 4143 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4144 | int |
| 4145 | qla2x00_set_exlogins_buffer(scsi_qla_host_t *vha) |
| 4146 | { |
| 4147 | int rval; |
| 4148 | uint16_t size, max_cnt, temp; |
| 4149 | struct qla_hw_data *ha = vha->hw; |
| 4150 | |
| 4151 | /* Return if we don't need to alloacate any extended logins */ |
| 4152 | if (!ql2xexlogins) |
| 4153 | return QLA_SUCCESS; |
| 4154 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4155 | if (!IS_EXLOGIN_OFFLD_CAPABLE(ha)) |
| 4156 | return QLA_SUCCESS; |
| 4157 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4158 | ql_log(ql_log_info, vha, 0xd021, "EXLOGIN count: %d.\n", ql2xexlogins); |
| 4159 | max_cnt = 0; |
| 4160 | rval = qla_get_exlogin_status(vha, &size, &max_cnt); |
| 4161 | if (rval != QLA_SUCCESS) { |
| 4162 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd029, |
| 4163 | "Failed to get exlogin status.\n"); |
| 4164 | return rval; |
| 4165 | } |
| 4166 | |
| 4167 | temp = (ql2xexlogins > max_cnt) ? max_cnt : ql2xexlogins; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4168 | temp *= size; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4169 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4170 | if (temp != ha->exlogin_size) { |
| 4171 | qla2x00_free_exlogin_buffer(ha); |
| 4172 | ha->exlogin_size = temp; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4173 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4174 | ql_log(ql_log_info, vha, 0xd024, |
| 4175 | "EXLOGIN: max_logins=%d, portdb=0x%x, total=%d.\n", |
| 4176 | max_cnt, size, temp); |
| 4177 | |
| 4178 | ql_log(ql_log_info, vha, 0xd025, |
| 4179 | "EXLOGIN: requested size=0x%x\n", ha->exlogin_size); |
| 4180 | |
| 4181 | /* Get consistent memory for extended logins */ |
| 4182 | ha->exlogin_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 4183 | ha->exlogin_size, &ha->exlogin_buf_dma, GFP_KERNEL); |
| 4184 | if (!ha->exlogin_buf) { |
| 4185 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd02a, |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4186 | "Failed to allocate memory for exlogin_buf_dma.\n"); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4187 | return -ENOMEM; |
| 4188 | } |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4189 | } |
| 4190 | |
| 4191 | /* Now configure the dma buffer */ |
| 4192 | rval = qla_set_exlogin_mem_cfg(vha, ha->exlogin_buf_dma); |
| 4193 | if (rval) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4194 | ql_log(ql_log_fatal, vha, 0xd033, |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4195 | "Setup extended login buffer ****FAILED****.\n"); |
| 4196 | qla2x00_free_exlogin_buffer(ha); |
| 4197 | } |
| 4198 | |
| 4199 | return rval; |
| 4200 | } |
| 4201 | |
| 4202 | /* |
| 4203 | * qla2x00_free_exlogin_buffer |
| 4204 | * |
| 4205 | * Input: |
| 4206 | * ha = adapter block pointer |
| 4207 | */ |
| 4208 | void |
| 4209 | qla2x00_free_exlogin_buffer(struct qla_hw_data *ha) |
| 4210 | { |
| 4211 | if (ha->exlogin_buf) { |
| 4212 | dma_free_coherent(&ha->pdev->dev, ha->exlogin_size, |
| 4213 | ha->exlogin_buf, ha->exlogin_buf_dma); |
| 4214 | ha->exlogin_buf = NULL; |
| 4215 | ha->exlogin_size = 0; |
| 4216 | } |
| 4217 | } |
| 4218 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4219 | static void |
| 4220 | qla2x00_number_of_exch(scsi_qla_host_t *vha, u32 *ret_cnt, u16 max_cnt) |
| 4221 | { |
| 4222 | u32 temp; |
| 4223 | *ret_cnt = FW_DEF_EXCHANGES_CNT; |
| 4224 | |
| 4225 | if (qla_ini_mode_enabled(vha)) { |
| 4226 | if (ql2xiniexchg > max_cnt) |
| 4227 | ql2xiniexchg = max_cnt; |
| 4228 | |
| 4229 | if (ql2xiniexchg > FW_DEF_EXCHANGES_CNT) |
| 4230 | *ret_cnt = ql2xiniexchg; |
| 4231 | } else if (qla_tgt_mode_enabled(vha)) { |
| 4232 | if (ql2xexchoffld > max_cnt) |
| 4233 | ql2xexchoffld = max_cnt; |
| 4234 | |
| 4235 | if (ql2xexchoffld > FW_DEF_EXCHANGES_CNT) |
| 4236 | *ret_cnt = ql2xexchoffld; |
| 4237 | } else if (qla_dual_mode_enabled(vha)) { |
| 4238 | temp = ql2xiniexchg + ql2xexchoffld; |
| 4239 | if (temp > max_cnt) { |
| 4240 | ql2xiniexchg -= (temp - max_cnt)/2; |
| 4241 | ql2xexchoffld -= (((temp - max_cnt)/2) + 1); |
| 4242 | temp = max_cnt; |
| 4243 | } |
| 4244 | |
| 4245 | if (temp > FW_DEF_EXCHANGES_CNT) |
| 4246 | *ret_cnt = temp; |
| 4247 | } |
| 4248 | } |
| 4249 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4250 | int |
| 4251 | qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) |
| 4252 | { |
| 4253 | int rval; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4254 | u16 size, max_cnt; |
| 4255 | u32 temp; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4256 | struct qla_hw_data *ha = vha->hw; |
| 4257 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4258 | if (!ha->flags.exchoffld_enabled) |
| 4259 | return QLA_SUCCESS; |
| 4260 | |
| 4261 | if (!IS_EXCHG_OFFLD_CAPABLE(ha)) |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4262 | return QLA_SUCCESS; |
| 4263 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4264 | max_cnt = 0; |
| 4265 | rval = qla_get_exchoffld_status(vha, &size, &max_cnt); |
| 4266 | if (rval != QLA_SUCCESS) { |
| 4267 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd012, |
| 4268 | "Failed to get exlogin status.\n"); |
| 4269 | return rval; |
| 4270 | } |
| 4271 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4272 | qla2x00_number_of_exch(vha, &temp, max_cnt); |
| 4273 | temp *= size; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4274 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4275 | if (temp != ha->exchoffld_size) { |
| 4276 | qla2x00_free_exchoffld_buffer(ha); |
| 4277 | ha->exchoffld_size = temp; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4278 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4279 | ql_log(ql_log_info, vha, 0xd016, |
| 4280 | "Exchange offload: max_count=%d, buffers=0x%x, total=%d.\n", |
| 4281 | max_cnt, size, temp); |
| 4282 | |
| 4283 | ql_log(ql_log_info, vha, 0xd017, |
| 4284 | "Exchange Buffers requested size = 0x%x\n", |
| 4285 | ha->exchoffld_size); |
| 4286 | |
| 4287 | /* Get consistent memory for extended logins */ |
| 4288 | ha->exchoffld_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 4289 | ha->exchoffld_size, &ha->exchoffld_buf_dma, GFP_KERNEL); |
| 4290 | if (!ha->exchoffld_buf) { |
| 4291 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
| 4292 | "Failed to allocate memory for exchoffld_buf_dma.\n"); |
| 4293 | return -ENOMEM; |
| 4294 | } |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4295 | } |
| 4296 | |
| 4297 | /* Now configure the dma buffer */ |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4298 | rval = qla_set_exchoffld_mem_cfg(vha); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4299 | if (rval) { |
| 4300 | ql_log(ql_log_fatal, vha, 0xd02e, |
| 4301 | "Setup exchange offload buffer ****FAILED****.\n"); |
| 4302 | qla2x00_free_exchoffld_buffer(ha); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4303 | } else { |
| 4304 | /* re-adjust number of target exchange */ |
| 4305 | struct init_cb_81xx *icb = (struct init_cb_81xx *)ha->init_cb; |
| 4306 | |
| 4307 | if (qla_ini_mode_enabled(vha)) |
| 4308 | icb->exchange_count = 0; |
| 4309 | else |
| 4310 | icb->exchange_count = cpu_to_le16(ql2xexchoffld); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4311 | } |
| 4312 | |
| 4313 | return rval; |
| 4314 | } |
| 4315 | |
| 4316 | /* |
| 4317 | * qla2x00_free_exchoffld_buffer |
| 4318 | * |
| 4319 | * Input: |
| 4320 | * ha = adapter block pointer |
| 4321 | */ |
| 4322 | void |
| 4323 | qla2x00_free_exchoffld_buffer(struct qla_hw_data *ha) |
| 4324 | { |
| 4325 | if (ha->exchoffld_buf) { |
| 4326 | dma_free_coherent(&ha->pdev->dev, ha->exchoffld_size, |
| 4327 | ha->exchoffld_buf, ha->exchoffld_buf_dma); |
| 4328 | ha->exchoffld_buf = NULL; |
| 4329 | ha->exchoffld_size = 0; |
| 4330 | } |
| 4331 | } |
| 4332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4333 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4334 | * qla2x00_free_fw_dump |
| 4335 | * Frees fw dump stuff. |
| 4336 | * |
| 4337 | * Input: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 4338 | * ha = adapter block pointer |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4339 | */ |
| 4340 | static void |
| 4341 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 4342 | { |
| 4343 | if (ha->fce) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4344 | dma_free_coherent(&ha->pdev->dev, |
| 4345 | FCE_SIZE, ha->fce, ha->fce_dma); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4346 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4347 | if (ha->eft) |
| 4348 | dma_free_coherent(&ha->pdev->dev, |
| 4349 | EFT_SIZE, ha->eft, ha->eft_dma); |
| 4350 | |
| 4351 | if (ha->fw_dump) |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4352 | vfree(ha->fw_dump); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4353 | if (ha->fw_dump_template) |
| 4354 | vfree(ha->fw_dump_template); |
| 4355 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4356 | ha->fce = NULL; |
| 4357 | ha->fce_dma = 0; |
| 4358 | ha->eft = NULL; |
| 4359 | ha->eft_dma = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4360 | ha->fw_dumped = 0; |
Hiral Patel | 61f098d | 2014-04-11 16:54:21 -0400 | [diff] [blame] | 4361 | ha->fw_dump_cap_flags = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4362 | ha->fw_dump_reading = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4363 | ha->fw_dump = NULL; |
| 4364 | ha->fw_dump_len = 0; |
| 4365 | ha->fw_dump_template = NULL; |
| 4366 | ha->fw_dump_template_len = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4367 | } |
| 4368 | |
| 4369 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4370 | * qla2x00_mem_free |
| 4371 | * Frees all adapter allocated memory. |
| 4372 | * |
| 4373 | * Input: |
| 4374 | * ha = adapter block pointer. |
| 4375 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 4376 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4377 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4378 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4379 | qla2x00_free_fw_dump(ha); |
| 4380 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4381 | if (ha->mctp_dump) |
| 4382 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 4383 | ha->mctp_dump_dma); |
| 4384 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4385 | if (ha->srb_mempool) |
| 4386 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4387 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4388 | if (ha->dcbx_tlv) |
| 4389 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 4390 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 4391 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4392 | if (ha->xgmac_data) |
| 4393 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 4394 | ha->xgmac_data, ha->xgmac_data_dma); |
| 4395 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4396 | if (ha->sns_cmd) |
| 4397 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4398 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4399 | |
| 4400 | if (ha->ct_sns) |
| 4401 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4402 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4403 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 4404 | if (ha->sfp_data) |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4405 | dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE, ha->sfp_data, |
| 4406 | ha->sfp_data_dma); |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 4407 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4408 | if (ha->ms_iocb) |
| 4409 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 4410 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4411 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4412 | dma_pool_free(ha->s_dma_pool, |
| 4413 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4414 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4415 | if (ha->async_pd) |
| 4416 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 4417 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4418 | if (ha->s_dma_pool) |
| 4419 | dma_pool_destroy(ha->s_dma_pool); |
| 4420 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4421 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 4422 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 4423 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4424 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4425 | if (IS_QLA82XX(ha)) { |
| 4426 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 4427 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 4428 | |
| 4429 | /* clean up allocated prev pool */ |
| 4430 | list_for_each_entry_safe(dsd_ptr, |
| 4431 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 4432 | dma_pool_free(ha->dl_dma_pool, |
| 4433 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 4434 | list_del(&dsd_ptr->list); |
| 4435 | kfree(dsd_ptr); |
| 4436 | } |
| 4437 | } |
| 4438 | } |
| 4439 | |
| 4440 | if (ha->dl_dma_pool) |
| 4441 | dma_pool_destroy(ha->dl_dma_pool); |
| 4442 | |
| 4443 | if (ha->fcp_cmnd_dma_pool) |
| 4444 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 4445 | |
| 4446 | if (ha->ctx_mempool) |
| 4447 | mempool_destroy(ha->ctx_mempool); |
| 4448 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4449 | qlt_mem_free(ha); |
| 4450 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4451 | if (ha->init_cb) |
| 4452 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4453 | ha->init_cb, ha->init_cb_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4454 | vfree(ha->optrom_buffer); |
| 4455 | kfree(ha->nvram); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4456 | kfree(ha->npiv_info); |
Andrew Vasquez | 7a67735 | 2012-02-09 11:15:56 -0800 | [diff] [blame] | 4457 | kfree(ha->swl); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4458 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4459 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4460 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4461 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4462 | ha->sns_cmd = NULL; |
| 4463 | ha->sns_cmd_dma = 0; |
| 4464 | ha->ct_sns = NULL; |
| 4465 | ha->ct_sns_dma = 0; |
| 4466 | ha->ms_iocb = NULL; |
| 4467 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4468 | ha->init_cb = NULL; |
| 4469 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4470 | ha->ex_init_cb = NULL; |
| 4471 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4472 | ha->async_pd = NULL; |
| 4473 | ha->async_pd_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4474 | |
| 4475 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4476 | ha->dl_dma_pool = NULL; |
| 4477 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4478 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4479 | ha->gid_list = NULL; |
| 4480 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4481 | |
| 4482 | ha->tgt.atio_ring = NULL; |
| 4483 | ha->tgt.atio_dma = 0; |
| 4484 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4485 | } |
| 4486 | |
| 4487 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 4488 | struct qla_hw_data *ha) |
| 4489 | { |
| 4490 | struct Scsi_Host *host; |
| 4491 | struct scsi_qla_host *vha = NULL; |
| 4492 | |
| 4493 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4494 | if (!host) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4495 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 4496 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4497 | return NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4498 | } |
| 4499 | |
| 4500 | /* Clear our data area */ |
| 4501 | vha = shost_priv(host); |
| 4502 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 4503 | |
| 4504 | vha->host = host; |
| 4505 | vha->host_no = host->host_no; |
| 4506 | vha->hw = ha; |
| 4507 | |
| 4508 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 4509 | INIT_LIST_HEAD(&vha->work_list); |
| 4510 | INIT_LIST_HEAD(&vha->list); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4511 | INIT_LIST_HEAD(&vha->qla_cmd_list); |
| 4512 | INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list); |
Alexei Potashnik | 71cdc07 | 2015-12-17 14:57:01 -0500 | [diff] [blame] | 4513 | INIT_LIST_HEAD(&vha->logo_list); |
Alexei Potashnik | b7bd104 | 2015-12-17 14:57:02 -0500 | [diff] [blame] | 4514 | INIT_LIST_HEAD(&vha->plogi_ack_list); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 4515 | INIT_LIST_HEAD(&vha->qp_list); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4516 | INIT_LIST_HEAD(&vha->gnl.fcports); |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 4517 | INIT_LIST_HEAD(&vha->nvme_rport_list); |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame] | 4518 | INIT_LIST_HEAD(&vha->gpnid_list); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4519 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4520 | spin_lock_init(&vha->work_lock); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4521 | spin_lock_init(&vha->cmd_list_lock); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4522 | init_waitqueue_head(&vha->fcport_waitQ); |
Joe Carnuccio | c4a9b53 | 2017-03-15 09:48:43 -0700 | [diff] [blame] | 4523 | init_waitqueue_head(&vha->vref_waitq); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4524 | |
Bart Van Assche | 2fdbc65 | 2017-01-20 13:31:13 -0800 | [diff] [blame] | 4525 | vha->gnl.size = sizeof(struct get_name_list_extended) * |
| 4526 | (ha->max_loop_id + 1); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4527 | vha->gnl.l = dma_alloc_coherent(&ha->pdev->dev, |
| 4528 | vha->gnl.size, &vha->gnl.ldma, GFP_KERNEL); |
| 4529 | if (!vha->gnl.l) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4530 | ql_log(ql_log_fatal, vha, 0xd04a, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4531 | "Alloc failed for name list.\n"); |
| 4532 | scsi_remove_host(vha->host); |
| 4533 | return NULL; |
| 4534 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4535 | |
| 4536 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4537 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 4538 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 4539 | vha->host, vha->hw, vha, |
| 4540 | dev_name(&(ha->pdev->dev))); |
| 4541 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4542 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4543 | } |
| 4544 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4545 | struct qla_work_evt * |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4546 | 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] | 4547 | { |
| 4548 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4549 | uint8_t bail; |
| 4550 | |
| 4551 | QLA_VHA_MARK_BUSY(vha, bail); |
| 4552 | if (bail) |
| 4553 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4554 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4555 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4556 | if (!e) { |
| 4557 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4558 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4559 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4560 | |
| 4561 | INIT_LIST_HEAD(&e->list); |
| 4562 | e->type = type; |
| 4563 | e->flags = QLA_EVT_FLAG_FREE; |
| 4564 | return e; |
| 4565 | } |
| 4566 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4567 | int |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4568 | 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] | 4569 | { |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4570 | unsigned long flags; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4571 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4572 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4573 | list_add_tail(&e->list, &vha->work_list); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4574 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 4575 | |
| 4576 | if (QLA_EARLY_LINKUP(vha->hw)) |
| 4577 | schedule_work(&vha->iocb_work); |
| 4578 | else |
| 4579 | qla2xxx_wake_dpc(vha); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4580 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4581 | return QLA_SUCCESS; |
| 4582 | } |
| 4583 | |
| 4584 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4585 | 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] | 4586 | u32 data) |
| 4587 | { |
| 4588 | struct qla_work_evt *e; |
| 4589 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4590 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4591 | if (!e) |
| 4592 | return QLA_FUNCTION_FAILED; |
| 4593 | |
| 4594 | e->u.aen.code = code; |
| 4595 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4596 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4597 | } |
| 4598 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4599 | int |
| 4600 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 4601 | { |
| 4602 | struct qla_work_evt *e; |
| 4603 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4604 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4605 | if (!e) |
| 4606 | return QLA_FUNCTION_FAILED; |
| 4607 | |
| 4608 | memcpy(e->u.idc_ack.mb, mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4609 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4610 | } |
| 4611 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4612 | #define qla2x00_post_async_work(name, type) \ |
| 4613 | int qla2x00_post_async_##name##_work( \ |
| 4614 | struct scsi_qla_host *vha, \ |
| 4615 | fc_port_t *fcport, uint16_t *data) \ |
| 4616 | { \ |
| 4617 | struct qla_work_evt *e; \ |
| 4618 | \ |
| 4619 | e = qla2x00_alloc_work(vha, type); \ |
| 4620 | if (!e) \ |
| 4621 | return QLA_FUNCTION_FAILED; \ |
| 4622 | \ |
| 4623 | e->u.logio.fcport = fcport; \ |
| 4624 | if (data) { \ |
| 4625 | e->u.logio.data[0] = data[0]; \ |
| 4626 | e->u.logio.data[1] = data[1]; \ |
| 4627 | } \ |
| 4628 | return qla2x00_post_work(vha, e); \ |
| 4629 | } |
| 4630 | |
| 4631 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4632 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 4633 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4634 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 4635 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4636 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4637 | int |
| 4638 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 4639 | { |
| 4640 | struct qla_work_evt *e; |
| 4641 | |
| 4642 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 4643 | if (!e) |
| 4644 | return QLA_FUNCTION_FAILED; |
| 4645 | |
| 4646 | e->u.uevent.code = code; |
| 4647 | return qla2x00_post_work(vha, e); |
| 4648 | } |
| 4649 | |
| 4650 | static void |
| 4651 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 4652 | { |
| 4653 | char event_string[40]; |
| 4654 | char *envp[] = { event_string, NULL }; |
| 4655 | |
| 4656 | switch (code) { |
| 4657 | case QLA_UEVENT_CODE_FW_DUMP: |
| 4658 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 4659 | vha->host_no); |
| 4660 | break; |
| 4661 | default: |
| 4662 | /* do nothing */ |
| 4663 | break; |
| 4664 | } |
| 4665 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 4666 | } |
| 4667 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4668 | int |
| 4669 | qlafx00_post_aenfx_work(struct scsi_qla_host *vha, uint32_t evtcode, |
| 4670 | uint32_t *data, int cnt) |
| 4671 | { |
| 4672 | struct qla_work_evt *e; |
| 4673 | |
| 4674 | e = qla2x00_alloc_work(vha, QLA_EVT_AENFX); |
| 4675 | if (!e) |
| 4676 | return QLA_FUNCTION_FAILED; |
| 4677 | |
| 4678 | e->u.aenfx.evtcode = evtcode; |
| 4679 | e->u.aenfx.count = cnt; |
| 4680 | memcpy(e->u.aenfx.mbx, data, sizeof(*data) * cnt); |
| 4681 | return qla2x00_post_work(vha, e); |
| 4682 | } |
| 4683 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4684 | int qla24xx_post_upd_fcport_work(struct scsi_qla_host *vha, fc_port_t *fcport) |
| 4685 | { |
| 4686 | struct qla_work_evt *e; |
| 4687 | |
| 4688 | e = qla2x00_alloc_work(vha, QLA_EVT_UPD_FCPORT); |
| 4689 | if (!e) |
| 4690 | return QLA_FUNCTION_FAILED; |
| 4691 | |
| 4692 | e->u.fcport.fcport = fcport; |
| 4693 | return qla2x00_post_work(vha, e); |
| 4694 | } |
| 4695 | |
| 4696 | static |
| 4697 | void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) |
| 4698 | { |
| 4699 | unsigned long flags; |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4700 | fc_port_t *fcport = NULL, *tfcp; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4701 | struct qlt_plogi_ack_t *pla = |
| 4702 | (struct qlt_plogi_ack_t *)e->u.new_sess.pla; |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4703 | uint8_t free_fcport = 0; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4704 | |
| 4705 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 4706 | fcport = qla2x00_find_fcport_by_wwpn(vha, e->u.new_sess.port_name, 1); |
| 4707 | if (fcport) { |
| 4708 | fcport->d_id = e->u.new_sess.id; |
| 4709 | if (pla) { |
| 4710 | fcport->fw_login_state = DSC_LS_PLOGI_PEND; |
| 4711 | qlt_plogi_ack_link(vha, pla, fcport, QLT_PLOGI_LINK_SAME_WWN); |
| 4712 | /* we took an extra ref_count to prevent PLOGI ACK when |
| 4713 | * fcport/sess has not been created. |
| 4714 | */ |
| 4715 | pla->ref_count--; |
| 4716 | } |
| 4717 | } else { |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4718 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4719 | fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
| 4720 | if (fcport) { |
| 4721 | fcport->d_id = e->u.new_sess.id; |
| 4722 | fcport->scan_state = QLA_FCPORT_FOUND; |
| 4723 | fcport->flags |= FCF_FABRIC_DEVICE; |
| 4724 | fcport->fw_login_state = DSC_LS_PLOGI_PEND; |
| 4725 | |
| 4726 | memcpy(fcport->port_name, e->u.new_sess.port_name, |
| 4727 | WWN_SIZE); |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4728 | } else { |
| 4729 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 4730 | "%s %8phC mem alloc fail.\n", |
| 4731 | __func__, e->u.new_sess.port_name); |
| 4732 | |
| 4733 | if (pla) |
| 4734 | kmem_cache_free(qla_tgt_plogi_cachep, pla); |
| 4735 | return; |
| 4736 | } |
| 4737 | |
| 4738 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 4739 | /* search again to make sure one else got ahead */ |
| 4740 | tfcp = qla2x00_find_fcport_by_wwpn(vha, |
| 4741 | e->u.new_sess.port_name, 1); |
| 4742 | if (tfcp) { |
| 4743 | /* should rarily happen */ |
| 4744 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 4745 | "%s %8phC found existing fcport b4 add. DS %d LS %d\n", |
| 4746 | __func__, tfcp->port_name, tfcp->disc_state, |
| 4747 | tfcp->fw_login_state); |
| 4748 | |
| 4749 | free_fcport = 1; |
| 4750 | } else { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4751 | list_add_tail(&fcport->list, &vha->vp_fcports); |
| 4752 | |
Quinn Tran | 1975903 | 2017-12-04 14:45:15 -0800 | [diff] [blame^] | 4753 | } |
| 4754 | if (pla) { |
| 4755 | qlt_plogi_ack_link(vha, pla, fcport, |
| 4756 | QLT_PLOGI_LINK_SAME_WWN); |
| 4757 | pla->ref_count--; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4758 | } |
| 4759 | } |
| 4760 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 4761 | |
| 4762 | if (fcport) { |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 4763 | if (pla) { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4764 | qlt_plogi_ack_unref(vha, pla); |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 4765 | } else { |
| 4766 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 4767 | tfcp = qla2x00_find_fcport_by_nportid(vha, |
| 4768 | &e->u.new_sess.id, 1); |
| 4769 | if (tfcp && (tfcp != fcport)) { |
| 4770 | /* |
| 4771 | * We have a conflict fcport with same NportID. |
| 4772 | */ |
| 4773 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 4774 | "%s %8phC found conflict b4 add. DS %d LS %d\n", |
| 4775 | __func__, tfcp->port_name, tfcp->disc_state, |
| 4776 | tfcp->fw_login_state); |
| 4777 | |
| 4778 | switch (tfcp->disc_state) { |
| 4779 | case DSC_DELETED: |
| 4780 | break; |
| 4781 | case DSC_DELETE_PEND: |
| 4782 | fcport->login_pause = 1; |
| 4783 | tfcp->conflict = fcport; |
| 4784 | break; |
| 4785 | default: |
| 4786 | fcport->login_pause = 1; |
| 4787 | tfcp->conflict = fcport; |
| 4788 | qlt_schedule_sess_for_deletion_lock |
| 4789 | (tfcp); |
| 4790 | break; |
| 4791 | } |
| 4792 | } |
| 4793 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 4794 | qla24xx_async_gnl(vha, fcport); |
| 4795 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4796 | } |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4797 | |
| 4798 | if (free_fcport) { |
| 4799 | qla2x00_free_fcport(fcport); |
| 4800 | if (pla) |
| 4801 | kmem_cache_free(qla_tgt_plogi_cachep, pla); |
| 4802 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4803 | } |
| 4804 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4805 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4806 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4807 | { |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4808 | struct qla_work_evt *e, *tmp; |
| 4809 | unsigned long flags; |
| 4810 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4811 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4812 | spin_lock_irqsave(&vha->work_lock, flags); |
| 4813 | list_splice_init(&vha->work_list, &work); |
| 4814 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 4815 | |
| 4816 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4817 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4818 | |
| 4819 | switch (e->type) { |
| 4820 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4821 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4822 | e->u.aen.code, e->u.aen.data); |
| 4823 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4824 | case QLA_EVT_IDC_ACK: |
| 4825 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 4826 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4827 | case QLA_EVT_ASYNC_LOGIN: |
| 4828 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 4829 | e->u.logio.data); |
| 4830 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4831 | case QLA_EVT_ASYNC_LOGOUT: |
| 4832 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 4833 | break; |
| 4834 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 4835 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 4836 | e->u.logio.data); |
| 4837 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4838 | case QLA_EVT_ASYNC_ADISC: |
| 4839 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 4840 | e->u.logio.data); |
| 4841 | break; |
| 4842 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 4843 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 4844 | e->u.logio.data); |
| 4845 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4846 | case QLA_EVT_UEVENT: |
| 4847 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 4848 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4849 | case QLA_EVT_AENFX: |
| 4850 | qlafx00_process_aen(vha, e); |
| 4851 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4852 | case QLA_EVT_GIDPN: |
| 4853 | qla24xx_async_gidpn(vha, e->u.fcport.fcport); |
| 4854 | break; |
| 4855 | case QLA_EVT_GPNID: |
| 4856 | qla24xx_async_gpnid(vha, &e->u.gpnid.id); |
| 4857 | break; |
| 4858 | case QLA_EVT_GPNID_DONE: |
| 4859 | qla24xx_async_gpnid_done(vha, e->u.iosb.sp); |
| 4860 | break; |
| 4861 | case QLA_EVT_NEW_SESS: |
| 4862 | qla24xx_create_new_sess(vha, e); |
| 4863 | break; |
| 4864 | case QLA_EVT_GPDB: |
| 4865 | qla24xx_async_gpdb(vha, e->u.fcport.fcport, |
| 4866 | e->u.fcport.opt); |
| 4867 | break; |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 4868 | case QLA_EVT_PRLI: |
| 4869 | qla24xx_async_prli(vha, e->u.fcport.fcport); |
| 4870 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4871 | case QLA_EVT_GPSC: |
| 4872 | qla24xx_async_gpsc(vha, e->u.fcport.fcport); |
| 4873 | break; |
| 4874 | case QLA_EVT_UPD_FCPORT: |
| 4875 | qla2x00_update_fcport(vha, e->u.fcport.fcport); |
| 4876 | break; |
| 4877 | case QLA_EVT_GNL: |
| 4878 | qla24xx_async_gnl(vha, e->u.fcport.fcport); |
| 4879 | break; |
| 4880 | case QLA_EVT_NACK: |
| 4881 | qla24xx_do_nack_work(vha, e); |
| 4882 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4883 | } |
| 4884 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 4885 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4886 | |
| 4887 | /* For each work completed decrement vha ref count */ |
| 4888 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4889 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4890 | } |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4891 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4892 | /* Relogins all the fcports of a vport |
| 4893 | * Context: dpc thread |
| 4894 | */ |
| 4895 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 4896 | { |
| 4897 | fc_port_t *fcport; |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 4898 | int status; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4899 | struct event_arg ea; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4900 | |
| 4901 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 4902 | /* |
| 4903 | * If the port is not ONLINE then try to login |
| 4904 | * to it if we haven't run out of retries. |
| 4905 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4906 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
| 4907 | fcport->login_retry && !(fcport->flags & FCF_ASYNC_SENT)) { |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 4908 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4909 | if (fcport->flags & FCF_FABRIC_DEVICE) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4910 | ql_dbg(ql_dbg_disc, fcport->vha, 0x2108, |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4911 | "%s %8phC DS %d LS %d\n", __func__, |
| 4912 | fcport->port_name, fcport->disc_state, |
| 4913 | fcport->fw_login_state); |
| 4914 | memset(&ea, 0, sizeof(ea)); |
| 4915 | ea.event = FCME_RELOGIN; |
| 4916 | ea.fcport = fcport; |
| 4917 | qla2x00_fcport_event_handler(vha, &ea); |
| 4918 | } else { |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 4919 | fcport->login_retry--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4920 | status = qla2x00_local_device_login(vha, |
| 4921 | fcport); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4922 | if (status == QLA_SUCCESS) { |
| 4923 | fcport->old_loop_id = fcport->loop_id; |
| 4924 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 4925 | "Port login OK: logged in ID 0x%x.\n", |
| 4926 | fcport->loop_id); |
| 4927 | qla2x00_update_fcport(vha, fcport); |
| 4928 | } else if (status == 1) { |
| 4929 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 4930 | /* retry the login again */ |
| 4931 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 4932 | "Retrying %d login again loop_id 0x%x.\n", |
| 4933 | fcport->login_retry, |
| 4934 | fcport->loop_id); |
| 4935 | } else { |
| 4936 | fcport->login_retry = 0; |
| 4937 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4938 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4939 | if (fcport->login_retry == 0 && |
| 4940 | status != QLA_SUCCESS) |
| 4941 | qla2x00_clear_loop_id(fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4942 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4943 | } |
| 4944 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 4945 | break; |
| 4946 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4947 | } |
| 4948 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4949 | /* Schedule work on any of the dpc-workqueues */ |
| 4950 | void |
| 4951 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 4952 | { |
| 4953 | struct qla_hw_data *ha = base_vha->hw; |
| 4954 | |
| 4955 | switch (work_code) { |
| 4956 | case MBA_IDC_AEN: /* 0x8200 */ |
| 4957 | if (ha->dpc_lp_wq) |
| 4958 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 4959 | break; |
| 4960 | |
| 4961 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 4962 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4963 | if (ha->dpc_hp_wq) |
| 4964 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 4965 | } else |
| 4966 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 4967 | "NIC Core reset is already active. Skip " |
| 4968 | "scheduling it again.\n"); |
| 4969 | break; |
| 4970 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 4971 | if (ha->dpc_hp_wq) |
| 4972 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 4973 | break; |
| 4974 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 4975 | if (ha->dpc_hp_wq) |
| 4976 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 4977 | break; |
| 4978 | default: |
| 4979 | ql_log(ql_log_warn, base_vha, 0xb05f, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 4980 | "Unknown work-code=0x%x.\n", work_code); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4981 | } |
| 4982 | |
| 4983 | return; |
| 4984 | } |
| 4985 | |
| 4986 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 4987 | void |
| 4988 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 4989 | { |
| 4990 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4991 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4992 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4993 | uint32_t dev_state = 0; |
| 4994 | |
| 4995 | qla83xx_idc_lock(base_vha, 0); |
| 4996 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4997 | qla83xx_reset_ownership(base_vha); |
| 4998 | if (ha->flags.nic_core_reset_owner) { |
| 4999 | ha->flags.nic_core_reset_owner = 0; |
| 5000 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5001 | QLA8XXX_DEV_FAILED); |
| 5002 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 5003 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 5004 | } |
| 5005 | qla83xx_idc_unlock(base_vha, 0); |
| 5006 | } |
| 5007 | |
| 5008 | /* Work: Execute IDC state handler */ |
| 5009 | void |
| 5010 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 5011 | { |
| 5012 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 5013 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5014 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5015 | uint32_t dev_state = 0; |
| 5016 | |
| 5017 | qla83xx_idc_lock(base_vha, 0); |
| 5018 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5019 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 5020 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 5021 | qla83xx_idc_state_handler(base_vha); |
| 5022 | qla83xx_idc_unlock(base_vha, 0); |
| 5023 | } |
| 5024 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5025 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5026 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 5027 | { |
| 5028 | int rval = QLA_SUCCESS; |
| 5029 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 5030 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 5031 | |
| 5032 | do { |
| 5033 | if (time_after(jiffies, heart_beat_wait)) { |
| 5034 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 5035 | "Nic Core f/w is not alive.\n"); |
| 5036 | rval = QLA_FUNCTION_FAILED; |
| 5037 | break; |
| 5038 | } |
| 5039 | |
| 5040 | qla83xx_idc_lock(base_vha, 0); |
| 5041 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 5042 | &heart_beat_counter1); |
| 5043 | qla83xx_idc_unlock(base_vha, 0); |
| 5044 | msleep(100); |
| 5045 | qla83xx_idc_lock(base_vha, 0); |
| 5046 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 5047 | &heart_beat_counter2); |
| 5048 | qla83xx_idc_unlock(base_vha, 0); |
| 5049 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 5050 | |
| 5051 | return rval; |
| 5052 | } |
| 5053 | |
| 5054 | /* Work: Perform NIC Core Reset handling */ |
| 5055 | void |
| 5056 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 5057 | { |
| 5058 | struct qla_hw_data *ha = |
| 5059 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 5060 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5061 | uint32_t dev_state = 0; |
| 5062 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 5063 | if (IS_QLA2031(ha)) { |
| 5064 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 5065 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 5066 | "Failed to dump mctp\n"); |
| 5067 | return; |
| 5068 | } |
| 5069 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5070 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 5071 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 5072 | qla83xx_idc_lock(base_vha, 0); |
| 5073 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5074 | &dev_state); |
| 5075 | qla83xx_idc_unlock(base_vha, 0); |
| 5076 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 5077 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 5078 | "Nic Core f/w is alive.\n"); |
| 5079 | return; |
| 5080 | } |
| 5081 | } |
| 5082 | |
| 5083 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 5084 | if (qla83xx_nic_core_reset(base_vha)) { |
| 5085 | /* NIC Core reset failed. */ |
| 5086 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 5087 | "NIC Core reset failed.\n"); |
| 5088 | } |
| 5089 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 5090 | } |
| 5091 | } |
| 5092 | |
| 5093 | /* Work: Handle 8200 IDC aens */ |
| 5094 | void |
| 5095 | qla83xx_service_idc_aen(struct work_struct *work) |
| 5096 | { |
| 5097 | struct qla_hw_data *ha = |
| 5098 | container_of(work, struct qla_hw_data, idc_aen); |
| 5099 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5100 | uint32_t dev_state, idc_control; |
| 5101 | |
| 5102 | qla83xx_idc_lock(base_vha, 0); |
| 5103 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5104 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 5105 | qla83xx_idc_unlock(base_vha, 0); |
| 5106 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 5107 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 5108 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 5109 | "Application requested NIC Core Reset.\n"); |
| 5110 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 5111 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 5112 | QLA_SUCCESS) { |
| 5113 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 5114 | "Other protocol driver requested NIC Core Reset.\n"); |
| 5115 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 5116 | } |
| 5117 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 5118 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 5119 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 5120 | } |
| 5121 | } |
| 5122 | |
| 5123 | static void |
| 5124 | qla83xx_wait_logic(void) |
| 5125 | { |
| 5126 | int i; |
| 5127 | |
| 5128 | /* Yield CPU */ |
| 5129 | if (!in_interrupt()) { |
| 5130 | /* |
| 5131 | * Wait about 200ms before retrying again. |
| 5132 | * This controls the number of retries for single |
| 5133 | * lock operation. |
| 5134 | */ |
| 5135 | msleep(100); |
| 5136 | schedule(); |
| 5137 | } else { |
| 5138 | for (i = 0; i < 20; i++) |
| 5139 | cpu_relax(); /* This a nop instr on i386 */ |
| 5140 | } |
| 5141 | } |
| 5142 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5143 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5144 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 5145 | { |
| 5146 | int rval; |
| 5147 | uint32_t data; |
| 5148 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 5149 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 5150 | struct qla_hw_data *ha = base_vha->hw; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5151 | ql_dbg(ql_dbg_p3p, base_vha, 0xb086, |
| 5152 | "Trying force recovery of the IDC lock.\n"); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5153 | |
| 5154 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 5155 | if (rval) |
| 5156 | return rval; |
| 5157 | |
| 5158 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 5159 | return QLA_SUCCESS; |
| 5160 | } else { |
| 5161 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 5162 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 5163 | data); |
| 5164 | if (rval) |
| 5165 | return rval; |
| 5166 | |
| 5167 | msleep(200); |
| 5168 | |
| 5169 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 5170 | &data); |
| 5171 | if (rval) |
| 5172 | return rval; |
| 5173 | |
| 5174 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 5175 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 5176 | ~(idc_lck_rcvry_stage_mask)); |
| 5177 | rval = qla83xx_wr_reg(base_vha, |
| 5178 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 5179 | if (rval) |
| 5180 | return rval; |
| 5181 | |
| 5182 | /* Forcefully perform IDC UnLock */ |
| 5183 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 5184 | &data); |
| 5185 | if (rval) |
| 5186 | return rval; |
| 5187 | /* Clear lock-id by setting 0xff */ |
| 5188 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5189 | 0xff); |
| 5190 | if (rval) |
| 5191 | return rval; |
| 5192 | /* Clear lock-recovery by setting 0x0 */ |
| 5193 | rval = qla83xx_wr_reg(base_vha, |
| 5194 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 5195 | if (rval) |
| 5196 | return rval; |
| 5197 | } else |
| 5198 | return QLA_SUCCESS; |
| 5199 | } |
| 5200 | |
| 5201 | return rval; |
| 5202 | } |
| 5203 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5204 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5205 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 5206 | { |
| 5207 | int rval = QLA_SUCCESS; |
| 5208 | uint32_t o_drv_lockid, n_drv_lockid; |
| 5209 | unsigned long lock_recovery_timeout; |
| 5210 | |
| 5211 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 5212 | retry_lockid: |
| 5213 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 5214 | if (rval) |
| 5215 | goto exit; |
| 5216 | |
| 5217 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 5218 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 5219 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 5220 | return QLA_SUCCESS; |
| 5221 | else |
| 5222 | return QLA_FUNCTION_FAILED; |
| 5223 | } |
| 5224 | |
| 5225 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 5226 | if (rval) |
| 5227 | goto exit; |
| 5228 | |
| 5229 | if (o_drv_lockid == n_drv_lockid) { |
| 5230 | qla83xx_wait_logic(); |
| 5231 | goto retry_lockid; |
| 5232 | } else |
| 5233 | return QLA_SUCCESS; |
| 5234 | |
| 5235 | exit: |
| 5236 | return rval; |
| 5237 | } |
| 5238 | |
| 5239 | void |
| 5240 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 5241 | { |
| 5242 | uint16_t options = (requester_id << 15) | BIT_6; |
| 5243 | uint32_t data; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5244 | uint32_t lock_owner; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5245 | struct qla_hw_data *ha = base_vha->hw; |
| 5246 | |
| 5247 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 5248 | retry_lock: |
| 5249 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 5250 | == QLA_SUCCESS) { |
| 5251 | if (data) { |
| 5252 | /* Setting lock-id to our function-number */ |
| 5253 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5254 | ha->portnum); |
| 5255 | } else { |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5256 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5257 | &lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5258 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5259 | "Failed to acquire IDC lock, acquired by %d, " |
| 5260 | "retrying...\n", lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5261 | |
| 5262 | /* Retry/Perform IDC-Lock recovery */ |
| 5263 | if (qla83xx_idc_lock_recovery(base_vha) |
| 5264 | == QLA_SUCCESS) { |
| 5265 | qla83xx_wait_logic(); |
| 5266 | goto retry_lock; |
| 5267 | } else |
| 5268 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 5269 | "IDC Lock recovery FAILED.\n"); |
| 5270 | } |
| 5271 | |
| 5272 | } |
| 5273 | |
| 5274 | return; |
| 5275 | |
| 5276 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 5277 | retry_lock2: |
| 5278 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 5279 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 5280 | "Failed to acquire IDC lock. retrying...\n"); |
| 5281 | /* Retry/Perform IDC-Lock recovery */ |
| 5282 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 5283 | qla83xx_wait_logic(); |
| 5284 | goto retry_lock2; |
| 5285 | } else |
| 5286 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 5287 | "IDC Lock recovery FAILED.\n"); |
| 5288 | } |
| 5289 | |
| 5290 | return; |
| 5291 | } |
| 5292 | |
| 5293 | void |
| 5294 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 5295 | { |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5296 | #if 0 |
| 5297 | uint16_t options = (requester_id << 15) | BIT_7; |
| 5298 | #endif |
| 5299 | uint16_t retry; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5300 | uint32_t data; |
| 5301 | struct qla_hw_data *ha = base_vha->hw; |
| 5302 | |
| 5303 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 5304 | * remote registers |
| 5305 | */ |
| 5306 | retry = 0; |
| 5307 | retry_unlock: |
| 5308 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 5309 | == QLA_SUCCESS) { |
| 5310 | if (data == ha->portnum) { |
| 5311 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 5312 | /* Clearing lock-id by setting 0xff */ |
| 5313 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 5314 | } else if (retry < 10) { |
| 5315 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 5316 | |
| 5317 | /* Retry for IDC-unlock */ |
| 5318 | qla83xx_wait_logic(); |
| 5319 | retry++; |
| 5320 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5321 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5322 | goto retry_unlock; |
| 5323 | } |
| 5324 | } else if (retry < 10) { |
| 5325 | /* Retry for IDC-unlock */ |
| 5326 | qla83xx_wait_logic(); |
| 5327 | retry++; |
| 5328 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5329 | "Failed to read drv-lockid, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5330 | goto retry_unlock; |
| 5331 | } |
| 5332 | |
| 5333 | return; |
| 5334 | |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5335 | #if 0 |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5336 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 5337 | retry = 0; |
| 5338 | retry_unlock2: |
| 5339 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 5340 | if (retry < 10) { |
| 5341 | /* Retry for IDC-unlock */ |
| 5342 | qla83xx_wait_logic(); |
| 5343 | retry++; |
| 5344 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5345 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5346 | goto retry_unlock2; |
| 5347 | } |
| 5348 | } |
| 5349 | |
| 5350 | return; |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5351 | #endif |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5352 | } |
| 5353 | |
| 5354 | int |
| 5355 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 5356 | { |
| 5357 | int rval = QLA_SUCCESS; |
| 5358 | struct qla_hw_data *ha = vha->hw; |
| 5359 | uint32_t drv_presence; |
| 5360 | |
| 5361 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 5362 | if (rval == QLA_SUCCESS) { |
| 5363 | drv_presence |= (1 << ha->portnum); |
| 5364 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5365 | drv_presence); |
| 5366 | } |
| 5367 | |
| 5368 | return rval; |
| 5369 | } |
| 5370 | |
| 5371 | int |
| 5372 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 5373 | { |
| 5374 | int rval = QLA_SUCCESS; |
| 5375 | |
| 5376 | qla83xx_idc_lock(vha, 0); |
| 5377 | rval = __qla83xx_set_drv_presence(vha); |
| 5378 | qla83xx_idc_unlock(vha, 0); |
| 5379 | |
| 5380 | return rval; |
| 5381 | } |
| 5382 | |
| 5383 | int |
| 5384 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 5385 | { |
| 5386 | int rval = QLA_SUCCESS; |
| 5387 | struct qla_hw_data *ha = vha->hw; |
| 5388 | uint32_t drv_presence; |
| 5389 | |
| 5390 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 5391 | if (rval == QLA_SUCCESS) { |
| 5392 | drv_presence &= ~(1 << ha->portnum); |
| 5393 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5394 | drv_presence); |
| 5395 | } |
| 5396 | |
| 5397 | return rval; |
| 5398 | } |
| 5399 | |
| 5400 | int |
| 5401 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 5402 | { |
| 5403 | int rval = QLA_SUCCESS; |
| 5404 | |
| 5405 | qla83xx_idc_lock(vha, 0); |
| 5406 | rval = __qla83xx_clear_drv_presence(vha); |
| 5407 | qla83xx_idc_unlock(vha, 0); |
| 5408 | |
| 5409 | return rval; |
| 5410 | } |
| 5411 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5412 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5413 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 5414 | { |
| 5415 | struct qla_hw_data *ha = vha->hw; |
| 5416 | uint32_t drv_ack, drv_presence; |
| 5417 | unsigned long ack_timeout; |
| 5418 | |
| 5419 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 5420 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 5421 | while (1) { |
| 5422 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 5423 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 5424 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5425 | break; |
| 5426 | |
| 5427 | if (time_after_eq(jiffies, ack_timeout)) { |
| 5428 | ql_log(ql_log_warn, vha, 0xb067, |
| 5429 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 5430 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 5431 | /* |
| 5432 | * The function(s) which did not ack in time are forced |
| 5433 | * to withdraw any further participation in the IDC |
| 5434 | * reset. |
| 5435 | */ |
| 5436 | if (drv_ack != drv_presence) |
| 5437 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5438 | drv_ack); |
| 5439 | break; |
| 5440 | } |
| 5441 | |
| 5442 | qla83xx_idc_unlock(vha, 0); |
| 5443 | msleep(1000); |
| 5444 | qla83xx_idc_lock(vha, 0); |
| 5445 | } |
| 5446 | |
| 5447 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 5448 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 5449 | } |
| 5450 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5451 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5452 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 5453 | { |
| 5454 | int rval = QLA_SUCCESS; |
| 5455 | uint32_t idc_control; |
| 5456 | |
| 5457 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 5458 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 5459 | |
| 5460 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 5461 | __qla83xx_get_idc_control(vha, &idc_control); |
| 5462 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 5463 | __qla83xx_set_idc_control(vha, 0); |
| 5464 | |
| 5465 | qla83xx_idc_unlock(vha, 0); |
| 5466 | rval = qla83xx_restart_nic_firmware(vha); |
| 5467 | qla83xx_idc_lock(vha, 0); |
| 5468 | |
| 5469 | if (rval != QLA_SUCCESS) { |
| 5470 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 5471 | "Failed to restart NIC f/w.\n"); |
| 5472 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 5473 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 5474 | } else { |
| 5475 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 5476 | "Success in restarting nic f/w.\n"); |
| 5477 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 5478 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 5479 | } |
| 5480 | |
| 5481 | return rval; |
| 5482 | } |
| 5483 | |
| 5484 | /* Assumes idc_lock always held on entry */ |
| 5485 | int |
| 5486 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 5487 | { |
| 5488 | struct qla_hw_data *ha = base_vha->hw; |
| 5489 | int rval = QLA_SUCCESS; |
| 5490 | unsigned long dev_init_timeout; |
| 5491 | uint32_t dev_state; |
| 5492 | |
| 5493 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 5494 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 5495 | |
| 5496 | while (1) { |
| 5497 | |
| 5498 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 5499 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 5500 | "Initialization TIMEOUT!\n"); |
| 5501 | /* Init timeout. Disable further NIC Core |
| 5502 | * communication. |
| 5503 | */ |
| 5504 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5505 | QLA8XXX_DEV_FAILED); |
| 5506 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 5507 | "HW State: FAILED.\n"); |
| 5508 | } |
| 5509 | |
| 5510 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5511 | switch (dev_state) { |
| 5512 | case QLA8XXX_DEV_READY: |
| 5513 | if (ha->flags.nic_core_reset_owner) |
| 5514 | qla83xx_idc_audit(base_vha, |
| 5515 | IDC_AUDIT_COMPLETION); |
| 5516 | ha->flags.nic_core_reset_owner = 0; |
| 5517 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 5518 | "Reset_owner reset by 0x%x.\n", |
| 5519 | ha->portnum); |
| 5520 | goto exit; |
| 5521 | case QLA8XXX_DEV_COLD: |
| 5522 | if (ha->flags.nic_core_reset_owner) |
| 5523 | rval = qla83xx_device_bootstrap(base_vha); |
| 5524 | else { |
| 5525 | /* Wait for AEN to change device-state */ |
| 5526 | qla83xx_idc_unlock(base_vha, 0); |
| 5527 | msleep(1000); |
| 5528 | qla83xx_idc_lock(base_vha, 0); |
| 5529 | } |
| 5530 | break; |
| 5531 | case QLA8XXX_DEV_INITIALIZING: |
| 5532 | /* Wait for AEN to change device-state */ |
| 5533 | qla83xx_idc_unlock(base_vha, 0); |
| 5534 | msleep(1000); |
| 5535 | qla83xx_idc_lock(base_vha, 0); |
| 5536 | break; |
| 5537 | case QLA8XXX_DEV_NEED_RESET: |
| 5538 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 5539 | qla83xx_need_reset_handler(base_vha); |
| 5540 | else { |
| 5541 | /* Wait for AEN to change device-state */ |
| 5542 | qla83xx_idc_unlock(base_vha, 0); |
| 5543 | msleep(1000); |
| 5544 | qla83xx_idc_lock(base_vha, 0); |
| 5545 | } |
| 5546 | /* reset timeout value after need reset handler */ |
| 5547 | dev_init_timeout = jiffies + |
| 5548 | (ha->fcoe_dev_init_timeout * HZ); |
| 5549 | break; |
| 5550 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 5551 | /* XXX: DEBUG for now */ |
| 5552 | qla83xx_idc_unlock(base_vha, 0); |
| 5553 | msleep(1000); |
| 5554 | qla83xx_idc_lock(base_vha, 0); |
| 5555 | break; |
| 5556 | case QLA8XXX_DEV_QUIESCENT: |
| 5557 | /* XXX: DEBUG for now */ |
| 5558 | if (ha->flags.quiesce_owner) |
| 5559 | goto exit; |
| 5560 | |
| 5561 | qla83xx_idc_unlock(base_vha, 0); |
| 5562 | msleep(1000); |
| 5563 | qla83xx_idc_lock(base_vha, 0); |
| 5564 | dev_init_timeout = jiffies + |
| 5565 | (ha->fcoe_dev_init_timeout * HZ); |
| 5566 | break; |
| 5567 | case QLA8XXX_DEV_FAILED: |
| 5568 | if (ha->flags.nic_core_reset_owner) |
| 5569 | qla83xx_idc_audit(base_vha, |
| 5570 | IDC_AUDIT_COMPLETION); |
| 5571 | ha->flags.nic_core_reset_owner = 0; |
| 5572 | __qla83xx_clear_drv_presence(base_vha); |
| 5573 | qla83xx_idc_unlock(base_vha, 0); |
| 5574 | qla8xxx_dev_failed_handler(base_vha); |
| 5575 | rval = QLA_FUNCTION_FAILED; |
| 5576 | qla83xx_idc_lock(base_vha, 0); |
| 5577 | goto exit; |
| 5578 | case QLA8XXX_BAD_VALUE: |
| 5579 | qla83xx_idc_unlock(base_vha, 0); |
| 5580 | msleep(1000); |
| 5581 | qla83xx_idc_lock(base_vha, 0); |
| 5582 | break; |
| 5583 | default: |
| 5584 | ql_log(ql_log_warn, base_vha, 0xb071, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 5585 | "Unknown Device State: %x.\n", dev_state); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5586 | qla83xx_idc_unlock(base_vha, 0); |
| 5587 | qla8xxx_dev_failed_handler(base_vha); |
| 5588 | rval = QLA_FUNCTION_FAILED; |
| 5589 | qla83xx_idc_lock(base_vha, 0); |
| 5590 | goto exit; |
| 5591 | } |
| 5592 | } |
| 5593 | |
| 5594 | exit: |
| 5595 | return rval; |
| 5596 | } |
| 5597 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5598 | void |
| 5599 | qla2x00_disable_board_on_pci_error(struct work_struct *work) |
| 5600 | { |
| 5601 | struct qla_hw_data *ha = container_of(work, struct qla_hw_data, |
| 5602 | board_disable); |
| 5603 | struct pci_dev *pdev = ha->pdev; |
| 5604 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5605 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5606 | /* |
| 5607 | * if UNLOAD flag is already set, then continue unload, |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 5608 | * where it was set first. |
| 5609 | */ |
| 5610 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5611 | return; |
| 5612 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5613 | ql_log(ql_log_warn, base_vha, 0x015b, |
| 5614 | "Disabling adapter.\n"); |
| 5615 | |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 5616 | if (!atomic_read(&pdev->enable_cnt)) { |
| 5617 | ql_log(ql_log_info, base_vha, 0xfffc, |
| 5618 | "PCI device disabled, no action req for PCI error=%lx\n", |
| 5619 | base_vha->pci_flags); |
| 5620 | return; |
| 5621 | } |
| 5622 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5623 | qla2x00_wait_for_sess_deletion(base_vha); |
| 5624 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5625 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 5626 | |
| 5627 | qla2x00_delete_all_vps(ha, base_vha); |
| 5628 | |
| 5629 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5630 | |
| 5631 | qla2x00_dfs_remove(base_vha); |
| 5632 | |
| 5633 | qla84xx_put_chip(base_vha); |
| 5634 | |
| 5635 | if (base_vha->timer_active) |
| 5636 | qla2x00_stop_timer(base_vha); |
| 5637 | |
| 5638 | base_vha->flags.online = 0; |
| 5639 | |
| 5640 | qla2x00_destroy_deferred_work(ha); |
| 5641 | |
| 5642 | /* |
| 5643 | * Do not try to stop beacon blink as it will issue a mailbox |
| 5644 | * command. |
| 5645 | */ |
| 5646 | qla2x00_free_sysfs_attr(base_vha, false); |
| 5647 | |
| 5648 | fc_remove_host(base_vha->host); |
| 5649 | |
| 5650 | scsi_remove_host(base_vha->host); |
| 5651 | |
| 5652 | base_vha->flags.init_done = 0; |
| 5653 | qla25xx_delete_queues(base_vha); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5654 | qla2x00_free_fcports(base_vha); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 5655 | qla2x00_free_irqs(base_vha); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5656 | qla2x00_mem_free(ha); |
| 5657 | qla82xx_md_free(base_vha); |
| 5658 | qla2x00_free_queues(ha); |
| 5659 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5660 | qla2x00_unmap_iobases(ha); |
| 5661 | |
| 5662 | pci_release_selected_regions(ha->pdev, ha->bars); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5663 | pci_disable_pcie_error_reporting(pdev); |
| 5664 | pci_disable_device(pdev); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5665 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 5666 | /* |
| 5667 | * Let qla2x00_remove_one cleanup qla_hw_data on device removal. |
| 5668 | */ |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5669 | } |
| 5670 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5671 | /************************************************************************** |
| 5672 | * qla2x00_do_dpc |
| 5673 | * This kernel thread is a task that is schedule by the interrupt handler |
| 5674 | * to perform the background processing for interrupts. |
| 5675 | * |
| 5676 | * Notes: |
| 5677 | * This task always run in the context of a kernel thread. It |
| 5678 | * is kick-off by the driver's detect code and starts up |
| 5679 | * up one per adapter. It immediately goes to sleep and waits for |
| 5680 | * some fibre event. When either the interrupt handler or |
| 5681 | * the timer routine detects a event it will one of the task |
| 5682 | * bits then wake us up. |
| 5683 | **************************************************************************/ |
| 5684 | static int |
| 5685 | qla2x00_do_dpc(void *data) |
| 5686 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5687 | scsi_qla_host_t *base_vha; |
| 5688 | struct qla_hw_data *ha; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5689 | uint32_t online; |
| 5690 | struct qla_qpair *qpair; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5691 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5692 | ha = (struct qla_hw_data *)data; |
| 5693 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5694 | |
Dongsheng Yang | 8698a74 | 2014-03-11 18:09:12 +0800 | [diff] [blame] | 5695 | set_user_nice(current, MIN_NICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5696 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5697 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5698 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5699 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 5700 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5701 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5702 | schedule(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5703 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5704 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 5705 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5706 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5707 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5708 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 5709 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5710 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5711 | } |
| 5712 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5713 | ha->dpc_active = 1; |
| 5714 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5715 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 5716 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 5717 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5718 | |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 5719 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5720 | break; |
| 5721 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5722 | qla2x00_do_work(base_vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5723 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5724 | if (IS_P3P_TYPE(ha)) { |
| 5725 | if (IS_QLA8044(ha)) { |
| 5726 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5727 | &base_vha->dpc_flags)) { |
| 5728 | qla8044_idc_lock(ha); |
| 5729 | qla8044_wr_direct(base_vha, |
| 5730 | QLA8044_CRB_DEV_STATE_INDEX, |
| 5731 | QLA8XXX_DEV_FAILED); |
| 5732 | qla8044_idc_unlock(ha); |
| 5733 | ql_log(ql_log_info, base_vha, 0x4004, |
| 5734 | "HW State: FAILED.\n"); |
| 5735 | qla8044_device_state_handler(base_vha); |
| 5736 | continue; |
| 5737 | } |
| 5738 | |
| 5739 | } else { |
| 5740 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5741 | &base_vha->dpc_flags)) { |
| 5742 | qla82xx_idc_lock(ha); |
| 5743 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
| 5744 | QLA8XXX_DEV_FAILED); |
| 5745 | qla82xx_idc_unlock(ha); |
| 5746 | ql_log(ql_log_info, base_vha, 0x0151, |
| 5747 | "HW State: FAILED.\n"); |
| 5748 | qla82xx_device_state_handler(base_vha); |
| 5749 | continue; |
| 5750 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5751 | } |
| 5752 | |
| 5753 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 5754 | &base_vha->dpc_flags)) { |
| 5755 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5756 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 5757 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5758 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 5759 | &base_vha->dpc_flags))) { |
| 5760 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 5761 | /* FCoE-ctx reset failed. |
| 5762 | * Escalate to chip-reset |
| 5763 | */ |
| 5764 | set_bit(ISP_ABORT_NEEDED, |
| 5765 | &base_vha->dpc_flags); |
| 5766 | } |
| 5767 | clear_bit(ABORT_ISP_ACTIVE, |
| 5768 | &base_vha->dpc_flags); |
| 5769 | } |
| 5770 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5771 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 5772 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5773 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5774 | } else if (IS_QLAFX00(ha)) { |
| 5775 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5776 | &base_vha->dpc_flags)) { |
| 5777 | ql_dbg(ql_dbg_dpc, base_vha, 0x4020, |
| 5778 | "Firmware Reset Recovery\n"); |
| 5779 | if (qlafx00_reset_initialize(base_vha)) { |
| 5780 | /* Failed. Abort isp later. */ |
| 5781 | if (!test_bit(UNLOADING, |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5782 | &base_vha->dpc_flags)) { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5783 | set_bit(ISP_UNRECOVERABLE, |
| 5784 | &base_vha->dpc_flags); |
| 5785 | ql_dbg(ql_dbg_dpc, base_vha, |
| 5786 | 0x4021, |
| 5787 | "Reset Recovery Failed\n"); |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5788 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5789 | } |
| 5790 | } |
| 5791 | |
| 5792 | if (test_and_clear_bit(FX00_TARGET_SCAN, |
| 5793 | &base_vha->dpc_flags)) { |
| 5794 | ql_dbg(ql_dbg_dpc, base_vha, 0x4022, |
| 5795 | "ISPFx00 Target Scan scheduled\n"); |
| 5796 | if (qlafx00_rescan_isp(base_vha)) { |
| 5797 | if (!test_bit(UNLOADING, |
| 5798 | &base_vha->dpc_flags)) |
| 5799 | set_bit(ISP_UNRECOVERABLE, |
| 5800 | &base_vha->dpc_flags); |
| 5801 | ql_dbg(ql_dbg_dpc, base_vha, 0x401e, |
| 5802 | "ISPFx00 Target Scan Failed\n"); |
| 5803 | } |
| 5804 | ql_dbg(ql_dbg_dpc, base_vha, 0x401f, |
| 5805 | "ISPFx00 Target Scan End\n"); |
| 5806 | } |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 5807 | if (test_and_clear_bit(FX00_HOST_INFO_RESEND, |
| 5808 | &base_vha->dpc_flags)) { |
| 5809 | ql_dbg(ql_dbg_dpc, base_vha, 0x4023, |
| 5810 | "ISPFx00 Host Info resend scheduled\n"); |
| 5811 | qlafx00_fx_disc(base_vha, |
| 5812 | &base_vha->hw->mr.fcport, |
| 5813 | FXDISC_REG_HOST_INFO); |
| 5814 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5815 | } |
| 5816 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 5817 | if (test_and_clear_bit(DETECT_SFP_CHANGE, |
| 5818 | &base_vha->dpc_flags) && |
| 5819 | !test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) { |
| 5820 | qla24xx_detect_sfp(base_vha); |
| 5821 | |
| 5822 | if (ha->flags.detected_lr_sfp != |
| 5823 | ha->flags.using_lr_setting) |
| 5824 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 5825 | } |
| 5826 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5827 | if (test_and_clear_bit(ISP_ABORT_NEEDED, |
| 5828 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5829 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5830 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 5831 | "ISP abort scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5832 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5833 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5834 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5835 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5836 | /* failed. retry later */ |
| 5837 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5838 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5839 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5840 | clear_bit(ABORT_ISP_ACTIVE, |
| 5841 | &base_vha->dpc_flags); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5842 | } |
| 5843 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5844 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 5845 | "ISP abort end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5846 | } |
| 5847 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 5848 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 5849 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5850 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 5851 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 5852 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5853 | if (IS_QLAFX00(ha)) |
| 5854 | goto loop_resync_check; |
| 5855 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5856 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5857 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 5858 | "Quiescence mode scheduled.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5859 | if (IS_P3P_TYPE(ha)) { |
| 5860 | if (IS_QLA82XX(ha)) |
| 5861 | qla82xx_device_state_handler(base_vha); |
| 5862 | if (IS_QLA8044(ha)) |
| 5863 | qla8044_device_state_handler(base_vha); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5864 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5865 | &base_vha->dpc_flags); |
| 5866 | if (!ha->flags.quiesce_owner) { |
| 5867 | qla2x00_perform_loop_resync(base_vha); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5868 | if (IS_QLA82XX(ha)) { |
| 5869 | qla82xx_idc_lock(ha); |
| 5870 | qla82xx_clear_qsnt_ready( |
| 5871 | base_vha); |
| 5872 | qla82xx_idc_unlock(ha); |
| 5873 | } else if (IS_QLA8044(ha)) { |
| 5874 | qla8044_idc_lock(ha); |
| 5875 | qla8044_clear_qsnt_ready( |
| 5876 | base_vha); |
| 5877 | qla8044_idc_unlock(ha); |
| 5878 | } |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5879 | } |
| 5880 | } else { |
| 5881 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5882 | &base_vha->dpc_flags); |
| 5883 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5884 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5885 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 5886 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5887 | } |
| 5888 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5889 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5890 | &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5891 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5892 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5893 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 5894 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5895 | qla2x00_rst_aen(base_vha); |
| 5896 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5897 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 5898 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5899 | } |
| 5900 | |
| 5901 | /* Retry each device up to login retry count */ |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 5902 | if (test_bit(RELOGIN_NEEDED, &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5903 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 5904 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5905 | |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 5906 | if (!base_vha->relogin_jif || |
| 5907 | time_after_eq(jiffies, base_vha->relogin_jif)) { |
| 5908 | base_vha->relogin_jif = jiffies + HZ; |
| 5909 | clear_bit(RELOGIN_NEEDED, &base_vha->dpc_flags); |
| 5910 | |
| 5911 | ql_dbg(ql_dbg_dpc, base_vha, 0x400d, |
| 5912 | "Relogin scheduled.\n"); |
| 5913 | qla2x00_relogin(base_vha); |
| 5914 | ql_dbg(ql_dbg_dpc, base_vha, 0x400e, |
| 5915 | "Relogin end.\n"); |
| 5916 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5917 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5918 | loop_resync_check: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5919 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5920 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5921 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5922 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 5923 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5924 | |
| 5925 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5926 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5927 | |
Bart Van Assche | 52c8282 | 2015-07-09 07:23:26 -0700 | [diff] [blame] | 5928 | qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5929 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5930 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 5931 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5932 | } |
| 5933 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5934 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 5935 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5936 | } |
| 5937 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5938 | if (IS_QLAFX00(ha)) |
| 5939 | goto intr_on_check; |
| 5940 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5941 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 5942 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 5943 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 5944 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 5945 | } |
| 5946 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5947 | intr_on_check: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5948 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 5949 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5950 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5951 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
Himanshu Madani | 90b604f | 2014-04-11 16:54:40 -0400 | [diff] [blame] | 5952 | &base_vha->dpc_flags)) { |
| 5953 | if (ha->beacon_blink_led == 1) |
| 5954 | ha->isp_ops->beacon_blink(base_vha); |
| 5955 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5956 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5957 | /* qpair online check */ |
| 5958 | if (test_and_clear_bit(QPAIR_ONLINE_CHECK_NEEDED, |
| 5959 | &base_vha->dpc_flags)) { |
| 5960 | if (ha->flags.eeh_busy || |
| 5961 | ha->flags.pci_channel_io_perm_failure) |
| 5962 | online = 0; |
| 5963 | else |
| 5964 | online = 1; |
| 5965 | |
| 5966 | mutex_lock(&ha->mq_lock); |
| 5967 | list_for_each_entry(qpair, &base_vha->qp_list, |
| 5968 | qp_list_elem) |
| 5969 | qpair->online = online; |
| 5970 | mutex_unlock(&ha->mq_lock); |
| 5971 | } |
| 5972 | |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 5973 | if (test_and_clear_bit(SET_ZIO_THRESHOLD_NEEDED, &base_vha->dpc_flags)) { |
| 5974 | ql_log(ql_log_info, base_vha, 0xffffff, |
| 5975 | "nvme: SET ZIO Activity exchange threshold to %d.\n", |
| 5976 | ha->nvme_last_rptd_aen); |
| 5977 | if (qla27xx_set_zio_threshold(base_vha, ha->nvme_last_rptd_aen)) { |
| 5978 | ql_log(ql_log_info, base_vha, 0xffffff, |
| 5979 | "nvme: Unable to SET ZIO Activity exchange threshold to %d.\n", |
| 5980 | ha->nvme_last_rptd_aen); |
| 5981 | } |
| 5982 | } |
| 5983 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5984 | if (!IS_QLAFX00(ha)) |
| 5985 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5986 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5987 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5988 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5989 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5990 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5991 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5992 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5993 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 5994 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5995 | |
| 5996 | /* |
| 5997 | * Make sure that nobody tries to wake us up again. |
| 5998 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5999 | ha->dpc_active = 0; |
| 6000 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 6001 | /* Cleanup any residual CTX SRBs. */ |
| 6002 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 6003 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 6004 | return 0; |
| 6005 | } |
| 6006 | |
| 6007 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6008 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 6009 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6010 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 6011 | struct task_struct *t = ha->dpc_thread; |
| 6012 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6013 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 6014 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6015 | } |
| 6016 | |
| 6017 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6018 | * qla2x00_rst_aen |
| 6019 | * Processes asynchronous reset. |
| 6020 | * |
| 6021 | * Input: |
| 6022 | * ha = adapter block pointer. |
| 6023 | */ |
| 6024 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6025 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6026 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6027 | if (vha->flags.online && !vha->flags.reset_active && |
| 6028 | !atomic_read(&vha->loop_down_timer) && |
| 6029 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6030 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6031 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6032 | |
| 6033 | /* |
| 6034 | * Issue marker command only when we are going to start |
| 6035 | * the I/O. |
| 6036 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6037 | vha->marker_needed = 1; |
| 6038 | } while (!atomic_read(&vha->loop_down_timer) && |
| 6039 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6040 | } |
| 6041 | } |
| 6042 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6043 | /************************************************************************** |
| 6044 | * qla2x00_timer |
| 6045 | * |
| 6046 | * Description: |
| 6047 | * One second timer |
| 6048 | * |
| 6049 | * Context: Interrupt |
| 6050 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6051 | void |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 6052 | qla2x00_timer(struct timer_list *t) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6053 | { |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 6054 | scsi_qla_host_t *vha = from_timer(vha, t, timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6055 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6056 | int start_dpc = 0; |
| 6057 | int index; |
| 6058 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6059 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6060 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 6061 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6062 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6063 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6064 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 6065 | "EEH = %d, restarting timer.\n", |
| 6066 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6067 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 6068 | return; |
| 6069 | } |
| 6070 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6071 | /* |
| 6072 | * Hardware read to raise pending EEH errors during mailbox waits. If |
| 6073 | * the read returns -1 then disable the board. |
| 6074 | */ |
| 6075 | if (!pci_channel_offline(ha->pdev)) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6076 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Joe Lawrence | c821e0d | 2014-08-26 17:11:41 -0400 | [diff] [blame] | 6077 | qla2x00_check_reg16_for_disconnect(vha, w); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6078 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6079 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 6080 | /* Make sure qla82xx_watchdog is run only for physical port */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6081 | if (!vha->vp_idx && IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6082 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 6083 | start_dpc++; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6084 | if (IS_QLA82XX(ha)) |
| 6085 | qla82xx_watchdog(vha); |
| 6086 | else if (IS_QLA8044(ha)) |
| 6087 | qla8044_watchdog(vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6088 | } |
| 6089 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6090 | if (!vha->vp_idx && IS_QLAFX00(ha)) |
| 6091 | qlafx00_timer_routine(vha); |
| 6092 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6093 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6094 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 6095 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 6096 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6097 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6098 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6099 | if (atomic_read(&vha->loop_down_timer) == |
| 6100 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6101 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6102 | ql_log(ql_log_info, vha, 0x6008, |
| 6103 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6104 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6105 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 6106 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6107 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 6108 | /* |
| 6109 | * Schedule an ISP abort to return any FCP2-device |
| 6110 | * commands. |
| 6111 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6112 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6113 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6114 | spin_lock_irqsave(&ha->hardware_lock, |
| 6115 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 6116 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6117 | for (index = 1; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 6118 | index < req->num_outstanding_cmds; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6119 | index++) { |
| 6120 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 6121 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6122 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6123 | if (!sp) |
| 6124 | continue; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 6125 | if (sp->cmd_type != TYPE_SRB) |
| 6126 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 6127 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 6128 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6129 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 6130 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6131 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6132 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 6133 | if (IS_QLA82XX(ha)) |
| 6134 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 6135 | &vha->dpc_flags); |
| 6136 | else |
| 6137 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6138 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6139 | break; |
| 6140 | } |
| 6141 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6142 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6143 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6144 | start_dpc++; |
| 6145 | } |
| 6146 | |
| 6147 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6148 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 6149 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6150 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6151 | "Loop down - aborting ISP.\n"); |
| 6152 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 6153 | if (IS_QLA82XX(ha)) |
| 6154 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 6155 | &vha->dpc_flags); |
| 6156 | else |
| 6157 | set_bit(ISP_ABORT_NEEDED, |
| 6158 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6159 | } |
| 6160 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6161 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 6162 | "Loop down - seconds remaining %d.\n", |
| 6163 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6164 | } |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 6165 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 6166 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 6167 | /* There is no beacon_blink function for ISP82xx */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6168 | if (!IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 6169 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 6170 | start_dpc++; |
| 6171 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 6172 | } |
| 6173 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 6174 | /* Process any deferred work. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6175 | if (!list_empty(&vha->work_list)) |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 6176 | start_dpc++; |
| 6177 | |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 6178 | /* |
| 6179 | * FC-NVME |
| 6180 | * see if the active AEN count has changed from what was last reported. |
| 6181 | */ |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6182 | if (!vha->vp_idx && |
| 6183 | atomic_read(&ha->nvme_active_aen_cnt) != ha->nvme_last_rptd_aen && |
| 6184 | ha->zio_mode == QLA_ZIO_MODE_6) { |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 6185 | ql_log(ql_log_info, vha, 0x3002, |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6186 | "nvme: Sched: Set ZIO exchange threshold to %d.\n", |
| 6187 | ha->nvme_last_rptd_aen); |
| 6188 | ha->nvme_last_rptd_aen = atomic_read(&ha->nvme_active_aen_cnt); |
| 6189 | set_bit(SET_ZIO_THRESHOLD_NEEDED, &vha->dpc_flags); |
| 6190 | start_dpc++; |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 6191 | } |
| 6192 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6193 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6194 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 6195 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 6196 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6197 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6198 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 6199 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6200 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 6201 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6202 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 6203 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6204 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 6205 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 6206 | "fcport_update_needed=%d start_dpc=%d " |
| 6207 | "reset_marker_needed=%d", |
| 6208 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 6209 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 6210 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 6211 | start_dpc, |
| 6212 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 6213 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 6214 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 6215 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 6216 | "relogin_needed=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6217 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 6218 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 6219 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 6220 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 6221 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6222 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6223 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6224 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6225 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6226 | } |
| 6227 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6228 | /* Firmware interface routines. */ |
| 6229 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6230 | #define FW_BLOBS 11 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6231 | #define FW_ISP21XX 0 |
| 6232 | #define FW_ISP22XX 1 |
| 6233 | #define FW_ISP2300 2 |
| 6234 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6235 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6236 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6237 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6238 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6239 | #define FW_ISP2031 8 |
| 6240 | #define FW_ISP8031 9 |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6241 | #define FW_ISP27XX 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6242 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6243 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 6244 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 6245 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 6246 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 6247 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6248 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6249 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6250 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6251 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 6252 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6253 | #define FW_FILE_ISP27XX "ql2700_fw.bin" |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6254 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6255 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6256 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6257 | |
| 6258 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6259 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 6260 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 6261 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 6262 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 6263 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6264 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6265 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6266 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6267 | { .name = FW_FILE_ISP2031, }, |
| 6268 | { .name = FW_FILE_ISP8031, }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6269 | { .name = FW_FILE_ISP27XX, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6270 | }; |
| 6271 | |
| 6272 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6273 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6274 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6275 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6276 | struct fw_blob *blob; |
| 6277 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6278 | if (IS_QLA2100(ha)) { |
| 6279 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 6280 | } else if (IS_QLA2200(ha)) { |
| 6281 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6282 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6283 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6284 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6285 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 6286 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6287 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6288 | } else if (IS_QLA25XX(ha)) { |
| 6289 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6290 | } else if (IS_QLA81XX(ha)) { |
| 6291 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6292 | } else if (IS_QLA82XX(ha)) { |
| 6293 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6294 | } else if (IS_QLA2031(ha)) { |
| 6295 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 6296 | } else if (IS_QLA8031(ha)) { |
| 6297 | blob = &qla_fw_blobs[FW_ISP8031]; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6298 | } else if (IS_QLA27XX(ha)) { |
| 6299 | blob = &qla_fw_blobs[FW_ISP27XX]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 6300 | } else { |
| 6301 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6302 | } |
| 6303 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6304 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6305 | if (blob->fw) |
| 6306 | goto out; |
| 6307 | |
| 6308 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6309 | ql_log(ql_log_warn, vha, 0x0063, |
| 6310 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6311 | blob->fw = NULL; |
| 6312 | blob = NULL; |
| 6313 | goto out; |
| 6314 | } |
| 6315 | |
| 6316 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6317 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6318 | return blob; |
| 6319 | } |
| 6320 | |
| 6321 | static void |
| 6322 | qla2x00_release_firmware(void) |
| 6323 | { |
| 6324 | int idx; |
| 6325 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6326 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6327 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 6328 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6329 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6330 | } |
| 6331 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6332 | static pci_ers_result_t |
| 6333 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 6334 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6335 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 6336 | struct qla_hw_data *ha = vha->hw; |
| 6337 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6338 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 6339 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 6340 | |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 6341 | if (!atomic_read(&pdev->enable_cnt)) { |
| 6342 | ql_log(ql_log_info, vha, 0xffff, |
| 6343 | "PCI device is disabled,state %x\n", state); |
| 6344 | return PCI_ERS_RESULT_NEED_RESET; |
| 6345 | } |
| 6346 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6347 | switch (state) { |
| 6348 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6349 | ha->flags.eeh_busy = 0; |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 6350 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6351 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6352 | qla2xxx_wake_dpc(vha); |
| 6353 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6354 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 6355 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6356 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6357 | /* For ISP82XX complete any pending mailbox cmd */ |
| 6358 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6359 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 6360 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 6361 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6362 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6363 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6364 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 6365 | /* Return back all IOs */ |
| 6366 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 6367 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6368 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6369 | qla2xxx_wake_dpc(vha); |
| 6370 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6371 | return PCI_ERS_RESULT_NEED_RESET; |
| 6372 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6373 | ha->flags.pci_channel_io_perm_failure = 1; |
| 6374 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 6375 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6376 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6377 | qla2xxx_wake_dpc(vha); |
| 6378 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6379 | return PCI_ERS_RESULT_DISCONNECT; |
| 6380 | } |
| 6381 | return PCI_ERS_RESULT_NEED_RESET; |
| 6382 | } |
| 6383 | |
| 6384 | static pci_ers_result_t |
| 6385 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 6386 | { |
| 6387 | int risc_paused = 0; |
| 6388 | uint32_t stat; |
| 6389 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6390 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6391 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6392 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 6393 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 6394 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 6395 | if (IS_QLA82XX(ha)) |
| 6396 | return PCI_ERS_RESULT_RECOVERED; |
| 6397 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6398 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 6399 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 6400 | stat = RD_REG_DWORD(®->hccr); |
| 6401 | if (stat & HCCR_RISC_PAUSE) |
| 6402 | risc_paused = 1; |
| 6403 | } else if (IS_QLA23XX(ha)) { |
| 6404 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 6405 | if (stat & HSR_RISC_PAUSED) |
| 6406 | risc_paused = 1; |
| 6407 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 6408 | stat = RD_REG_DWORD(®24->host_status); |
| 6409 | if (stat & HSRX_RISC_PAUSED) |
| 6410 | risc_paused = 1; |
| 6411 | } |
| 6412 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 6413 | |
| 6414 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6415 | ql_log(ql_log_info, base_vha, 0x9003, |
| 6416 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6417 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6418 | |
| 6419 | return PCI_ERS_RESULT_NEED_RESET; |
| 6420 | } else |
| 6421 | return PCI_ERS_RESULT_RECOVERED; |
| 6422 | } |
| 6423 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 6424 | static uint32_t |
| 6425 | qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6426 | { |
| 6427 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 6428 | uint32_t drv_active = 0; |
| 6429 | struct qla_hw_data *ha = base_vha->hw; |
| 6430 | int fn; |
| 6431 | struct pci_dev *other_pdev = NULL; |
| 6432 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6433 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 6434 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6435 | |
| 6436 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 6437 | |
| 6438 | if (base_vha->flags.online) { |
| 6439 | /* Abort all outstanding commands, |
| 6440 | * so as to be requeued later */ |
| 6441 | qla2x00_abort_isp_cleanup(base_vha); |
| 6442 | } |
| 6443 | |
| 6444 | |
| 6445 | fn = PCI_FUNC(ha->pdev->devfn); |
| 6446 | while (fn > 0) { |
| 6447 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6448 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 6449 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6450 | other_pdev = |
| 6451 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 6452 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 6453 | fn)); |
| 6454 | |
| 6455 | if (!other_pdev) |
| 6456 | continue; |
| 6457 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6458 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 6459 | "Found PCI func available and enable at 0x%x.\n", |
| 6460 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6461 | pci_dev_put(other_pdev); |
| 6462 | break; |
| 6463 | } |
| 6464 | pci_dev_put(other_pdev); |
| 6465 | } |
| 6466 | |
| 6467 | if (!fn) { |
| 6468 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6469 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 6470 | "This devfn is reset owner = 0x%x.\n", |
| 6471 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6472 | qla82xx_idc_lock(ha); |
| 6473 | |
| 6474 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6475 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6476 | |
| 6477 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 6478 | QLA82XX_IDC_VERSION); |
| 6479 | |
| 6480 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6481 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 6482 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6483 | |
| 6484 | qla82xx_idc_unlock(ha); |
| 6485 | /* Reset if device is not already reset |
| 6486 | * drv_active would be 0 if a reset has already been done |
| 6487 | */ |
| 6488 | if (drv_active) |
| 6489 | rval = qla82xx_start_firmware(base_vha); |
| 6490 | else |
| 6491 | rval = QLA_SUCCESS; |
| 6492 | qla82xx_idc_lock(ha); |
| 6493 | |
| 6494 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6495 | ql_log(ql_log_info, base_vha, 0x900b, |
| 6496 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6497 | qla82xx_clear_drv_active(ha); |
| 6498 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6499 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6500 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6501 | ql_log(ql_log_info, base_vha, 0x900c, |
| 6502 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6503 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6504 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6505 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6506 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6507 | rval = qla82xx_restart_isp(base_vha); |
| 6508 | qla82xx_idc_lock(ha); |
| 6509 | /* Clear driver state register */ |
| 6510 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 6511 | qla82xx_set_drv_active(base_vha); |
| 6512 | } |
| 6513 | qla82xx_idc_unlock(ha); |
| 6514 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6515 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 6516 | "This devfn is not reset owner = 0x%x.\n", |
| 6517 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6518 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6519 | QLA8XXX_DEV_READY)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6520 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6521 | rval = qla82xx_restart_isp(base_vha); |
| 6522 | qla82xx_idc_lock(ha); |
| 6523 | qla82xx_set_drv_active(base_vha); |
| 6524 | qla82xx_idc_unlock(ha); |
| 6525 | } |
| 6526 | } |
| 6527 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 6528 | |
| 6529 | return rval; |
| 6530 | } |
| 6531 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6532 | static pci_ers_result_t |
| 6533 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 6534 | { |
| 6535 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6536 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6537 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6538 | struct rsp_que *rsp; |
| 6539 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6540 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6541 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 6542 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6543 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6544 | /* Workaround: qla2xxx driver which access hardware earlier |
| 6545 | * needs error state to be pci_channel_io_online. |
| 6546 | * Otherwise mailbox command timesout. |
| 6547 | */ |
| 6548 | pdev->error_state = pci_channel_io_normal; |
| 6549 | |
| 6550 | pci_restore_state(pdev); |
| 6551 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 6552 | /* pci_restore_state() clears the saved_state flag of the device |
| 6553 | * save restored state which resets saved_state flag |
| 6554 | */ |
| 6555 | pci_save_state(pdev); |
| 6556 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 6557 | if (ha->mem_only) |
| 6558 | rc = pci_enable_device_mem(pdev); |
| 6559 | else |
| 6560 | rc = pci_enable_device(pdev); |
| 6561 | |
| 6562 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6563 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6564 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6565 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6566 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6567 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6568 | rsp = ha->rsp_q_map[0]; |
| 6569 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6570 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6571 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6572 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6573 | goto exit_slot_reset; |
| 6574 | |
| 6575 | if (IS_QLA82XX(ha)) { |
| 6576 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 6577 | ret = PCI_ERS_RESULT_RECOVERED; |
| 6578 | goto exit_slot_reset; |
| 6579 | } else |
| 6580 | goto exit_slot_reset; |
| 6581 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6582 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6583 | while (ha->flags.mbox_busy && retries--) |
| 6584 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6585 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6586 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6587 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6588 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6589 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6590 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6591 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6592 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6593 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 6594 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6595 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6596 | return ret; |
| 6597 | } |
| 6598 | |
| 6599 | static void |
| 6600 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 6601 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6602 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6603 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6604 | int ret; |
| 6605 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6606 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 6607 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6608 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6609 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6610 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6611 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 6612 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6613 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6614 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 6615 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 6616 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6617 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6618 | } |
| 6619 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 6620 | static void |
| 6621 | qla83xx_disable_laser(scsi_qla_host_t *vha) |
| 6622 | { |
| 6623 | uint32_t reg, data, fn; |
| 6624 | struct qla_hw_data *ha = vha->hw; |
| 6625 | struct device_reg_24xx __iomem *isp_reg = &ha->iobase->isp24; |
| 6626 | |
| 6627 | /* pci func #/port # */ |
| 6628 | ql_dbg(ql_dbg_init, vha, 0x004b, |
| 6629 | "Disabling Laser for hba: %p\n", vha); |
| 6630 | |
| 6631 | fn = (RD_REG_DWORD(&isp_reg->ctrl_status) & |
| 6632 | (BIT_15|BIT_14|BIT_13|BIT_12)); |
| 6633 | |
| 6634 | fn = (fn >> 12); |
| 6635 | |
| 6636 | if (fn & 1) |
| 6637 | reg = PORT_1_2031; |
| 6638 | else |
| 6639 | reg = PORT_0_2031; |
| 6640 | |
| 6641 | data = LASER_OFF_2031; |
| 6642 | |
| 6643 | qla83xx_wr_reg(vha, reg, data); |
| 6644 | } |
| 6645 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 6646 | static int qla2xxx_map_queues(struct Scsi_Host *shost) |
| 6647 | { |
Quinn Tran | d68b850 | 2017-12-04 14:44:59 -0800 | [diff] [blame] | 6648 | int rc; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 6649 | scsi_qla_host_t *vha = (scsi_qla_host_t *)shost->hostdata; |
| 6650 | |
Quinn Tran | d68b850 | 2017-12-04 14:44:59 -0800 | [diff] [blame] | 6651 | if (USER_CTRL_IRQ(vha->hw)) |
| 6652 | rc = blk_mq_map_queues(&shost->tag_set); |
| 6653 | else |
| 6654 | rc = blk_mq_pci_map_queues(&shost->tag_set, vha->hw->pdev); |
| 6655 | return rc; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 6656 | } |
| 6657 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 6658 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6659 | .error_detected = qla2xxx_pci_error_detected, |
| 6660 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 6661 | .slot_reset = qla2xxx_pci_slot_reset, |
| 6662 | .resume = qla2xxx_pci_resume, |
| 6663 | }; |
| 6664 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6665 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 6666 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 6667 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 6668 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 6669 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 6670 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 6671 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 6672 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 6673 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 6674 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 6675 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 6676 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 6677 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6678 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6679 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6680 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6681 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 6682 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6683 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISPF001) }, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6684 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8044) }, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6685 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2071) }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6686 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2271) }, |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 6687 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2261) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6688 | { 0 }, |
| 6689 | }; |
| 6690 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 6691 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6692 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 6693 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 6694 | .driver = { |
| 6695 | .owner = THIS_MODULE, |
| 6696 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6697 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6698 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 6699 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 6700 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6701 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6702 | }; |
| 6703 | |
Al Viro | 75ef9de | 2013-04-04 19:09:41 -0400 | [diff] [blame] | 6704 | static const struct file_operations apidev_fops = { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6705 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 6706 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6707 | }; |
| 6708 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6709 | /** |
| 6710 | * qla2x00_module_init - Module initialization. |
| 6711 | **/ |
| 6712 | static int __init |
| 6713 | qla2x00_module_init(void) |
| 6714 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6715 | int ret = 0; |
| 6716 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6717 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6718 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 6719 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6720 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6721 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 6722 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6723 | return -ENOMEM; |
| 6724 | } |
| 6725 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6726 | /* Initialize target kmem_cache and mem_pools */ |
| 6727 | ret = qlt_init(); |
| 6728 | if (ret < 0) { |
| 6729 | kmem_cache_destroy(srb_cachep); |
| 6730 | return ret; |
| 6731 | } else if (ret > 0) { |
| 6732 | /* |
| 6733 | * If initiator mode is explictly disabled by qlt_init(), |
| 6734 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 6735 | * performing scsi_scan_target() during LOOP UP event. |
| 6736 | */ |
| 6737 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 6738 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 6739 | } |
| 6740 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6741 | /* Derive version string. */ |
| 6742 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 6743 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 6744 | strcat(qla2x00_version_str, "-debug"); |
Joe Carnuccio | fed0f68 | 2017-08-23 15:05:10 -0700 | [diff] [blame] | 6745 | if (ql2xextended_error_logging == 1) |
| 6746 | ql2xextended_error_logging = QL_DBG_DEFAULT1_MASK; |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 6747 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 6748 | qla2xxx_transport_template = |
| 6749 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6750 | if (!qla2xxx_transport_template) { |
| 6751 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6752 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 6753 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6754 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6755 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6756 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6757 | |
| 6758 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 6759 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6760 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 6761 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6762 | } |
| 6763 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6764 | qla2xxx_transport_vport_template = |
| 6765 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 6766 | if (!qla2xxx_transport_vport_template) { |
| 6767 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6768 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6769 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6770 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 6771 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6772 | return -ENODEV; |
| 6773 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6774 | ql_log(ql_log_info, NULL, 0x0005, |
| 6775 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 6776 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6777 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6778 | if (ret) { |
| 6779 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6780 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6781 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6782 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6783 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 6784 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 6785 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6786 | } |
| 6787 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6788 | } |
| 6789 | |
| 6790 | /** |
| 6791 | * qla2x00_module_exit - Module cleanup. |
| 6792 | **/ |
| 6793 | static void __exit |
| 6794 | qla2x00_module_exit(void) |
| 6795 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6796 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6797 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6798 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6799 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6800 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6801 | if (ctx_cachep) |
| 6802 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6803 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6804 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6805 | } |
| 6806 | |
| 6807 | module_init(qla2x00_module_init); |
| 6808 | module_exit(qla2x00_module_exit); |
| 6809 | |
| 6810 | MODULE_AUTHOR("QLogic Corporation"); |
| 6811 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 6812 | MODULE_LICENSE("GPL"); |
| 6813 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6814 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 6815 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 6816 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 6817 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 6818 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 6819 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |