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 | |
Quinn Tran | 9ecf0b0 | 2017-12-28 12:33:19 -0800 | [diff] [blame] | 280 | int qla2xuseresexchforels; |
| 281 | module_param(qla2xuseresexchforels, int, 0444); |
| 282 | MODULE_PARM_DESC(qla2xuseresexchforels, |
| 283 | "Reserve 1/2 of emergency exchanges for ELS.\n" |
| 284 | " 0 (default): disabled"); |
| 285 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 287 | * SCSI host template entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | */ |
| 289 | static int qla2xxx_slave_configure(struct scsi_device * device); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 290 | static int qla2xxx_slave_alloc(struct scsi_device *); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 291 | static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); |
| 292 | static void qla2xxx_scan_start(struct Scsi_Host *); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 293 | static void qla2xxx_slave_destroy(struct scsi_device *); |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 294 | static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | static int qla2xxx_eh_abort(struct scsi_cmnd *); |
| 296 | static int qla2xxx_eh_device_reset(struct scsi_cmnd *); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 297 | static int qla2xxx_eh_target_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); |
| 299 | static int qla2xxx_eh_host_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 301 | static void qla2x00_clear_drv_active(struct qla_hw_data *); |
Saurav Kashyap | 3491255 | 2013-06-25 11:27:18 -0400 | [diff] [blame] | 302 | static void qla2x00_free_device(scsi_qla_host_t *); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 303 | static int qla2xxx_map_queues(struct Scsi_Host *shost); |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 304 | static void qla2x00_destroy_deferred_work(struct qla_hw_data *); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 305 | |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 306 | |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 307 | struct scsi_host_template qla2xxx_driver_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | .module = THIS_MODULE, |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 309 | .name = QLA2XXX_DRIVER_NAME, |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 310 | .queuecommand = qla2xxx_queuecommand, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 311 | |
Christoph Hellwig | b6a05c8 | 2017-01-30 13:18:58 +0100 | [diff] [blame] | 312 | .eh_timed_out = fc_eh_timed_out, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 313 | .eh_abort_handler = qla2xxx_eh_abort, |
| 314 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 315 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 316 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 317 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 318 | |
| 319 | .slave_configure = qla2xxx_slave_configure, |
| 320 | |
| 321 | .slave_alloc = qla2xxx_slave_alloc, |
| 322 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 323 | .scan_finished = qla2xxx_scan_finished, |
| 324 | .scan_start = qla2xxx_scan_start, |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 325 | .change_queue_depth = scsi_change_queue_depth, |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 326 | .map_queues = qla2xxx_map_queues, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 327 | .this_id = -1, |
| 328 | .cmd_per_lun = 3, |
| 329 | .use_clustering = ENABLE_CLUSTERING, |
| 330 | .sg_tablesize = SG_ALL, |
| 331 | |
| 332 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 333 | .shost_attrs = qla2x00_host_attrs, |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 334 | |
| 335 | .supported_mode = MODE_INITIATOR, |
Christoph Hellwig | c40ecc1 | 2014-11-13 14:25:11 +0100 | [diff] [blame] | 336 | .track_queue_depth = 1, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 337 | }; |
| 338 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 340 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | /* TODO Convert to inlines |
| 343 | * |
| 344 | * Timer routines |
| 345 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 347 | __inline__ void |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 348 | qla2x00_start_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | { |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 350 | timer_setup(&vha->timer, qla2x00_timer, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 351 | vha->timer.expires = jiffies + interval * HZ; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 352 | add_timer(&vha->timer); |
| 353 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 357 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 359 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 360 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 361 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 362 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 363 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 364 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 365 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 366 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | } |
| 368 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 369 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 370 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 372 | del_timer_sync(&vha->timer); |
| 373 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | } |
| 375 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | static int qla2x00_do_dpc(void *data); |
| 377 | |
| 378 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 379 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 380 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 381 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 382 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 383 | static void qla2x00_mem_free(struct qla_hw_data *); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 384 | int qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 385 | struct qla_qpair *qpair); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | /* -------------------------------------------------------------------------- */ |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 388 | static void qla_init_base_qpair(struct scsi_qla_host *vha, struct req_que *req, |
| 389 | struct rsp_que *rsp) |
| 390 | { |
| 391 | struct qla_hw_data *ha = vha->hw; |
| 392 | rsp->qpair = ha->base_qpair; |
| 393 | rsp->req = req; |
Quinn Tran | 0691094 | 2018-09-04 14:19:12 -0700 | [diff] [blame] | 394 | ha->base_qpair->hw = ha; |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 395 | ha->base_qpair->req = req; |
| 396 | ha->base_qpair->rsp = rsp; |
| 397 | ha->base_qpair->vha = vha; |
| 398 | ha->base_qpair->qp_lock_ptr = &ha->hardware_lock; |
| 399 | ha->base_qpair->use_shadow_reg = IS_SHADOW_REG_CAPABLE(ha) ? 1 : 0; |
| 400 | ha->base_qpair->msix = &ha->msix_entries[QLA_MSIX_RSP_Q]; |
Quinn Tran | 6a62946 | 2018-09-04 14:19:15 -0700 | [diff] [blame] | 401 | ha->base_qpair->srb_mempool = ha->srb_mempool; |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 402 | INIT_LIST_HEAD(&ha->base_qpair->hints_list); |
| 403 | ha->base_qpair->enable_class_2 = ql2xenableclass2; |
| 404 | /* init qpair to this cpu. Will adjust at run time. */ |
Bart Van Assche | 8653188 | 2017-11-06 11:59:05 -0800 | [diff] [blame] | 405 | qla_cpu_update(rsp->qpair, raw_smp_processor_id()); |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 406 | ha->base_qpair->pdev = ha->pdev; |
| 407 | |
| 408 | if (IS_QLA27XX(ha) || IS_QLA83XX(ha)) |
| 409 | ha->base_qpair->reqq_start_iocbs = qla_83xx_start_iocbs; |
| 410 | } |
| 411 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 412 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 413 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 414 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 415 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 416 | ha->req_q_map = kcalloc(ha->max_req_queues, sizeof(struct req_que *), |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 417 | GFP_KERNEL); |
| 418 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 419 | ql_log(ql_log_fatal, vha, 0x003b, |
| 420 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 421 | goto fail_req_map; |
| 422 | } |
| 423 | |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 424 | ha->rsp_q_map = kcalloc(ha->max_rsp_queues, sizeof(struct rsp_que *), |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 425 | GFP_KERNEL); |
| 426 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 427 | ql_log(ql_log_fatal, vha, 0x003c, |
| 428 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 429 | goto fail_rsp_map; |
| 430 | } |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 431 | |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 432 | ha->base_qpair = kzalloc(sizeof(struct qla_qpair), GFP_KERNEL); |
| 433 | if (ha->base_qpair == NULL) { |
| 434 | ql_log(ql_log_warn, vha, 0x00e0, |
| 435 | "Failed to allocate base queue pair memory.\n"); |
| 436 | goto fail_base_qpair; |
| 437 | } |
| 438 | |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 439 | qla_init_base_qpair(vha, req, rsp); |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 440 | |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 441 | if ((ql2xmqsupport || ql2xnvmeenable) && ha->max_qpairs) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 442 | ha->queue_pair_map = kcalloc(ha->max_qpairs, sizeof(struct qla_qpair *), |
| 443 | GFP_KERNEL); |
| 444 | if (!ha->queue_pair_map) { |
| 445 | ql_log(ql_log_fatal, vha, 0x0180, |
| 446 | "Unable to allocate memory for queue pair ptrs.\n"); |
| 447 | goto fail_qpair_map; |
| 448 | } |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 449 | } |
| 450 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 451 | /* |
| 452 | * Make sure we record at least the request and response queue zero in |
| 453 | * case we need to free them if part of the probe fails. |
| 454 | */ |
| 455 | ha->rsp_q_map[0] = rsp; |
| 456 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 457 | set_bit(0, ha->rsp_qid_map); |
| 458 | set_bit(0, ha->req_qid_map); |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 459 | return 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 460 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 461 | fail_qpair_map: |
Quinn Tran | 82de802 | 2017-06-13 20:47:17 -0700 | [diff] [blame] | 462 | kfree(ha->base_qpair); |
| 463 | ha->base_qpair = NULL; |
| 464 | fail_base_qpair: |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 465 | kfree(ha->rsp_q_map); |
| 466 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 467 | fail_rsp_map: |
| 468 | kfree(ha->req_q_map); |
| 469 | ha->req_q_map = NULL; |
| 470 | fail_req_map: |
| 471 | return -ENOMEM; |
| 472 | } |
| 473 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 474 | 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] | 475 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 476 | if (IS_QLAFX00(ha)) { |
| 477 | if (req && req->ring_fx00) |
| 478 | dma_free_coherent(&ha->pdev->dev, |
| 479 | (req->length_fx00 + 1) * sizeof(request_t), |
| 480 | req->ring_fx00, req->dma_fx00); |
| 481 | } else if (req && req->ring) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 482 | dma_free_coherent(&ha->pdev->dev, |
| 483 | (req->length + 1) * sizeof(request_t), |
| 484 | req->ring, req->dma); |
| 485 | |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 486 | if (req) |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 487 | kfree(req->outstanding_cmds); |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 488 | |
| 489 | kfree(req); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 490 | } |
| 491 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 492 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 493 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 494 | if (IS_QLAFX00(ha)) { |
Meelis Roos | 3f6c9be | 2018-03-08 15:44:37 +0200 | [diff] [blame] | 495 | if (rsp && rsp->ring_fx00) |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 496 | dma_free_coherent(&ha->pdev->dev, |
| 497 | (rsp->length_fx00 + 1) * sizeof(request_t), |
| 498 | rsp->ring_fx00, rsp->dma_fx00); |
| 499 | } else if (rsp && rsp->ring) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 500 | dma_free_coherent(&ha->pdev->dev, |
| 501 | (rsp->length + 1) * sizeof(response_t), |
| 502 | rsp->ring, rsp->dma); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 503 | } |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 504 | kfree(rsp); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 505 | } |
| 506 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 507 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 508 | { |
| 509 | struct req_que *req; |
| 510 | struct rsp_que *rsp; |
| 511 | int cnt; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 512 | unsigned long flags; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 513 | |
Quinn Tran | 82de802 | 2017-06-13 20:47:17 -0700 | [diff] [blame] | 514 | if (ha->queue_pair_map) { |
| 515 | kfree(ha->queue_pair_map); |
| 516 | ha->queue_pair_map = NULL; |
| 517 | } |
| 518 | if (ha->base_qpair) { |
| 519 | kfree(ha->base_qpair); |
| 520 | ha->base_qpair = NULL; |
| 521 | } |
| 522 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 523 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 524 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 525 | if (!test_bit(cnt, ha->req_qid_map)) |
| 526 | continue; |
| 527 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 528 | req = ha->req_q_map[cnt]; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 529 | clear_bit(cnt, ha->req_qid_map); |
| 530 | ha->req_q_map[cnt] = NULL; |
| 531 | |
| 532 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 533 | qla2x00_free_req_que(ha, req); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 534 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 535 | } |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 536 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 537 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 538 | kfree(ha->req_q_map); |
| 539 | ha->req_q_map = NULL; |
| 540 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 541 | |
| 542 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 543 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 544 | if (!test_bit(cnt, ha->rsp_qid_map)) |
| 545 | continue; |
| 546 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 547 | rsp = ha->rsp_q_map[cnt]; |
Dave Jones | c3c4239 | 2016-12-27 13:13:21 -0500 | [diff] [blame] | 548 | clear_bit(cnt, ha->rsp_qid_map); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 549 | ha->rsp_q_map[cnt] = NULL; |
| 550 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 551 | qla2x00_free_rsp_que(ha, rsp); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 552 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 553 | } |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 554 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 555 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 556 | kfree(ha->rsp_q_map); |
| 557 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 558 | } |
| 559 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 561 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 563 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | static char *pci_bus_modes[] = { |
| 565 | "33", "66", "100", "133", |
| 566 | }; |
| 567 | uint16_t pci_bus; |
| 568 | |
| 569 | strcpy(str, "PCI"); |
| 570 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 571 | if (pci_bus) { |
| 572 | strcat(str, "-X ("); |
| 573 | strcat(str, pci_bus_modes[pci_bus]); |
| 574 | } else { |
| 575 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 576 | strcat(str, " ("); |
| 577 | strcat(str, pci_bus_modes[pci_bus]); |
| 578 | } |
| 579 | strcat(str, " MHz)"); |
| 580 | |
| 581 | return (str); |
| 582 | } |
| 583 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 584 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 585 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 586 | { |
| 587 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 588 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 589 | uint32_t pci_bus; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 590 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 591 | if (pci_is_pcie(ha->pdev)) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 592 | char lwstr[6]; |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 593 | uint32_t lstat, lspeed, lwidth; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 594 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 595 | pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); |
| 596 | lspeed = lstat & PCI_EXP_LNKCAP_SLS; |
| 597 | lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 598 | |
| 599 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 600 | switch (lspeed) { |
| 601 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 602 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 603 | break; |
| 604 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 605 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 606 | break; |
| 607 | case 3: |
| 608 | strcat(str, "8.0GT/s "); |
| 609 | break; |
| 610 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 611 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 612 | break; |
| 613 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 614 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 615 | strcat(str, lwstr); |
| 616 | |
| 617 | return str; |
| 618 | } |
| 619 | |
| 620 | strcpy(str, "PCI"); |
| 621 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 622 | if (pci_bus == 0 || pci_bus == 8) { |
| 623 | strcat(str, " ("); |
| 624 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 625 | } else { |
| 626 | strcat(str, "-X "); |
| 627 | if (pci_bus & BIT_2) |
| 628 | strcat(str, "Mode 2"); |
| 629 | else |
| 630 | strcat(str, "Mode 1"); |
| 631 | strcat(str, " ("); |
| 632 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 633 | } |
| 634 | strcat(str, " MHz)"); |
| 635 | |
| 636 | return str; |
| 637 | } |
| 638 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 639 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 640 | 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] | 641 | { |
| 642 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 643 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 644 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 645 | snprintf(str, size, "%d.%02d.%02d ", ha->fw_major_version, |
| 646 | ha->fw_minor_version, ha->fw_subminor_version); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | |
| 648 | if (ha->fw_attributes & BIT_9) { |
| 649 | strcat(str, "FLX"); |
| 650 | return (str); |
| 651 | } |
| 652 | |
| 653 | switch (ha->fw_attributes & 0xFF) { |
| 654 | case 0x7: |
| 655 | strcat(str, "EF"); |
| 656 | break; |
| 657 | case 0x17: |
| 658 | strcat(str, "TP"); |
| 659 | break; |
| 660 | case 0x37: |
| 661 | strcat(str, "IP"); |
| 662 | break; |
| 663 | case 0x77: |
| 664 | strcat(str, "VI"); |
| 665 | break; |
| 666 | default: |
| 667 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 668 | strcat(str, un_str); |
| 669 | break; |
| 670 | } |
| 671 | if (ha->fw_attributes & 0x100) |
| 672 | strcat(str, "X"); |
| 673 | |
| 674 | return (str); |
| 675 | } |
| 676 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 677 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 678 | 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] | 679 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 680 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 681 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 682 | snprintf(str, size, "%d.%02d.%02d (%x)", ha->fw_major_version, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 683 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 684 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 685 | } |
| 686 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 687 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 688 | qla2x00_sp_free_dma(void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 689 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 690 | srb_t *sp = ptr; |
| 691 | struct qla_hw_data *ha = sp->vha->hw; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 692 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 693 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 694 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 695 | if (sp->flags & SRB_DMA_VALID) { |
| 696 | scsi_dma_unmap(cmd); |
| 697 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 698 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 699 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 700 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 701 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 702 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 703 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 704 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 705 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 706 | if (!ctx) |
| 707 | goto end; |
| 708 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 709 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 710 | /* List assured to be having elements */ |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 711 | qla2x00_clean_dsd_pool(ha, ctx); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 712 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 713 | } |
| 714 | |
| 715 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 716 | struct crc_context *ctx0 = ctx; |
| 717 | |
| 718 | dma_pool_free(ha->dl_dma_pool, ctx0, ctx0->crc_ctx_dma); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 719 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 720 | } |
| 721 | |
| 722 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 723 | struct ct6_dsd *ctx1 = ctx; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 724 | |
| 725 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 726 | ctx1->fcp_cmnd_dma); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 727 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 728 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 729 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 730 | mempool_free(ctx1, ha->ctx_mempool); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 731 | } |
| 732 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 733 | end: |
himanshu.madhani@cavium.com | 6fcd98f | 2017-07-21 09:32:23 -0700 | [diff] [blame] | 734 | if (sp->type != SRB_NVME_CMD && sp->type != SRB_NVME_LS) { |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 735 | CMD_SP(cmd) = NULL; |
| 736 | qla2x00_rel_sp(sp); |
| 737 | } |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 738 | } |
| 739 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 740 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 741 | qla2x00_sp_compl(void *ptr, int res) |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 742 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 743 | srb_t *sp = ptr; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 744 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 745 | |
| 746 | cmd->result = res; |
| 747 | |
| 748 | if (atomic_read(&sp->ref_count) == 0) { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 749 | ql_dbg(ql_dbg_io, sp->vha, 0x3015, |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 750 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 751 | sp, GET_CMD_SP(sp)); |
| 752 | if (ql2xextended_error_logging & ql_dbg_io) |
Hiral Patel | 8fbdac8 | 2015-08-04 13:37:56 -0400 | [diff] [blame] | 753 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 754 | return; |
| 755 | } |
| 756 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 757 | return; |
| 758 | |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 759 | sp->free(sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 760 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 761 | } |
| 762 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 763 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 764 | qla2xxx_qpair_sp_free_dma(void *ptr) |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 765 | { |
| 766 | srb_t *sp = (srb_t *)ptr; |
| 767 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 768 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 769 | void *ctx = GET_CMD_CTX_SP(sp); |
| 770 | |
| 771 | if (sp->flags & SRB_DMA_VALID) { |
| 772 | scsi_dma_unmap(cmd); |
| 773 | sp->flags &= ~SRB_DMA_VALID; |
| 774 | } |
| 775 | |
| 776 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 777 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 778 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 779 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 780 | } |
| 781 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 782 | if (!ctx) |
| 783 | goto end; |
| 784 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 785 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 786 | /* List assured to be having elements */ |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 787 | qla2x00_clean_dsd_pool(ha, ctx); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 788 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 789 | } |
| 790 | |
| 791 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 792 | struct crc_context *ctx0 = ctx; |
| 793 | |
| 794 | dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 795 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 796 | } |
| 797 | |
| 798 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 799 | struct ct6_dsd *ctx1 = ctx; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 800 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 801 | ctx1->fcp_cmnd_dma); |
| 802 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 803 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 804 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 805 | mempool_free(ctx1, ha->ctx_mempool); |
| 806 | } |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 807 | end: |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 808 | CMD_SP(cmd) = NULL; |
| 809 | qla2xxx_rel_qpair_sp(sp->qpair, sp); |
| 810 | } |
| 811 | |
| 812 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 813 | qla2xxx_qpair_sp_compl(void *ptr, int res) |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 814 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 815 | srb_t *sp = ptr; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 816 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 817 | |
| 818 | cmd->result = res; |
| 819 | |
| 820 | if (atomic_read(&sp->ref_count) == 0) { |
| 821 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079, |
| 822 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 823 | sp, GET_CMD_SP(sp)); |
| 824 | if (ql2xextended_error_logging & ql_dbg_io) |
| 825 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
| 826 | return; |
| 827 | } |
| 828 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 829 | return; |
| 830 | |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 831 | sp->free(sp); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 832 | cmd->scsi_done(cmd); |
| 833 | } |
| 834 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 835 | /* If we are SP1 here, we need to still take and release the host_lock as SP1 |
| 836 | * does not have the changes necessary to avoid taking host->host_lock. |
| 837 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 839 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 840 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 841 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 842 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 843 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 844 | struct qla_hw_data *ha = vha->hw; |
| 845 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 846 | srb_t *sp; |
| 847 | int rval; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 848 | struct qla_qpair *qpair = NULL; |
| 849 | uint32_t tag; |
| 850 | uint16_t hwq; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 851 | |
Mauricio Faria de Oliveira | 04dfaa5 | 2016-11-07 17:53:30 -0200 | [diff] [blame] | 852 | if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { |
| 853 | cmd->result = DID_NO_CONNECT << 16; |
| 854 | goto qc24_fail_command; |
| 855 | } |
| 856 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 857 | if (ha->mqenable) { |
| 858 | if (shost_use_blk_mq(vha->host)) { |
| 859 | tag = blk_mq_unique_tag(cmd->request); |
| 860 | hwq = blk_mq_unique_tag_to_hwq(tag); |
| 861 | qpair = ha->queue_pair_map[hwq]; |
| 862 | } else if (vha->vp_idx && vha->qpair) { |
| 863 | qpair = vha->qpair; |
| 864 | } |
| 865 | |
| 866 | if (qpair) |
| 867 | return qla2xxx_mqueuecommand(host, cmd, qpair); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 868 | } |
| 869 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 870 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 871 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 872 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 873 | "PCI Channel IO permanent failure, exiting " |
| 874 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 875 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 876 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 877 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 878 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 879 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 880 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 881 | goto qc24_fail_command; |
| 882 | } |
| 883 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 884 | rval = fc_remote_port_chkready(rport); |
| 885 | if (rval) { |
| 886 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 887 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 888 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 889 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 890 | goto qc24_fail_command; |
| 891 | } |
| 892 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 893 | if (!vha->flags.difdix_supported && |
| 894 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 895 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 896 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 897 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 898 | cmd->result = DID_NO_CONNECT << 16; |
| 899 | goto qc24_fail_command; |
| 900 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 901 | |
| 902 | if (!fcport) { |
| 903 | cmd->result = DID_NO_CONNECT << 16; |
| 904 | goto qc24_fail_command; |
| 905 | } |
| 906 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 907 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 908 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 909 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 910 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 911 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 912 | atomic_read(&fcport->state), |
| 913 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 914 | cmd->result = DID_NO_CONNECT << 16; |
| 915 | goto qc24_fail_command; |
| 916 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 917 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 918 | } |
| 919 | |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 920 | /* |
| 921 | * Return target busy if we've received a non-zero retry_delay_timer |
| 922 | * in a FCP_RSP. |
| 923 | */ |
Bruno Prémont | 975f7d4 | 2014-12-19 10:29:16 +0100 | [diff] [blame] | 924 | if (fcport->retry_delay_timestamp == 0) { |
| 925 | /* retry delay not set */ |
| 926 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 927 | fcport->retry_delay_timestamp = 0; |
| 928 | else |
| 929 | goto qc24_target_busy; |
| 930 | |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 931 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 932 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 933 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 934 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 935 | sp->u.scmd.cmd = cmd; |
| 936 | sp->type = SRB_SCSI_CMD; |
| 937 | atomic_set(&sp->ref_count, 1); |
| 938 | CMD_SP(cmd) = (void *)sp; |
| 939 | sp->free = qla2x00_sp_free_dma; |
| 940 | sp->done = qla2x00_sp_compl; |
| 941 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 942 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 943 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 944 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 945 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 946 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 947 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 948 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 949 | return 0; |
| 950 | |
| 951 | qc24_host_busy_free_sp: |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 952 | sp->free(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 953 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 954 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 955 | return SCSI_MLQUEUE_HOST_BUSY; |
| 956 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 957 | qc24_target_busy: |
| 958 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 959 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 960 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 961 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 962 | |
| 963 | return 0; |
| 964 | } |
| 965 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 966 | /* For MQ supported I/O */ |
| 967 | int |
| 968 | qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 969 | struct qla_qpair *qpair) |
| 970 | { |
| 971 | scsi_qla_host_t *vha = shost_priv(host); |
| 972 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 973 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
| 974 | struct qla_hw_data *ha = vha->hw; |
| 975 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
| 976 | srb_t *sp; |
| 977 | int rval; |
| 978 | |
| 979 | rval = fc_remote_port_chkready(rport); |
| 980 | if (rval) { |
| 981 | cmd->result = rval; |
| 982 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3076, |
| 983 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 984 | cmd, rval); |
| 985 | goto qc24_fail_command; |
| 986 | } |
| 987 | |
| 988 | if (!fcport) { |
| 989 | cmd->result = DID_NO_CONNECT << 16; |
| 990 | goto qc24_fail_command; |
| 991 | } |
| 992 | |
| 993 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 994 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
| 995 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
| 996 | ql_dbg(ql_dbg_io, vha, 0x3077, |
| 997 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 998 | atomic_read(&fcport->state), |
| 999 | atomic_read(&base_vha->loop_state)); |
| 1000 | cmd->result = DID_NO_CONNECT << 16; |
| 1001 | goto qc24_fail_command; |
| 1002 | } |
| 1003 | goto qc24_target_busy; |
| 1004 | } |
| 1005 | |
| 1006 | /* |
| 1007 | * Return target busy if we've received a non-zero retry_delay_timer |
| 1008 | * in a FCP_RSP. |
| 1009 | */ |
| 1010 | if (fcport->retry_delay_timestamp == 0) { |
| 1011 | /* retry delay not set */ |
| 1012 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
| 1013 | fcport->retry_delay_timestamp = 0; |
| 1014 | else |
| 1015 | goto qc24_target_busy; |
| 1016 | |
Quinn Tran | 6a62946 | 2018-09-04 14:19:15 -0700 | [diff] [blame] | 1017 | sp = qla2xxx_get_qpair_sp(vha, qpair, fcport, GFP_ATOMIC); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1018 | if (!sp) |
| 1019 | goto qc24_host_busy; |
| 1020 | |
| 1021 | sp->u.scmd.cmd = cmd; |
| 1022 | sp->type = SRB_SCSI_CMD; |
| 1023 | atomic_set(&sp->ref_count, 1); |
| 1024 | CMD_SP(cmd) = (void *)sp; |
| 1025 | sp->free = qla2xxx_qpair_sp_free_dma; |
| 1026 | sp->done = qla2xxx_qpair_sp_compl; |
| 1027 | sp->qpair = qpair; |
| 1028 | |
| 1029 | rval = ha->isp_ops->start_scsi_mq(sp); |
| 1030 | if (rval != QLA_SUCCESS) { |
| 1031 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3078, |
| 1032 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
| 1033 | if (rval == QLA_INTERFACE_ERROR) |
| 1034 | goto qc24_fail_command; |
| 1035 | goto qc24_host_busy_free_sp; |
| 1036 | } |
| 1037 | |
| 1038 | return 0; |
| 1039 | |
| 1040 | qc24_host_busy_free_sp: |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 1041 | sp->free(sp); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1042 | |
| 1043 | qc24_host_busy: |
| 1044 | return SCSI_MLQUEUE_HOST_BUSY; |
| 1045 | |
| 1046 | qc24_target_busy: |
| 1047 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 1048 | |
| 1049 | qc24_fail_command: |
| 1050 | cmd->scsi_done(cmd); |
| 1051 | |
| 1052 | return 0; |
| 1053 | } |
| 1054 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | /* |
| 1056 | * qla2x00_eh_wait_on_command |
| 1057 | * Waits for the command to be returned by the Firmware for some |
| 1058 | * max time. |
| 1059 | * |
| 1060 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1061 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | * |
| 1063 | * Return: |
| 1064 | * Not Found : 0 |
| 1065 | * Found : 1 |
| 1066 | */ |
| 1067 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1068 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 1070 | #define ABORT_POLLING_PERIOD 1000 |
Chad Dupuis | 478c3b0 | 2014-04-11 16:54:35 -0400 | [diff] [blame] | 1071 | #define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1072 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1073 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1074 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1075 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1076 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1077 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1078 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 1079 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1080 | return ret; |
| 1081 | } |
| 1082 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 1083 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 1084 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1085 | } |
| 1086 | if (CMD_SP(cmd)) |
| 1087 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1089 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1090 | } |
| 1091 | |
| 1092 | /* |
| 1093 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1094 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 1096 | * finally HBA is disabled ie marked offline |
| 1097 | * |
| 1098 | * Input: |
| 1099 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1100 | * |
| 1101 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | * Does context switching-Release SPIN_LOCK |
| 1103 | * (if any) before calling this routine. |
| 1104 | * |
| 1105 | * Return: |
| 1106 | * Success (Adapter is online) : 0 |
| 1107 | * Failed (Adapter is offline/disabled) : 1 |
| 1108 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 1109 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1110 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 1112 | int return_status; |
| 1113 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1114 | struct qla_hw_data *ha = vha->hw; |
| 1115 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1117 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1118 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1119 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1120 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1121 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | |
| 1123 | msleep(1000); |
| 1124 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1125 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1126 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | else |
| 1128 | return_status = QLA_FUNCTION_FAILED; |
| 1129 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | return (return_status); |
| 1131 | } |
| 1132 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1133 | static inline int test_fcport_count(scsi_qla_host_t *vha) |
| 1134 | { |
| 1135 | struct qla_hw_data *ha = vha->hw; |
| 1136 | unsigned long flags; |
| 1137 | int res; |
| 1138 | |
| 1139 | spin_lock_irqsave(&ha->tgt.sess_lock, flags); |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 1140 | ql_dbg(ql_dbg_init, vha, 0x00ec, |
| 1141 | "tgt %p, fcport_count=%d\n", |
| 1142 | vha, vha->fcport_count); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1143 | res = (vha->fcport_count == 0); |
| 1144 | spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); |
| 1145 | |
| 1146 | return res; |
| 1147 | } |
| 1148 | |
| 1149 | /* |
| 1150 | * qla2x00_wait_for_sess_deletion can only be called from remove_one. |
| 1151 | * it has dependency on UNLOADING flag to stop device discovery |
| 1152 | */ |
Quinn Tran | efa93f4 | 2018-07-18 14:29:52 -0700 | [diff] [blame] | 1153 | void |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1154 | qla2x00_wait_for_sess_deletion(scsi_qla_host_t *vha) |
| 1155 | { |
| 1156 | qla2x00_mark_all_devices_lost(vha, 0); |
| 1157 | |
Joe Carnuccio | b85e095 | 2017-08-23 15:05:11 -0700 | [diff] [blame] | 1158 | wait_event_timeout(vha->fcport_waitQ, test_fcport_count(vha), 10*HZ); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1159 | } |
| 1160 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1161 | /* |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1162 | * qla2x00_wait_for_hba_ready |
| 1163 | * Wait till the HBA is ready before doing driver unload |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1164 | * |
| 1165 | * Input: |
| 1166 | * ha - pointer to host adapter structure |
| 1167 | * |
| 1168 | * Note: |
| 1169 | * Does context switching-Release SPIN_LOCK |
| 1170 | * (if any) before calling this routine. |
| 1171 | * |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1172 | */ |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1173 | static void |
| 1174 | qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1175 | { |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1176 | struct qla_hw_data *ha = vha->hw; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1177 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1178 | |
Dan Carpenter | 1d48390 | 2016-08-03 21:42:32 +0300 | [diff] [blame] | 1179 | while ((qla2x00_reset_active(vha) || ha->dpc_active || |
| 1180 | ha->flags.mbox_busy) || |
| 1181 | test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags) || |
| 1182 | test_bit(FX00_TARGET_SCAN, &vha->dpc_flags)) { |
| 1183 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 1184 | break; |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1185 | msleep(1000); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1186 | } |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1187 | } |
| 1188 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 1189 | int |
| 1190 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 1191 | { |
| 1192 | int return_status; |
| 1193 | unsigned long wait_reset; |
| 1194 | struct qla_hw_data *ha = vha->hw; |
| 1195 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 1196 | |
| 1197 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 1198 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1199 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1200 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1201 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 1202 | |
| 1203 | msleep(1000); |
| 1204 | |
| 1205 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 1206 | ha->flags.chip_reset_done) |
| 1207 | break; |
| 1208 | } |
| 1209 | if (ha->flags.chip_reset_done) |
| 1210 | return_status = QLA_SUCCESS; |
| 1211 | else |
| 1212 | return_status = QLA_FUNCTION_FAILED; |
| 1213 | |
| 1214 | return return_status; |
| 1215 | } |
| 1216 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 1217 | static void |
| 1218 | sp_get(struct srb *sp) |
| 1219 | { |
| 1220 | atomic_inc(&sp->ref_count); |
| 1221 | } |
| 1222 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1223 | #define ISP_REG_DISCONNECT 0xffffffffU |
| 1224 | /************************************************************************** |
| 1225 | * qla2x00_isp_reg_stat |
| 1226 | * |
| 1227 | * Description: |
| 1228 | * Read the host status register of ISP before aborting the command. |
| 1229 | * |
| 1230 | * Input: |
| 1231 | * ha = pointer to host adapter structure. |
| 1232 | * |
| 1233 | * |
| 1234 | * Returns: |
| 1235 | * Either true or false. |
| 1236 | * |
| 1237 | * Note: Return true if there is register disconnect. |
| 1238 | **************************************************************************/ |
| 1239 | static inline |
| 1240 | uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) |
| 1241 | { |
| 1242 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
Sawan Chandak | bf6061b1 | 2017-03-31 14:37:03 -0700 | [diff] [blame] | 1243 | struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1244 | |
Sawan Chandak | bf6061b1 | 2017-03-31 14:37:03 -0700 | [diff] [blame] | 1245 | if (IS_P3P_TYPE(ha)) |
| 1246 | return ((RD_REG_DWORD(®82->host_int)) == ISP_REG_DISCONNECT); |
| 1247 | else |
| 1248 | return ((RD_REG_DWORD(®->host_status)) == |
| 1249 | ISP_REG_DISCONNECT); |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1250 | } |
| 1251 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | /************************************************************************** |
| 1253 | * qla2xxx_eh_abort |
| 1254 | * |
| 1255 | * Description: |
| 1256 | * The abort function will abort the specified command. |
| 1257 | * |
| 1258 | * Input: |
| 1259 | * cmd = Linux SCSI command packet to be aborted. |
| 1260 | * |
| 1261 | * Returns: |
| 1262 | * Either SUCCESS or FAILED. |
| 1263 | * |
| 1264 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1265 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1266 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1267 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1268 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 1269 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1270 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1271 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1272 | int ret; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1273 | unsigned int id; |
| 1274 | uint64_t lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1275 | unsigned long flags; |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1276 | int rval, wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1277 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1278 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1279 | if (qla2x00_isp_reg_stat(ha)) { |
| 1280 | ql_log(ql_log_info, vha, 0x8042, |
| 1281 | "PCI/Register disconnect, exiting.\n"); |
| 1282 | return FAILED; |
| 1283 | } |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1284 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1285 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1286 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1287 | ret = fc_block_scsi_eh(cmd); |
| 1288 | if (ret != 0) |
| 1289 | return ret; |
| 1290 | ret = SUCCESS; |
| 1291 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1292 | id = cmd->device->id; |
| 1293 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1294 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1295 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1296 | sp = (srb_t *) CMD_SP(cmd); |
| 1297 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1298 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1299 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1300 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1301 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1302 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | c7bc4ca | 2015-08-04 13:37:57 -0400 | [diff] [blame] | 1303 | "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n", |
| 1304 | vha->host_no, id, lun, sp, cmd, sp->handle); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1305 | |
| 1306 | /* Get a reference to the sp and drop the lock.*/ |
| 1307 | sp_get(sp); |
| 1308 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1309 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1310 | rval = ha->isp_ops->abort_command(sp); |
| 1311 | if (rval) { |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1312 | if (rval == QLA_FUNCTION_PARAMETER_ERROR) |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1313 | ret = SUCCESS; |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1314 | else |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1315 | ret = FAILED; |
| 1316 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1317 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1318 | "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1319 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1320 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1321 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1322 | wait = 1; |
| 1323 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1324 | |
| 1325 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 1326 | sp->done(sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1327 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1328 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 1329 | /* Did the command return during mailbox execution? */ |
| 1330 | if (ret == FAILED && !CMD_SP(cmd)) |
| 1331 | ret = SUCCESS; |
| 1332 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1333 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1334 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1335 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1336 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1337 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1338 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1339 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1341 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1342 | ql_log(ql_log_info, vha, 0x801c, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1343 | "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1344 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1346 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | } |
| 1348 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1349 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1350 | 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] | 1351 | uint64_t l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1352 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1353 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1354 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1355 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1356 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1357 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1358 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1359 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1360 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1361 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1362 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1363 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1364 | for (cnt = 1; status == QLA_SUCCESS && |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1365 | cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1366 | sp = req->outstanding_cmds[cnt]; |
| 1367 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1368 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1369 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1370 | continue; |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 1371 | if (vha->vp_idx != sp->vha->vp_idx) |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1372 | continue; |
| 1373 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1374 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1375 | switch (type) { |
| 1376 | case WAIT_HOST: |
| 1377 | match = 1; |
| 1378 | break; |
| 1379 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1380 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1381 | break; |
| 1382 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1383 | match = (cmd->device->id == t && |
| 1384 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1385 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1386 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1387 | if (!match) |
| 1388 | continue; |
| 1389 | |
| 1390 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1391 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1392 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1394 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1395 | |
| 1396 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1397 | } |
| 1398 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1399 | static char *reset_errors[] = { |
| 1400 | "HBA not online", |
| 1401 | "HBA not ready", |
| 1402 | "Task management failed", |
| 1403 | "Waiting for command completions", |
| 1404 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1405 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1406 | static int |
| 1407 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1408 | 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] | 1409 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1410 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1411 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1412 | int err; |
| 1413 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1414 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1415 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1416 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1417 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1418 | err = fc_block_scsi_eh(cmd); |
| 1419 | if (err != 0) |
| 1420 | return err; |
| 1421 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1422 | ql_log(ql_log_info, vha, 0x8009, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1423 | "%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] | 1424 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1425 | |
| 1426 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1427 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1428 | ql_log(ql_log_warn, vha, 0x800a, |
| 1429 | "Wait for hba online 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 = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1433 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1434 | != QLA_SUCCESS) { |
| 1435 | ql_log(ql_log_warn, vha, 0x800c, |
| 1436 | "do_reset 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 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1440 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1441 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1442 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1443 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1444 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1445 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1446 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1447 | ql_log(ql_log_info, vha, 0x800e, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1448 | "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1449 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1450 | |
| 1451 | return SUCCESS; |
| 1452 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1453 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1454 | ql_log(ql_log_info, vha, 0x800f, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1455 | "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1456 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1457 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1458 | return FAILED; |
| 1459 | } |
| 1460 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1461 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1463 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1464 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1465 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1466 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1467 | if (qla2x00_isp_reg_stat(ha)) { |
| 1468 | ql_log(ql_log_info, vha, 0x803e, |
| 1469 | "PCI/Register disconnect, exiting.\n"); |
| 1470 | return FAILED; |
| 1471 | } |
| 1472 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1473 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1474 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | } |
| 1476 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1477 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1478 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1479 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1480 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1481 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1482 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1483 | if (qla2x00_isp_reg_stat(ha)) { |
| 1484 | ql_log(ql_log_info, vha, 0x803f, |
| 1485 | "PCI/Register disconnect, exiting.\n"); |
| 1486 | return FAILED; |
| 1487 | } |
| 1488 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1489 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1490 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1491 | } |
| 1492 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1493 | /************************************************************************** |
| 1494 | * qla2xxx_eh_bus_reset |
| 1495 | * |
| 1496 | * Description: |
| 1497 | * The bus reset function will reset the bus and abort any executing |
| 1498 | * commands. |
| 1499 | * |
| 1500 | * Input: |
| 1501 | * cmd = Linux SCSI command packet of the command that cause the |
| 1502 | * bus reset. |
| 1503 | * |
| 1504 | * Returns: |
| 1505 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1506 | * |
| 1507 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1508 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1509 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1510 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1511 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1512 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1513 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1514 | unsigned int id; |
| 1515 | uint64_t lun; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1516 | struct qla_hw_data *ha = vha->hw; |
| 1517 | |
| 1518 | if (qla2x00_isp_reg_stat(ha)) { |
| 1519 | ql_log(ql_log_info, vha, 0x8040, |
| 1520 | "PCI/Register disconnect, exiting.\n"); |
| 1521 | return FAILED; |
| 1522 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1523 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1524 | id = cmd->device->id; |
| 1525 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1526 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1527 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1528 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1529 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1531 | ret = fc_block_scsi_eh(cmd); |
| 1532 | if (ret != 0) |
| 1533 | return ret; |
| 1534 | ret = FAILED; |
| 1535 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1536 | ql_log(ql_log_info, vha, 0x8012, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1537 | "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] | 1538 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1539 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1540 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1541 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1542 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1543 | } |
| 1544 | |
Saurav Kashyap | ad537689 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1545 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1546 | ret = SUCCESS; |
| 1547 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1548 | if (ret == FAILED) |
| 1549 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1550 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1551 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1552 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1553 | QLA_SUCCESS) { |
| 1554 | ql_log(ql_log_warn, vha, 0x8014, |
| 1555 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1556 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1557 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1558 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1559 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1560 | ql_log(ql_log_warn, vha, 0x802b, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1561 | "BUS RESET %s nexus=%ld:%d:%llu.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1562 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1563 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1564 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1565 | } |
| 1566 | |
| 1567 | /************************************************************************** |
| 1568 | * qla2xxx_eh_host_reset |
| 1569 | * |
| 1570 | * Description: |
| 1571 | * The reset function will reset the Adapter. |
| 1572 | * |
| 1573 | * Input: |
| 1574 | * cmd = Linux SCSI command packet of the command that cause the |
| 1575 | * adapter reset. |
| 1576 | * |
| 1577 | * Returns: |
| 1578 | * Either SUCCESS or FAILED. |
| 1579 | * |
| 1580 | * Note: |
| 1581 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1582 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1583 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1584 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1585 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1586 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1587 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1588 | unsigned int id; |
| 1589 | uint64_t lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1590 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1591 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1592 | if (qla2x00_isp_reg_stat(ha)) { |
| 1593 | ql_log(ql_log_info, vha, 0x8041, |
| 1594 | "PCI/Register disconnect, exiting.\n"); |
| 1595 | schedule_work(&ha->board_disable); |
| 1596 | return SUCCESS; |
| 1597 | } |
| 1598 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1599 | id = cmd->device->id; |
| 1600 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1601 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1602 | ql_log(ql_log_info, vha, 0x8018, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1603 | "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] | 1604 | |
Chad Dupuis | 63ee707 | 2014-04-11 16:54:46 -0400 | [diff] [blame] | 1605 | /* |
| 1606 | * No point in issuing another reset if one is active. Also do not |
| 1607 | * attempt a reset if we are updating flash. |
| 1608 | */ |
| 1609 | if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1610 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1611 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1612 | if (vha != base_vha) { |
| 1613 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1614 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1615 | } else { |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1616 | if (IS_P3P_TYPE(vha->hw)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1617 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1618 | /* Ctx reset success */ |
| 1619 | ret = SUCCESS; |
| 1620 | goto eh_host_reset_lock; |
| 1621 | } |
| 1622 | /* fall thru if ctx reset failed */ |
| 1623 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1624 | if (ha->wq) |
| 1625 | flush_workqueue(ha->wq); |
| 1626 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1627 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1628 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1629 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1630 | /* failed. schedule dpc to try */ |
| 1631 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1632 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1633 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1634 | ql_log(ql_log_warn, vha, 0x802a, |
| 1635 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1636 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1637 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1638 | } |
| 1639 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1640 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1641 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1642 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1643 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1644 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1645 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1647 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1648 | ql_log(ql_log_info, vha, 0x8017, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1649 | "ADAPTER RESET %s nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1650 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1651 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1652 | return ret; |
| 1653 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1654 | |
| 1655 | /* |
| 1656 | * qla2x00_loop_reset |
| 1657 | * Issue loop reset. |
| 1658 | * |
| 1659 | * Input: |
| 1660 | * ha = adapter block pointer. |
| 1661 | * |
| 1662 | * Returns: |
| 1663 | * 0 = success |
| 1664 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1665 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1666 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1667 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1668 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1669 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1670 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1671 | |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1672 | if (IS_QLAFX00(ha)) { |
| 1673 | return qlafx00_loop_reset(vha); |
| 1674 | } |
| 1675 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1676 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1677 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1678 | if (fcport->port_type != FCT_TARGET) |
| 1679 | continue; |
| 1680 | |
| 1681 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1682 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1683 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1684 | "Bus Reset failed: Reset=%d " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1685 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1686 | } |
| 1687 | } |
| 1688 | } |
| 1689 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1690 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1691 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Andrew Vasquez | 0b7e7c5 | 2013-02-08 01:57:42 -0500 | [diff] [blame] | 1692 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1693 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1694 | qla2x00_mark_all_devices_lost(vha, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1695 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1696 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1697 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1698 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1699 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1700 | } |
| 1701 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1702 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1703 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad537689 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1704 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1705 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1706 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1707 | } |
| 1708 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1709 | /* 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] | 1710 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1711 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1712 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | } |
| 1714 | |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1715 | static void |
| 1716 | __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1717 | { |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1718 | int cnt, status; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1719 | unsigned long flags; |
| 1720 | srb_t *sp; |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1721 | scsi_qla_host_t *vha = qp->vha; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1722 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1723 | struct req_que *req; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 1724 | struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; |
| 1725 | struct qla_tgt_cmd *cmd; |
| 1726 | uint8_t trace = 0; |
Arun Easi | c0cb449 | 2014-09-25 06:14:51 -0400 | [diff] [blame] | 1727 | |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 1728 | if (!ha->req_q_map) |
| 1729 | return; |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1730 | spin_lock_irqsave(qp->qp_lock_ptr, flags); |
| 1731 | req = qp->req; |
| 1732 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
| 1733 | sp = req->outstanding_cmds[cnt]; |
| 1734 | if (sp) { |
| 1735 | req->outstanding_cmds[cnt] = NULL; |
Quinn Tran | 6b0431d | 2018-09-04 14:19:13 -0700 | [diff] [blame] | 1736 | switch (sp->cmd_type) { |
| 1737 | case TYPE_SRB: |
| 1738 | if (sp->cmd_type == TYPE_SRB) { |
| 1739 | if (sp->type == SRB_NVME_CMD || |
| 1740 | sp->type == SRB_NVME_LS) { |
| 1741 | sp_get(sp); |
| 1742 | spin_unlock_irqrestore |
| 1743 | (qp->qp_lock_ptr, |
| 1744 | flags); |
| 1745 | qla_nvme_abort(ha, sp, res); |
| 1746 | spin_lock_irqsave |
| 1747 | (qp->qp_lock_ptr, |
| 1748 | flags); |
| 1749 | } else if (GET_CMD_SP(sp) && |
| 1750 | !ha->flags.eeh_busy && |
| 1751 | (!test_bit(ABORT_ISP_ACTIVE, |
| 1752 | &vha->dpc_flags)) && |
| 1753 | (sp->type == SRB_SCSI_CMD)) { |
| 1754 | /* |
| 1755 | * Don't abort commands in |
| 1756 | * adapter during EEH |
| 1757 | * recovery as it's not |
| 1758 | * accessible/responding. |
| 1759 | * |
| 1760 | * Get a reference to the sp |
| 1761 | * and drop the lock. The |
| 1762 | * reference ensures this |
| 1763 | * sp->done() call and not the |
| 1764 | * call in qla2xxx_eh_abort() |
| 1765 | * ends the SCSI command (with |
| 1766 | * result 'res'). |
| 1767 | */ |
| 1768 | sp_get(sp); |
| 1769 | spin_unlock_irqrestore |
| 1770 | (qp->qp_lock_ptr, |
| 1771 | flags); |
| 1772 | status = qla2xxx_eh_abort( |
| 1773 | GET_CMD_SP(sp)); |
| 1774 | spin_lock_irqsave |
| 1775 | (qp->qp_lock_ptr, |
| 1776 | flags); |
| 1777 | /* |
| 1778 | * Get rid of extra reference |
| 1779 | * if immediate exit from |
| 1780 | * ql2xxx_eh_abort |
| 1781 | */ |
| 1782 | if (status == FAILED && |
| 1783 | (qla2x00_isp_reg_stat(ha))) |
| 1784 | atomic_dec( |
| 1785 | &sp->ref_count); |
| 1786 | } |
| 1787 | sp->done(sp, res); |
| 1788 | break; |
| 1789 | case TYPE_TGT_CMD: |
| 1790 | if (!vha->hw->tgt.tgt_ops || |
| 1791 | !tgt || qla_ini_mode_enabled(vha)) { |
| 1792 | if (!trace) |
| 1793 | ql_dbg(ql_dbg_tgt_mgt, |
| 1794 | vha, 0xf003, |
| 1795 | "HOST-ABORT-HNDLR: dpc_flags=%lx. Target mode disabled\n", |
| 1796 | vha->dpc_flags); |
| 1797 | continue; |
| 1798 | } |
| 1799 | cmd = (struct qla_tgt_cmd *)sp; |
| 1800 | qlt_abort_cmd_on_host_reset(cmd->vha, |
| 1801 | cmd); |
| 1802 | break; |
| 1803 | case TYPE_TGT_TMCMD: |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1804 | /* |
Quinn Tran | 6b0431d | 2018-09-04 14:19:13 -0700 | [diff] [blame] | 1805 | * Currently, only ABTS response gets on |
| 1806 | * the outstanding_cmds[] |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1807 | */ |
Quinn Tran | 6b0431d | 2018-09-04 14:19:13 -0700 | [diff] [blame] | 1808 | ha->tgt.tgt_ops->free_mcmd( |
| 1809 | (struct qla_tgt_mgmt_cmd *)sp); |
| 1810 | break; |
| 1811 | default: |
| 1812 | break; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 1813 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1814 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1815 | } |
| 1816 | } |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1817 | spin_unlock_irqrestore(qp->qp_lock_ptr, flags); |
| 1818 | } |
| 1819 | |
| 1820 | void |
| 1821 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
| 1822 | { |
| 1823 | int que; |
| 1824 | struct qla_hw_data *ha = vha->hw; |
| 1825 | |
| 1826 | __qla2x00_abort_all_cmds(ha->base_qpair, res); |
| 1827 | |
| 1828 | for (que = 0; que < ha->max_qpairs; que++) { |
| 1829 | if (!ha->queue_pair_map[que]) |
| 1830 | continue; |
| 1831 | |
| 1832 | __qla2x00_abort_all_cmds(ha->queue_pair_map[que], res); |
| 1833 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1834 | } |
| 1835 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1836 | static int |
| 1837 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1838 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1839 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1840 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1841 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1842 | return -ENXIO; |
| 1843 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1844 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1845 | |
| 1846 | return 0; |
| 1847 | } |
| 1848 | |
| 1849 | static int |
| 1850 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1851 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1852 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1853 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1854 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1855 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1856 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1857 | |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 1858 | scsi_change_queue_depth(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1859 | return 0; |
| 1860 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1861 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1862 | static void |
| 1863 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1864 | { |
| 1865 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1866 | } |
| 1867 | |
| 1868 | /** |
| 1869 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1870 | * @ha: HA context |
| 1871 | * |
| 1872 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1873 | * supported addressing method. |
| 1874 | */ |
| 1875 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1876 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1877 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1878 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1879 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1880 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1881 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1882 | /* Any upper-dword bits set? */ |
| 1883 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1884 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1885 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1886 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1887 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1888 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1889 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1890 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1891 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1892 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1893 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1894 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1895 | } |
| 1896 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1897 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1898 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1899 | { |
| 1900 | unsigned long flags = 0; |
| 1901 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1902 | |
| 1903 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1904 | ha->interrupts_on = 1; |
| 1905 | /* enable risc and host interrupts */ |
| 1906 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1907 | RD_REG_WORD(®->ictrl); |
| 1908 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1909 | |
| 1910 | } |
| 1911 | |
| 1912 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1913 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1914 | { |
| 1915 | unsigned long flags = 0; |
| 1916 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1917 | |
| 1918 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1919 | ha->interrupts_on = 0; |
| 1920 | /* disable risc and host interrupts */ |
| 1921 | WRT_REG_WORD(®->ictrl, 0); |
| 1922 | RD_REG_WORD(®->ictrl); |
| 1923 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1924 | } |
| 1925 | |
| 1926 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1927 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1928 | { |
| 1929 | unsigned long flags = 0; |
| 1930 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1931 | |
| 1932 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1933 | ha->interrupts_on = 1; |
| 1934 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1935 | RD_REG_DWORD(®->ictrl); |
| 1936 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1937 | } |
| 1938 | |
| 1939 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1940 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1941 | { |
| 1942 | unsigned long flags = 0; |
| 1943 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1944 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1945 | if (IS_NOPOLLING_TYPE(ha)) |
| 1946 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1947 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1948 | ha->interrupts_on = 0; |
| 1949 | WRT_REG_DWORD(®->ictrl, 0); |
| 1950 | RD_REG_DWORD(®->ictrl); |
| 1951 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1952 | } |
| 1953 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1954 | static int |
| 1955 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1956 | { |
| 1957 | resource_size_t pio; |
| 1958 | uint16_t msix; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1959 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1960 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1961 | QLA2XXX_DRIVER_NAME)) { |
| 1962 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1963 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1964 | pci_name(ha->pdev)); |
| 1965 | goto iospace_error_exit; |
| 1966 | } |
| 1967 | if (!(ha->bars & 1)) |
| 1968 | goto skip_pio; |
| 1969 | |
| 1970 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1971 | pio = pci_resource_start(ha->pdev, 0); |
| 1972 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1973 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1974 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1975 | "Invalid pci I/O region size (%s).\n", |
| 1976 | pci_name(ha->pdev)); |
| 1977 | pio = 0; |
| 1978 | } |
| 1979 | } else { |
| 1980 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1981 | "Region #0 no a PIO resource (%s).\n", |
| 1982 | pci_name(ha->pdev)); |
| 1983 | pio = 0; |
| 1984 | } |
| 1985 | ha->pio_address = pio; |
| 1986 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1987 | "PIO address=%llu.\n", |
| 1988 | (unsigned long long)ha->pio_address); |
| 1989 | |
| 1990 | skip_pio: |
| 1991 | /* Use MMIO operations for all accesses. */ |
| 1992 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1993 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1994 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1995 | pci_name(ha->pdev)); |
| 1996 | goto iospace_error_exit; |
| 1997 | } |
| 1998 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1999 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 2000 | "Invalid PCI mem region size (%s), aborting.\n", |
| 2001 | pci_name(ha->pdev)); |
| 2002 | goto iospace_error_exit; |
| 2003 | } |
| 2004 | |
| 2005 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 2006 | if (!ha->iobase) { |
| 2007 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 2008 | "Cannot remap MMIO (%s), aborting.\n", |
| 2009 | pci_name(ha->pdev)); |
| 2010 | goto iospace_error_exit; |
| 2011 | } |
| 2012 | |
| 2013 | /* Determine queue resources */ |
| 2014 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2015 | ha->msix_count = QLA_BASE_VECTORS; |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 2016 | if (!ql2xmqsupport || !ql2xnvmeenable || |
| 2017 | (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2018 | goto mqiobase_exit; |
| 2019 | |
| 2020 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 2021 | pci_resource_len(ha->pdev, 3)); |
| 2022 | if (ha->mqiobase) { |
| 2023 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 2024 | "MQIO Base=%p.\n", ha->mqiobase); |
| 2025 | /* Read MSIX vector size of the board */ |
| 2026 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2027 | ha->msix_count = msix + 1; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2028 | /* Max queues are bounded by available msix vectors */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2029 | /* MB interrupt uses 1 vector */ |
| 2030 | ha->max_req_queues = ha->msix_count - 1; |
| 2031 | ha->max_rsp_queues = ha->max_req_queues; |
| 2032 | /* Queue pairs is the max value minus the base queue pair */ |
| 2033 | ha->max_qpairs = ha->max_rsp_queues - 1; |
| 2034 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0188, |
| 2035 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
| 2036 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2037 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2038 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2039 | } else |
| 2040 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 2041 | "BAR 3 not enabled.\n"); |
| 2042 | |
| 2043 | mqiobase_exit: |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2044 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2045 | "MSIX Count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2046 | return (0); |
| 2047 | |
| 2048 | iospace_error_exit: |
| 2049 | return (-ENOMEM); |
| 2050 | } |
| 2051 | |
| 2052 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2053 | static int |
| 2054 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 2055 | { |
| 2056 | uint16_t msix; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2057 | |
| 2058 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 2059 | QLA2XXX_DRIVER_NAME)) { |
| 2060 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 2061 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 2062 | pci_name(ha->pdev)); |
| 2063 | |
| 2064 | goto iospace_error_exit; |
| 2065 | } |
| 2066 | |
| 2067 | /* Use MMIO operations for all accesses. */ |
| 2068 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 2069 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 2070 | "Invalid pci I/O region size (%s).\n", |
| 2071 | pci_name(ha->pdev)); |
| 2072 | goto iospace_error_exit; |
| 2073 | } |
| 2074 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 2075 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 2076 | "Invalid PCI mem region size (%s), aborting\n", |
| 2077 | pci_name(ha->pdev)); |
| 2078 | goto iospace_error_exit; |
| 2079 | } |
| 2080 | |
| 2081 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 2082 | if (!ha->iobase) { |
| 2083 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 2084 | "Cannot remap MMIO (%s), aborting.\n", |
| 2085 | pci_name(ha->pdev)); |
| 2086 | goto iospace_error_exit; |
| 2087 | } |
| 2088 | |
| 2089 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 2090 | /* 83XX 26XX always use MQ type access for queues |
| 2091 | * - mbar 2, a.k.a region 4 */ |
| 2092 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2093 | ha->msix_count = QLA_BASE_VECTORS; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2094 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 2095 | pci_resource_len(ha->pdev, 4)); |
| 2096 | |
| 2097 | if (!ha->mqiobase) { |
| 2098 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 2099 | "BAR2/region4 not enabled\n"); |
| 2100 | goto mqiobase_exit; |
| 2101 | } |
| 2102 | |
| 2103 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 2104 | pci_resource_len(ha->pdev, 2)); |
| 2105 | if (ha->msixbase) { |
| 2106 | /* Read MSIX vector size of the board */ |
| 2107 | pci_read_config_word(ha->pdev, |
| 2108 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 2109 | ha->msix_count = (msix & PCI_MSIX_FLAGS_QSIZE) + 1; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 2110 | /* |
| 2111 | * By default, driver uses at least two msix vectors |
| 2112 | * (default & rspq) |
| 2113 | */ |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 2114 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2115 | /* MB interrupt uses 1 vector */ |
| 2116 | ha->max_req_queues = ha->msix_count - 1; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 2117 | |
| 2118 | /* ATIOQ needs 1 vector. That's 1 less QPair */ |
| 2119 | if (QLA_TGT_MODE_ENABLED()) |
| 2120 | ha->max_req_queues--; |
| 2121 | |
Michael Hernandez | d0d2c68 | 2017-02-15 15:37:20 -0800 | [diff] [blame] | 2122 | ha->max_rsp_queues = ha->max_req_queues; |
| 2123 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2124 | /* Queue pairs is the max value minus |
| 2125 | * the base queue pair */ |
| 2126 | ha->max_qpairs = ha->max_req_queues - 1; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2127 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x00e3, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2128 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2129 | } |
| 2130 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2131 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2132 | } else |
| 2133 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 2134 | "BAR 1 not enabled.\n"); |
| 2135 | |
| 2136 | mqiobase_exit: |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2137 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2138 | "MSIX Count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2139 | return 0; |
| 2140 | |
| 2141 | iospace_error_exit: |
| 2142 | return -ENOMEM; |
| 2143 | } |
| 2144 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2145 | static struct isp_operations qla2100_isp_ops = { |
| 2146 | .pci_config = qla2100_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 = qla2100_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 = qla2100_fw_dump, |
| 2171 | .beacon_on = NULL, |
| 2172 | .beacon_off = NULL, |
| 2173 | .beacon_blink = NULL, |
| 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, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [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 qla2300_isp_ops = { |
| 2185 | .pci_config = qla2300_pci_config, |
| 2186 | .reset_chip = qla2x00_reset_chip, |
| 2187 | .chip_diag = qla2x00_chip_diag, |
| 2188 | .config_rings = qla2x00_config_rings, |
| 2189 | .reset_adapter = qla2x00_reset_adapter, |
| 2190 | .nvram_config = qla2x00_nvram_config, |
| 2191 | .update_fw_options = qla2x00_update_fw_options, |
| 2192 | .load_risc = qla2x00_load_risc, |
| 2193 | .pci_info_str = qla2x00_pci_info_str, |
| 2194 | .fw_version_str = qla2x00_fw_version_str, |
| 2195 | .intr_handler = qla2300_intr_handler, |
| 2196 | .enable_intrs = qla2x00_enable_intrs, |
| 2197 | .disable_intrs = qla2x00_disable_intrs, |
| 2198 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2199 | .target_reset = qla2x00_abort_target, |
| 2200 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2201 | .fabric_login = qla2x00_login_fabric, |
| 2202 | .fabric_logout = qla2x00_fabric_logout, |
| 2203 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 2204 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 2205 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 2206 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 2207 | .read_nvram = qla2x00_read_nvram_data, |
| 2208 | .write_nvram = qla2x00_write_nvram_data, |
| 2209 | .fw_dump = qla2300_fw_dump, |
| 2210 | .beacon_on = qla2x00_beacon_on, |
| 2211 | .beacon_off = qla2x00_beacon_off, |
| 2212 | .beacon_blink = qla2x00_beacon_blink, |
| 2213 | .read_optrom = qla2x00_read_optrom_data, |
| 2214 | .write_optrom = qla2x00_write_optrom_data, |
| 2215 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2216 | .start_scsi = qla2x00_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 | |
| 2223 | static struct isp_operations qla24xx_isp_ops = { |
| 2224 | .pci_config = qla24xx_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 | fd34f55 | 2007-07-19 15:06:00 -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 = qla24xx_read_nvram_data, |
| 2247 | .write_nvram = qla24xx_write_nvram_data, |
| 2248 | .fw_dump = qla24xx_fw_dump, |
| 2249 | .beacon_on = qla24xx_beacon_on, |
| 2250 | .beacon_off = qla24xx_beacon_off, |
| 2251 | .beacon_blink = qla24xx_beacon_blink, |
| 2252 | .read_optrom = qla24xx_read_optrom_data, |
| 2253 | .write_optrom = qla24xx_write_optrom_data, |
| 2254 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2255 | .start_scsi = qla24xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2256 | .start_scsi_mq = NULL, |
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 | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2260 | }; |
| 2261 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2262 | static struct isp_operations qla25xx_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 = qla24xx_nvram_config, |
| 2269 | .update_fw_options = qla24xx_update_fw_options, |
| 2270 | .load_risc = qla24xx_load_risc, |
| 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, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2277 | .target_reset = qla24xx_abort_target, |
| 2278 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 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, |
| 2285 | .read_nvram = qla25xx_read_nvram_data, |
| 2286 | .write_nvram = qla25xx_write_nvram_data, |
| 2287 | .fw_dump = qla25xx_fw_dump, |
| 2288 | .beacon_on = qla24xx_beacon_on, |
| 2289 | .beacon_off = qla24xx_beacon_off, |
| 2290 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 2291 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2292 | .write_optrom = qla24xx_write_optrom_data, |
| 2293 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -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, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2299 | }; |
| 2300 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2301 | static struct isp_operations qla81xx_isp_ops = { |
| 2302 | .pci_config = qla25xx_pci_config, |
| 2303 | .reset_chip = qla24xx_reset_chip, |
| 2304 | .chip_diag = qla24xx_chip_diag, |
| 2305 | .config_rings = qla24xx_config_rings, |
| 2306 | .reset_adapter = qla24xx_reset_adapter, |
| 2307 | .nvram_config = qla81xx_nvram_config, |
| 2308 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 2309 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2310 | .pci_info_str = qla24xx_pci_info_str, |
| 2311 | .fw_version_str = qla24xx_fw_version_str, |
| 2312 | .intr_handler = qla24xx_intr_handler, |
| 2313 | .enable_intrs = qla24xx_enable_intrs, |
| 2314 | .disable_intrs = qla24xx_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, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 2324 | .read_nvram = NULL, |
| 2325 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2326 | .fw_dump = qla81xx_fw_dump, |
| 2327 | .beacon_on = qla24xx_beacon_on, |
| 2328 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2329 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2330 | .read_optrom = qla25xx_read_optrom_data, |
| 2331 | .write_optrom = qla24xx_write_optrom_data, |
| 2332 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 2333 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2334 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2335 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2336 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2337 | .initialize_adapter = qla2x00_initialize_adapter, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2338 | }; |
| 2339 | |
| 2340 | static struct isp_operations qla82xx_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, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 2349 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2350 | .fw_version_str = qla24xx_fw_version_str, |
| 2351 | .intr_handler = qla82xx_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 = qla24xx_read_nvram_data, |
| 2364 | .write_nvram = qla24xx_write_nvram_data, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2365 | .fw_dump = qla82xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 2366 | .beacon_on = qla82xx_beacon_on, |
| 2367 | .beacon_off = qla82xx_beacon_off, |
| 2368 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2369 | .read_optrom = qla82xx_read_optrom_data, |
| 2370 | .write_optrom = qla82xx_write_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2371 | .get_flash_version = qla82xx_get_flash_version, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2372 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2373 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2374 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2375 | .iospace_config = qla82xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2376 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2377 | }; |
| 2378 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2379 | static struct isp_operations qla8044_isp_ops = { |
| 2380 | .pci_config = qla82xx_pci_config, |
| 2381 | .reset_chip = qla82xx_reset_chip, |
| 2382 | .chip_diag = qla24xx_chip_diag, |
| 2383 | .config_rings = qla82xx_config_rings, |
| 2384 | .reset_adapter = qla24xx_reset_adapter, |
| 2385 | .nvram_config = qla81xx_nvram_config, |
| 2386 | .update_fw_options = qla24xx_update_fw_options, |
| 2387 | .load_risc = qla82xx_load_risc, |
| 2388 | .pci_info_str = qla24xx_pci_info_str, |
| 2389 | .fw_version_str = qla24xx_fw_version_str, |
| 2390 | .intr_handler = qla8044_intr_handler, |
| 2391 | .enable_intrs = qla82xx_enable_intrs, |
| 2392 | .disable_intrs = qla82xx_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, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2404 | .fw_dump = qla8044_fw_dump, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2405 | .beacon_on = qla82xx_beacon_on, |
| 2406 | .beacon_off = qla82xx_beacon_off, |
| 2407 | .beacon_blink = NULL, |
Saurav Kashyap | 888e639 | 2014-02-26 04:15:13 -0500 | [diff] [blame] | 2408 | .read_optrom = qla8044_read_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2409 | .write_optrom = qla8044_write_optrom_data, |
| 2410 | .get_flash_version = qla82xx_get_flash_version, |
| 2411 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2412 | .start_scsi_mq = NULL, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2413 | .abort_isp = qla8044_abort_isp, |
| 2414 | .iospace_config = qla82xx_iospace_config, |
| 2415 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2416 | }; |
| 2417 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2418 | static struct isp_operations qla83xx_isp_ops = { |
| 2419 | .pci_config = qla25xx_pci_config, |
| 2420 | .reset_chip = qla24xx_reset_chip, |
| 2421 | .chip_diag = qla24xx_chip_diag, |
| 2422 | .config_rings = qla24xx_config_rings, |
| 2423 | .reset_adapter = qla24xx_reset_adapter, |
| 2424 | .nvram_config = qla81xx_nvram_config, |
| 2425 | .update_fw_options = qla81xx_update_fw_options, |
| 2426 | .load_risc = qla81xx_load_risc, |
| 2427 | .pci_info_str = qla24xx_pci_info_str, |
| 2428 | .fw_version_str = qla24xx_fw_version_str, |
| 2429 | .intr_handler = qla24xx_intr_handler, |
| 2430 | .enable_intrs = qla24xx_enable_intrs, |
| 2431 | .disable_intrs = qla24xx_disable_intrs, |
| 2432 | .abort_command = qla24xx_abort_command, |
| 2433 | .target_reset = qla24xx_abort_target, |
| 2434 | .lun_reset = qla24xx_lun_reset, |
| 2435 | .fabric_login = qla24xx_login_fabric, |
| 2436 | .fabric_logout = qla24xx_fabric_logout, |
| 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 = NULL, |
| 2442 | .write_nvram = NULL, |
| 2443 | .fw_dump = qla83xx_fw_dump, |
| 2444 | .beacon_on = qla24xx_beacon_on, |
| 2445 | .beacon_off = qla24xx_beacon_off, |
| 2446 | .beacon_blink = qla83xx_beacon_blink, |
| 2447 | .read_optrom = qla25xx_read_optrom_data, |
| 2448 | .write_optrom = qla24xx_write_optrom_data, |
| 2449 | .get_flash_version = qla24xx_get_flash_version, |
| 2450 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2451 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2452 | .abort_isp = qla2x00_abort_isp, |
| 2453 | .iospace_config = qla83xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2454 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2455 | }; |
| 2456 | |
| 2457 | static struct isp_operations qlafx00_isp_ops = { |
| 2458 | .pci_config = qlafx00_pci_config, |
| 2459 | .reset_chip = qlafx00_soft_reset, |
| 2460 | .chip_diag = qlafx00_chip_diag, |
| 2461 | .config_rings = qlafx00_config_rings, |
| 2462 | .reset_adapter = qlafx00_soft_reset, |
| 2463 | .nvram_config = NULL, |
| 2464 | .update_fw_options = NULL, |
| 2465 | .load_risc = NULL, |
| 2466 | .pci_info_str = qlafx00_pci_info_str, |
| 2467 | .fw_version_str = qlafx00_fw_version_str, |
| 2468 | .intr_handler = qlafx00_intr_handler, |
| 2469 | .enable_intrs = qlafx00_enable_intrs, |
| 2470 | .disable_intrs = qlafx00_disable_intrs, |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2471 | .abort_command = qla24xx_async_abort_command, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2472 | .target_reset = qlafx00_abort_target, |
| 2473 | .lun_reset = qlafx00_lun_reset, |
| 2474 | .fabric_login = NULL, |
| 2475 | .fabric_logout = NULL, |
| 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 = qla24xx_read_nvram_data, |
| 2481 | .write_nvram = qla24xx_write_nvram_data, |
| 2482 | .fw_dump = NULL, |
| 2483 | .beacon_on = qla24xx_beacon_on, |
| 2484 | .beacon_off = qla24xx_beacon_off, |
| 2485 | .beacon_blink = NULL, |
| 2486 | .read_optrom = qla24xx_read_optrom_data, |
| 2487 | .write_optrom = qla24xx_write_optrom_data, |
| 2488 | .get_flash_version = qla24xx_get_flash_version, |
| 2489 | .start_scsi = qlafx00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2490 | .start_scsi_mq = NULL, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2491 | .abort_isp = qlafx00_abort_isp, |
| 2492 | .iospace_config = qlafx00_iospace_config, |
| 2493 | .initialize_adapter = qlafx00_initialize_adapter, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2494 | }; |
| 2495 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2496 | static struct isp_operations qla27xx_isp_ops = { |
| 2497 | .pci_config = qla25xx_pci_config, |
| 2498 | .reset_chip = qla24xx_reset_chip, |
| 2499 | .chip_diag = qla24xx_chip_diag, |
| 2500 | .config_rings = qla24xx_config_rings, |
| 2501 | .reset_adapter = qla24xx_reset_adapter, |
| 2502 | .nvram_config = qla81xx_nvram_config, |
| 2503 | .update_fw_options = qla81xx_update_fw_options, |
| 2504 | .load_risc = qla81xx_load_risc, |
| 2505 | .pci_info_str = qla24xx_pci_info_str, |
| 2506 | .fw_version_str = qla24xx_fw_version_str, |
| 2507 | .intr_handler = qla24xx_intr_handler, |
| 2508 | .enable_intrs = qla24xx_enable_intrs, |
| 2509 | .disable_intrs = qla24xx_disable_intrs, |
| 2510 | .abort_command = qla24xx_abort_command, |
| 2511 | .target_reset = qla24xx_abort_target, |
| 2512 | .lun_reset = qla24xx_lun_reset, |
| 2513 | .fabric_login = qla24xx_login_fabric, |
| 2514 | .fabric_logout = qla24xx_fabric_logout, |
| 2515 | .calc_req_entries = NULL, |
| 2516 | .build_iocbs = NULL, |
| 2517 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2518 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2519 | .read_nvram = NULL, |
| 2520 | .write_nvram = NULL, |
| 2521 | .fw_dump = qla27xx_fwdump, |
| 2522 | .beacon_on = qla24xx_beacon_on, |
| 2523 | .beacon_off = qla24xx_beacon_off, |
| 2524 | .beacon_blink = qla83xx_beacon_blink, |
| 2525 | .read_optrom = qla25xx_read_optrom_data, |
| 2526 | .write_optrom = qla24xx_write_optrom_data, |
| 2527 | .get_flash_version = qla24xx_get_flash_version, |
| 2528 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2529 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2530 | .abort_isp = qla2x00_abort_isp, |
| 2531 | .iospace_config = qla83xx_iospace_config, |
| 2532 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2533 | }; |
| 2534 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2535 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2536 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2537 | { |
| 2538 | ha->device_type = DT_EXTENDED_IDS; |
| 2539 | switch (ha->pdev->device) { |
| 2540 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2541 | ha->isp_type |= DT_ISP2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2542 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2543 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2544 | break; |
| 2545 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2546 | ha->isp_type |= DT_ISP2200; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2547 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2548 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2549 | break; |
| 2550 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2551 | ha->isp_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2552 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2553 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2554 | break; |
| 2555 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2556 | ha->isp_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2557 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2558 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2559 | break; |
| 2560 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2561 | ha->isp_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2562 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2563 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2564 | ha->pdev->subsystem_device == 0x0170) |
| 2565 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2566 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2567 | break; |
| 2568 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2569 | ha->isp_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2570 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2571 | break; |
| 2572 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2573 | ha->isp_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2574 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2575 | break; |
| 2576 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2577 | ha->isp_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2578 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2579 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2580 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2581 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2582 | break; |
| 2583 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2584 | ha->isp_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2585 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2586 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2587 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2588 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2589 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2590 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2591 | ha->isp_type |= DT_ISP8432; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2592 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2593 | ha->device_type |= DT_FWI2; |
| 2594 | ha->device_type |= DT_IIDMA; |
| 2595 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2596 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2597 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2598 | ha->isp_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2599 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2600 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2601 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2602 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2603 | ha->isp_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2604 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2605 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2606 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2607 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2608 | ha->isp_type |= DT_ISP2532; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2609 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2610 | ha->device_type |= DT_FWI2; |
| 2611 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2612 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2613 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2614 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2615 | ha->isp_type |= DT_ISP8001; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2616 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2617 | ha->device_type |= DT_FWI2; |
| 2618 | ha->device_type |= DT_IIDMA; |
| 2619 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2620 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2621 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2622 | ha->isp_type |= DT_ISP8021; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2623 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2624 | ha->device_type |= DT_FWI2; |
| 2625 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2626 | /* Initialize 82XX ISP flags */ |
| 2627 | qla82xx_init_flags(ha); |
| 2628 | break; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2629 | case PCI_DEVICE_ID_QLOGIC_ISP8044: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2630 | ha->isp_type |= DT_ISP8044; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2631 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2632 | ha->device_type |= DT_FWI2; |
| 2633 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2634 | /* Initialize 82XX ISP flags */ |
| 2635 | qla82xx_init_flags(ha); |
| 2636 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2637 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2638 | ha->isp_type |= DT_ISP2031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2639 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2640 | ha->device_type |= DT_FWI2; |
| 2641 | ha->device_type |= DT_IIDMA; |
| 2642 | ha->device_type |= DT_T10_PI; |
| 2643 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2644 | break; |
| 2645 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2646 | ha->isp_type |= DT_ISP8031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2647 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2648 | ha->device_type |= DT_FWI2; |
| 2649 | ha->device_type |= DT_IIDMA; |
| 2650 | ha->device_type |= DT_T10_PI; |
| 2651 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2652 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2653 | case PCI_DEVICE_ID_QLOGIC_ISPF001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2654 | ha->isp_type |= DT_ISPFX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2655 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2656 | case PCI_DEVICE_ID_QLOGIC_ISP2071: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2657 | ha->isp_type |= DT_ISP2071; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2658 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2659 | ha->device_type |= DT_FWI2; |
| 2660 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2661 | ha->device_type |= DT_T10_PI; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2662 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2663 | break; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2664 | case PCI_DEVICE_ID_QLOGIC_ISP2271: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2665 | ha->isp_type |= DT_ISP2271; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2666 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2667 | ha->device_type |= DT_FWI2; |
| 2668 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2669 | ha->device_type |= DT_T10_PI; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2670 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2671 | break; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2672 | case PCI_DEVICE_ID_QLOGIC_ISP2261: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2673 | ha->isp_type |= DT_ISP2261; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2674 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2675 | ha->device_type |= DT_FWI2; |
| 2676 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2677 | ha->device_type |= DT_T10_PI; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2678 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2679 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2680 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2681 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2682 | if (IS_QLA82XX(ha)) |
Saurav Kashyap | 43a9c38 | 2014-02-26 04:15:16 -0500 | [diff] [blame] | 2683 | ha->port_no = ha->portnum & 1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2684 | else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2685 | /* Get adapter physical port no from interrupt pin register. */ |
| 2686 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2687 | if (IS_QLA27XX(ha)) |
| 2688 | ha->port_no--; |
| 2689 | else |
| 2690 | ha->port_no = !(ha->port_no & 1); |
| 2691 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2692 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2693 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2694 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2695 | ha->device_type, ha->port_no, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2696 | } |
| 2697 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2698 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2699 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2700 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2701 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2702 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2703 | if (vha->hw->flags.running_gold_fw) |
| 2704 | return; |
| 2705 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2706 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2707 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2708 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2709 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2710 | } |
| 2711 | |
| 2712 | static int |
| 2713 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2714 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2715 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2716 | |
Bill Kuzeja | a5dd506e | 2016-10-21 16:45:27 -0400 | [diff] [blame] | 2717 | if (test_bit(UNLOADING, &vha->dpc_flags)) |
| 2718 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2719 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2720 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2721 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2722 | return 1; |
| 2723 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2724 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2725 | } |
| 2726 | |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2727 | static void qla2x00_iocb_work_fn(struct work_struct *work) |
| 2728 | { |
| 2729 | struct scsi_qla_host *vha = container_of(work, |
| 2730 | struct scsi_qla_host, iocb_work); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2731 | struct qla_hw_data *ha = vha->hw; |
| 2732 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Quinn Tran | 0aca778 | 2018-09-04 14:19:16 -0700 | [diff] [blame^] | 2733 | int i = 2; |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2734 | unsigned long flags; |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2735 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2736 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 2737 | return; |
| 2738 | |
| 2739 | while (!list_empty(&vha->work_list) && i > 0) { |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2740 | qla2x00_do_work(vha); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2741 | i--; |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2742 | } |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2743 | |
| 2744 | spin_lock_irqsave(&vha->work_lock, flags); |
| 2745 | clear_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags); |
| 2746 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2747 | } |
| 2748 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2749 | /* |
| 2750 | * PCI driver interface |
| 2751 | */ |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 2752 | static int |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2753 | 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] | 2754 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2755 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2756 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2757 | scsi_qla_host_t *base_vha = NULL; |
| 2758 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2759 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2760 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2761 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2762 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2763 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2764 | struct req_que *req = NULL; |
| 2765 | struct rsp_que *rsp = NULL; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 2766 | int i; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2767 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2768 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2769 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2770 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2771 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2772 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2773 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2774 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2775 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2776 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2777 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2778 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2779 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031 || |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2780 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISPF001 || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2781 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8044 || |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2782 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2071 || |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2783 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271 || |
| 2784 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2261) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2785 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2786 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2787 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2788 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2789 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2790 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2791 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2792 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2793 | if (mem_only) { |
| 2794 | if (pci_enable_device_mem(pdev)) |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2795 | return ret; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2796 | } else { |
| 2797 | if (pci_enable_device(pdev)) |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2798 | return ret; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2799 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2800 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2801 | /* This may fail but that's ok */ |
| 2802 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2803 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2804 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2805 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2806 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2807 | "Unable to allocate memory for ha.\n"); |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2808 | goto disable_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2809 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2810 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2811 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2812 | ha->pdev = pdev; |
Quinn Tran | 33e7997 | 2014-09-25 06:14:55 -0400 | [diff] [blame] | 2813 | INIT_LIST_HEAD(&ha->tgt.q_full_list); |
| 2814 | spin_lock_init(&ha->tgt.q_full_lock); |
Quinn Tran | 7560151 | 2015-12-17 14:57:04 -0500 | [diff] [blame] | 2815 | spin_lock_init(&ha->tgt.sess_lock); |
Quinn Tran | 2f424b9 | 2015-12-17 14:57:07 -0500 | [diff] [blame] | 2816 | spin_lock_init(&ha->tgt.atio_lock); |
| 2817 | |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 2818 | atomic_set(&ha->nvme_active_aen_cnt, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2819 | |
| 2820 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2821 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2822 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2823 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2824 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2825 | mutex_init(&ha->selflogin_lock); |
Chad Dupuis | 7a8ab9c | 2014-02-26 04:14:56 -0500 | [diff] [blame] | 2826 | mutex_init(&ha->optrom_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2827 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2828 | /* Set ISP-type information. */ |
| 2829 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2830 | |
| 2831 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2832 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2833 | IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2834 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2835 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2836 | ha->prev_topology = 0; |
| 2837 | ha->init_cb_size = sizeof(init_cb_t); |
| 2838 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2839 | ha->optrom_size = OPTROM_SIZE_2300; |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 2840 | ha->max_exchg = FW_MAX_EXCHANGES_CNT; |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 2841 | atomic_set(&ha->num_pend_mbx_stage1, 0); |
| 2842 | atomic_set(&ha->num_pend_mbx_stage2, 0); |
| 2843 | atomic_set(&ha->num_pend_mbx_stage3, 0); |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 2844 | atomic_set(&ha->zio_threshold, DEFAULT_ZIO_THRESHOLD); |
| 2845 | ha->last_zio_threshold = DEFAULT_ZIO_THRESHOLD; |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2846 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2847 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2848 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2849 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2850 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2851 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2852 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2853 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2854 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2855 | ha->flash_conf_off = ~0; |
| 2856 | ha->flash_data_off = ~0; |
| 2857 | ha->nvram_conf_off = ~0; |
| 2858 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2859 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2860 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2861 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2862 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2863 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2864 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2865 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2866 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2867 | ha->flash_conf_off = ~0; |
| 2868 | ha->flash_data_off = ~0; |
| 2869 | ha->nvram_conf_off = ~0; |
| 2870 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2871 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2872 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2873 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2874 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2875 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2876 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2877 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2878 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2879 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2880 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2881 | ha->flash_conf_off = ~0; |
| 2882 | ha->flash_data_off = ~0; |
| 2883 | ha->nvram_conf_off = ~0; |
| 2884 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2885 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2886 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2887 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2888 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2889 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2890 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2891 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2892 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2893 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2894 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2895 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2896 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2897 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2898 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2899 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2900 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2901 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2902 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2903 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2904 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2905 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2906 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2907 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2908 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2909 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2910 | ha->gid_list_info_size = 8; |
| 2911 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2912 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2913 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2914 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2915 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2916 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2917 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2918 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2919 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2920 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2921 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2922 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 2923 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2924 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2925 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2926 | ha->gid_list_info_size = 8; |
| 2927 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2928 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2929 | ha->isp_ops = &qla81xx_isp_ops; |
| 2930 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2931 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2932 | ha->nvram_conf_off = ~0; |
| 2933 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2934 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2935 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2936 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2937 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2938 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2939 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2940 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2941 | ha->gid_list_info_size = 8; |
| 2942 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2943 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2944 | ha->isp_ops = &qla82xx_isp_ops; |
| 2945 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2946 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2947 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2948 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2949 | } else if (IS_QLA8044(ha)) { |
| 2950 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2951 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2952 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2953 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2954 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2955 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2956 | ha->gid_list_info_size = 8; |
| 2957 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2958 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2959 | ha->isp_ops = &qla8044_isp_ops; |
| 2960 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2961 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2962 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2963 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2964 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2965 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2966 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2967 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Saurav Kashyap | f2ea653 | 2014-09-25 06:14:54 -0400 | [diff] [blame] | 2968 | req_length = REQUEST_ENTRY_CNT_83XX; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2969 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Arun Easi | b8aa4bd | 2013-01-30 03:34:40 -0500 | [diff] [blame] | 2970 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2971 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2972 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2973 | ha->gid_list_info_size = 8; |
| 2974 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2975 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2976 | ha->isp_ops = &qla83xx_isp_ops; |
| 2977 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2978 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2979 | ha->nvram_conf_off = ~0; |
| 2980 | ha->nvram_data_off = ~0; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2981 | } else if (IS_QLAFX00(ha)) { |
| 2982 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_FX00; |
| 2983 | ha->mbx_count = MAILBOX_REGISTER_COUNT_FX00; |
| 2984 | ha->aen_mbx_count = AEN_MAILBOX_REGISTER_COUNT_FX00; |
| 2985 | req_length = REQUEST_ENTRY_CNT_FX00; |
| 2986 | rsp_length = RESPONSE_ENTRY_CNT_FX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2987 | ha->isp_ops = &qlafx00_isp_ops; |
| 2988 | ha->port_down_retry_count = 30; /* default value */ |
| 2989 | ha->mr.fw_hbt_cnt = QLAFX00_HEARTBEAT_INTERVAL; |
| 2990 | ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; |
Armen Baloyan | 71e5600 | 2013-08-27 01:37:38 -0400 | [diff] [blame] | 2991 | ha->mr.fw_critemp_timer_tick = QLAFX00_CRITEMP_INTERVAL; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2992 | ha->mr.fw_hbt_en = 1; |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 2993 | ha->mr.host_info_resend = false; |
| 2994 | ha->mr.hinfo_resend_timer_tick = QLAFX00_HINFO_RESEND_INTERVAL; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2995 | } else if (IS_QLA27XX(ha)) { |
| 2996 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
| 2997 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2998 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2999 | req_length = REQUEST_ENTRY_CNT_83XX; |
| 3000 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 3001 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3002 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 3003 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 3004 | ha->gid_list_info_size = 8; |
| 3005 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 3006 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 3007 | ha->isp_ops = &qla27xx_isp_ops; |
| 3008 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 3009 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 3010 | ha->nvram_conf_off = ~0; |
| 3011 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3012 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3013 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3014 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 3015 | "mbx_count=%d, req_length=%d, " |
| 3016 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3017 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 3018 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3019 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 3020 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3021 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3022 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 3023 | "isp_ops=%p, flash_conf_off=%d, " |
| 3024 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 3025 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 3026 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 3027 | |
| 3028 | /* Configure PCI I/O space */ |
| 3029 | ret = ha->isp_ops->iospace_config(ha); |
| 3030 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3031 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 3032 | |
| 3033 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 3034 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 3035 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 3036 | mutex_init(&ha->vport_lock); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3037 | mutex_init(&ha->mq_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 3038 | init_completion(&ha->mbx_cmd_comp); |
| 3039 | complete(&ha->mbx_cmd_comp); |
| 3040 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 3041 | init_completion(&ha->dcbx_comp); |
Chad Dupuis | f356bef | 2013-02-08 01:58:04 -0500 | [diff] [blame] | 3042 | init_completion(&ha->lb_portup_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3043 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3044 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3045 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 3046 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3047 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 3048 | "64 Bit addressing is %s.\n", |
| 3049 | ha->flags.enable_64bit_addressing ? "enable" : |
| 3050 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3051 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3052 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3053 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 3054 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3055 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3056 | goto probe_hw_failed; |
| 3057 | } |
| 3058 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3059 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3060 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3061 | req->max_q_depth = ql2xmaxqdepth; |
| 3062 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3063 | |
| 3064 | base_vha = qla2x00_create_host(sht, ha); |
| 3065 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3066 | ret = -ENOMEM; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3067 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3068 | } |
| 3069 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3070 | pci_set_drvdata(pdev, base_vha); |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 3071 | set_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3072 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3073 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3074 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3075 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Quinn Tran | f6602f3 | 2018-08-02 13:16:53 -0700 | [diff] [blame] | 3076 | base_vha->mgmt_svr_loop_id = |
| 3077 | qla2x00_reserve_mgmt_server_loop_id(base_vha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3078 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3079 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 3080 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 3081 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3082 | /* Setup fcport template structure. */ |
| 3083 | ha->mr.fcport.vha = base_vha; |
| 3084 | ha->mr.fcport.port_type = FCT_UNKNOWN; |
| 3085 | ha->mr.fcport.loop_id = FC_NO_LOOP_ID; |
| 3086 | qla2x00_set_fcport_state(&ha->mr.fcport, FCS_UNCONFIGURED); |
| 3087 | ha->mr.fcport.supported_classes = FC_COS_UNSPECIFIED; |
| 3088 | ha->mr.fcport.scan_state = 1; |
| 3089 | |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 3090 | /* Set the SG table size based on ISP type */ |
| 3091 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3092 | if (IS_QLA2100(ha)) |
| 3093 | host->sg_tablesize = 32; |
| 3094 | } else { |
| 3095 | if (!IS_QLA82XX(ha)) |
| 3096 | host->sg_tablesize = QLA_SG_ALL; |
| 3097 | } |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3098 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3099 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 3100 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 3101 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3102 | host->max_cmd_len = 32; |
| 3103 | else |
| 3104 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 3105 | host->max_channel = MAX_BUSES - 1; |
Hannes Reinecke | 755f516 | 2014-06-03 10:58:54 +0200 | [diff] [blame] | 3106 | /* Older HBAs support only 16-bit LUNs */ |
| 3107 | if (!IS_QLAFX00(ha) && !IS_FWI2_CAPABLE(ha) && |
| 3108 | ql2xmaxlun > 0xffff) |
| 3109 | host->max_lun = 0xffff; |
| 3110 | else |
| 3111 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3112 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3113 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3114 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3115 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 3116 | "max_id=%d this_id=%d " |
| 3117 | "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] | 3118 | "max_lun=%llu transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3119 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 3120 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 3121 | host->transportt, sht->vendor_id); |
| 3122 | |
Himanshu Madhani | 1010f21 | 2017-10-16 11:26:05 -0700 | [diff] [blame] | 3123 | INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn); |
| 3124 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3125 | /* Set up the irqs */ |
| 3126 | ret = qla2x00_request_irqs(ha, rsp); |
| 3127 | if (ret) |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 3128 | goto probe_failed; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3129 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3130 | /* Alloc arrays of request and response ring ptrs */ |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 3131 | ret = qla2x00_alloc_queues(ha, req, rsp); |
| 3132 | if (ret) { |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3133 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 3134 | "Failed to allocate memory for queue pointers..." |
| 3135 | "aborting.\n"); |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 3136 | goto probe_failed; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3137 | } |
| 3138 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3139 | if (ha->mqenable && shost_use_blk_mq(host)) { |
| 3140 | /* number of hardware queues supported by blk/scsi-mq*/ |
| 3141 | host->nr_hw_queues = ha->max_qpairs; |
| 3142 | |
| 3143 | ql_dbg(ql_dbg_init, base_vha, 0x0192, |
| 3144 | "blk/scsi-mq enabled, HW queues = %d.\n", host->nr_hw_queues); |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 3145 | } else { |
| 3146 | if (ql2xnvmeenable) { |
| 3147 | host->nr_hw_queues = ha->max_qpairs; |
| 3148 | ql_dbg(ql_dbg_init, base_vha, 0x0194, |
| 3149 | "FC-NVMe support is enabled, HW queues=%d\n", |
| 3150 | host->nr_hw_queues); |
| 3151 | } else { |
| 3152 | ql_dbg(ql_dbg_init, base_vha, 0x0193, |
| 3153 | "blk/scsi-mq disabled.\n"); |
| 3154 | } |
| 3155 | } |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3156 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3157 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3158 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3159 | pci_save_state(pdev); |
| 3160 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3161 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3162 | rsp->req = req; |
| 3163 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3164 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3165 | if (IS_QLAFX00(ha)) { |
| 3166 | ha->rsp_q_map[0] = rsp; |
| 3167 | ha->req_q_map[0] = req; |
| 3168 | set_bit(0, ha->req_qid_map); |
| 3169 | set_bit(0, ha->rsp_qid_map); |
| 3170 | } |
| 3171 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 3172 | /* FWI2-capable only. */ |
| 3173 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 3174 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 3175 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 3176 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3177 | if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 3178 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 3179 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 3180 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 3181 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 3182 | } |
| 3183 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3184 | if (IS_QLAFX00(ha)) { |
| 3185 | req->req_q_in = &ha->iobase->ispfx00.req_q_in; |
| 3186 | req->req_q_out = &ha->iobase->ispfx00.req_q_out; |
| 3187 | rsp->rsp_q_in = &ha->iobase->ispfx00.rsp_q_in; |
| 3188 | rsp->rsp_q_out = &ha->iobase->ispfx00.rsp_q_out; |
| 3189 | } |
| 3190 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3191 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3192 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 3193 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 3194 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 3195 | } |
| 3196 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3197 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 3198 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 3199 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 3200 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 3201 | "req->req_q_in=%p req->req_q_out=%p " |
| 3202 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 3203 | req->req_q_in, req->req_q_out, |
| 3204 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 3205 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 3206 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 3207 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 3208 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 3209 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 3210 | 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] | 3211 | |
himanshu.madhani@cavium.com | d48cc67 | 2018-07-02 13:01:59 -0700 | [diff] [blame] | 3212 | ha->wq = alloc_workqueue("qla2xxx_wq", 0, 0); |
| 3213 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3214 | if (ha->isp_ops->initialize_adapter(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3215 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 3216 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 3217 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3218 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3219 | if (IS_QLA82XX(ha)) { |
| 3220 | qla82xx_idc_lock(ha); |
| 3221 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3222 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3223 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3224 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 3225 | "HW State: FAILED.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3226 | } else if (IS_QLA8044(ha)) { |
| 3227 | qla8044_idc_lock(ha); |
| 3228 | qla8044_wr_direct(base_vha, |
| 3229 | QLA8044_CRB_DEV_STATE_INDEX, |
| 3230 | QLA8XXX_DEV_FAILED); |
| 3231 | qla8044_idc_unlock(ha); |
| 3232 | ql_log(ql_log_fatal, base_vha, 0x0150, |
| 3233 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3234 | } |
| 3235 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3236 | ret = -ENODEV; |
| 3237 | goto probe_failed; |
| 3238 | } |
| 3239 | |
Chad Dupuis | 3b1bef6 | 2014-02-26 04:15:04 -0500 | [diff] [blame] | 3240 | if (IS_QLAFX00(ha)) |
| 3241 | host->can_queue = QLAFX00_MAX_CANQUEUE; |
| 3242 | else |
| 3243 | host->can_queue = req->num_outstanding_cmds - 10; |
| 3244 | |
| 3245 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 3246 | "can_queue=%d, req=%p, mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 3247 | host->can_queue, base_vha->req, |
| 3248 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
| 3249 | |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3250 | if (ha->mqenable) { |
| 3251 | bool mq = false; |
| 3252 | bool startit = false; |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3253 | |
| 3254 | if (QLA_TGT_MODE_ENABLED()) { |
| 3255 | mq = true; |
| 3256 | startit = false; |
| 3257 | } |
| 3258 | |
| 3259 | if ((ql2x_ini_mode == QLA2XXX_INI_MODE_ENABLED) && |
| 3260 | shost_use_blk_mq(host)) { |
| 3261 | mq = true; |
| 3262 | startit = true; |
| 3263 | } |
| 3264 | |
| 3265 | if (mq) { |
| 3266 | /* Create start of day qpairs for Block MQ */ |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3267 | for (i = 0; i < ha->max_qpairs; i++) |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3268 | qla2xxx_create_qpair(base_vha, 5, 0, startit); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3269 | } |
| 3270 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3271 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3272 | if (ha->flags.running_gold_fw) |
| 3273 | goto skip_dpc; |
| 3274 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3275 | /* |
| 3276 | * Startup the kernel thread for this host adapter |
| 3277 | */ |
| 3278 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3279 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3280 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3281 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 3282 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3283 | ret = PTR_ERR(ha->dpc_thread); |
Douglas Miller | e2532b4 | 2017-10-20 08:17:22 -0500 | [diff] [blame] | 3284 | ha->dpc_thread = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3285 | goto probe_failed; |
| 3286 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3287 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 3288 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3289 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3290 | /* |
| 3291 | * If we're not coming up in initiator mode, we might sit for |
| 3292 | * a while without waking up the dpc thread, which leads to a |
| 3293 | * stuck process warning. So just kick the dpc once here and |
| 3294 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 3295 | */ |
| 3296 | qla2xxx_wake_dpc(base_vha); |
| 3297 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 3298 | INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); |
| 3299 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3300 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 3301 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 3302 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 3303 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 3304 | |
| 3305 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 3306 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 3307 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 3308 | INIT_WORK(&ha->idc_state_handler, |
| 3309 | qla83xx_idc_state_handler_work); |
| 3310 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 3311 | qla83xx_nic_core_unrecoverable_work); |
| 3312 | } |
| 3313 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3314 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3315 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 3316 | base_vha->host->irq = ha->pdev->irq; |
| 3317 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3318 | /* Initialized the timer */ |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 3319 | qla2x00_start_timer(base_vha, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3320 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 3321 | "Started qla2x00_timer with " |
| 3322 | "interval=%d.\n", WATCH_INTERVAL); |
| 3323 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 3324 | "Detected hba at address=%p.\n", |
| 3325 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3326 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 3327 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3328 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3329 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3330 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3331 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 3332 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3333 | if (ql2xenabledif == 1) |
| 3334 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3335 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3336 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3337 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3338 | | SHOST_DIF_TYPE3_PROTECTION |
| 3339 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3340 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3341 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3342 | |
| 3343 | guard = SHOST_DIX_GUARD_CRC; |
| 3344 | |
| 3345 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 3346 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 3347 | guard |= SHOST_DIX_GUARD_IP; |
| 3348 | |
| 3349 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3350 | } else |
| 3351 | base_vha->flags.difdix_supported = 0; |
| 3352 | } |
| 3353 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3354 | ha->isp_ops->enable_intrs(ha); |
| 3355 | |
Armen Baloyan | 1fe19ee | 2013-08-27 01:37:41 -0400 | [diff] [blame] | 3356 | if (IS_QLAFX00(ha)) { |
| 3357 | ret = qlafx00_fx_disc(base_vha, |
| 3358 | &base_vha->hw->mr.fcport, FXDISC_GET_CONFIG_INFO); |
| 3359 | host->sg_tablesize = (ha->mr.extended_io_enabled) ? |
| 3360 | QLA_SG_ALL : 128; |
| 3361 | } |
| 3362 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3363 | ret = scsi_add_host(host, &pdev->dev); |
| 3364 | if (ret) |
| 3365 | goto probe_failed; |
| 3366 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3367 | base_vha->flags.init_done = 1; |
| 3368 | base_vha->flags.online = 1; |
Saurav Kashyap | edaa5c7 | 2014-04-11 16:54:14 -0400 | [diff] [blame] | 3369 | ha->prev_minidump_failed = 0; |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3370 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3371 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 3372 | "Init done and hba is online.\n"); |
| 3373 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3374 | if (qla_ini_mode_enabled(base_vha) || |
| 3375 | qla_dual_mode_enabled(base_vha)) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3376 | scsi_scan_host(host); |
| 3377 | else |
| 3378 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 3379 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 3380 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3381 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3382 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3383 | if (IS_QLAFX00(ha)) { |
| 3384 | ret = qlafx00_fx_disc(base_vha, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3385 | &base_vha->hw->mr.fcport, FXDISC_GET_PORT_INFO); |
| 3386 | |
| 3387 | /* Register system information */ |
| 3388 | ret = qlafx00_fx_disc(base_vha, |
| 3389 | &base_vha->hw->mr.fcport, FXDISC_REG_HOST_INFO); |
| 3390 | } |
| 3391 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3392 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3393 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3394 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3395 | |
Armen Baloyan | 03eb912 | 2013-10-30 03:38:22 -0400 | [diff] [blame] | 3396 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 3397 | "QLogic %s - %s.\n", ha->model_number, ha->model_desc); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3398 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 3399 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 3400 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 3401 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 3402 | base_vha->host_no, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 3403 | 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] | 3404 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3405 | qlt_add_target(ha, base_vha); |
| 3406 | |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 3407 | clear_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 3408 | |
| 3409 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3410 | return -ENODEV; |
| 3411 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 3412 | if (ha->flags.detected_lr_sfp) { |
| 3413 | ql_log(ql_log_info, base_vha, 0xffff, |
| 3414 | "Reset chip to pick up LR SFP setting\n"); |
| 3415 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 3416 | qla2xxx_wake_dpc(base_vha); |
| 3417 | } |
| 3418 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3419 | return 0; |
| 3420 | |
| 3421 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3422 | if (base_vha->timer_active) |
| 3423 | qla2x00_stop_timer(base_vha); |
| 3424 | base_vha->flags.online = 0; |
| 3425 | if (ha->dpc_thread) { |
| 3426 | struct task_struct *t = ha->dpc_thread; |
| 3427 | |
| 3428 | ha->dpc_thread = NULL; |
| 3429 | kthread_stop(t); |
| 3430 | } |
| 3431 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3432 | qla2x00_free_device(base_vha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3433 | scsi_host_put(base_vha->host); |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 3434 | /* |
| 3435 | * Need to NULL out local req/rsp after |
| 3436 | * qla2x00_free_device => qla2x00_free_queues frees |
| 3437 | * what these are pointing to. Or else we'll |
| 3438 | * fall over below in qla2x00_free_req/rsp_que. |
| 3439 | */ |
| 3440 | req = NULL; |
| 3441 | rsp = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3442 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3443 | probe_hw_failed: |
himanshu.madhani@cavium.com | d64d6c5 | 2018-01-15 20:46:46 -0800 | [diff] [blame] | 3444 | qla2x00_mem_free(ha); |
| 3445 | qla2x00_free_req_que(ha, req); |
| 3446 | qla2x00_free_rsp_que(ha, rsp); |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 3447 | qla2x00_clear_drv_active(ha); |
| 3448 | |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3449 | iospace_config_failed: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3450 | if (IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3451 | if (!ha->nx_pcibase) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3452 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3453 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3454 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3455 | } else { |
| 3456 | if (ha->iobase) |
| 3457 | iounmap(ha->iobase); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3458 | if (ha->cregbase) |
| 3459 | iounmap(ha->cregbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3460 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3461 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3462 | kfree(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3463 | |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 3464 | disable_device: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3465 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3466 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3467 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3468 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 3469 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3470 | qla2x00_shutdown(struct pci_dev *pdev) |
| 3471 | { |
| 3472 | scsi_qla_host_t *vha; |
| 3473 | struct qla_hw_data *ha; |
| 3474 | |
| 3475 | vha = pci_get_drvdata(pdev); |
| 3476 | ha = vha->hw; |
| 3477 | |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 3478 | ql_log(ql_log_info, vha, 0xfffa, |
| 3479 | "Adapter shutdown\n"); |
| 3480 | |
| 3481 | /* |
| 3482 | * Prevent future board_disable and wait |
| 3483 | * until any pending board_disable has completed. |
| 3484 | */ |
| 3485 | set_bit(PFLG_DRIVER_REMOVING, &vha->pci_flags); |
| 3486 | cancel_work_sync(&ha->board_disable); |
| 3487 | |
| 3488 | if (!atomic_read(&pdev->enable_cnt)) |
| 3489 | return; |
| 3490 | |
Armen Baloyan | 4247934 | 2013-08-27 01:37:37 -0400 | [diff] [blame] | 3491 | /* Notify ISPFX00 firmware */ |
| 3492 | if (IS_QLAFX00(ha)) |
| 3493 | qlafx00_driver_shutdown(vha, 20); |
| 3494 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3495 | /* Turn-off FCE trace */ |
| 3496 | if (ha->flags.fce_enabled) { |
| 3497 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 3498 | ha->flags.fce_enabled = 0; |
| 3499 | } |
| 3500 | |
| 3501 | /* Turn-off EFT trace */ |
| 3502 | if (ha->eft) |
| 3503 | qla2x00_disable_eft_trace(vha); |
| 3504 | |
Quinn Tran | 3407fc3 | 2017-12-28 12:33:11 -0800 | [diff] [blame] | 3505 | if (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
| 3506 | if (ha->flags.fw_started) |
| 3507 | qla2x00_abort_isp_cleanup(vha); |
| 3508 | } else { |
| 3509 | /* Stop currently executing firmware. */ |
| 3510 | qla2x00_try_to_stop_firmware(vha); |
| 3511 | } |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3512 | |
| 3513 | /* Turn adapter off line */ |
| 3514 | vha->flags.online = 0; |
| 3515 | |
| 3516 | /* turn-off interrupts on the card */ |
| 3517 | if (ha->interrupts_on) { |
| 3518 | vha->flags.init_done = 0; |
| 3519 | ha->isp_ops->disable_intrs(ha); |
| 3520 | } |
| 3521 | |
| 3522 | qla2x00_free_irqs(vha); |
| 3523 | |
| 3524 | qla2x00_free_fw_dump(ha); |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3525 | |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3526 | pci_disable_device(pdev); |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 3527 | ql_log(ql_log_info, vha, 0xfffe, |
| 3528 | "Adapter shutdown successfully.\n"); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3529 | } |
| 3530 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3531 | /* Deletes all the virtual ports for a given ha */ |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3532 | static void |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3533 | 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] | 3534 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3535 | scsi_qla_host_t *vha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3536 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3537 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3538 | mutex_lock(&ha->vport_lock); |
| 3539 | while (ha->cur_vport_count) { |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3540 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3541 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3542 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 3543 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 3544 | 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] | 3545 | scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3546 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3547 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3548 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3549 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3550 | fc_vport_terminate(vha->fc_vport); |
| 3551 | scsi_host_put(vha->host); |
| 3552 | |
| 3553 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3554 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3555 | mutex_unlock(&ha->vport_lock); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3556 | } |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3557 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3558 | /* Stops all deferred work threads */ |
| 3559 | static void |
| 3560 | qla2x00_destroy_deferred_work(struct qla_hw_data *ha) |
| 3561 | { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3562 | /* Cancel all work and destroy DPC workqueues */ |
| 3563 | if (ha->dpc_lp_wq) { |
| 3564 | cancel_work_sync(&ha->idc_aen); |
| 3565 | destroy_workqueue(ha->dpc_lp_wq); |
| 3566 | ha->dpc_lp_wq = NULL; |
| 3567 | } |
| 3568 | |
| 3569 | if (ha->dpc_hp_wq) { |
| 3570 | cancel_work_sync(&ha->nic_core_reset); |
| 3571 | cancel_work_sync(&ha->idc_state_handler); |
| 3572 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 3573 | destroy_workqueue(ha->dpc_hp_wq); |
| 3574 | ha->dpc_hp_wq = NULL; |
| 3575 | } |
| 3576 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3577 | /* Kill the kernel thread for this host */ |
| 3578 | if (ha->dpc_thread) { |
| 3579 | struct task_struct *t = ha->dpc_thread; |
| 3580 | |
| 3581 | /* |
| 3582 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 3583 | * so we need to zero it out. |
| 3584 | */ |
| 3585 | ha->dpc_thread = NULL; |
| 3586 | kthread_stop(t); |
| 3587 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3588 | } |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3589 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3590 | static void |
| 3591 | qla2x00_unmap_iobases(struct qla_hw_data *ha) |
| 3592 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3593 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 3594 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3595 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3596 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3597 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3598 | } else { |
| 3599 | if (ha->iobase) |
| 3600 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3601 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3602 | if (ha->cregbase) |
| 3603 | iounmap(ha->cregbase); |
| 3604 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3605 | if (ha->mqiobase) |
| 3606 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3607 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3608 | if ((IS_QLA83XX(ha) || IS_QLA27XX(ha)) && ha->msixbase) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3609 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3610 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3611 | } |
| 3612 | |
| 3613 | static void |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3614 | qla2x00_clear_drv_active(struct qla_hw_data *ha) |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3615 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3616 | if (IS_QLA8044(ha)) { |
| 3617 | qla8044_idc_lock(ha); |
Saurav Kashyap | c41afc9 | 2013-11-07 02:54:56 -0500 | [diff] [blame] | 3618 | qla8044_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3619 | qla8044_idc_unlock(ha); |
| 3620 | } else if (IS_QLA82XX(ha)) { |
| 3621 | qla82xx_idc_lock(ha); |
| 3622 | qla82xx_clear_drv_active(ha); |
| 3623 | qla82xx_idc_unlock(ha); |
| 3624 | } |
| 3625 | } |
| 3626 | |
| 3627 | static void |
| 3628 | qla2x00_remove_one(struct pci_dev *pdev) |
| 3629 | { |
| 3630 | scsi_qla_host_t *base_vha; |
| 3631 | struct qla_hw_data *ha; |
| 3632 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3633 | base_vha = pci_get_drvdata(pdev); |
| 3634 | ha = base_vha->hw; |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 3635 | ql_log(ql_log_info, base_vha, 0xb079, |
| 3636 | "Removing driver\n"); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3637 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3638 | /* Indicate device removal to prevent future board_disable and wait |
| 3639 | * until any pending board_disable has completed. */ |
| 3640 | set_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags); |
| 3641 | cancel_work_sync(&ha->board_disable); |
| 3642 | |
| 3643 | /* |
| 3644 | * If the PCI device is disabled then there was a PCI-disconnect and |
| 3645 | * qla2x00_disable_board_on_pci_error has taken care of most of the |
| 3646 | * resources. |
| 3647 | */ |
| 3648 | if (!atomic_read(&pdev->enable_cnt)) { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3649 | dma_free_coherent(&ha->pdev->dev, base_vha->gnl.size, |
| 3650 | base_vha->gnl.l, base_vha->gnl.ldma); |
| 3651 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3652 | scsi_host_put(base_vha->host); |
| 3653 | kfree(ha); |
| 3654 | pci_set_drvdata(pdev, NULL); |
| 3655 | return; |
| 3656 | } |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 3657 | qla2x00_wait_for_hba_ready(base_vha); |
| 3658 | |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 3659 | if (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
| 3660 | if (ha->flags.fw_started) |
| 3661 | qla2x00_abort_isp_cleanup(base_vha); |
| 3662 | } else if (!IS_QLAFX00(ha)) { |
| 3663 | if (IS_QLA8031(ha)) { |
| 3664 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 3665 | "Clearing fcoe driver presence.\n"); |
| 3666 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 3667 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 3668 | "Error while clearing DRV-Presence.\n"); |
| 3669 | } |
| 3670 | |
| 3671 | qla2x00_try_to_stop_firmware(base_vha); |
| 3672 | } |
| 3673 | |
Quinn Tran | 2ce87cc | 2018-01-23 11:05:21 -0800 | [diff] [blame] | 3674 | qla2x00_wait_for_sess_deletion(base_vha); |
| 3675 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3676 | /* |
| 3677 | * if UNLOAD flag is already set, then continue unload, |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 3678 | * where it was set first. |
| 3679 | */ |
| 3680 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3681 | return; |
| 3682 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3683 | set_bit(UNLOADING, &base_vha->dpc_flags); |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 3684 | |
| 3685 | qla_nvme_delete(base_vha); |
| 3686 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3687 | dma_free_coherent(&ha->pdev->dev, |
| 3688 | base_vha->gnl.size, base_vha->gnl.l, base_vha->gnl.ldma); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3689 | |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 3690 | vfree(base_vha->scan.l); |
| 3691 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3692 | if (IS_QLAFX00(ha)) |
| 3693 | qlafx00_driver_shutdown(base_vha, 20); |
| 3694 | |
| 3695 | qla2x00_delete_all_vps(ha, base_vha); |
| 3696 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3697 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 3698 | |
| 3699 | qla2x00_dfs_remove(base_vha); |
| 3700 | |
| 3701 | qla84xx_put_chip(base_vha); |
| 3702 | |
| 3703 | /* Disable timer */ |
| 3704 | if (base_vha->timer_active) |
| 3705 | qla2x00_stop_timer(base_vha); |
| 3706 | |
| 3707 | base_vha->flags.online = 0; |
| 3708 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3709 | /* free DMA memory */ |
| 3710 | if (ha->exlogin_buf) |
| 3711 | qla2x00_free_exlogin_buffer(ha); |
| 3712 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3713 | /* free DMA memory */ |
| 3714 | if (ha->exchoffld_buf) |
| 3715 | qla2x00_free_exchoffld_buffer(ha); |
| 3716 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3717 | qla2x00_destroy_deferred_work(ha); |
| 3718 | |
| 3719 | qlt_remove_target(ha, base_vha); |
| 3720 | |
| 3721 | qla2x00_free_sysfs_attr(base_vha, true); |
| 3722 | |
| 3723 | fc_remove_host(base_vha->host); |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3724 | qlt_remove_target_resources(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3725 | |
| 3726 | scsi_remove_host(base_vha->host); |
| 3727 | |
| 3728 | qla2x00_free_device(base_vha); |
| 3729 | |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3730 | qla2x00_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3731 | |
Arun Easi | d2749ff | 2014-09-25 05:16:51 -0400 | [diff] [blame] | 3732 | scsi_host_put(base_vha->host); |
| 3733 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3734 | qla2x00_unmap_iobases(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3735 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3736 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3737 | kfree(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3738 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3739 | pci_disable_pcie_error_reporting(pdev); |
| 3740 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 3741 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3742 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3743 | |
| 3744 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3745 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3746 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3747 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3748 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3749 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 3750 | |
| 3751 | /* Disable timer */ |
| 3752 | if (vha->timer_active) |
| 3753 | qla2x00_stop_timer(vha); |
| 3754 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3755 | qla25xx_delete_queues(vha); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3756 | vha->flags.online = 0; |
| 3757 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3758 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3759 | if (ha->interrupts_on) { |
| 3760 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 3761 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3762 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3763 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3764 | qla2x00_free_fcports(vha); |
| 3765 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3766 | qla2x00_free_irqs(vha); |
| 3767 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3768 | /* Flush the work queue and remove it */ |
| 3769 | if (ha->wq) { |
| 3770 | flush_workqueue(ha->wq); |
| 3771 | destroy_workqueue(ha->wq); |
| 3772 | ha->wq = NULL; |
| 3773 | } |
| 3774 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3775 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3776 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3777 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 3778 | qla82xx_md_free(vha); |
| 3779 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3780 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3781 | } |
| 3782 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3783 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 3784 | { |
| 3785 | fc_port_t *fcport, *tfcport; |
| 3786 | |
| 3787 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 3788 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3789 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3790 | kfree(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3791 | } |
| 3792 | } |
| 3793 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3794 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3795 | 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] | 3796 | int defer) |
| 3797 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3798 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3799 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3800 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3801 | |
| 3802 | if (!fcport->rport) |
| 3803 | return; |
| 3804 | |
| 3805 | rport = fcport->rport; |
| 3806 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3807 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3808 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3809 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3810 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3811 | qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3812 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 3813 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3814 | } else { |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3815 | int now; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3816 | if (rport) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3817 | ql_dbg(ql_dbg_disc, fcport->vha, 0x2109, |
| 3818 | "%s %8phN. rport %p roles %x\n", |
| 3819 | __func__, fcport->port_name, rport, |
| 3820 | rport->roles); |
Alexei Potashnik | d20ed91 | 2015-07-14 16:00:47 -0400 | [diff] [blame] | 3821 | fc_remote_port_delete(rport); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3822 | } |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3823 | qlt_do_generation_tick(vha, &now); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3824 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3825 | } |
| 3826 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3827 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3828 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 3829 | * |
| 3830 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 3831 | * |
| 3832 | * Return: None. |
| 3833 | * |
| 3834 | * Context: |
| 3835 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3836 | 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] | 3837 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3838 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3839 | if (IS_QLAFX00(vha->hw)) { |
| 3840 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
| 3841 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3842 | return; |
| 3843 | } |
| 3844 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3845 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3846 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3847 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3848 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3849 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3850 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3851 | * We may need to retry the login, so don't change the state of the |
| 3852 | * port but do the retries. |
| 3853 | */ |
| 3854 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3855 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3856 | |
| 3857 | if (!do_login) |
| 3858 | return; |
| 3859 | |
Arun Easi | a1d0285 | 2015-08-04 13:38:02 -0400 | [diff] [blame] | 3860 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3861 | } |
| 3862 | |
| 3863 | /* |
| 3864 | * qla2x00_mark_all_devices_lost |
| 3865 | * Updates fcport state when device goes offline. |
| 3866 | * |
| 3867 | * Input: |
| 3868 | * ha = adapter block pointer. |
| 3869 | * fcport = port structure pointer. |
| 3870 | * |
| 3871 | * Return: |
| 3872 | * None. |
| 3873 | * |
| 3874 | * Context: |
| 3875 | */ |
| 3876 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3877 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3878 | { |
| 3879 | fc_port_t *fcport; |
| 3880 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3881 | ql_dbg(ql_dbg_disc, vha, 0x20f1, |
| 3882 | "Mark all dev lost\n"); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3883 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3884 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3885 | fcport->scan_state = 0; |
Quinn Tran | d8630bb | 2017-12-28 12:33:43 -0800 | [diff] [blame] | 3886 | qlt_schedule_sess_for_deletion(fcport); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3887 | |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3888 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3889 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3890 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3891 | /* |
| 3892 | * No point in marking the device as lost, if the device is |
| 3893 | * already DEAD. |
| 3894 | */ |
| 3895 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3896 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3897 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3898 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3899 | if (defer) |
| 3900 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3901 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3902 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3903 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3904 | } |
| 3905 | } |
| 3906 | |
| 3907 | /* |
| 3908 | * qla2x00_mem_alloc |
| 3909 | * Allocates adapter memory. |
| 3910 | * |
| 3911 | * Returns: |
| 3912 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3913 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3914 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3915 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3916 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3917 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3918 | { |
| 3919 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3920 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3921 | 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] | 3922 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3923 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3924 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3925 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3926 | if (qlt_mem_alloc(ha) < 0) |
| 3927 | goto fail_free_init_cb; |
| 3928 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3929 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3930 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3931 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3932 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3933 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3934 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3935 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3936 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3937 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3938 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3939 | /* Allocate cache for CT6 Ctx. */ |
| 3940 | if (!ctx_cachep) { |
| 3941 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3942 | sizeof(struct ct6_dsd), 0, |
| 3943 | SLAB_HWCACHE_ALIGN, NULL); |
| 3944 | if (!ctx_cachep) |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3945 | goto fail_free_srb_mempool; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3946 | } |
| 3947 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3948 | ctx_cachep); |
| 3949 | if (!ha->ctx_mempool) |
| 3950 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3951 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3952 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3953 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3954 | } |
| 3955 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3956 | /* Get memory for cached NVRAM */ |
| 3957 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3958 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3959 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3960 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3961 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3962 | ha->pdev->device); |
| 3963 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3964 | DMA_POOL_SIZE, 8, 0); |
| 3965 | if (!ha->s_dma_pool) |
| 3966 | goto fail_free_nvram; |
| 3967 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3968 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3969 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3970 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3971 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3972 | if (IS_P3P_TYPE(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3973 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3974 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3975 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3976 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3977 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3978 | goto fail_s_dma_pool; |
| 3979 | } |
| 3980 | |
| 3981 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3982 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3983 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3984 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3985 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3986 | goto fail_dl_dma_pool; |
| 3987 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3988 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3989 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3990 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3991 | } |
| 3992 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3993 | /* Allocate memory for SNS commands */ |
| 3994 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3995 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3996 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3997 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3998 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3999 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4000 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 4001 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4002 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4003 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4004 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4005 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4006 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4007 | goto fail_dma_pool; |
| 4008 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4009 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4010 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4011 | if (!ha->ct_sns) |
| 4012 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4013 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 4014 | "ms_iocb=%p ct_sns=%p.\n", |
| 4015 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4016 | } |
| 4017 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4018 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4019 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 4020 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4021 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 4022 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4023 | goto fail_req; |
| 4024 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4025 | (*req)->length = req_len; |
| 4026 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 4027 | ((*req)->length + 1) * sizeof(request_t), |
| 4028 | &(*req)->dma, GFP_KERNEL); |
| 4029 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4030 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 4031 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4032 | goto fail_req_ring; |
| 4033 | } |
| 4034 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4035 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 4036 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4037 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 4038 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4039 | goto fail_rsp; |
| 4040 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4041 | (*rsp)->hw = ha; |
| 4042 | (*rsp)->length = rsp_len; |
| 4043 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 4044 | ((*rsp)->length + 1) * sizeof(response_t), |
| 4045 | &(*rsp)->dma, GFP_KERNEL); |
| 4046 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4047 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 4048 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4049 | goto fail_rsp_ring; |
| 4050 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4051 | (*req)->rsp = *rsp; |
| 4052 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4053 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 4054 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 4055 | "rsp->length=%d rsp->ring=%p.\n", |
| 4056 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 4057 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4058 | /* Allocate memory for NVRAM data for vports */ |
| 4059 | if (ha->nvram_npiv_size) { |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 4060 | ha->npiv_info = kcalloc(ha->nvram_npiv_size, |
| 4061 | sizeof(struct qla_npiv_entry), |
| 4062 | GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4063 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4064 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 4065 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4066 | goto fail_npiv_info; |
| 4067 | } |
| 4068 | } else |
| 4069 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4070 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4071 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4072 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4073 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 4074 | &ha->ex_init_cb_dma); |
| 4075 | if (!ha->ex_init_cb) |
| 4076 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4077 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 4078 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4079 | } |
| 4080 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4081 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 4082 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4083 | /* Get consistent memory allocated for Async Port-Database. */ |
| 4084 | if (!IS_FWI2_CAPABLE(ha)) { |
| 4085 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 4086 | &ha->async_pd_dma); |
| 4087 | if (!ha->async_pd) |
| 4088 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4089 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 4090 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4091 | } |
| 4092 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4093 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4094 | |
| 4095 | /* Allocate memory for our loop_id bitmap */ |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 4096 | ha->loop_id_map = kcalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE), |
| 4097 | sizeof(long), |
| 4098 | GFP_KERNEL); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4099 | if (!ha->loop_id_map) |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4100 | goto fail_loop_id_map; |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4101 | else { |
| 4102 | qla2x00_set_reserved_loop_ids(ha); |
| 4103 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 4104 | "loop_id_map=%p.\n", ha->loop_id_map); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4105 | } |
| 4106 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4107 | ha->sfp_data = dma_alloc_coherent(&ha->pdev->dev, |
| 4108 | SFP_DEV_SIZE, &ha->sfp_data_dma, GFP_KERNEL); |
| 4109 | if (!ha->sfp_data) { |
| 4110 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b, |
| 4111 | "Unable to allocate memory for SFP read-data.\n"); |
| 4112 | goto fail_sfp_data; |
| 4113 | } |
| 4114 | |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 4115 | return 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4116 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4117 | fail_sfp_data: |
| 4118 | kfree(ha->loop_id_map); |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4119 | fail_loop_id_map: |
| 4120 | 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] | 4121 | fail_async_pd: |
| 4122 | 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] | 4123 | fail_ex_init_cb: |
| 4124 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4125 | fail_npiv_info: |
| 4126 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 4127 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 4128 | (*rsp)->ring = NULL; |
| 4129 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4130 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4131 | kfree(*rsp); |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 4132 | *rsp = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4133 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4134 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 4135 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 4136 | (*req)->ring = NULL; |
| 4137 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4138 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4139 | kfree(*req); |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 4140 | *req = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4141 | fail_req: |
| 4142 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 4143 | ha->ct_sns, ha->ct_sns_dma); |
| 4144 | ha->ct_sns = NULL; |
| 4145 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4146 | fail_free_ms_iocb: |
| 4147 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 4148 | ha->ms_iocb = NULL; |
| 4149 | ha->ms_iocb_dma = 0; |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4150 | |
| 4151 | if (ha->sns_cmd) |
| 4152 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
| 4153 | ha->sns_cmd, ha->sns_cmd_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4154 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 4155 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4156 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 4157 | ha->fcp_cmnd_dma_pool = NULL; |
| 4158 | } |
| 4159 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 4160 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4161 | dma_pool_destroy(ha->dl_dma_pool); |
| 4162 | ha->dl_dma_pool = NULL; |
| 4163 | } |
| 4164 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4165 | dma_pool_destroy(ha->s_dma_pool); |
| 4166 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4167 | fail_free_nvram: |
| 4168 | kfree(ha->nvram); |
| 4169 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4170 | fail_free_ctx_mempool: |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4171 | if (ha->ctx_mempool) |
| 4172 | mempool_destroy(ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4173 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4174 | fail_free_srb_mempool: |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4175 | if (ha->srb_mempool) |
| 4176 | mempool_destroy(ha->srb_mempool); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4177 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4178 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 4179 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 4180 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4181 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4182 | ha->gid_list = NULL; |
| 4183 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4184 | fail_free_tgt_mem: |
| 4185 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4186 | fail_free_init_cb: |
| 4187 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 4188 | ha->init_cb_dma); |
| 4189 | ha->init_cb = NULL; |
| 4190 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4191 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4192 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 4193 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4194 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4195 | } |
| 4196 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4197 | int |
| 4198 | qla2x00_set_exlogins_buffer(scsi_qla_host_t *vha) |
| 4199 | { |
| 4200 | int rval; |
| 4201 | uint16_t size, max_cnt, temp; |
| 4202 | struct qla_hw_data *ha = vha->hw; |
| 4203 | |
| 4204 | /* Return if we don't need to alloacate any extended logins */ |
| 4205 | if (!ql2xexlogins) |
| 4206 | return QLA_SUCCESS; |
| 4207 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4208 | if (!IS_EXLOGIN_OFFLD_CAPABLE(ha)) |
| 4209 | return QLA_SUCCESS; |
| 4210 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4211 | ql_log(ql_log_info, vha, 0xd021, "EXLOGIN count: %d.\n", ql2xexlogins); |
| 4212 | max_cnt = 0; |
| 4213 | rval = qla_get_exlogin_status(vha, &size, &max_cnt); |
| 4214 | if (rval != QLA_SUCCESS) { |
| 4215 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd029, |
| 4216 | "Failed to get exlogin status.\n"); |
| 4217 | return rval; |
| 4218 | } |
| 4219 | |
| 4220 | temp = (ql2xexlogins > max_cnt) ? max_cnt : ql2xexlogins; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4221 | temp *= size; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4222 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4223 | if (temp != ha->exlogin_size) { |
| 4224 | qla2x00_free_exlogin_buffer(ha); |
| 4225 | ha->exlogin_size = temp; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4226 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4227 | ql_log(ql_log_info, vha, 0xd024, |
| 4228 | "EXLOGIN: max_logins=%d, portdb=0x%x, total=%d.\n", |
| 4229 | max_cnt, size, temp); |
| 4230 | |
| 4231 | ql_log(ql_log_info, vha, 0xd025, |
| 4232 | "EXLOGIN: requested size=0x%x\n", ha->exlogin_size); |
| 4233 | |
| 4234 | /* Get consistent memory for extended logins */ |
| 4235 | ha->exlogin_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 4236 | ha->exlogin_size, &ha->exlogin_buf_dma, GFP_KERNEL); |
| 4237 | if (!ha->exlogin_buf) { |
| 4238 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd02a, |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4239 | "Failed to allocate memory for exlogin_buf_dma.\n"); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4240 | return -ENOMEM; |
| 4241 | } |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4242 | } |
| 4243 | |
| 4244 | /* Now configure the dma buffer */ |
| 4245 | rval = qla_set_exlogin_mem_cfg(vha, ha->exlogin_buf_dma); |
| 4246 | if (rval) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4247 | ql_log(ql_log_fatal, vha, 0xd033, |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4248 | "Setup extended login buffer ****FAILED****.\n"); |
| 4249 | qla2x00_free_exlogin_buffer(ha); |
| 4250 | } |
| 4251 | |
| 4252 | return rval; |
| 4253 | } |
| 4254 | |
| 4255 | /* |
| 4256 | * qla2x00_free_exlogin_buffer |
| 4257 | * |
| 4258 | * Input: |
| 4259 | * ha = adapter block pointer |
| 4260 | */ |
| 4261 | void |
| 4262 | qla2x00_free_exlogin_buffer(struct qla_hw_data *ha) |
| 4263 | { |
| 4264 | if (ha->exlogin_buf) { |
| 4265 | dma_free_coherent(&ha->pdev->dev, ha->exlogin_size, |
| 4266 | ha->exlogin_buf, ha->exlogin_buf_dma); |
| 4267 | ha->exlogin_buf = NULL; |
| 4268 | ha->exlogin_size = 0; |
| 4269 | } |
| 4270 | } |
| 4271 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4272 | static void |
| 4273 | qla2x00_number_of_exch(scsi_qla_host_t *vha, u32 *ret_cnt, u16 max_cnt) |
| 4274 | { |
| 4275 | u32 temp; |
| 4276 | *ret_cnt = FW_DEF_EXCHANGES_CNT; |
| 4277 | |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4278 | if (max_cnt > vha->hw->max_exchg) |
| 4279 | max_cnt = vha->hw->max_exchg; |
| 4280 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4281 | if (qla_ini_mode_enabled(vha)) { |
| 4282 | if (ql2xiniexchg > max_cnt) |
| 4283 | ql2xiniexchg = max_cnt; |
| 4284 | |
| 4285 | if (ql2xiniexchg > FW_DEF_EXCHANGES_CNT) |
| 4286 | *ret_cnt = ql2xiniexchg; |
| 4287 | } else if (qla_tgt_mode_enabled(vha)) { |
| 4288 | if (ql2xexchoffld > max_cnt) |
| 4289 | ql2xexchoffld = max_cnt; |
| 4290 | |
| 4291 | if (ql2xexchoffld > FW_DEF_EXCHANGES_CNT) |
| 4292 | *ret_cnt = ql2xexchoffld; |
| 4293 | } else if (qla_dual_mode_enabled(vha)) { |
| 4294 | temp = ql2xiniexchg + ql2xexchoffld; |
| 4295 | if (temp > max_cnt) { |
| 4296 | ql2xiniexchg -= (temp - max_cnt)/2; |
| 4297 | ql2xexchoffld -= (((temp - max_cnt)/2) + 1); |
| 4298 | temp = max_cnt; |
| 4299 | } |
| 4300 | |
| 4301 | if (temp > FW_DEF_EXCHANGES_CNT) |
| 4302 | *ret_cnt = temp; |
| 4303 | } |
| 4304 | } |
| 4305 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4306 | int |
| 4307 | qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) |
| 4308 | { |
| 4309 | int rval; |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4310 | u16 size, max_cnt; |
| 4311 | u32 actual_cnt, totsz; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4312 | struct qla_hw_data *ha = vha->hw; |
| 4313 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4314 | if (!ha->flags.exchoffld_enabled) |
| 4315 | return QLA_SUCCESS; |
| 4316 | |
| 4317 | if (!IS_EXCHG_OFFLD_CAPABLE(ha)) |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4318 | return QLA_SUCCESS; |
| 4319 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4320 | max_cnt = 0; |
| 4321 | rval = qla_get_exchoffld_status(vha, &size, &max_cnt); |
| 4322 | if (rval != QLA_SUCCESS) { |
| 4323 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd012, |
| 4324 | "Failed to get exlogin status.\n"); |
| 4325 | return rval; |
| 4326 | } |
| 4327 | |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4328 | qla2x00_number_of_exch(vha, &actual_cnt, max_cnt); |
| 4329 | ql_log(ql_log_info, vha, 0xd014, |
| 4330 | "Actual exchange offload count: %d.\n", actual_cnt); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4331 | |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4332 | totsz = actual_cnt * size; |
| 4333 | |
| 4334 | if (totsz != ha->exchoffld_size) { |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4335 | qla2x00_free_exchoffld_buffer(ha); |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4336 | ha->exchoffld_size = totsz; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4337 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4338 | ql_log(ql_log_info, vha, 0xd016, |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4339 | "Exchange offload: max_count=%d, actual count=%d entry sz=0x%x, total sz=0x%x\n", |
| 4340 | max_cnt, actual_cnt, size, totsz); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4341 | |
| 4342 | ql_log(ql_log_info, vha, 0xd017, |
| 4343 | "Exchange Buffers requested size = 0x%x\n", |
| 4344 | ha->exchoffld_size); |
| 4345 | |
| 4346 | /* Get consistent memory for extended logins */ |
| 4347 | ha->exchoffld_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 4348 | ha->exchoffld_size, &ha->exchoffld_buf_dma, GFP_KERNEL); |
| 4349 | if (!ha->exchoffld_buf) { |
| 4350 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4351 | "Failed to allocate memory for Exchange Offload.\n"); |
| 4352 | |
| 4353 | if (ha->max_exchg > |
| 4354 | (FW_DEF_EXCHANGES_CNT + REDUCE_EXCHANGES_CNT)) { |
| 4355 | ha->max_exchg -= REDUCE_EXCHANGES_CNT; |
| 4356 | } else if (ha->max_exchg > |
| 4357 | (FW_DEF_EXCHANGES_CNT + 512)) { |
| 4358 | ha->max_exchg -= 512; |
| 4359 | } else { |
| 4360 | ha->flags.exchoffld_enabled = 0; |
| 4361 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
| 4362 | "Disabling Exchange offload due to lack of memory\n"); |
| 4363 | } |
| 4364 | ha->exchoffld_size = 0; |
| 4365 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4366 | return -ENOMEM; |
| 4367 | } |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4368 | } |
| 4369 | |
| 4370 | /* Now configure the dma buffer */ |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4371 | rval = qla_set_exchoffld_mem_cfg(vha); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4372 | if (rval) { |
| 4373 | ql_log(ql_log_fatal, vha, 0xd02e, |
| 4374 | "Setup exchange offload buffer ****FAILED****.\n"); |
| 4375 | qla2x00_free_exchoffld_buffer(ha); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4376 | } else { |
| 4377 | /* re-adjust number of target exchange */ |
| 4378 | struct init_cb_81xx *icb = (struct init_cb_81xx *)ha->init_cb; |
| 4379 | |
| 4380 | if (qla_ini_mode_enabled(vha)) |
| 4381 | icb->exchange_count = 0; |
| 4382 | else |
| 4383 | icb->exchange_count = cpu_to_le16(ql2xexchoffld); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4384 | } |
| 4385 | |
| 4386 | return rval; |
| 4387 | } |
| 4388 | |
| 4389 | /* |
| 4390 | * qla2x00_free_exchoffld_buffer |
| 4391 | * |
| 4392 | * Input: |
| 4393 | * ha = adapter block pointer |
| 4394 | */ |
| 4395 | void |
| 4396 | qla2x00_free_exchoffld_buffer(struct qla_hw_data *ha) |
| 4397 | { |
| 4398 | if (ha->exchoffld_buf) { |
| 4399 | dma_free_coherent(&ha->pdev->dev, ha->exchoffld_size, |
| 4400 | ha->exchoffld_buf, ha->exchoffld_buf_dma); |
| 4401 | ha->exchoffld_buf = NULL; |
| 4402 | ha->exchoffld_size = 0; |
| 4403 | } |
| 4404 | } |
| 4405 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4406 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4407 | * qla2x00_free_fw_dump |
| 4408 | * Frees fw dump stuff. |
| 4409 | * |
| 4410 | * Input: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 4411 | * ha = adapter block pointer |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4412 | */ |
| 4413 | static void |
| 4414 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 4415 | { |
| 4416 | if (ha->fce) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4417 | dma_free_coherent(&ha->pdev->dev, |
| 4418 | FCE_SIZE, ha->fce, ha->fce_dma); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4419 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4420 | if (ha->eft) |
| 4421 | dma_free_coherent(&ha->pdev->dev, |
| 4422 | EFT_SIZE, ha->eft, ha->eft_dma); |
| 4423 | |
| 4424 | if (ha->fw_dump) |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4425 | vfree(ha->fw_dump); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4426 | if (ha->fw_dump_template) |
| 4427 | vfree(ha->fw_dump_template); |
| 4428 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4429 | ha->fce = NULL; |
| 4430 | ha->fce_dma = 0; |
| 4431 | ha->eft = NULL; |
| 4432 | ha->eft_dma = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4433 | ha->fw_dumped = 0; |
Hiral Patel | 61f098d | 2014-04-11 16:54:21 -0400 | [diff] [blame] | 4434 | ha->fw_dump_cap_flags = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4435 | ha->fw_dump_reading = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4436 | ha->fw_dump = NULL; |
| 4437 | ha->fw_dump_len = 0; |
| 4438 | ha->fw_dump_template = NULL; |
| 4439 | ha->fw_dump_template_len = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4440 | } |
| 4441 | |
| 4442 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4443 | * qla2x00_mem_free |
| 4444 | * Frees all adapter allocated memory. |
| 4445 | * |
| 4446 | * Input: |
| 4447 | * ha = adapter block pointer. |
| 4448 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 4449 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4450 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4451 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4452 | qla2x00_free_fw_dump(ha); |
| 4453 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4454 | if (ha->mctp_dump) |
| 4455 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 4456 | ha->mctp_dump_dma); |
| 4457 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4458 | if (ha->srb_mempool) |
| 4459 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4460 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4461 | if (ha->dcbx_tlv) |
| 4462 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 4463 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 4464 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4465 | if (ha->xgmac_data) |
| 4466 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 4467 | ha->xgmac_data, ha->xgmac_data_dma); |
| 4468 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4469 | if (ha->sns_cmd) |
| 4470 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4471 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4472 | |
| 4473 | if (ha->ct_sns) |
| 4474 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4475 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4476 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 4477 | if (ha->sfp_data) |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4478 | dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE, ha->sfp_data, |
| 4479 | ha->sfp_data_dma); |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 4480 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4481 | if (ha->ms_iocb) |
| 4482 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 4483 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4484 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4485 | dma_pool_free(ha->s_dma_pool, |
| 4486 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4487 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4488 | if (ha->async_pd) |
| 4489 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 4490 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4491 | if (ha->s_dma_pool) |
| 4492 | dma_pool_destroy(ha->s_dma_pool); |
| 4493 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4494 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 4495 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 4496 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4497 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4498 | if (IS_QLA82XX(ha)) { |
| 4499 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 4500 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 4501 | |
| 4502 | /* clean up allocated prev pool */ |
| 4503 | list_for_each_entry_safe(dsd_ptr, |
| 4504 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 4505 | dma_pool_free(ha->dl_dma_pool, |
| 4506 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 4507 | list_del(&dsd_ptr->list); |
| 4508 | kfree(dsd_ptr); |
| 4509 | } |
| 4510 | } |
| 4511 | } |
| 4512 | |
| 4513 | if (ha->dl_dma_pool) |
| 4514 | dma_pool_destroy(ha->dl_dma_pool); |
| 4515 | |
| 4516 | if (ha->fcp_cmnd_dma_pool) |
| 4517 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 4518 | |
| 4519 | if (ha->ctx_mempool) |
| 4520 | mempool_destroy(ha->ctx_mempool); |
| 4521 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4522 | qlt_mem_free(ha); |
| 4523 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4524 | if (ha->init_cb) |
| 4525 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4526 | ha->init_cb, ha->init_cb_dma); |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 4527 | |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 4528 | vfree(ha->optrom_buffer); |
| 4529 | kfree(ha->nvram); |
| 4530 | kfree(ha->npiv_info); |
| 4531 | kfree(ha->swl); |
| 4532 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4533 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4534 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4535 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4536 | ha->sns_cmd = NULL; |
| 4537 | ha->sns_cmd_dma = 0; |
| 4538 | ha->ct_sns = NULL; |
| 4539 | ha->ct_sns_dma = 0; |
| 4540 | ha->ms_iocb = NULL; |
| 4541 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4542 | ha->init_cb = NULL; |
| 4543 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4544 | ha->ex_init_cb = NULL; |
| 4545 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4546 | ha->async_pd = NULL; |
| 4547 | ha->async_pd_dma = 0; |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 4548 | ha->loop_id_map = NULL; |
| 4549 | ha->npiv_info = NULL; |
| 4550 | ha->optrom_buffer = NULL; |
| 4551 | ha->swl = NULL; |
| 4552 | ha->nvram = NULL; |
| 4553 | ha->mctp_dump = NULL; |
| 4554 | ha->dcbx_tlv = NULL; |
| 4555 | ha->xgmac_data = NULL; |
| 4556 | ha->sfp_data = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4557 | |
| 4558 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4559 | ha->dl_dma_pool = NULL; |
| 4560 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4561 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4562 | ha->gid_list = NULL; |
| 4563 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4564 | |
| 4565 | ha->tgt.atio_ring = NULL; |
| 4566 | ha->tgt.atio_dma = 0; |
| 4567 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4568 | } |
| 4569 | |
| 4570 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 4571 | struct qla_hw_data *ha) |
| 4572 | { |
| 4573 | struct Scsi_Host *host; |
| 4574 | struct scsi_qla_host *vha = NULL; |
| 4575 | |
| 4576 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4577 | if (!host) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4578 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 4579 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4580 | return NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4581 | } |
| 4582 | |
| 4583 | /* Clear our data area */ |
| 4584 | vha = shost_priv(host); |
| 4585 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 4586 | |
| 4587 | vha->host = host; |
| 4588 | vha->host_no = host->host_no; |
| 4589 | vha->hw = ha; |
| 4590 | |
| 4591 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 4592 | INIT_LIST_HEAD(&vha->work_list); |
| 4593 | INIT_LIST_HEAD(&vha->list); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4594 | INIT_LIST_HEAD(&vha->qla_cmd_list); |
| 4595 | INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list); |
Alexei Potashnik | 71cdc07 | 2015-12-17 14:57:01 -0500 | [diff] [blame] | 4596 | INIT_LIST_HEAD(&vha->logo_list); |
Alexei Potashnik | b7bd104 | 2015-12-17 14:57:02 -0500 | [diff] [blame] | 4597 | INIT_LIST_HEAD(&vha->plogi_ack_list); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 4598 | INIT_LIST_HEAD(&vha->qp_list); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4599 | INIT_LIST_HEAD(&vha->gnl.fcports); |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 4600 | INIT_LIST_HEAD(&vha->nvme_rport_list); |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame] | 4601 | INIT_LIST_HEAD(&vha->gpnid_list); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4602 | INIT_WORK(&vha->iocb_work, qla2x00_iocb_work_fn); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4603 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4604 | spin_lock_init(&vha->work_lock); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4605 | spin_lock_init(&vha->cmd_list_lock); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4606 | init_waitqueue_head(&vha->fcport_waitQ); |
Joe Carnuccio | c4a9b53 | 2017-03-15 09:48:43 -0700 | [diff] [blame] | 4607 | init_waitqueue_head(&vha->vref_waitq); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4608 | |
Bart Van Assche | 2fdbc65 | 2017-01-20 13:31:13 -0800 | [diff] [blame] | 4609 | vha->gnl.size = sizeof(struct get_name_list_extended) * |
| 4610 | (ha->max_loop_id + 1); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4611 | vha->gnl.l = dma_alloc_coherent(&ha->pdev->dev, |
| 4612 | vha->gnl.size, &vha->gnl.ldma, GFP_KERNEL); |
| 4613 | if (!vha->gnl.l) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4614 | ql_log(ql_log_fatal, vha, 0xd04a, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4615 | "Alloc failed for name list.\n"); |
| 4616 | scsi_remove_host(vha->host); |
| 4617 | return NULL; |
| 4618 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4619 | |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4620 | /* todo: what about ext login? */ |
| 4621 | vha->scan.size = ha->max_fibre_devices * sizeof(struct fab_scan_rp); |
| 4622 | vha->scan.l = vmalloc(vha->scan.size); |
| 4623 | if (!vha->scan.l) { |
| 4624 | ql_log(ql_log_fatal, vha, 0xd04a, |
| 4625 | "Alloc failed for scan database.\n"); |
| 4626 | dma_free_coherent(&ha->pdev->dev, vha->gnl.size, |
| 4627 | vha->gnl.l, vha->gnl.ldma); |
| 4628 | scsi_remove_host(vha->host); |
| 4629 | return NULL; |
| 4630 | } |
Quinn Tran | f352eeb | 2017-12-28 12:33:35 -0800 | [diff] [blame] | 4631 | INIT_DELAYED_WORK(&vha->scan.scan_work, qla_scan_work_fn); |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4632 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4633 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4634 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 4635 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 4636 | vha->host, vha->hw, vha, |
| 4637 | dev_name(&(ha->pdev->dev))); |
| 4638 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4639 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4640 | } |
| 4641 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4642 | struct qla_work_evt * |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4643 | 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] | 4644 | { |
| 4645 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4646 | uint8_t bail; |
| 4647 | |
| 4648 | QLA_VHA_MARK_BUSY(vha, bail); |
| 4649 | if (bail) |
| 4650 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4651 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4652 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4653 | if (!e) { |
| 4654 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4655 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4656 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4657 | |
| 4658 | INIT_LIST_HEAD(&e->list); |
| 4659 | e->type = type; |
| 4660 | e->flags = QLA_EVT_FLAG_FREE; |
| 4661 | return e; |
| 4662 | } |
| 4663 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4664 | int |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4665 | 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] | 4666 | { |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4667 | unsigned long flags; |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4668 | bool q = false; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4669 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4670 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4671 | list_add_tail(&e->list, &vha->work_list); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4672 | |
| 4673 | if (!test_and_set_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags)) |
| 4674 | q = true; |
| 4675 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4676 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 4677 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4678 | if (q) |
| 4679 | queue_work(vha->hw->wq, &vha->iocb_work); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4680 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4681 | return QLA_SUCCESS; |
| 4682 | } |
| 4683 | |
| 4684 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4685 | 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] | 4686 | u32 data) |
| 4687 | { |
| 4688 | struct qla_work_evt *e; |
| 4689 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4690 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4691 | if (!e) |
| 4692 | return QLA_FUNCTION_FAILED; |
| 4693 | |
| 4694 | e->u.aen.code = code; |
| 4695 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4696 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4697 | } |
| 4698 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4699 | int |
| 4700 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 4701 | { |
| 4702 | struct qla_work_evt *e; |
| 4703 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4704 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4705 | if (!e) |
| 4706 | return QLA_FUNCTION_FAILED; |
| 4707 | |
| 4708 | 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] | 4709 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4710 | } |
| 4711 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4712 | #define qla2x00_post_async_work(name, type) \ |
| 4713 | int qla2x00_post_async_##name##_work( \ |
| 4714 | struct scsi_qla_host *vha, \ |
| 4715 | fc_port_t *fcport, uint16_t *data) \ |
| 4716 | { \ |
| 4717 | struct qla_work_evt *e; \ |
| 4718 | \ |
| 4719 | e = qla2x00_alloc_work(vha, type); \ |
| 4720 | if (!e) \ |
| 4721 | return QLA_FUNCTION_FAILED; \ |
| 4722 | \ |
| 4723 | e->u.logio.fcport = fcport; \ |
| 4724 | if (data) { \ |
| 4725 | e->u.logio.data[0] = data[0]; \ |
| 4726 | e->u.logio.data[1] = data[1]; \ |
| 4727 | } \ |
Quinn Tran | 6d674927 | 2017-12-28 12:33:41 -0800 | [diff] [blame] | 4728 | fcport->flags |= FCF_ASYNC_ACTIVE; \ |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4729 | return qla2x00_post_work(vha, e); \ |
| 4730 | } |
| 4731 | |
| 4732 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4733 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 4734 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4735 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 4736 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Quinn Tran | 11aea16 | 2017-12-28 12:33:20 -0800 | [diff] [blame] | 4737 | qla2x00_post_async_work(prlo, QLA_EVT_ASYNC_PRLO); |
| 4738 | qla2x00_post_async_work(prlo_done, QLA_EVT_ASYNC_PRLO_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4739 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4740 | int |
| 4741 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 4742 | { |
| 4743 | struct qla_work_evt *e; |
| 4744 | |
| 4745 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 4746 | if (!e) |
| 4747 | return QLA_FUNCTION_FAILED; |
| 4748 | |
| 4749 | e->u.uevent.code = code; |
| 4750 | return qla2x00_post_work(vha, e); |
| 4751 | } |
| 4752 | |
| 4753 | static void |
| 4754 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 4755 | { |
| 4756 | char event_string[40]; |
| 4757 | char *envp[] = { event_string, NULL }; |
| 4758 | |
| 4759 | switch (code) { |
| 4760 | case QLA_UEVENT_CODE_FW_DUMP: |
| 4761 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 4762 | vha->host_no); |
| 4763 | break; |
| 4764 | default: |
| 4765 | /* do nothing */ |
| 4766 | break; |
| 4767 | } |
| 4768 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 4769 | } |
| 4770 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4771 | int |
| 4772 | qlafx00_post_aenfx_work(struct scsi_qla_host *vha, uint32_t evtcode, |
| 4773 | uint32_t *data, int cnt) |
| 4774 | { |
| 4775 | struct qla_work_evt *e; |
| 4776 | |
| 4777 | e = qla2x00_alloc_work(vha, QLA_EVT_AENFX); |
| 4778 | if (!e) |
| 4779 | return QLA_FUNCTION_FAILED; |
| 4780 | |
| 4781 | e->u.aenfx.evtcode = evtcode; |
| 4782 | e->u.aenfx.count = cnt; |
| 4783 | memcpy(e->u.aenfx.mbx, data, sizeof(*data) * cnt); |
| 4784 | return qla2x00_post_work(vha, e); |
| 4785 | } |
| 4786 | |
Quinn Tran | cd4ed6b | 2018-08-31 11:24:31 -0700 | [diff] [blame] | 4787 | void qla24xx_sched_upd_fcport(fc_port_t *fcport) |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4788 | { |
Quinn Tran | cd4ed6b | 2018-08-31 11:24:31 -0700 | [diff] [blame] | 4789 | unsigned long flags; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4790 | |
Quinn Tran | cd4ed6b | 2018-08-31 11:24:31 -0700 | [diff] [blame] | 4791 | if (IS_SW_RESV_ADDR(fcport->d_id)) |
| 4792 | return; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4793 | |
Quinn Tran | cd4ed6b | 2018-08-31 11:24:31 -0700 | [diff] [blame] | 4794 | spin_lock_irqsave(&fcport->vha->work_lock, flags); |
| 4795 | if (fcport->disc_state == DSC_UPD_FCPORT) { |
| 4796 | spin_unlock_irqrestore(&fcport->vha->work_lock, flags); |
| 4797 | return; |
| 4798 | } |
| 4799 | fcport->jiffies_at_registration = jiffies; |
| 4800 | fcport->sec_since_registration = 0; |
| 4801 | fcport->next_disc_state = DSC_DELETED; |
| 4802 | fcport->disc_state = DSC_UPD_FCPORT; |
| 4803 | spin_unlock_irqrestore(&fcport->vha->work_lock, flags); |
| 4804 | |
| 4805 | queue_work(system_unbound_wq, &fcport->reg_work); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4806 | } |
| 4807 | |
| 4808 | static |
| 4809 | void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) |
| 4810 | { |
| 4811 | unsigned long flags; |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4812 | fc_port_t *fcport = NULL, *tfcp; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4813 | struct qlt_plogi_ack_t *pla = |
| 4814 | (struct qlt_plogi_ack_t *)e->u.new_sess.pla; |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4815 | uint8_t free_fcport = 0; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4816 | |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4817 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 4818 | "%s %d %8phC enter\n", |
| 4819 | __func__, __LINE__, e->u.new_sess.port_name); |
| 4820 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4821 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 4822 | fcport = qla2x00_find_fcport_by_wwpn(vha, e->u.new_sess.port_name, 1); |
| 4823 | if (fcport) { |
| 4824 | fcport->d_id = e->u.new_sess.id; |
| 4825 | if (pla) { |
| 4826 | fcport->fw_login_state = DSC_LS_PLOGI_PEND; |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4827 | memcpy(fcport->node_name, |
| 4828 | pla->iocb.u.isp24.u.plogi.node_name, |
| 4829 | WWN_SIZE); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4830 | qlt_plogi_ack_link(vha, pla, fcport, QLT_PLOGI_LINK_SAME_WWN); |
| 4831 | /* we took an extra ref_count to prevent PLOGI ACK when |
| 4832 | * fcport/sess has not been created. |
| 4833 | */ |
| 4834 | pla->ref_count--; |
| 4835 | } |
| 4836 | } else { |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4837 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4838 | fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
| 4839 | if (fcport) { |
| 4840 | fcport->d_id = e->u.new_sess.id; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4841 | fcport->flags |= FCF_FABRIC_DEVICE; |
| 4842 | fcport->fw_login_state = DSC_LS_PLOGI_PEND; |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 4843 | if (e->u.new_sess.fc4_type == FS_FC4TYPE_FCP) |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4844 | fcport->fc4_type = FC4_TYPE_FCP_SCSI; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4845 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 4846 | if (e->u.new_sess.fc4_type == FS_FC4TYPE_NVME) { |
Darren Trapp | 2b5b964 | 2018-02-27 16:31:12 -0800 | [diff] [blame] | 4847 | fcport->fc4_type = FC4_TYPE_OTHER; |
| 4848 | fcport->fc4f_nvme = FC4_TYPE_NVME; |
| 4849 | } |
Quinn Tran | 33b2835 | 2018-03-20 23:09:40 -0700 | [diff] [blame] | 4850 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4851 | memcpy(fcport->port_name, e->u.new_sess.port_name, |
| 4852 | WWN_SIZE); |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4853 | } else { |
| 4854 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 4855 | "%s %8phC mem alloc fail.\n", |
| 4856 | __func__, e->u.new_sess.port_name); |
| 4857 | |
| 4858 | if (pla) |
| 4859 | kmem_cache_free(qla_tgt_plogi_cachep, pla); |
| 4860 | return; |
| 4861 | } |
| 4862 | |
| 4863 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4864 | /* search again to make sure no one else got ahead */ |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4865 | tfcp = qla2x00_find_fcport_by_wwpn(vha, |
| 4866 | e->u.new_sess.port_name, 1); |
| 4867 | if (tfcp) { |
| 4868 | /* should rarily happen */ |
| 4869 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 4870 | "%s %8phC found existing fcport b4 add. DS %d LS %d\n", |
| 4871 | __func__, tfcp->port_name, tfcp->disc_state, |
| 4872 | tfcp->fw_login_state); |
| 4873 | |
| 4874 | free_fcport = 1; |
| 4875 | } else { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4876 | list_add_tail(&fcport->list, &vha->vp_fcports); |
| 4877 | |
Quinn Tran | 1975903 | 2017-12-04 14:45:15 -0800 | [diff] [blame] | 4878 | } |
| 4879 | if (pla) { |
| 4880 | qlt_plogi_ack_link(vha, pla, fcport, |
| 4881 | QLT_PLOGI_LINK_SAME_WWN); |
| 4882 | pla->ref_count--; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4883 | } |
| 4884 | } |
| 4885 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 4886 | |
| 4887 | if (fcport) { |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4888 | fcport->id_changed = 1; |
| 4889 | fcport->scan_state = QLA_FCPORT_FOUND; |
| 4890 | memcpy(fcport->node_name, e->u.new_sess.node_name, WWN_SIZE); |
| 4891 | |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 4892 | if (pla) { |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4893 | if (pla->iocb.u.isp24.status_subcode == ELS_PRLI) { |
| 4894 | u16 wd3_lo; |
| 4895 | |
| 4896 | fcport->fw_login_state = DSC_LS_PRLI_PEND; |
| 4897 | fcport->local = 0; |
| 4898 | fcport->loop_id = |
| 4899 | le16_to_cpu( |
| 4900 | pla->iocb.u.isp24.nport_handle); |
| 4901 | fcport->fw_login_state = DSC_LS_PRLI_PEND; |
| 4902 | wd3_lo = |
| 4903 | le16_to_cpu( |
| 4904 | pla->iocb.u.isp24.u.prli.wd3_lo); |
| 4905 | |
| 4906 | if (wd3_lo & BIT_7) |
| 4907 | fcport->conf_compl_supported = 1; |
| 4908 | |
| 4909 | if ((wd3_lo & BIT_4) == 0) |
| 4910 | fcport->port_type = FCT_INITIATOR; |
| 4911 | else |
| 4912 | fcport->port_type = FCT_TARGET; |
| 4913 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4914 | qlt_plogi_ack_unref(vha, pla); |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 4915 | } else { |
Hannes Reinecke | 1c6cacf | 2018-02-22 09:49:35 +0100 | [diff] [blame] | 4916 | fc_port_t *dfcp = NULL; |
| 4917 | |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 4918 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 4919 | tfcp = qla2x00_find_fcport_by_nportid(vha, |
| 4920 | &e->u.new_sess.id, 1); |
| 4921 | if (tfcp && (tfcp != fcport)) { |
| 4922 | /* |
| 4923 | * We have a conflict fcport with same NportID. |
| 4924 | */ |
| 4925 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 4926 | "%s %8phC found conflict b4 add. DS %d LS %d\n", |
| 4927 | __func__, tfcp->port_name, tfcp->disc_state, |
| 4928 | tfcp->fw_login_state); |
| 4929 | |
| 4930 | switch (tfcp->disc_state) { |
| 4931 | case DSC_DELETED: |
| 4932 | break; |
| 4933 | case DSC_DELETE_PEND: |
| 4934 | fcport->login_pause = 1; |
| 4935 | tfcp->conflict = fcport; |
| 4936 | break; |
| 4937 | default: |
| 4938 | fcport->login_pause = 1; |
| 4939 | tfcp->conflict = fcport; |
Hannes Reinecke | 1c6cacf | 2018-02-22 09:49:35 +0100 | [diff] [blame] | 4940 | dfcp = tfcp; |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 4941 | break; |
| 4942 | } |
| 4943 | } |
| 4944 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
Hannes Reinecke | 1c6cacf | 2018-02-22 09:49:35 +0100 | [diff] [blame] | 4945 | if (dfcp) |
| 4946 | qlt_schedule_sess_for_deletion(tfcp); |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4947 | |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4948 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 4949 | if (N2N_TOPO(vha->hw)) |
| 4950 | fcport->flags &= ~FCF_FABRIC_DEVICE; |
| 4951 | |
| 4952 | if (N2N_TOPO(vha->hw)) { |
| 4953 | if (vha->flags.nvme_enabled) { |
| 4954 | fcport->fc4f_nvme = 1; |
| 4955 | fcport->n2n_flag = 1; |
| 4956 | } |
| 4957 | fcport->fw_login_state = 0; |
| 4958 | /* |
| 4959 | * wait link init done before sending login |
| 4960 | */ |
| 4961 | } else { |
| 4962 | qla24xx_fcport_handle_login(vha, fcport); |
| 4963 | } |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 4964 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4965 | } |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4966 | |
| 4967 | if (free_fcport) { |
| 4968 | qla2x00_free_fcport(fcport); |
| 4969 | if (pla) |
| 4970 | kmem_cache_free(qla_tgt_plogi_cachep, pla); |
| 4971 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4972 | } |
| 4973 | |
Quinn Tran | e374f9f | 2017-12-28 12:33:31 -0800 | [diff] [blame] | 4974 | static void qla_sp_retry(struct scsi_qla_host *vha, struct qla_work_evt *e) |
| 4975 | { |
| 4976 | struct srb *sp = e->u.iosb.sp; |
| 4977 | int rval; |
| 4978 | |
| 4979 | rval = qla2x00_start_sp(sp); |
| 4980 | if (rval != QLA_SUCCESS) { |
| 4981 | ql_dbg(ql_dbg_disc, vha, 0x2043, |
| 4982 | "%s: %s: Re-issue IOCB failed (%d).\n", |
| 4983 | __func__, sp->name, rval); |
| 4984 | qla24xx_sp_unmap(vha, sp); |
| 4985 | } |
| 4986 | } |
| 4987 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4988 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4989 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4990 | { |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4991 | struct qla_work_evt *e, *tmp; |
| 4992 | unsigned long flags; |
| 4993 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4994 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4995 | spin_lock_irqsave(&vha->work_lock, flags); |
| 4996 | list_splice_init(&vha->work_list, &work); |
| 4997 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 4998 | |
| 4999 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5000 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5001 | |
| 5002 | switch (e->type) { |
| 5003 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5004 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5005 | e->u.aen.code, e->u.aen.data); |
| 5006 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 5007 | case QLA_EVT_IDC_ACK: |
| 5008 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 5009 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5010 | case QLA_EVT_ASYNC_LOGIN: |
| 5011 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 5012 | e->u.logio.data); |
| 5013 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5014 | case QLA_EVT_ASYNC_LOGOUT: |
| 5015 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 5016 | break; |
| 5017 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 5018 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 5019 | e->u.logio.data); |
| 5020 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 5021 | case QLA_EVT_ASYNC_ADISC: |
| 5022 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 5023 | e->u.logio.data); |
| 5024 | break; |
| 5025 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 5026 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 5027 | e->u.logio.data); |
| 5028 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 5029 | case QLA_EVT_UEVENT: |
| 5030 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 5031 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5032 | case QLA_EVT_AENFX: |
| 5033 | qlafx00_process_aen(vha, e); |
| 5034 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5035 | case QLA_EVT_GIDPN: |
| 5036 | qla24xx_async_gidpn(vha, e->u.fcport.fcport); |
| 5037 | break; |
| 5038 | case QLA_EVT_GPNID: |
| 5039 | qla24xx_async_gpnid(vha, &e->u.gpnid.id); |
| 5040 | break; |
Quinn Tran | e374f9f | 2017-12-28 12:33:31 -0800 | [diff] [blame] | 5041 | case QLA_EVT_UNMAP: |
| 5042 | qla24xx_sp_unmap(vha, e->u.iosb.sp); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5043 | break; |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5044 | case QLA_EVT_RELOGIN: |
| 5045 | qla2x00_relogin(vha); |
| 5046 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5047 | case QLA_EVT_NEW_SESS: |
| 5048 | qla24xx_create_new_sess(vha, e); |
| 5049 | break; |
| 5050 | case QLA_EVT_GPDB: |
| 5051 | qla24xx_async_gpdb(vha, e->u.fcport.fcport, |
| 5052 | e->u.fcport.opt); |
| 5053 | break; |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 5054 | case QLA_EVT_PRLI: |
| 5055 | qla24xx_async_prli(vha, e->u.fcport.fcport); |
| 5056 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5057 | case QLA_EVT_GPSC: |
| 5058 | qla24xx_async_gpsc(vha, e->u.fcport.fcport); |
| 5059 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5060 | case QLA_EVT_GNL: |
| 5061 | qla24xx_async_gnl(vha, e->u.fcport.fcport); |
| 5062 | break; |
| 5063 | case QLA_EVT_NACK: |
| 5064 | qla24xx_do_nack_work(vha, e); |
| 5065 | break; |
Quinn Tran | 11aea16 | 2017-12-28 12:33:20 -0800 | [diff] [blame] | 5066 | case QLA_EVT_ASYNC_PRLO: |
| 5067 | qla2x00_async_prlo(vha, e->u.logio.fcport); |
| 5068 | break; |
| 5069 | case QLA_EVT_ASYNC_PRLO_DONE: |
| 5070 | qla2x00_async_prlo_done(vha, e->u.logio.fcport, |
| 5071 | e->u.logio.data); |
| 5072 | break; |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 5073 | case QLA_EVT_GPNFT: |
Quinn Tran | 33b2835 | 2018-03-20 23:09:40 -0700 | [diff] [blame] | 5074 | qla24xx_async_gpnft(vha, e->u.gpnft.fc4_type, |
| 5075 | e->u.gpnft.sp); |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 5076 | break; |
| 5077 | case QLA_EVT_GPNFT_DONE: |
| 5078 | qla24xx_async_gpnft_done(vha, e->u.iosb.sp); |
| 5079 | break; |
| 5080 | case QLA_EVT_GNNFT_DONE: |
| 5081 | qla24xx_async_gnnft_done(vha, e->u.iosb.sp); |
| 5082 | break; |
| 5083 | case QLA_EVT_GNNID: |
| 5084 | qla24xx_async_gnnid(vha, e->u.fcport.fcport); |
| 5085 | break; |
| 5086 | case QLA_EVT_GFPNID: |
| 5087 | qla24xx_async_gfpnid(vha, e->u.fcport.fcport); |
| 5088 | break; |
Quinn Tran | e374f9f | 2017-12-28 12:33:31 -0800 | [diff] [blame] | 5089 | case QLA_EVT_SP_RETRY: |
| 5090 | qla_sp_retry(vha, e); |
Quinn Tran | cc28e0a | 2018-05-01 09:01:48 -0700 | [diff] [blame] | 5091 | break; |
| 5092 | case QLA_EVT_IIDMA: |
| 5093 | qla_do_iidma_work(vha, e->u.fcport.fcport); |
| 5094 | break; |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 5095 | case QLA_EVT_ELS_PLOGI: |
| 5096 | qla24xx_els_dcmd2_iocb(vha, ELS_DCMD_PLOGI, |
| 5097 | e->u.fcport.fcport, false); |
| 5098 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5099 | } |
| 5100 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 5101 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 5102 | |
| 5103 | /* For each work completed decrement vha ref count */ |
| 5104 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5105 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5106 | } |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 5107 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5108 | int qla24xx_post_relogin_work(struct scsi_qla_host *vha) |
| 5109 | { |
| 5110 | struct qla_work_evt *e; |
| 5111 | |
| 5112 | e = qla2x00_alloc_work(vha, QLA_EVT_RELOGIN); |
| 5113 | |
| 5114 | if (!e) { |
| 5115 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 5116 | return QLA_FUNCTION_FAILED; |
| 5117 | } |
| 5118 | |
| 5119 | return qla2x00_post_work(vha, e); |
| 5120 | } |
| 5121 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5122 | /* Relogins all the fcports of a vport |
| 5123 | * Context: dpc thread |
| 5124 | */ |
| 5125 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 5126 | { |
| 5127 | fc_port_t *fcport; |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 5128 | int status, relogin_needed = 0; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5129 | struct event_arg ea; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5130 | |
| 5131 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 5132 | /* |
| 5133 | * If the port is not ONLINE then try to login |
| 5134 | * to it if we haven't run out of retries. |
| 5135 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 5136 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 5137 | fcport->login_retry) { |
| 5138 | if (fcport->scan_state != QLA_FCPORT_FOUND || |
| 5139 | fcport->disc_state == DSC_LOGIN_COMPLETE) |
| 5140 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5141 | |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 5142 | if (fcport->flags & (FCF_ASYNC_SENT|FCF_ASYNC_ACTIVE) || |
| 5143 | fcport->disc_state == DSC_DELETE_PEND) { |
| 5144 | relogin_needed = 1; |
| 5145 | } else { |
| 5146 | if (vha->hw->current_topology != ISP_CFG_NL) { |
| 5147 | memset(&ea, 0, sizeof(ea)); |
| 5148 | ea.event = FCME_RELOGIN; |
| 5149 | ea.fcport = fcport; |
| 5150 | qla2x00_fcport_event_handler(vha, &ea); |
| 5151 | } else if (vha->hw->current_topology == |
| 5152 | ISP_CFG_NL) { |
| 5153 | fcport->login_retry--; |
| 5154 | status = |
| 5155 | qla2x00_local_device_login(vha, |
| 5156 | fcport); |
| 5157 | if (status == QLA_SUCCESS) { |
| 5158 | fcport->old_loop_id = |
| 5159 | fcport->loop_id; |
| 5160 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 5161 | "Port login OK: logged in ID 0x%x.\n", |
| 5162 | fcport->loop_id); |
| 5163 | qla2x00_update_fcport |
| 5164 | (vha, fcport); |
| 5165 | } else if (status == 1) { |
| 5166 | set_bit(RELOGIN_NEEDED, |
| 5167 | &vha->dpc_flags); |
| 5168 | /* retry the login again */ |
| 5169 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 5170 | "Retrying %d login again loop_id 0x%x.\n", |
| 5171 | fcport->login_retry, |
| 5172 | fcport->loop_id); |
| 5173 | } else { |
| 5174 | fcport->login_retry = 0; |
| 5175 | } |
| 5176 | |
| 5177 | if (fcport->login_retry == 0 && |
| 5178 | status != QLA_SUCCESS) |
| 5179 | qla2x00_clear_loop_id(fcport); |
| 5180 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5181 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5182 | } |
| 5183 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 5184 | break; |
| 5185 | } |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5186 | |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 5187 | if (relogin_needed) |
| 5188 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 5189 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5190 | ql_dbg(ql_dbg_disc, vha, 0x400e, |
| 5191 | "Relogin end.\n"); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5192 | } |
| 5193 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5194 | /* Schedule work on any of the dpc-workqueues */ |
| 5195 | void |
| 5196 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 5197 | { |
| 5198 | struct qla_hw_data *ha = base_vha->hw; |
| 5199 | |
| 5200 | switch (work_code) { |
| 5201 | case MBA_IDC_AEN: /* 0x8200 */ |
| 5202 | if (ha->dpc_lp_wq) |
| 5203 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 5204 | break; |
| 5205 | |
| 5206 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 5207 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 5208 | if (ha->dpc_hp_wq) |
| 5209 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 5210 | } else |
| 5211 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 5212 | "NIC Core reset is already active. Skip " |
| 5213 | "scheduling it again.\n"); |
| 5214 | break; |
| 5215 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 5216 | if (ha->dpc_hp_wq) |
| 5217 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 5218 | break; |
| 5219 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 5220 | if (ha->dpc_hp_wq) |
| 5221 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 5222 | break; |
| 5223 | default: |
| 5224 | ql_log(ql_log_warn, base_vha, 0xb05f, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 5225 | "Unknown work-code=0x%x.\n", work_code); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5226 | } |
| 5227 | |
| 5228 | return; |
| 5229 | } |
| 5230 | |
| 5231 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 5232 | void |
| 5233 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 5234 | { |
| 5235 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 5236 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5237 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5238 | uint32_t dev_state = 0; |
| 5239 | |
| 5240 | qla83xx_idc_lock(base_vha, 0); |
| 5241 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5242 | qla83xx_reset_ownership(base_vha); |
| 5243 | if (ha->flags.nic_core_reset_owner) { |
| 5244 | ha->flags.nic_core_reset_owner = 0; |
| 5245 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5246 | QLA8XXX_DEV_FAILED); |
| 5247 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 5248 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 5249 | } |
| 5250 | qla83xx_idc_unlock(base_vha, 0); |
| 5251 | } |
| 5252 | |
| 5253 | /* Work: Execute IDC state handler */ |
| 5254 | void |
| 5255 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 5256 | { |
| 5257 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 5258 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5259 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5260 | uint32_t dev_state = 0; |
| 5261 | |
| 5262 | qla83xx_idc_lock(base_vha, 0); |
| 5263 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5264 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 5265 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 5266 | qla83xx_idc_state_handler(base_vha); |
| 5267 | qla83xx_idc_unlock(base_vha, 0); |
| 5268 | } |
| 5269 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5270 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5271 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 5272 | { |
| 5273 | int rval = QLA_SUCCESS; |
| 5274 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 5275 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 5276 | |
| 5277 | do { |
| 5278 | if (time_after(jiffies, heart_beat_wait)) { |
| 5279 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 5280 | "Nic Core f/w is not alive.\n"); |
| 5281 | rval = QLA_FUNCTION_FAILED; |
| 5282 | break; |
| 5283 | } |
| 5284 | |
| 5285 | qla83xx_idc_lock(base_vha, 0); |
| 5286 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 5287 | &heart_beat_counter1); |
| 5288 | qla83xx_idc_unlock(base_vha, 0); |
| 5289 | msleep(100); |
| 5290 | qla83xx_idc_lock(base_vha, 0); |
| 5291 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 5292 | &heart_beat_counter2); |
| 5293 | qla83xx_idc_unlock(base_vha, 0); |
| 5294 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 5295 | |
| 5296 | return rval; |
| 5297 | } |
| 5298 | |
| 5299 | /* Work: Perform NIC Core Reset handling */ |
| 5300 | void |
| 5301 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 5302 | { |
| 5303 | struct qla_hw_data *ha = |
| 5304 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 5305 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5306 | uint32_t dev_state = 0; |
| 5307 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 5308 | if (IS_QLA2031(ha)) { |
| 5309 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 5310 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 5311 | "Failed to dump mctp\n"); |
| 5312 | return; |
| 5313 | } |
| 5314 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5315 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 5316 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 5317 | qla83xx_idc_lock(base_vha, 0); |
| 5318 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5319 | &dev_state); |
| 5320 | qla83xx_idc_unlock(base_vha, 0); |
| 5321 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 5322 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 5323 | "Nic Core f/w is alive.\n"); |
| 5324 | return; |
| 5325 | } |
| 5326 | } |
| 5327 | |
| 5328 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 5329 | if (qla83xx_nic_core_reset(base_vha)) { |
| 5330 | /* NIC Core reset failed. */ |
| 5331 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 5332 | "NIC Core reset failed.\n"); |
| 5333 | } |
| 5334 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 5335 | } |
| 5336 | } |
| 5337 | |
| 5338 | /* Work: Handle 8200 IDC aens */ |
| 5339 | void |
| 5340 | qla83xx_service_idc_aen(struct work_struct *work) |
| 5341 | { |
| 5342 | struct qla_hw_data *ha = |
| 5343 | container_of(work, struct qla_hw_data, idc_aen); |
| 5344 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5345 | uint32_t dev_state, idc_control; |
| 5346 | |
| 5347 | qla83xx_idc_lock(base_vha, 0); |
| 5348 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5349 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 5350 | qla83xx_idc_unlock(base_vha, 0); |
| 5351 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 5352 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 5353 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 5354 | "Application requested NIC Core Reset.\n"); |
| 5355 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 5356 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 5357 | QLA_SUCCESS) { |
| 5358 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 5359 | "Other protocol driver requested NIC Core Reset.\n"); |
| 5360 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 5361 | } |
| 5362 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 5363 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 5364 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 5365 | } |
| 5366 | } |
| 5367 | |
| 5368 | static void |
| 5369 | qla83xx_wait_logic(void) |
| 5370 | { |
| 5371 | int i; |
| 5372 | |
| 5373 | /* Yield CPU */ |
| 5374 | if (!in_interrupt()) { |
| 5375 | /* |
| 5376 | * Wait about 200ms before retrying again. |
| 5377 | * This controls the number of retries for single |
| 5378 | * lock operation. |
| 5379 | */ |
| 5380 | msleep(100); |
| 5381 | schedule(); |
| 5382 | } else { |
| 5383 | for (i = 0; i < 20; i++) |
| 5384 | cpu_relax(); /* This a nop instr on i386 */ |
| 5385 | } |
| 5386 | } |
| 5387 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5388 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5389 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 5390 | { |
| 5391 | int rval; |
| 5392 | uint32_t data; |
| 5393 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 5394 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 5395 | struct qla_hw_data *ha = base_vha->hw; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5396 | ql_dbg(ql_dbg_p3p, base_vha, 0xb086, |
| 5397 | "Trying force recovery of the IDC lock.\n"); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5398 | |
| 5399 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 5400 | if (rval) |
| 5401 | return rval; |
| 5402 | |
| 5403 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 5404 | return QLA_SUCCESS; |
| 5405 | } else { |
| 5406 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 5407 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 5408 | data); |
| 5409 | if (rval) |
| 5410 | return rval; |
| 5411 | |
| 5412 | msleep(200); |
| 5413 | |
| 5414 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 5415 | &data); |
| 5416 | if (rval) |
| 5417 | return rval; |
| 5418 | |
| 5419 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 5420 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 5421 | ~(idc_lck_rcvry_stage_mask)); |
| 5422 | rval = qla83xx_wr_reg(base_vha, |
| 5423 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 5424 | if (rval) |
| 5425 | return rval; |
| 5426 | |
| 5427 | /* Forcefully perform IDC UnLock */ |
| 5428 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 5429 | &data); |
| 5430 | if (rval) |
| 5431 | return rval; |
| 5432 | /* Clear lock-id by setting 0xff */ |
| 5433 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5434 | 0xff); |
| 5435 | if (rval) |
| 5436 | return rval; |
| 5437 | /* Clear lock-recovery by setting 0x0 */ |
| 5438 | rval = qla83xx_wr_reg(base_vha, |
| 5439 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 5440 | if (rval) |
| 5441 | return rval; |
| 5442 | } else |
| 5443 | return QLA_SUCCESS; |
| 5444 | } |
| 5445 | |
| 5446 | return rval; |
| 5447 | } |
| 5448 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5449 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5450 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 5451 | { |
| 5452 | int rval = QLA_SUCCESS; |
| 5453 | uint32_t o_drv_lockid, n_drv_lockid; |
| 5454 | unsigned long lock_recovery_timeout; |
| 5455 | |
| 5456 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 5457 | retry_lockid: |
| 5458 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 5459 | if (rval) |
| 5460 | goto exit; |
| 5461 | |
| 5462 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 5463 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 5464 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 5465 | return QLA_SUCCESS; |
| 5466 | else |
| 5467 | return QLA_FUNCTION_FAILED; |
| 5468 | } |
| 5469 | |
| 5470 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 5471 | if (rval) |
| 5472 | goto exit; |
| 5473 | |
| 5474 | if (o_drv_lockid == n_drv_lockid) { |
| 5475 | qla83xx_wait_logic(); |
| 5476 | goto retry_lockid; |
| 5477 | } else |
| 5478 | return QLA_SUCCESS; |
| 5479 | |
| 5480 | exit: |
| 5481 | return rval; |
| 5482 | } |
| 5483 | |
| 5484 | void |
| 5485 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 5486 | { |
| 5487 | uint16_t options = (requester_id << 15) | BIT_6; |
| 5488 | uint32_t data; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5489 | uint32_t lock_owner; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5490 | struct qla_hw_data *ha = base_vha->hw; |
| 5491 | |
| 5492 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 5493 | retry_lock: |
| 5494 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 5495 | == QLA_SUCCESS) { |
| 5496 | if (data) { |
| 5497 | /* Setting lock-id to our function-number */ |
| 5498 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5499 | ha->portnum); |
| 5500 | } else { |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5501 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5502 | &lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5503 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5504 | "Failed to acquire IDC lock, acquired by %d, " |
| 5505 | "retrying...\n", lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5506 | |
| 5507 | /* Retry/Perform IDC-Lock recovery */ |
| 5508 | if (qla83xx_idc_lock_recovery(base_vha) |
| 5509 | == QLA_SUCCESS) { |
| 5510 | qla83xx_wait_logic(); |
| 5511 | goto retry_lock; |
| 5512 | } else |
| 5513 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 5514 | "IDC Lock recovery FAILED.\n"); |
| 5515 | } |
| 5516 | |
| 5517 | } |
| 5518 | |
| 5519 | return; |
| 5520 | |
| 5521 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 5522 | retry_lock2: |
| 5523 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 5524 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 5525 | "Failed to acquire IDC lock. retrying...\n"); |
| 5526 | /* Retry/Perform IDC-Lock recovery */ |
| 5527 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 5528 | qla83xx_wait_logic(); |
| 5529 | goto retry_lock2; |
| 5530 | } else |
| 5531 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 5532 | "IDC Lock recovery FAILED.\n"); |
| 5533 | } |
| 5534 | |
| 5535 | return; |
| 5536 | } |
| 5537 | |
| 5538 | void |
| 5539 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 5540 | { |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5541 | #if 0 |
| 5542 | uint16_t options = (requester_id << 15) | BIT_7; |
| 5543 | #endif |
| 5544 | uint16_t retry; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5545 | uint32_t data; |
| 5546 | struct qla_hw_data *ha = base_vha->hw; |
| 5547 | |
| 5548 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 5549 | * remote registers |
| 5550 | */ |
| 5551 | retry = 0; |
| 5552 | retry_unlock: |
| 5553 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 5554 | == QLA_SUCCESS) { |
| 5555 | if (data == ha->portnum) { |
| 5556 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 5557 | /* Clearing lock-id by setting 0xff */ |
| 5558 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 5559 | } else if (retry < 10) { |
| 5560 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 5561 | |
| 5562 | /* Retry for IDC-unlock */ |
| 5563 | qla83xx_wait_logic(); |
| 5564 | retry++; |
| 5565 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5566 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5567 | goto retry_unlock; |
| 5568 | } |
| 5569 | } else if (retry < 10) { |
| 5570 | /* Retry for IDC-unlock */ |
| 5571 | qla83xx_wait_logic(); |
| 5572 | retry++; |
| 5573 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5574 | "Failed to read drv-lockid, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5575 | goto retry_unlock; |
| 5576 | } |
| 5577 | |
| 5578 | return; |
| 5579 | |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5580 | #if 0 |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5581 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 5582 | retry = 0; |
| 5583 | retry_unlock2: |
| 5584 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 5585 | if (retry < 10) { |
| 5586 | /* Retry for IDC-unlock */ |
| 5587 | qla83xx_wait_logic(); |
| 5588 | retry++; |
| 5589 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5590 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5591 | goto retry_unlock2; |
| 5592 | } |
| 5593 | } |
| 5594 | |
| 5595 | return; |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5596 | #endif |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5597 | } |
| 5598 | |
| 5599 | int |
| 5600 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 5601 | { |
| 5602 | int rval = QLA_SUCCESS; |
| 5603 | struct qla_hw_data *ha = vha->hw; |
| 5604 | uint32_t drv_presence; |
| 5605 | |
| 5606 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 5607 | if (rval == QLA_SUCCESS) { |
| 5608 | drv_presence |= (1 << ha->portnum); |
| 5609 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5610 | drv_presence); |
| 5611 | } |
| 5612 | |
| 5613 | return rval; |
| 5614 | } |
| 5615 | |
| 5616 | int |
| 5617 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 5618 | { |
| 5619 | int rval = QLA_SUCCESS; |
| 5620 | |
| 5621 | qla83xx_idc_lock(vha, 0); |
| 5622 | rval = __qla83xx_set_drv_presence(vha); |
| 5623 | qla83xx_idc_unlock(vha, 0); |
| 5624 | |
| 5625 | return rval; |
| 5626 | } |
| 5627 | |
| 5628 | int |
| 5629 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 5630 | { |
| 5631 | int rval = QLA_SUCCESS; |
| 5632 | struct qla_hw_data *ha = vha->hw; |
| 5633 | uint32_t drv_presence; |
| 5634 | |
| 5635 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 5636 | if (rval == QLA_SUCCESS) { |
| 5637 | drv_presence &= ~(1 << ha->portnum); |
| 5638 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5639 | drv_presence); |
| 5640 | } |
| 5641 | |
| 5642 | return rval; |
| 5643 | } |
| 5644 | |
| 5645 | int |
| 5646 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 5647 | { |
| 5648 | int rval = QLA_SUCCESS; |
| 5649 | |
| 5650 | qla83xx_idc_lock(vha, 0); |
| 5651 | rval = __qla83xx_clear_drv_presence(vha); |
| 5652 | qla83xx_idc_unlock(vha, 0); |
| 5653 | |
| 5654 | return rval; |
| 5655 | } |
| 5656 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5657 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5658 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 5659 | { |
| 5660 | struct qla_hw_data *ha = vha->hw; |
| 5661 | uint32_t drv_ack, drv_presence; |
| 5662 | unsigned long ack_timeout; |
| 5663 | |
| 5664 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 5665 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 5666 | while (1) { |
| 5667 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 5668 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 5669 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5670 | break; |
| 5671 | |
| 5672 | if (time_after_eq(jiffies, ack_timeout)) { |
| 5673 | ql_log(ql_log_warn, vha, 0xb067, |
| 5674 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 5675 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 5676 | /* |
| 5677 | * The function(s) which did not ack in time are forced |
| 5678 | * to withdraw any further participation in the IDC |
| 5679 | * reset. |
| 5680 | */ |
| 5681 | if (drv_ack != drv_presence) |
| 5682 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5683 | drv_ack); |
| 5684 | break; |
| 5685 | } |
| 5686 | |
| 5687 | qla83xx_idc_unlock(vha, 0); |
| 5688 | msleep(1000); |
| 5689 | qla83xx_idc_lock(vha, 0); |
| 5690 | } |
| 5691 | |
| 5692 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 5693 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 5694 | } |
| 5695 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5696 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5697 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 5698 | { |
| 5699 | int rval = QLA_SUCCESS; |
| 5700 | uint32_t idc_control; |
| 5701 | |
| 5702 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 5703 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 5704 | |
| 5705 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 5706 | __qla83xx_get_idc_control(vha, &idc_control); |
| 5707 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 5708 | __qla83xx_set_idc_control(vha, 0); |
| 5709 | |
| 5710 | qla83xx_idc_unlock(vha, 0); |
| 5711 | rval = qla83xx_restart_nic_firmware(vha); |
| 5712 | qla83xx_idc_lock(vha, 0); |
| 5713 | |
| 5714 | if (rval != QLA_SUCCESS) { |
| 5715 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 5716 | "Failed to restart NIC f/w.\n"); |
| 5717 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 5718 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 5719 | } else { |
| 5720 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 5721 | "Success in restarting nic f/w.\n"); |
| 5722 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 5723 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 5724 | } |
| 5725 | |
| 5726 | return rval; |
| 5727 | } |
| 5728 | |
| 5729 | /* Assumes idc_lock always held on entry */ |
| 5730 | int |
| 5731 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 5732 | { |
| 5733 | struct qla_hw_data *ha = base_vha->hw; |
| 5734 | int rval = QLA_SUCCESS; |
| 5735 | unsigned long dev_init_timeout; |
| 5736 | uint32_t dev_state; |
| 5737 | |
| 5738 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 5739 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 5740 | |
| 5741 | while (1) { |
| 5742 | |
| 5743 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 5744 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 5745 | "Initialization TIMEOUT!\n"); |
| 5746 | /* Init timeout. Disable further NIC Core |
| 5747 | * communication. |
| 5748 | */ |
| 5749 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5750 | QLA8XXX_DEV_FAILED); |
| 5751 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 5752 | "HW State: FAILED.\n"); |
| 5753 | } |
| 5754 | |
| 5755 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5756 | switch (dev_state) { |
| 5757 | case QLA8XXX_DEV_READY: |
| 5758 | if (ha->flags.nic_core_reset_owner) |
| 5759 | qla83xx_idc_audit(base_vha, |
| 5760 | IDC_AUDIT_COMPLETION); |
| 5761 | ha->flags.nic_core_reset_owner = 0; |
| 5762 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 5763 | "Reset_owner reset by 0x%x.\n", |
| 5764 | ha->portnum); |
| 5765 | goto exit; |
| 5766 | case QLA8XXX_DEV_COLD: |
| 5767 | if (ha->flags.nic_core_reset_owner) |
| 5768 | rval = qla83xx_device_bootstrap(base_vha); |
| 5769 | else { |
| 5770 | /* Wait for AEN to change device-state */ |
| 5771 | qla83xx_idc_unlock(base_vha, 0); |
| 5772 | msleep(1000); |
| 5773 | qla83xx_idc_lock(base_vha, 0); |
| 5774 | } |
| 5775 | break; |
| 5776 | case QLA8XXX_DEV_INITIALIZING: |
| 5777 | /* Wait for AEN to change device-state */ |
| 5778 | qla83xx_idc_unlock(base_vha, 0); |
| 5779 | msleep(1000); |
| 5780 | qla83xx_idc_lock(base_vha, 0); |
| 5781 | break; |
| 5782 | case QLA8XXX_DEV_NEED_RESET: |
| 5783 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 5784 | qla83xx_need_reset_handler(base_vha); |
| 5785 | else { |
| 5786 | /* Wait for AEN to change device-state */ |
| 5787 | qla83xx_idc_unlock(base_vha, 0); |
| 5788 | msleep(1000); |
| 5789 | qla83xx_idc_lock(base_vha, 0); |
| 5790 | } |
| 5791 | /* reset timeout value after need reset handler */ |
| 5792 | dev_init_timeout = jiffies + |
| 5793 | (ha->fcoe_dev_init_timeout * HZ); |
| 5794 | break; |
| 5795 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 5796 | /* XXX: DEBUG for now */ |
| 5797 | qla83xx_idc_unlock(base_vha, 0); |
| 5798 | msleep(1000); |
| 5799 | qla83xx_idc_lock(base_vha, 0); |
| 5800 | break; |
| 5801 | case QLA8XXX_DEV_QUIESCENT: |
| 5802 | /* XXX: DEBUG for now */ |
| 5803 | if (ha->flags.quiesce_owner) |
| 5804 | goto exit; |
| 5805 | |
| 5806 | qla83xx_idc_unlock(base_vha, 0); |
| 5807 | msleep(1000); |
| 5808 | qla83xx_idc_lock(base_vha, 0); |
| 5809 | dev_init_timeout = jiffies + |
| 5810 | (ha->fcoe_dev_init_timeout * HZ); |
| 5811 | break; |
| 5812 | case QLA8XXX_DEV_FAILED: |
| 5813 | if (ha->flags.nic_core_reset_owner) |
| 5814 | qla83xx_idc_audit(base_vha, |
| 5815 | IDC_AUDIT_COMPLETION); |
| 5816 | ha->flags.nic_core_reset_owner = 0; |
| 5817 | __qla83xx_clear_drv_presence(base_vha); |
| 5818 | qla83xx_idc_unlock(base_vha, 0); |
| 5819 | qla8xxx_dev_failed_handler(base_vha); |
| 5820 | rval = QLA_FUNCTION_FAILED; |
| 5821 | qla83xx_idc_lock(base_vha, 0); |
| 5822 | goto exit; |
| 5823 | case QLA8XXX_BAD_VALUE: |
| 5824 | qla83xx_idc_unlock(base_vha, 0); |
| 5825 | msleep(1000); |
| 5826 | qla83xx_idc_lock(base_vha, 0); |
| 5827 | break; |
| 5828 | default: |
| 5829 | ql_log(ql_log_warn, base_vha, 0xb071, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 5830 | "Unknown Device State: %x.\n", dev_state); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5831 | qla83xx_idc_unlock(base_vha, 0); |
| 5832 | qla8xxx_dev_failed_handler(base_vha); |
| 5833 | rval = QLA_FUNCTION_FAILED; |
| 5834 | qla83xx_idc_lock(base_vha, 0); |
| 5835 | goto exit; |
| 5836 | } |
| 5837 | } |
| 5838 | |
| 5839 | exit: |
| 5840 | return rval; |
| 5841 | } |
| 5842 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5843 | void |
| 5844 | qla2x00_disable_board_on_pci_error(struct work_struct *work) |
| 5845 | { |
| 5846 | struct qla_hw_data *ha = container_of(work, struct qla_hw_data, |
| 5847 | board_disable); |
| 5848 | struct pci_dev *pdev = ha->pdev; |
| 5849 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5850 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5851 | /* |
| 5852 | * if UNLOAD flag is already set, then continue unload, |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 5853 | * where it was set first. |
| 5854 | */ |
| 5855 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5856 | return; |
| 5857 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5858 | ql_log(ql_log_warn, base_vha, 0x015b, |
| 5859 | "Disabling adapter.\n"); |
| 5860 | |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 5861 | if (!atomic_read(&pdev->enable_cnt)) { |
| 5862 | ql_log(ql_log_info, base_vha, 0xfffc, |
| 5863 | "PCI device disabled, no action req for PCI error=%lx\n", |
| 5864 | base_vha->pci_flags); |
| 5865 | return; |
| 5866 | } |
| 5867 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5868 | qla2x00_wait_for_sess_deletion(base_vha); |
| 5869 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5870 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 5871 | |
| 5872 | qla2x00_delete_all_vps(ha, base_vha); |
| 5873 | |
| 5874 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5875 | |
| 5876 | qla2x00_dfs_remove(base_vha); |
| 5877 | |
| 5878 | qla84xx_put_chip(base_vha); |
| 5879 | |
| 5880 | if (base_vha->timer_active) |
| 5881 | qla2x00_stop_timer(base_vha); |
| 5882 | |
| 5883 | base_vha->flags.online = 0; |
| 5884 | |
| 5885 | qla2x00_destroy_deferred_work(ha); |
| 5886 | |
| 5887 | /* |
| 5888 | * Do not try to stop beacon blink as it will issue a mailbox |
| 5889 | * command. |
| 5890 | */ |
| 5891 | qla2x00_free_sysfs_attr(base_vha, false); |
| 5892 | |
| 5893 | fc_remove_host(base_vha->host); |
| 5894 | |
| 5895 | scsi_remove_host(base_vha->host); |
| 5896 | |
| 5897 | base_vha->flags.init_done = 0; |
| 5898 | qla25xx_delete_queues(base_vha); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5899 | qla2x00_free_fcports(base_vha); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 5900 | qla2x00_free_irqs(base_vha); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5901 | qla2x00_mem_free(ha); |
| 5902 | qla82xx_md_free(base_vha); |
| 5903 | qla2x00_free_queues(ha); |
| 5904 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5905 | qla2x00_unmap_iobases(ha); |
| 5906 | |
| 5907 | pci_release_selected_regions(ha->pdev, ha->bars); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5908 | pci_disable_pcie_error_reporting(pdev); |
| 5909 | pci_disable_device(pdev); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5910 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 5911 | /* |
| 5912 | * Let qla2x00_remove_one cleanup qla_hw_data on device removal. |
| 5913 | */ |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5914 | } |
| 5915 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5916 | /************************************************************************** |
| 5917 | * qla2x00_do_dpc |
| 5918 | * This kernel thread is a task that is schedule by the interrupt handler |
| 5919 | * to perform the background processing for interrupts. |
| 5920 | * |
| 5921 | * Notes: |
| 5922 | * This task always run in the context of a kernel thread. It |
| 5923 | * is kick-off by the driver's detect code and starts up |
| 5924 | * up one per adapter. It immediately goes to sleep and waits for |
| 5925 | * some fibre event. When either the interrupt handler or |
| 5926 | * the timer routine detects a event it will one of the task |
| 5927 | * bits then wake us up. |
| 5928 | **************************************************************************/ |
| 5929 | static int |
| 5930 | qla2x00_do_dpc(void *data) |
| 5931 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5932 | scsi_qla_host_t *base_vha; |
| 5933 | struct qla_hw_data *ha; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5934 | uint32_t online; |
| 5935 | struct qla_qpair *qpair; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5936 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5937 | ha = (struct qla_hw_data *)data; |
| 5938 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5939 | |
Dongsheng Yang | 8698a74 | 2014-03-11 18:09:12 +0800 | [diff] [blame] | 5940 | set_user_nice(current, MIN_NICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5941 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5942 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5943 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5944 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 5945 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5946 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5947 | schedule(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5948 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5949 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 5950 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5951 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5952 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5953 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 5954 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5955 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5956 | } |
| 5957 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5958 | ha->dpc_active = 1; |
| 5959 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5960 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 5961 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 5962 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5963 | |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 5964 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5965 | break; |
| 5966 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5967 | if (IS_P3P_TYPE(ha)) { |
| 5968 | if (IS_QLA8044(ha)) { |
| 5969 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5970 | &base_vha->dpc_flags)) { |
| 5971 | qla8044_idc_lock(ha); |
| 5972 | qla8044_wr_direct(base_vha, |
| 5973 | QLA8044_CRB_DEV_STATE_INDEX, |
| 5974 | QLA8XXX_DEV_FAILED); |
| 5975 | qla8044_idc_unlock(ha); |
| 5976 | ql_log(ql_log_info, base_vha, 0x4004, |
| 5977 | "HW State: FAILED.\n"); |
| 5978 | qla8044_device_state_handler(base_vha); |
| 5979 | continue; |
| 5980 | } |
| 5981 | |
| 5982 | } else { |
| 5983 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5984 | &base_vha->dpc_flags)) { |
| 5985 | qla82xx_idc_lock(ha); |
| 5986 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
| 5987 | QLA8XXX_DEV_FAILED); |
| 5988 | qla82xx_idc_unlock(ha); |
| 5989 | ql_log(ql_log_info, base_vha, 0x0151, |
| 5990 | "HW State: FAILED.\n"); |
| 5991 | qla82xx_device_state_handler(base_vha); |
| 5992 | continue; |
| 5993 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5994 | } |
| 5995 | |
| 5996 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 5997 | &base_vha->dpc_flags)) { |
| 5998 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5999 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 6000 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6001 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 6002 | &base_vha->dpc_flags))) { |
| 6003 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 6004 | /* FCoE-ctx reset failed. |
| 6005 | * Escalate to chip-reset |
| 6006 | */ |
| 6007 | set_bit(ISP_ABORT_NEEDED, |
| 6008 | &base_vha->dpc_flags); |
| 6009 | } |
| 6010 | clear_bit(ABORT_ISP_ACTIVE, |
| 6011 | &base_vha->dpc_flags); |
| 6012 | } |
| 6013 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6014 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 6015 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6016 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6017 | } else if (IS_QLAFX00(ha)) { |
| 6018 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 6019 | &base_vha->dpc_flags)) { |
| 6020 | ql_dbg(ql_dbg_dpc, base_vha, 0x4020, |
| 6021 | "Firmware Reset Recovery\n"); |
| 6022 | if (qlafx00_reset_initialize(base_vha)) { |
| 6023 | /* Failed. Abort isp later. */ |
| 6024 | if (!test_bit(UNLOADING, |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 6025 | &base_vha->dpc_flags)) { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6026 | set_bit(ISP_UNRECOVERABLE, |
| 6027 | &base_vha->dpc_flags); |
| 6028 | ql_dbg(ql_dbg_dpc, base_vha, |
| 6029 | 0x4021, |
| 6030 | "Reset Recovery Failed\n"); |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 6031 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6032 | } |
| 6033 | } |
| 6034 | |
| 6035 | if (test_and_clear_bit(FX00_TARGET_SCAN, |
| 6036 | &base_vha->dpc_flags)) { |
| 6037 | ql_dbg(ql_dbg_dpc, base_vha, 0x4022, |
| 6038 | "ISPFx00 Target Scan scheduled\n"); |
| 6039 | if (qlafx00_rescan_isp(base_vha)) { |
| 6040 | if (!test_bit(UNLOADING, |
| 6041 | &base_vha->dpc_flags)) |
| 6042 | set_bit(ISP_UNRECOVERABLE, |
| 6043 | &base_vha->dpc_flags); |
| 6044 | ql_dbg(ql_dbg_dpc, base_vha, 0x401e, |
| 6045 | "ISPFx00 Target Scan Failed\n"); |
| 6046 | } |
| 6047 | ql_dbg(ql_dbg_dpc, base_vha, 0x401f, |
| 6048 | "ISPFx00 Target Scan End\n"); |
| 6049 | } |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 6050 | if (test_and_clear_bit(FX00_HOST_INFO_RESEND, |
| 6051 | &base_vha->dpc_flags)) { |
| 6052 | ql_dbg(ql_dbg_dpc, base_vha, 0x4023, |
| 6053 | "ISPFx00 Host Info resend scheduled\n"); |
| 6054 | qlafx00_fx_disc(base_vha, |
| 6055 | &base_vha->hw->mr.fcport, |
| 6056 | FXDISC_REG_HOST_INFO); |
| 6057 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6058 | } |
| 6059 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 6060 | if (test_and_clear_bit(DETECT_SFP_CHANGE, |
| 6061 | &base_vha->dpc_flags) && |
| 6062 | !test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) { |
| 6063 | qla24xx_detect_sfp(base_vha); |
| 6064 | |
| 6065 | if (ha->flags.detected_lr_sfp != |
| 6066 | ha->flags.using_lr_setting) |
| 6067 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 6068 | } |
| 6069 | |
Quinn Tran | b08abbd | 2018-07-18 14:29:54 -0700 | [diff] [blame] | 6070 | if (test_and_clear_bit |
| 6071 | (ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 6072 | !test_bit(UNLOADING, &base_vha->dpc_flags)) { |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame] | 6073 | bool do_reset = true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6074 | |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame] | 6075 | switch (ql2x_ini_mode) { |
| 6076 | case QLA2XXX_INI_MODE_ENABLED: |
| 6077 | break; |
| 6078 | case QLA2XXX_INI_MODE_DISABLED: |
| 6079 | if (!qla_tgt_mode_enabled(base_vha)) |
| 6080 | do_reset = false; |
| 6081 | break; |
| 6082 | case QLA2XXX_INI_MODE_DUAL: |
| 6083 | if (!qla_dual_mode_enabled(base_vha)) |
| 6084 | do_reset = false; |
| 6085 | break; |
| 6086 | default: |
| 6087 | break; |
| 6088 | } |
| 6089 | |
| 6090 | if (do_reset && !(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6091 | &base_vha->dpc_flags))) { |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame] | 6092 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 6093 | "ISP abort scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6094 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6095 | /* failed. retry later */ |
| 6096 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6097 | &base_vha->dpc_flags); |
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 | clear_bit(ABORT_ISP_ACTIVE, |
| 6100 | &base_vha->dpc_flags); |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame] | 6101 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 6102 | "ISP abort end.\n"); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 6103 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6104 | } |
| 6105 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 6106 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 6107 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6108 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 6109 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 6110 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6111 | if (IS_QLAFX00(ha)) |
| 6112 | goto loop_resync_check; |
| 6113 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6114 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6115 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 6116 | "Quiescence mode scheduled.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6117 | if (IS_P3P_TYPE(ha)) { |
| 6118 | if (IS_QLA82XX(ha)) |
| 6119 | qla82xx_device_state_handler(base_vha); |
| 6120 | if (IS_QLA8044(ha)) |
| 6121 | qla8044_device_state_handler(base_vha); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 6122 | clear_bit(ISP_QUIESCE_NEEDED, |
| 6123 | &base_vha->dpc_flags); |
| 6124 | if (!ha->flags.quiesce_owner) { |
| 6125 | qla2x00_perform_loop_resync(base_vha); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6126 | if (IS_QLA82XX(ha)) { |
| 6127 | qla82xx_idc_lock(ha); |
| 6128 | qla82xx_clear_qsnt_ready( |
| 6129 | base_vha); |
| 6130 | qla82xx_idc_unlock(ha); |
| 6131 | } else if (IS_QLA8044(ha)) { |
| 6132 | qla8044_idc_lock(ha); |
| 6133 | qla8044_clear_qsnt_ready( |
| 6134 | base_vha); |
| 6135 | qla8044_idc_unlock(ha); |
| 6136 | } |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 6137 | } |
| 6138 | } else { |
| 6139 | clear_bit(ISP_QUIESCE_NEEDED, |
| 6140 | &base_vha->dpc_flags); |
| 6141 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6142 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6143 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 6144 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6145 | } |
| 6146 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6147 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6148 | &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6149 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6150 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6151 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 6152 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6153 | qla2x00_rst_aen(base_vha); |
| 6154 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6155 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 6156 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6157 | } |
| 6158 | |
| 6159 | /* Retry each device up to login retry count */ |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 6160 | if (test_bit(RELOGIN_NEEDED, &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6161 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 6162 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6163 | |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 6164 | if (!base_vha->relogin_jif || |
| 6165 | time_after_eq(jiffies, base_vha->relogin_jif)) { |
| 6166 | base_vha->relogin_jif = jiffies + HZ; |
| 6167 | clear_bit(RELOGIN_NEEDED, &base_vha->dpc_flags); |
| 6168 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 6169 | ql_dbg(ql_dbg_disc, base_vha, 0x400d, |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 6170 | "Relogin scheduled.\n"); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 6171 | qla24xx_post_relogin_work(base_vha); |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 6172 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6173 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6174 | loop_resync_check: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6175 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6176 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6177 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6178 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 6179 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6180 | |
| 6181 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6182 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6183 | |
Bart Van Assche | 52c8282 | 2015-07-09 07:23:26 -0700 | [diff] [blame] | 6184 | qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6185 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6186 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 6187 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6188 | } |
| 6189 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6190 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 6191 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6192 | } |
| 6193 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6194 | if (IS_QLAFX00(ha)) |
| 6195 | goto intr_on_check; |
| 6196 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6197 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 6198 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 6199 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 6200 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 6201 | } |
| 6202 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6203 | intr_on_check: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6204 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 6205 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6206 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6207 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
Himanshu Madani | 90b604f | 2014-04-11 16:54:40 -0400 | [diff] [blame] | 6208 | &base_vha->dpc_flags)) { |
| 6209 | if (ha->beacon_blink_led == 1) |
| 6210 | ha->isp_ops->beacon_blink(base_vha); |
| 6211 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 6212 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6213 | /* qpair online check */ |
| 6214 | if (test_and_clear_bit(QPAIR_ONLINE_CHECK_NEEDED, |
| 6215 | &base_vha->dpc_flags)) { |
| 6216 | if (ha->flags.eeh_busy || |
| 6217 | ha->flags.pci_channel_io_perm_failure) |
| 6218 | online = 0; |
| 6219 | else |
| 6220 | online = 1; |
| 6221 | |
| 6222 | mutex_lock(&ha->mq_lock); |
| 6223 | list_for_each_entry(qpair, &base_vha->qp_list, |
| 6224 | qp_list_elem) |
| 6225 | qpair->online = online; |
| 6226 | mutex_unlock(&ha->mq_lock); |
| 6227 | } |
| 6228 | |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6229 | if (test_and_clear_bit(SET_NVME_ZIO_THRESHOLD_NEEDED, |
| 6230 | &base_vha->dpc_flags)) { |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6231 | ql_log(ql_log_info, base_vha, 0xffffff, |
| 6232 | "nvme: SET ZIO Activity exchange threshold to %d.\n", |
| 6233 | ha->nvme_last_rptd_aen); |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6234 | if (qla27xx_set_zio_threshold(base_vha, |
| 6235 | ha->nvme_last_rptd_aen)) { |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6236 | ql_log(ql_log_info, base_vha, 0xffffff, |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6237 | "nvme: Unable to SET ZIO Activity exchange threshold to %d.\n", |
| 6238 | ha->nvme_last_rptd_aen); |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6239 | } |
| 6240 | } |
| 6241 | |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6242 | if (test_and_clear_bit(SET_ZIO_THRESHOLD_NEEDED, |
| 6243 | &base_vha->dpc_flags)) { |
| 6244 | ql_log(ql_log_info, base_vha, 0xffffff, |
| 6245 | "SET ZIO Activity exchange threshold to %d.\n", |
| 6246 | ha->last_zio_threshold); |
| 6247 | qla27xx_set_zio_threshold(base_vha, |
| 6248 | ha->last_zio_threshold); |
| 6249 | } |
| 6250 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6251 | if (!IS_QLAFX00(ha)) |
| 6252 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6253 | |
Quinn Tran | 48acad0 | 2018-08-02 13:16:44 -0700 | [diff] [blame] | 6254 | if (test_and_clear_bit(N2N_LINK_RESET, |
| 6255 | &base_vha->dpc_flags)) { |
| 6256 | qla2x00_lip_reset(base_vha); |
| 6257 | } |
| 6258 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6259 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 6260 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 6261 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6262 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 6263 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6264 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6265 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 6266 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6267 | |
| 6268 | /* |
| 6269 | * Make sure that nobody tries to wake us up again. |
| 6270 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6271 | ha->dpc_active = 0; |
| 6272 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 6273 | /* Cleanup any residual CTX SRBs. */ |
| 6274 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 6275 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 6276 | return 0; |
| 6277 | } |
| 6278 | |
| 6279 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6280 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 6281 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6282 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 6283 | struct task_struct *t = ha->dpc_thread; |
| 6284 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6285 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 6286 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6287 | } |
| 6288 | |
| 6289 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6290 | * qla2x00_rst_aen |
| 6291 | * Processes asynchronous reset. |
| 6292 | * |
| 6293 | * Input: |
| 6294 | * ha = adapter block pointer. |
| 6295 | */ |
| 6296 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6297 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6298 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6299 | if (vha->flags.online && !vha->flags.reset_active && |
| 6300 | !atomic_read(&vha->loop_down_timer) && |
| 6301 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6302 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6303 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6304 | |
| 6305 | /* |
| 6306 | * Issue marker command only when we are going to start |
| 6307 | * the I/O. |
| 6308 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6309 | vha->marker_needed = 1; |
| 6310 | } while (!atomic_read(&vha->loop_down_timer) && |
| 6311 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6312 | } |
| 6313 | } |
| 6314 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6315 | /************************************************************************** |
| 6316 | * qla2x00_timer |
| 6317 | * |
| 6318 | * Description: |
| 6319 | * One second timer |
| 6320 | * |
| 6321 | * Context: Interrupt |
| 6322 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6323 | void |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 6324 | qla2x00_timer(struct timer_list *t) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6325 | { |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 6326 | scsi_qla_host_t *vha = from_timer(vha, t, timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6327 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6328 | int start_dpc = 0; |
| 6329 | int index; |
| 6330 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6331 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6332 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 6333 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6334 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6335 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6336 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 6337 | "EEH = %d, restarting timer.\n", |
| 6338 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6339 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 6340 | return; |
| 6341 | } |
| 6342 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6343 | /* |
| 6344 | * Hardware read to raise pending EEH errors during mailbox waits. If |
| 6345 | * the read returns -1 then disable the board. |
| 6346 | */ |
| 6347 | if (!pci_channel_offline(ha->pdev)) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6348 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Joe Lawrence | c821e0d | 2014-08-26 17:11:41 -0400 | [diff] [blame] | 6349 | qla2x00_check_reg16_for_disconnect(vha, w); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6350 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6351 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 6352 | /* Make sure qla82xx_watchdog is run only for physical port */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6353 | if (!vha->vp_idx && IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6354 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 6355 | start_dpc++; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6356 | if (IS_QLA82XX(ha)) |
| 6357 | qla82xx_watchdog(vha); |
| 6358 | else if (IS_QLA8044(ha)) |
| 6359 | qla8044_watchdog(vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6360 | } |
| 6361 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6362 | if (!vha->vp_idx && IS_QLAFX00(ha)) |
| 6363 | qlafx00_timer_routine(vha); |
| 6364 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6365 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6366 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 6367 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 6368 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6369 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6370 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6371 | if (atomic_read(&vha->loop_down_timer) == |
| 6372 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6373 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6374 | ql_log(ql_log_info, vha, 0x6008, |
| 6375 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6376 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6377 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 6378 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6379 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 6380 | /* |
| 6381 | * Schedule an ISP abort to return any FCP2-device |
| 6382 | * commands. |
| 6383 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6384 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6385 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6386 | spin_lock_irqsave(&ha->hardware_lock, |
| 6387 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 6388 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6389 | for (index = 1; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 6390 | index < req->num_outstanding_cmds; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6391 | index++) { |
| 6392 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 6393 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6394 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6395 | if (!sp) |
| 6396 | continue; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 6397 | if (sp->cmd_type != TYPE_SRB) |
| 6398 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 6399 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 6400 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6401 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 6402 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6403 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6404 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 6405 | if (IS_QLA82XX(ha)) |
| 6406 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 6407 | &vha->dpc_flags); |
| 6408 | else |
| 6409 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6410 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6411 | break; |
| 6412 | } |
| 6413 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6414 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6415 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6416 | start_dpc++; |
| 6417 | } |
| 6418 | |
| 6419 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6420 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 6421 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6422 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6423 | "Loop down - aborting ISP.\n"); |
| 6424 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 6425 | if (IS_QLA82XX(ha)) |
| 6426 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 6427 | &vha->dpc_flags); |
| 6428 | else |
| 6429 | set_bit(ISP_ABORT_NEEDED, |
| 6430 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6431 | } |
| 6432 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6433 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 6434 | "Loop down - seconds remaining %d.\n", |
| 6435 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6436 | } |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 6437 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 6438 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 6439 | /* There is no beacon_blink function for ISP82xx */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6440 | if (!IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 6441 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 6442 | start_dpc++; |
| 6443 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 6444 | } |
| 6445 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 6446 | /* Process any deferred work. */ |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 6447 | if (!list_empty(&vha->work_list)) { |
| 6448 | unsigned long flags; |
| 6449 | bool q = false; |
| 6450 | |
| 6451 | spin_lock_irqsave(&vha->work_lock, flags); |
| 6452 | if (!test_and_set_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags)) |
| 6453 | q = true; |
| 6454 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 6455 | if (q) |
| 6456 | queue_work(vha->hw->wq, &vha->iocb_work); |
| 6457 | } |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 6458 | |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 6459 | /* |
| 6460 | * FC-NVME |
| 6461 | * see if the active AEN count has changed from what was last reported. |
| 6462 | */ |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6463 | if (!vha->vp_idx && (atomic_read(&ha->nvme_active_aen_cnt) != |
| 6464 | ha->nvme_last_rptd_aen) && ha->zio_mode == QLA_ZIO_MODE_6) { |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 6465 | ql_log(ql_log_info, vha, 0x3002, |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6466 | "nvme: Sched: Set ZIO exchange threshold to %d.\n", |
| 6467 | ha->nvme_last_rptd_aen); |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6468 | ha->nvme_last_rptd_aen = atomic_read(&ha->nvme_active_aen_cnt); |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6469 | set_bit(SET_NVME_ZIO_THRESHOLD_NEEDED, &vha->dpc_flags); |
| 6470 | start_dpc++; |
| 6471 | } |
| 6472 | |
| 6473 | if (!vha->vp_idx && |
| 6474 | (atomic_read(&ha->zio_threshold) != ha->last_zio_threshold) && |
| 6475 | (ha->zio_mode == QLA_ZIO_MODE_6) && |
| 6476 | (IS_QLA83XX(ha) || IS_QLA27XX(ha))) { |
| 6477 | ql_log(ql_log_info, vha, 0x3002, |
| 6478 | "Sched: Set ZIO exchange threshold to %d.\n", |
| 6479 | ha->last_zio_threshold); |
| 6480 | ha->last_zio_threshold = atomic_read(&ha->zio_threshold); |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6481 | set_bit(SET_ZIO_THRESHOLD_NEEDED, &vha->dpc_flags); |
| 6482 | start_dpc++; |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 6483 | } |
| 6484 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6485 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6486 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 6487 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 6488 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6489 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6490 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 6491 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6492 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 6493 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6494 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 6495 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6496 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 6497 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 6498 | "fcport_update_needed=%d start_dpc=%d " |
| 6499 | "reset_marker_needed=%d", |
| 6500 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 6501 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 6502 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 6503 | start_dpc, |
| 6504 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 6505 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 6506 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 6507 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 6508 | "relogin_needed=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6509 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 6510 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 6511 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 6512 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 6513 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6514 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6515 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6516 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6517 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6518 | } |
| 6519 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6520 | /* Firmware interface routines. */ |
| 6521 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6522 | #define FW_BLOBS 11 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6523 | #define FW_ISP21XX 0 |
| 6524 | #define FW_ISP22XX 1 |
| 6525 | #define FW_ISP2300 2 |
| 6526 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6527 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6528 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6529 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6530 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6531 | #define FW_ISP2031 8 |
| 6532 | #define FW_ISP8031 9 |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6533 | #define FW_ISP27XX 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6534 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6535 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 6536 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 6537 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 6538 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 6539 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6540 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6541 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6542 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6543 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 6544 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6545 | #define FW_FILE_ISP27XX "ql2700_fw.bin" |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6546 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6547 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6548 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6549 | |
| 6550 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6551 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 6552 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 6553 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 6554 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 6555 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6556 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6557 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6558 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6559 | { .name = FW_FILE_ISP2031, }, |
| 6560 | { .name = FW_FILE_ISP8031, }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6561 | { .name = FW_FILE_ISP27XX, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6562 | }; |
| 6563 | |
| 6564 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6565 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6566 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6567 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6568 | struct fw_blob *blob; |
| 6569 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6570 | if (IS_QLA2100(ha)) { |
| 6571 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 6572 | } else if (IS_QLA2200(ha)) { |
| 6573 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6574 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6575 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6576 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6577 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 6578 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6579 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6580 | } else if (IS_QLA25XX(ha)) { |
| 6581 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6582 | } else if (IS_QLA81XX(ha)) { |
| 6583 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6584 | } else if (IS_QLA82XX(ha)) { |
| 6585 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6586 | } else if (IS_QLA2031(ha)) { |
| 6587 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 6588 | } else if (IS_QLA8031(ha)) { |
| 6589 | blob = &qla_fw_blobs[FW_ISP8031]; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6590 | } else if (IS_QLA27XX(ha)) { |
| 6591 | blob = &qla_fw_blobs[FW_ISP27XX]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 6592 | } else { |
| 6593 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6594 | } |
| 6595 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6596 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6597 | if (blob->fw) |
| 6598 | goto out; |
| 6599 | |
| 6600 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6601 | ql_log(ql_log_warn, vha, 0x0063, |
| 6602 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6603 | blob->fw = NULL; |
| 6604 | blob = NULL; |
| 6605 | goto out; |
| 6606 | } |
| 6607 | |
| 6608 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6609 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6610 | return blob; |
| 6611 | } |
| 6612 | |
| 6613 | static void |
| 6614 | qla2x00_release_firmware(void) |
| 6615 | { |
| 6616 | int idx; |
| 6617 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6618 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6619 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 6620 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6621 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6622 | } |
| 6623 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6624 | static pci_ers_result_t |
| 6625 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 6626 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6627 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 6628 | struct qla_hw_data *ha = vha->hw; |
| 6629 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6630 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 6631 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 6632 | |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 6633 | if (!atomic_read(&pdev->enable_cnt)) { |
| 6634 | ql_log(ql_log_info, vha, 0xffff, |
| 6635 | "PCI device is disabled,state %x\n", state); |
| 6636 | return PCI_ERS_RESULT_NEED_RESET; |
| 6637 | } |
| 6638 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6639 | switch (state) { |
| 6640 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6641 | ha->flags.eeh_busy = 0; |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 6642 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6643 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6644 | qla2xxx_wake_dpc(vha); |
| 6645 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6646 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 6647 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6648 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6649 | /* For ISP82XX complete any pending mailbox cmd */ |
| 6650 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6651 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 6652 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 6653 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6654 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6655 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6656 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 6657 | /* Return back all IOs */ |
| 6658 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 6659 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6660 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6661 | qla2xxx_wake_dpc(vha); |
| 6662 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6663 | return PCI_ERS_RESULT_NEED_RESET; |
| 6664 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6665 | ha->flags.pci_channel_io_perm_failure = 1; |
| 6666 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 6667 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6668 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6669 | qla2xxx_wake_dpc(vha); |
| 6670 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6671 | return PCI_ERS_RESULT_DISCONNECT; |
| 6672 | } |
| 6673 | return PCI_ERS_RESULT_NEED_RESET; |
| 6674 | } |
| 6675 | |
| 6676 | static pci_ers_result_t |
| 6677 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 6678 | { |
| 6679 | int risc_paused = 0; |
| 6680 | uint32_t stat; |
| 6681 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6682 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6683 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6684 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 6685 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 6686 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 6687 | if (IS_QLA82XX(ha)) |
| 6688 | return PCI_ERS_RESULT_RECOVERED; |
| 6689 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6690 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 6691 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 6692 | stat = RD_REG_DWORD(®->hccr); |
| 6693 | if (stat & HCCR_RISC_PAUSE) |
| 6694 | risc_paused = 1; |
| 6695 | } else if (IS_QLA23XX(ha)) { |
| 6696 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 6697 | if (stat & HSR_RISC_PAUSED) |
| 6698 | risc_paused = 1; |
| 6699 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 6700 | stat = RD_REG_DWORD(®24->host_status); |
| 6701 | if (stat & HSRX_RISC_PAUSED) |
| 6702 | risc_paused = 1; |
| 6703 | } |
| 6704 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 6705 | |
| 6706 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6707 | ql_log(ql_log_info, base_vha, 0x9003, |
| 6708 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6709 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6710 | |
| 6711 | return PCI_ERS_RESULT_NEED_RESET; |
| 6712 | } else |
| 6713 | return PCI_ERS_RESULT_RECOVERED; |
| 6714 | } |
| 6715 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 6716 | static uint32_t |
| 6717 | qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6718 | { |
| 6719 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 6720 | uint32_t drv_active = 0; |
| 6721 | struct qla_hw_data *ha = base_vha->hw; |
| 6722 | int fn; |
| 6723 | struct pci_dev *other_pdev = NULL; |
| 6724 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6725 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 6726 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6727 | |
| 6728 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 6729 | |
| 6730 | if (base_vha->flags.online) { |
| 6731 | /* Abort all outstanding commands, |
| 6732 | * so as to be requeued later */ |
| 6733 | qla2x00_abort_isp_cleanup(base_vha); |
| 6734 | } |
| 6735 | |
| 6736 | |
| 6737 | fn = PCI_FUNC(ha->pdev->devfn); |
| 6738 | while (fn > 0) { |
| 6739 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6740 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 6741 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6742 | other_pdev = |
| 6743 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 6744 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 6745 | fn)); |
| 6746 | |
| 6747 | if (!other_pdev) |
| 6748 | continue; |
| 6749 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6750 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 6751 | "Found PCI func available and enable at 0x%x.\n", |
| 6752 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6753 | pci_dev_put(other_pdev); |
| 6754 | break; |
| 6755 | } |
| 6756 | pci_dev_put(other_pdev); |
| 6757 | } |
| 6758 | |
| 6759 | if (!fn) { |
| 6760 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6761 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 6762 | "This devfn is reset owner = 0x%x.\n", |
| 6763 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6764 | qla82xx_idc_lock(ha); |
| 6765 | |
| 6766 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6767 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6768 | |
| 6769 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 6770 | QLA82XX_IDC_VERSION); |
| 6771 | |
| 6772 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6773 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 6774 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6775 | |
| 6776 | qla82xx_idc_unlock(ha); |
| 6777 | /* Reset if device is not already reset |
| 6778 | * drv_active would be 0 if a reset has already been done |
| 6779 | */ |
| 6780 | if (drv_active) |
| 6781 | rval = qla82xx_start_firmware(base_vha); |
| 6782 | else |
| 6783 | rval = QLA_SUCCESS; |
| 6784 | qla82xx_idc_lock(ha); |
| 6785 | |
| 6786 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6787 | ql_log(ql_log_info, base_vha, 0x900b, |
| 6788 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6789 | qla82xx_clear_drv_active(ha); |
| 6790 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6791 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6792 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6793 | ql_log(ql_log_info, base_vha, 0x900c, |
| 6794 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6795 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6796 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6797 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6798 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6799 | rval = qla82xx_restart_isp(base_vha); |
| 6800 | qla82xx_idc_lock(ha); |
| 6801 | /* Clear driver state register */ |
| 6802 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 6803 | qla82xx_set_drv_active(base_vha); |
| 6804 | } |
| 6805 | qla82xx_idc_unlock(ha); |
| 6806 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6807 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 6808 | "This devfn is not reset owner = 0x%x.\n", |
| 6809 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6810 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6811 | QLA8XXX_DEV_READY)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6812 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6813 | rval = qla82xx_restart_isp(base_vha); |
| 6814 | qla82xx_idc_lock(ha); |
| 6815 | qla82xx_set_drv_active(base_vha); |
| 6816 | qla82xx_idc_unlock(ha); |
| 6817 | } |
| 6818 | } |
| 6819 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 6820 | |
| 6821 | return rval; |
| 6822 | } |
| 6823 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6824 | static pci_ers_result_t |
| 6825 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 6826 | { |
| 6827 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6828 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6829 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6830 | struct rsp_que *rsp; |
| 6831 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6832 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6833 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 6834 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6835 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6836 | /* Workaround: qla2xxx driver which access hardware earlier |
| 6837 | * needs error state to be pci_channel_io_online. |
| 6838 | * Otherwise mailbox command timesout. |
| 6839 | */ |
| 6840 | pdev->error_state = pci_channel_io_normal; |
| 6841 | |
| 6842 | pci_restore_state(pdev); |
| 6843 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 6844 | /* pci_restore_state() clears the saved_state flag of the device |
| 6845 | * save restored state which resets saved_state flag |
| 6846 | */ |
| 6847 | pci_save_state(pdev); |
| 6848 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 6849 | if (ha->mem_only) |
| 6850 | rc = pci_enable_device_mem(pdev); |
| 6851 | else |
| 6852 | rc = pci_enable_device(pdev); |
| 6853 | |
| 6854 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6855 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6856 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6857 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6858 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6859 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6860 | rsp = ha->rsp_q_map[0]; |
| 6861 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6862 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6863 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6864 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6865 | goto exit_slot_reset; |
| 6866 | |
| 6867 | if (IS_QLA82XX(ha)) { |
| 6868 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 6869 | ret = PCI_ERS_RESULT_RECOVERED; |
| 6870 | goto exit_slot_reset; |
| 6871 | } else |
| 6872 | goto exit_slot_reset; |
| 6873 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6874 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6875 | while (ha->flags.mbox_busy && retries--) |
| 6876 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6877 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6878 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6879 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6880 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6881 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6882 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6883 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6884 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6885 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 6886 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6887 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6888 | return ret; |
| 6889 | } |
| 6890 | |
| 6891 | static void |
| 6892 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 6893 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6894 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6895 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6896 | int ret; |
| 6897 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6898 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 6899 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6900 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6901 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6902 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6903 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 6904 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6905 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6906 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 6907 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 6908 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6909 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6910 | } |
| 6911 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 6912 | static int qla2xxx_map_queues(struct Scsi_Host *shost) |
| 6913 | { |
Quinn Tran | d68b850 | 2017-12-04 14:44:59 -0800 | [diff] [blame] | 6914 | int rc; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 6915 | scsi_qla_host_t *vha = (scsi_qla_host_t *)shost->hostdata; |
| 6916 | |
Quinn Tran | d68b850 | 2017-12-04 14:44:59 -0800 | [diff] [blame] | 6917 | if (USER_CTRL_IRQ(vha->hw)) |
| 6918 | rc = blk_mq_map_queues(&shost->tag_set); |
| 6919 | else |
Keith Busch | f23f5bec | 2018-03-27 09:39:06 -0600 | [diff] [blame] | 6920 | rc = blk_mq_pci_map_queues(&shost->tag_set, vha->hw->pdev, 0); |
Quinn Tran | d68b850 | 2017-12-04 14:44:59 -0800 | [diff] [blame] | 6921 | return rc; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 6922 | } |
| 6923 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 6924 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6925 | .error_detected = qla2xxx_pci_error_detected, |
| 6926 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 6927 | .slot_reset = qla2xxx_pci_slot_reset, |
| 6928 | .resume = qla2xxx_pci_resume, |
| 6929 | }; |
| 6930 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6931 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 6932 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 6933 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 6934 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 6935 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 6936 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 6937 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 6938 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 6939 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 6940 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 6941 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 6942 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 6943 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6944 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6945 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6946 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6947 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 6948 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6949 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISPF001) }, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6950 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8044) }, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6951 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2071) }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6952 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2271) }, |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 6953 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2261) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6954 | { 0 }, |
| 6955 | }; |
| 6956 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 6957 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6958 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 6959 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 6960 | .driver = { |
| 6961 | .owner = THIS_MODULE, |
| 6962 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6963 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6964 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 6965 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 6966 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6967 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6968 | }; |
| 6969 | |
Al Viro | 75ef9de | 2013-04-04 19:09:41 -0400 | [diff] [blame] | 6970 | static const struct file_operations apidev_fops = { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6971 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 6972 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6973 | }; |
| 6974 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6975 | /** |
| 6976 | * qla2x00_module_init - Module initialization. |
| 6977 | **/ |
| 6978 | static int __init |
| 6979 | qla2x00_module_init(void) |
| 6980 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6981 | int ret = 0; |
| 6982 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6983 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6984 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 6985 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6986 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6987 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 6988 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6989 | return -ENOMEM; |
| 6990 | } |
| 6991 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6992 | /* Initialize target kmem_cache and mem_pools */ |
| 6993 | ret = qlt_init(); |
| 6994 | if (ret < 0) { |
| 6995 | kmem_cache_destroy(srb_cachep); |
| 6996 | return ret; |
| 6997 | } else if (ret > 0) { |
| 6998 | /* |
| 6999 | * If initiator mode is explictly disabled by qlt_init(), |
| 7000 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 7001 | * performing scsi_scan_target() during LOOP UP event. |
| 7002 | */ |
| 7003 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 7004 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 7005 | } |
| 7006 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7007 | /* Derive version string. */ |
| 7008 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 7009 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 7010 | strcat(qla2x00_version_str, "-debug"); |
Joe Carnuccio | fed0f68 | 2017-08-23 15:05:10 -0700 | [diff] [blame] | 7011 | if (ql2xextended_error_logging == 1) |
| 7012 | ql2xextended_error_logging = QL_DBG_DEFAULT1_MASK; |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 7013 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 7014 | qla2xxx_transport_template = |
| 7015 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7016 | if (!qla2xxx_transport_template) { |
| 7017 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7018 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 7019 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 7020 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7021 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7022 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 7023 | |
| 7024 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 7025 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7026 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 7027 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 7028 | } |
| 7029 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7030 | qla2xxx_transport_vport_template = |
| 7031 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 7032 | if (!qla2xxx_transport_vport_template) { |
| 7033 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 7034 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7035 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7036 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 7037 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7038 | return -ENODEV; |
| 7039 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7040 | ql_log(ql_log_info, NULL, 0x0005, |
| 7041 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 7042 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 7043 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 7044 | if (ret) { |
| 7045 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 7046 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 7047 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7048 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7049 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 7050 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 7051 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 7052 | } |
| 7053 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7054 | } |
| 7055 | |
| 7056 | /** |
| 7057 | * qla2x00_module_exit - Module cleanup. |
| 7058 | **/ |
| 7059 | static void __exit |
| 7060 | qla2x00_module_exit(void) |
| 7061 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 7062 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 7063 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 7064 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 7065 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 7066 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 7067 | if (ctx_cachep) |
| 7068 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7069 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7070 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7071 | } |
| 7072 | |
| 7073 | module_init(qla2x00_module_init); |
| 7074 | module_exit(qla2x00_module_exit); |
| 7075 | |
| 7076 | MODULE_AUTHOR("QLogic Corporation"); |
| 7077 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 7078 | MODULE_LICENSE("GPL"); |
| 7079 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 7080 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 7081 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 7082 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 7083 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 7084 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 7085 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |