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; |
| 394 | ha->base_qpair->req = req; |
| 395 | ha->base_qpair->rsp = rsp; |
| 396 | ha->base_qpair->vha = vha; |
| 397 | ha->base_qpair->qp_lock_ptr = &ha->hardware_lock; |
| 398 | ha->base_qpair->use_shadow_reg = IS_SHADOW_REG_CAPABLE(ha) ? 1 : 0; |
| 399 | ha->base_qpair->msix = &ha->msix_entries[QLA_MSIX_RSP_Q]; |
| 400 | INIT_LIST_HEAD(&ha->base_qpair->hints_list); |
| 401 | ha->base_qpair->enable_class_2 = ql2xenableclass2; |
| 402 | /* init qpair to this cpu. Will adjust at run time. */ |
Bart Van Assche | 8653188 | 2017-11-06 11:59:05 -0800 | [diff] [blame] | 403 | qla_cpu_update(rsp->qpair, raw_smp_processor_id()); |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 404 | ha->base_qpair->pdev = ha->pdev; |
| 405 | |
| 406 | if (IS_QLA27XX(ha) || IS_QLA83XX(ha)) |
| 407 | ha->base_qpair->reqq_start_iocbs = qla_83xx_start_iocbs; |
| 408 | } |
| 409 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 410 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 411 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 412 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 413 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 414 | 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] | 415 | GFP_KERNEL); |
| 416 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 417 | ql_log(ql_log_fatal, vha, 0x003b, |
| 418 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 419 | goto fail_req_map; |
| 420 | } |
| 421 | |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 422 | 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] | 423 | GFP_KERNEL); |
| 424 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 425 | ql_log(ql_log_fatal, vha, 0x003c, |
| 426 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 427 | goto fail_rsp_map; |
| 428 | } |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 429 | |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 430 | ha->base_qpair = kzalloc(sizeof(struct qla_qpair), GFP_KERNEL); |
| 431 | if (ha->base_qpair == NULL) { |
| 432 | ql_log(ql_log_warn, vha, 0x00e0, |
| 433 | "Failed to allocate base queue pair memory.\n"); |
| 434 | goto fail_base_qpair; |
| 435 | } |
| 436 | |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 437 | qla_init_base_qpair(vha, req, rsp); |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 438 | |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 439 | if ((ql2xmqsupport || ql2xnvmeenable) && ha->max_qpairs) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 440 | ha->queue_pair_map = kcalloc(ha->max_qpairs, sizeof(struct qla_qpair *), |
| 441 | GFP_KERNEL); |
| 442 | if (!ha->queue_pair_map) { |
| 443 | ql_log(ql_log_fatal, vha, 0x0180, |
| 444 | "Unable to allocate memory for queue pair ptrs.\n"); |
| 445 | goto fail_qpair_map; |
| 446 | } |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 447 | } |
| 448 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 449 | /* |
| 450 | * Make sure we record at least the request and response queue zero in |
| 451 | * case we need to free them if part of the probe fails. |
| 452 | */ |
| 453 | ha->rsp_q_map[0] = rsp; |
| 454 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 455 | set_bit(0, ha->rsp_qid_map); |
| 456 | set_bit(0, ha->req_qid_map); |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 457 | return 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 458 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 459 | fail_qpair_map: |
Quinn Tran | 82de802 | 2017-06-13 20:47:17 -0700 | [diff] [blame] | 460 | kfree(ha->base_qpair); |
| 461 | ha->base_qpair = NULL; |
| 462 | fail_base_qpair: |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 463 | kfree(ha->rsp_q_map); |
| 464 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 465 | fail_rsp_map: |
| 466 | kfree(ha->req_q_map); |
| 467 | ha->req_q_map = NULL; |
| 468 | fail_req_map: |
| 469 | return -ENOMEM; |
| 470 | } |
| 471 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 472 | 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] | 473 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 474 | if (IS_QLAFX00(ha)) { |
| 475 | if (req && req->ring_fx00) |
| 476 | dma_free_coherent(&ha->pdev->dev, |
| 477 | (req->length_fx00 + 1) * sizeof(request_t), |
| 478 | req->ring_fx00, req->dma_fx00); |
| 479 | } else if (req && req->ring) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 480 | dma_free_coherent(&ha->pdev->dev, |
| 481 | (req->length + 1) * sizeof(request_t), |
| 482 | req->ring, req->dma); |
| 483 | |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 484 | if (req) |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 485 | kfree(req->outstanding_cmds); |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 486 | |
| 487 | kfree(req); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 488 | } |
| 489 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 490 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 491 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 492 | if (IS_QLAFX00(ha)) { |
Meelis Roos | 3f6c9be | 2018-03-08 15:44:37 +0200 | [diff] [blame] | 493 | if (rsp && rsp->ring_fx00) |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 494 | dma_free_coherent(&ha->pdev->dev, |
| 495 | (rsp->length_fx00 + 1) * sizeof(request_t), |
| 496 | rsp->ring_fx00, rsp->dma_fx00); |
| 497 | } else if (rsp && rsp->ring) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 498 | dma_free_coherent(&ha->pdev->dev, |
| 499 | (rsp->length + 1) * sizeof(response_t), |
| 500 | rsp->ring, rsp->dma); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 501 | } |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 502 | kfree(rsp); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 503 | } |
| 504 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 505 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 506 | { |
| 507 | struct req_que *req; |
| 508 | struct rsp_que *rsp; |
| 509 | int cnt; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 510 | unsigned long flags; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 511 | |
Quinn Tran | 82de802 | 2017-06-13 20:47:17 -0700 | [diff] [blame] | 512 | if (ha->queue_pair_map) { |
| 513 | kfree(ha->queue_pair_map); |
| 514 | ha->queue_pair_map = NULL; |
| 515 | } |
| 516 | if (ha->base_qpair) { |
| 517 | kfree(ha->base_qpair); |
| 518 | ha->base_qpair = NULL; |
| 519 | } |
| 520 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 521 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 522 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 523 | if (!test_bit(cnt, ha->req_qid_map)) |
| 524 | continue; |
| 525 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 526 | req = ha->req_q_map[cnt]; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 527 | clear_bit(cnt, ha->req_qid_map); |
| 528 | ha->req_q_map[cnt] = NULL; |
| 529 | |
| 530 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 531 | qla2x00_free_req_que(ha, req); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 532 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 533 | } |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 534 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 535 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 536 | kfree(ha->req_q_map); |
| 537 | ha->req_q_map = NULL; |
| 538 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 539 | |
| 540 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 541 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 542 | if (!test_bit(cnt, ha->rsp_qid_map)) |
| 543 | continue; |
| 544 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 545 | rsp = ha->rsp_q_map[cnt]; |
Dave Jones | c3c4239 | 2016-12-27 13:13:21 -0500 | [diff] [blame] | 546 | clear_bit(cnt, ha->rsp_qid_map); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 547 | ha->rsp_q_map[cnt] = NULL; |
| 548 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 549 | qla2x00_free_rsp_que(ha, rsp); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 550 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 551 | } |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 552 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 553 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 554 | kfree(ha->rsp_q_map); |
| 555 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 556 | } |
| 557 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 559 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 561 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | static char *pci_bus_modes[] = { |
| 563 | "33", "66", "100", "133", |
| 564 | }; |
| 565 | uint16_t pci_bus; |
| 566 | |
| 567 | strcpy(str, "PCI"); |
| 568 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 569 | if (pci_bus) { |
| 570 | strcat(str, "-X ("); |
| 571 | strcat(str, pci_bus_modes[pci_bus]); |
| 572 | } else { |
| 573 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 574 | strcat(str, " ("); |
| 575 | strcat(str, pci_bus_modes[pci_bus]); |
| 576 | } |
| 577 | strcat(str, " MHz)"); |
| 578 | |
| 579 | return (str); |
| 580 | } |
| 581 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 582 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 583 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 584 | { |
| 585 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 586 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 587 | uint32_t pci_bus; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 588 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 589 | if (pci_is_pcie(ha->pdev)) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 590 | char lwstr[6]; |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 591 | uint32_t lstat, lspeed, lwidth; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 592 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 593 | pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); |
| 594 | lspeed = lstat & PCI_EXP_LNKCAP_SLS; |
| 595 | lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 596 | |
| 597 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 598 | switch (lspeed) { |
| 599 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 600 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 601 | break; |
| 602 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 603 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 604 | break; |
| 605 | case 3: |
| 606 | strcat(str, "8.0GT/s "); |
| 607 | break; |
| 608 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 609 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 610 | break; |
| 611 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 612 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 613 | strcat(str, lwstr); |
| 614 | |
| 615 | return str; |
| 616 | } |
| 617 | |
| 618 | strcpy(str, "PCI"); |
| 619 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 620 | if (pci_bus == 0 || pci_bus == 8) { |
| 621 | strcat(str, " ("); |
| 622 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 623 | } else { |
| 624 | strcat(str, "-X "); |
| 625 | if (pci_bus & BIT_2) |
| 626 | strcat(str, "Mode 2"); |
| 627 | else |
| 628 | strcat(str, "Mode 1"); |
| 629 | strcat(str, " ("); |
| 630 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 631 | } |
| 632 | strcat(str, " MHz)"); |
| 633 | |
| 634 | return str; |
| 635 | } |
| 636 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 637 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 638 | 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] | 639 | { |
| 640 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 641 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 642 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 643 | snprintf(str, size, "%d.%02d.%02d ", ha->fw_major_version, |
| 644 | ha->fw_minor_version, ha->fw_subminor_version); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | |
| 646 | if (ha->fw_attributes & BIT_9) { |
| 647 | strcat(str, "FLX"); |
| 648 | return (str); |
| 649 | } |
| 650 | |
| 651 | switch (ha->fw_attributes & 0xFF) { |
| 652 | case 0x7: |
| 653 | strcat(str, "EF"); |
| 654 | break; |
| 655 | case 0x17: |
| 656 | strcat(str, "TP"); |
| 657 | break; |
| 658 | case 0x37: |
| 659 | strcat(str, "IP"); |
| 660 | break; |
| 661 | case 0x77: |
| 662 | strcat(str, "VI"); |
| 663 | break; |
| 664 | default: |
| 665 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 666 | strcat(str, un_str); |
| 667 | break; |
| 668 | } |
| 669 | if (ha->fw_attributes & 0x100) |
| 670 | strcat(str, "X"); |
| 671 | |
| 672 | return (str); |
| 673 | } |
| 674 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 675 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 676 | 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] | 677 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 678 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 679 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 680 | snprintf(str, size, "%d.%02d.%02d (%x)", ha->fw_major_version, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 681 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 682 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 683 | } |
| 684 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 685 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 686 | qla2x00_sp_free_dma(void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 687 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 688 | srb_t *sp = ptr; |
| 689 | struct qla_hw_data *ha = sp->vha->hw; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 690 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 691 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 692 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 693 | if (sp->flags & SRB_DMA_VALID) { |
| 694 | scsi_dma_unmap(cmd); |
| 695 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 696 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 697 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 698 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 699 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 700 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 701 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 702 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 703 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 704 | if (!ctx) |
| 705 | goto end; |
| 706 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 707 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 708 | /* List assured to be having elements */ |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 709 | qla2x00_clean_dsd_pool(ha, ctx); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 710 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 711 | } |
| 712 | |
| 713 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 714 | struct crc_context *ctx0 = ctx; |
| 715 | |
| 716 | dma_pool_free(ha->dl_dma_pool, ctx0, ctx0->crc_ctx_dma); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 717 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 718 | } |
| 719 | |
| 720 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 721 | struct ct6_dsd *ctx1 = ctx; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 722 | |
| 723 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 724 | ctx1->fcp_cmnd_dma); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 725 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 726 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 727 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 728 | mempool_free(ctx1, ha->ctx_mempool); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 729 | } |
| 730 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 731 | end: |
himanshu.madhani@cavium.com | 6fcd98f | 2017-07-21 09:32:23 -0700 | [diff] [blame] | 732 | if (sp->type != SRB_NVME_CMD && sp->type != SRB_NVME_LS) { |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 733 | CMD_SP(cmd) = NULL; |
| 734 | qla2x00_rel_sp(sp); |
| 735 | } |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 736 | } |
| 737 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 738 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 739 | qla2x00_sp_compl(void *ptr, int res) |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 740 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 741 | srb_t *sp = ptr; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 742 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 743 | |
| 744 | cmd->result = res; |
| 745 | |
| 746 | if (atomic_read(&sp->ref_count) == 0) { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 747 | ql_dbg(ql_dbg_io, sp->vha, 0x3015, |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 748 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 749 | sp, GET_CMD_SP(sp)); |
| 750 | if (ql2xextended_error_logging & ql_dbg_io) |
Hiral Patel | 8fbdac8 | 2015-08-04 13:37:56 -0400 | [diff] [blame] | 751 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 752 | return; |
| 753 | } |
| 754 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 755 | return; |
| 756 | |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 757 | sp->free(sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 758 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 759 | } |
| 760 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 761 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 762 | qla2xxx_qpair_sp_free_dma(void *ptr) |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 763 | { |
| 764 | srb_t *sp = (srb_t *)ptr; |
| 765 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 766 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 767 | void *ctx = GET_CMD_CTX_SP(sp); |
| 768 | |
| 769 | if (sp->flags & SRB_DMA_VALID) { |
| 770 | scsi_dma_unmap(cmd); |
| 771 | sp->flags &= ~SRB_DMA_VALID; |
| 772 | } |
| 773 | |
| 774 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 775 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 776 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 777 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 778 | } |
| 779 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 780 | if (!ctx) |
| 781 | goto end; |
| 782 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 783 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 784 | /* List assured to be having elements */ |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 785 | qla2x00_clean_dsd_pool(ha, ctx); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 786 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 787 | } |
| 788 | |
| 789 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 790 | struct crc_context *ctx0 = ctx; |
| 791 | |
| 792 | dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 793 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 794 | } |
| 795 | |
| 796 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 797 | struct ct6_dsd *ctx1 = ctx; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 798 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 799 | ctx1->fcp_cmnd_dma); |
| 800 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 801 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 802 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 803 | mempool_free(ctx1, ha->ctx_mempool); |
| 804 | } |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 805 | end: |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 806 | CMD_SP(cmd) = NULL; |
| 807 | qla2xxx_rel_qpair_sp(sp->qpair, sp); |
| 808 | } |
| 809 | |
| 810 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 811 | qla2xxx_qpair_sp_compl(void *ptr, int res) |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 812 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 813 | srb_t *sp = ptr; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 814 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 815 | |
| 816 | cmd->result = res; |
| 817 | |
| 818 | if (atomic_read(&sp->ref_count) == 0) { |
| 819 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079, |
| 820 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 821 | sp, GET_CMD_SP(sp)); |
| 822 | if (ql2xextended_error_logging & ql_dbg_io) |
| 823 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
| 824 | return; |
| 825 | } |
| 826 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 827 | return; |
| 828 | |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 829 | sp->free(sp); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 830 | cmd->scsi_done(cmd); |
| 831 | } |
| 832 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 833 | /* If we are SP1 here, we need to still take and release the host_lock as SP1 |
| 834 | * does not have the changes necessary to avoid taking host->host_lock. |
| 835 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 837 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 838 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 839 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 840 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 841 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 842 | struct qla_hw_data *ha = vha->hw; |
| 843 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 844 | srb_t *sp; |
| 845 | int rval; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 846 | struct qla_qpair *qpair = NULL; |
| 847 | uint32_t tag; |
| 848 | uint16_t hwq; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 849 | |
Mauricio Faria de Oliveira | 04dfaa5 | 2016-11-07 17:53:30 -0200 | [diff] [blame] | 850 | if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { |
| 851 | cmd->result = DID_NO_CONNECT << 16; |
| 852 | goto qc24_fail_command; |
| 853 | } |
| 854 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 855 | if (ha->mqenable) { |
| 856 | if (shost_use_blk_mq(vha->host)) { |
| 857 | tag = blk_mq_unique_tag(cmd->request); |
| 858 | hwq = blk_mq_unique_tag_to_hwq(tag); |
| 859 | qpair = ha->queue_pair_map[hwq]; |
| 860 | } else if (vha->vp_idx && vha->qpair) { |
| 861 | qpair = vha->qpair; |
| 862 | } |
| 863 | |
| 864 | if (qpair) |
| 865 | return qla2xxx_mqueuecommand(host, cmd, qpair); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 866 | } |
| 867 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 868 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 869 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 870 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 871 | "PCI Channel IO permanent failure, exiting " |
| 872 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 873 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 874 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 875 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 876 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 877 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 878 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 879 | goto qc24_fail_command; |
| 880 | } |
| 881 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 882 | rval = fc_remote_port_chkready(rport); |
| 883 | if (rval) { |
| 884 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 885 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 886 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 887 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 888 | goto qc24_fail_command; |
| 889 | } |
| 890 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 891 | if (!vha->flags.difdix_supported && |
| 892 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 893 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 894 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 895 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 896 | cmd->result = DID_NO_CONNECT << 16; |
| 897 | goto qc24_fail_command; |
| 898 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 899 | |
| 900 | if (!fcport) { |
| 901 | cmd->result = DID_NO_CONNECT << 16; |
| 902 | goto qc24_fail_command; |
| 903 | } |
| 904 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 905 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 906 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 907 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 908 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 909 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 910 | atomic_read(&fcport->state), |
| 911 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 912 | cmd->result = DID_NO_CONNECT << 16; |
| 913 | goto qc24_fail_command; |
| 914 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 915 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 916 | } |
| 917 | |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 918 | /* |
| 919 | * Return target busy if we've received a non-zero retry_delay_timer |
| 920 | * in a FCP_RSP. |
| 921 | */ |
Bruno Prémont | 975f7d4 | 2014-12-19 10:29:16 +0100 | [diff] [blame] | 922 | if (fcport->retry_delay_timestamp == 0) { |
| 923 | /* retry delay not set */ |
| 924 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 925 | fcport->retry_delay_timestamp = 0; |
| 926 | else |
| 927 | goto qc24_target_busy; |
| 928 | |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 929 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 930 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 931 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 932 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 933 | sp->u.scmd.cmd = cmd; |
| 934 | sp->type = SRB_SCSI_CMD; |
| 935 | atomic_set(&sp->ref_count, 1); |
| 936 | CMD_SP(cmd) = (void *)sp; |
| 937 | sp->free = qla2x00_sp_free_dma; |
| 938 | sp->done = qla2x00_sp_compl; |
| 939 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 940 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 941 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 942 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 943 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 944 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 945 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 946 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 947 | return 0; |
| 948 | |
| 949 | qc24_host_busy_free_sp: |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 950 | sp->free(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 951 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 952 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 953 | return SCSI_MLQUEUE_HOST_BUSY; |
| 954 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 955 | qc24_target_busy: |
| 956 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 957 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 958 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 959 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 960 | |
| 961 | return 0; |
| 962 | } |
| 963 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 964 | /* For MQ supported I/O */ |
| 965 | int |
| 966 | qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 967 | struct qla_qpair *qpair) |
| 968 | { |
| 969 | scsi_qla_host_t *vha = shost_priv(host); |
| 970 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 971 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
| 972 | struct qla_hw_data *ha = vha->hw; |
| 973 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
| 974 | srb_t *sp; |
| 975 | int rval; |
| 976 | |
| 977 | rval = fc_remote_port_chkready(rport); |
| 978 | if (rval) { |
| 979 | cmd->result = rval; |
| 980 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3076, |
| 981 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 982 | cmd, rval); |
| 983 | goto qc24_fail_command; |
| 984 | } |
| 985 | |
| 986 | if (!fcport) { |
| 987 | cmd->result = DID_NO_CONNECT << 16; |
| 988 | goto qc24_fail_command; |
| 989 | } |
| 990 | |
| 991 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 992 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
| 993 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
| 994 | ql_dbg(ql_dbg_io, vha, 0x3077, |
| 995 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 996 | atomic_read(&fcport->state), |
| 997 | atomic_read(&base_vha->loop_state)); |
| 998 | cmd->result = DID_NO_CONNECT << 16; |
| 999 | goto qc24_fail_command; |
| 1000 | } |
| 1001 | goto qc24_target_busy; |
| 1002 | } |
| 1003 | |
| 1004 | /* |
| 1005 | * Return target busy if we've received a non-zero retry_delay_timer |
| 1006 | * in a FCP_RSP. |
| 1007 | */ |
| 1008 | if (fcport->retry_delay_timestamp == 0) { |
| 1009 | /* retry delay not set */ |
| 1010 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
| 1011 | fcport->retry_delay_timestamp = 0; |
| 1012 | else |
| 1013 | goto qc24_target_busy; |
| 1014 | |
| 1015 | sp = qla2xxx_get_qpair_sp(qpair, fcport, GFP_ATOMIC); |
| 1016 | if (!sp) |
| 1017 | goto qc24_host_busy; |
| 1018 | |
| 1019 | sp->u.scmd.cmd = cmd; |
| 1020 | sp->type = SRB_SCSI_CMD; |
| 1021 | atomic_set(&sp->ref_count, 1); |
| 1022 | CMD_SP(cmd) = (void *)sp; |
| 1023 | sp->free = qla2xxx_qpair_sp_free_dma; |
| 1024 | sp->done = qla2xxx_qpair_sp_compl; |
| 1025 | sp->qpair = qpair; |
| 1026 | |
| 1027 | rval = ha->isp_ops->start_scsi_mq(sp); |
| 1028 | if (rval != QLA_SUCCESS) { |
| 1029 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3078, |
| 1030 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
| 1031 | if (rval == QLA_INTERFACE_ERROR) |
| 1032 | goto qc24_fail_command; |
| 1033 | goto qc24_host_busy_free_sp; |
| 1034 | } |
| 1035 | |
| 1036 | return 0; |
| 1037 | |
| 1038 | qc24_host_busy_free_sp: |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 1039 | sp->free(sp); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1040 | |
| 1041 | qc24_host_busy: |
| 1042 | return SCSI_MLQUEUE_HOST_BUSY; |
| 1043 | |
| 1044 | qc24_target_busy: |
| 1045 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 1046 | |
| 1047 | qc24_fail_command: |
| 1048 | cmd->scsi_done(cmd); |
| 1049 | |
| 1050 | return 0; |
| 1051 | } |
| 1052 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | /* |
| 1054 | * qla2x00_eh_wait_on_command |
| 1055 | * Waits for the command to be returned by the Firmware for some |
| 1056 | * max time. |
| 1057 | * |
| 1058 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | * |
| 1061 | * Return: |
| 1062 | * Not Found : 0 |
| 1063 | * Found : 1 |
| 1064 | */ |
| 1065 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1066 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 1068 | #define ABORT_POLLING_PERIOD 1000 |
Chad Dupuis | 478c3b0 | 2014-04-11 16:54:35 -0400 | [diff] [blame] | 1069 | #define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1070 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1071 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1072 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1073 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1075 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1076 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 1077 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1078 | return ret; |
| 1079 | } |
| 1080 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 1081 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 1082 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1083 | } |
| 1084 | if (CMD_SP(cmd)) |
| 1085 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1087 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | /* |
| 1091 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1092 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 1094 | * finally HBA is disabled ie marked offline |
| 1095 | * |
| 1096 | * Input: |
| 1097 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1098 | * |
| 1099 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | * Does context switching-Release SPIN_LOCK |
| 1101 | * (if any) before calling this routine. |
| 1102 | * |
| 1103 | * Return: |
| 1104 | * Success (Adapter is online) : 0 |
| 1105 | * Failed (Adapter is offline/disabled) : 1 |
| 1106 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 1107 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1108 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 1110 | int return_status; |
| 1111 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1112 | struct qla_hw_data *ha = vha->hw; |
| 1113 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1115 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1116 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1117 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1118 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1119 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | |
| 1121 | msleep(1000); |
| 1122 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1123 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1124 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | else |
| 1126 | return_status = QLA_FUNCTION_FAILED; |
| 1127 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1128 | return (return_status); |
| 1129 | } |
| 1130 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1131 | static inline int test_fcport_count(scsi_qla_host_t *vha) |
| 1132 | { |
| 1133 | struct qla_hw_data *ha = vha->hw; |
| 1134 | unsigned long flags; |
| 1135 | int res; |
| 1136 | |
| 1137 | spin_lock_irqsave(&ha->tgt.sess_lock, flags); |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 1138 | ql_dbg(ql_dbg_init, vha, 0x00ec, |
| 1139 | "tgt %p, fcport_count=%d\n", |
| 1140 | vha, vha->fcport_count); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1141 | res = (vha->fcport_count == 0); |
| 1142 | spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); |
| 1143 | |
| 1144 | return res; |
| 1145 | } |
| 1146 | |
| 1147 | /* |
| 1148 | * qla2x00_wait_for_sess_deletion can only be called from remove_one. |
| 1149 | * it has dependency on UNLOADING flag to stop device discovery |
| 1150 | */ |
Quinn Tran | efa93f4 | 2018-07-18 14:29:52 -0700 | [diff] [blame] | 1151 | void |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1152 | qla2x00_wait_for_sess_deletion(scsi_qla_host_t *vha) |
| 1153 | { |
| 1154 | qla2x00_mark_all_devices_lost(vha, 0); |
| 1155 | |
Joe Carnuccio | b85e095 | 2017-08-23 15:05:11 -0700 | [diff] [blame] | 1156 | wait_event_timeout(vha->fcport_waitQ, test_fcport_count(vha), 10*HZ); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1157 | } |
| 1158 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1159 | /* |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1160 | * qla2x00_wait_for_hba_ready |
| 1161 | * Wait till the HBA is ready before doing driver unload |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1162 | * |
| 1163 | * Input: |
| 1164 | * ha - pointer to host adapter structure |
| 1165 | * |
| 1166 | * Note: |
| 1167 | * Does context switching-Release SPIN_LOCK |
| 1168 | * (if any) before calling this routine. |
| 1169 | * |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1170 | */ |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1171 | static void |
| 1172 | qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1173 | { |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1174 | struct qla_hw_data *ha = vha->hw; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1175 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1176 | |
Dan Carpenter | 1d48390 | 2016-08-03 21:42:32 +0300 | [diff] [blame] | 1177 | while ((qla2x00_reset_active(vha) || ha->dpc_active || |
| 1178 | ha->flags.mbox_busy) || |
| 1179 | test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags) || |
| 1180 | test_bit(FX00_TARGET_SCAN, &vha->dpc_flags)) { |
| 1181 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 1182 | break; |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1183 | msleep(1000); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1184 | } |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1185 | } |
| 1186 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 1187 | int |
| 1188 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 1189 | { |
| 1190 | int return_status; |
| 1191 | unsigned long wait_reset; |
| 1192 | struct qla_hw_data *ha = vha->hw; |
| 1193 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 1194 | |
| 1195 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 1196 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1197 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1198 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1199 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 1200 | |
| 1201 | msleep(1000); |
| 1202 | |
| 1203 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 1204 | ha->flags.chip_reset_done) |
| 1205 | break; |
| 1206 | } |
| 1207 | if (ha->flags.chip_reset_done) |
| 1208 | return_status = QLA_SUCCESS; |
| 1209 | else |
| 1210 | return_status = QLA_FUNCTION_FAILED; |
| 1211 | |
| 1212 | return return_status; |
| 1213 | } |
| 1214 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 1215 | static void |
| 1216 | sp_get(struct srb *sp) |
| 1217 | { |
| 1218 | atomic_inc(&sp->ref_count); |
| 1219 | } |
| 1220 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1221 | #define ISP_REG_DISCONNECT 0xffffffffU |
| 1222 | /************************************************************************** |
| 1223 | * qla2x00_isp_reg_stat |
| 1224 | * |
| 1225 | * Description: |
| 1226 | * Read the host status register of ISP before aborting the command. |
| 1227 | * |
| 1228 | * Input: |
| 1229 | * ha = pointer to host adapter structure. |
| 1230 | * |
| 1231 | * |
| 1232 | * Returns: |
| 1233 | * Either true or false. |
| 1234 | * |
| 1235 | * Note: Return true if there is register disconnect. |
| 1236 | **************************************************************************/ |
| 1237 | static inline |
| 1238 | uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) |
| 1239 | { |
| 1240 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
Sawan Chandak | bf6061b1 | 2017-03-31 14:37:03 -0700 | [diff] [blame] | 1241 | struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1242 | |
Sawan Chandak | bf6061b1 | 2017-03-31 14:37:03 -0700 | [diff] [blame] | 1243 | if (IS_P3P_TYPE(ha)) |
| 1244 | return ((RD_REG_DWORD(®82->host_int)) == ISP_REG_DISCONNECT); |
| 1245 | else |
| 1246 | return ((RD_REG_DWORD(®->host_status)) == |
| 1247 | ISP_REG_DISCONNECT); |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1248 | } |
| 1249 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1250 | /************************************************************************** |
| 1251 | * qla2xxx_eh_abort |
| 1252 | * |
| 1253 | * Description: |
| 1254 | * The abort function will abort the specified command. |
| 1255 | * |
| 1256 | * Input: |
| 1257 | * cmd = Linux SCSI command packet to be aborted. |
| 1258 | * |
| 1259 | * Returns: |
| 1260 | * Either SUCCESS or FAILED. |
| 1261 | * |
| 1262 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1263 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1264 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1265 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1266 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 1267 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1268 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1269 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1270 | int ret; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1271 | unsigned int id; |
| 1272 | uint64_t lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1273 | unsigned long flags; |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1274 | int rval, wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1275 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1277 | if (qla2x00_isp_reg_stat(ha)) { |
| 1278 | ql_log(ql_log_info, vha, 0x8042, |
| 1279 | "PCI/Register disconnect, exiting.\n"); |
| 1280 | return FAILED; |
| 1281 | } |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1282 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1283 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1284 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1285 | ret = fc_block_scsi_eh(cmd); |
| 1286 | if (ret != 0) |
| 1287 | return ret; |
| 1288 | ret = SUCCESS; |
| 1289 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1290 | id = cmd->device->id; |
| 1291 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1292 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1293 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1294 | sp = (srb_t *) CMD_SP(cmd); |
| 1295 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1296 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1297 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1298 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1299 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1300 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | c7bc4ca | 2015-08-04 13:37:57 -0400 | [diff] [blame] | 1301 | "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n", |
| 1302 | vha->host_no, id, lun, sp, cmd, sp->handle); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1303 | |
| 1304 | /* Get a reference to the sp and drop the lock.*/ |
| 1305 | sp_get(sp); |
| 1306 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1307 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1308 | rval = ha->isp_ops->abort_command(sp); |
| 1309 | if (rval) { |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1310 | if (rval == QLA_FUNCTION_PARAMETER_ERROR) |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1311 | ret = SUCCESS; |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1312 | else |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1313 | ret = FAILED; |
| 1314 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1315 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1316 | "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1317 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1318 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1319 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1320 | wait = 1; |
| 1321 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1322 | |
| 1323 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 1324 | sp->done(sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1325 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1326 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 1327 | /* Did the command return during mailbox execution? */ |
| 1328 | if (ret == FAILED && !CMD_SP(cmd)) |
| 1329 | ret = SUCCESS; |
| 1330 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1331 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1332 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1333 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1334 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1335 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1336 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1337 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1338 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1340 | ql_log(ql_log_info, vha, 0x801c, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1341 | "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1342 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1343 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1344 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | } |
| 1346 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1347 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1348 | 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] | 1349 | uint64_t l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1350 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1351 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1352 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1353 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1354 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1355 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1356 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1357 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1358 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1359 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1360 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1361 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1362 | for (cnt = 1; status == QLA_SUCCESS && |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1363 | cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1364 | sp = req->outstanding_cmds[cnt]; |
| 1365 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1366 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1367 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1368 | continue; |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 1369 | if (vha->vp_idx != sp->vha->vp_idx) |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1370 | continue; |
| 1371 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1372 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1373 | switch (type) { |
| 1374 | case WAIT_HOST: |
| 1375 | match = 1; |
| 1376 | break; |
| 1377 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1378 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1379 | break; |
| 1380 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1381 | match = (cmd->device->id == t && |
| 1382 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1383 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1384 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1385 | if (!match) |
| 1386 | continue; |
| 1387 | |
| 1388 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1389 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1390 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1391 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1392 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1393 | |
| 1394 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1395 | } |
| 1396 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1397 | static char *reset_errors[] = { |
| 1398 | "HBA not online", |
| 1399 | "HBA not ready", |
| 1400 | "Task management failed", |
| 1401 | "Waiting for command completions", |
| 1402 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1403 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1404 | static int |
| 1405 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1406 | 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] | 1407 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1408 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1409 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1410 | int err; |
| 1411 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1412 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1413 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1414 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1415 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1416 | err = fc_block_scsi_eh(cmd); |
| 1417 | if (err != 0) |
| 1418 | return err; |
| 1419 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1420 | ql_log(ql_log_info, vha, 0x8009, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1421 | "%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] | 1422 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1423 | |
| 1424 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1425 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1426 | ql_log(ql_log_warn, vha, 0x800a, |
| 1427 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1428 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1429 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1430 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1431 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1432 | != QLA_SUCCESS) { |
| 1433 | ql_log(ql_log_warn, vha, 0x800c, |
| 1434 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1435 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1436 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1437 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1438 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1439 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1440 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1441 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1442 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1443 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1444 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1445 | ql_log(ql_log_info, vha, 0x800e, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1446 | "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1447 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1448 | |
| 1449 | return SUCCESS; |
| 1450 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1451 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1452 | ql_log(ql_log_info, vha, 0x800f, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1453 | "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1454 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1455 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1456 | return FAILED; |
| 1457 | } |
| 1458 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1459 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1460 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1461 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1462 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1463 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1465 | if (qla2x00_isp_reg_stat(ha)) { |
| 1466 | ql_log(ql_log_info, vha, 0x803e, |
| 1467 | "PCI/Register disconnect, exiting.\n"); |
| 1468 | return FAILED; |
| 1469 | } |
| 1470 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1471 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1472 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | } |
| 1474 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1476 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1477 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1478 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1479 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1480 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1481 | if (qla2x00_isp_reg_stat(ha)) { |
| 1482 | ql_log(ql_log_info, vha, 0x803f, |
| 1483 | "PCI/Register disconnect, exiting.\n"); |
| 1484 | return FAILED; |
| 1485 | } |
| 1486 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1487 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1488 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | } |
| 1490 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1491 | /************************************************************************** |
| 1492 | * qla2xxx_eh_bus_reset |
| 1493 | * |
| 1494 | * Description: |
| 1495 | * The bus reset function will reset the bus and abort any executing |
| 1496 | * commands. |
| 1497 | * |
| 1498 | * Input: |
| 1499 | * cmd = Linux SCSI command packet of the command that cause the |
| 1500 | * bus reset. |
| 1501 | * |
| 1502 | * Returns: |
| 1503 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1504 | * |
| 1505 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1506 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1507 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1508 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1509 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1510 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1511 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1512 | unsigned int id; |
| 1513 | uint64_t lun; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1514 | struct qla_hw_data *ha = vha->hw; |
| 1515 | |
| 1516 | if (qla2x00_isp_reg_stat(ha)) { |
| 1517 | ql_log(ql_log_info, vha, 0x8040, |
| 1518 | "PCI/Register disconnect, exiting.\n"); |
| 1519 | return FAILED; |
| 1520 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1521 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1522 | id = cmd->device->id; |
| 1523 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1524 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1525 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1526 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1527 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1529 | ret = fc_block_scsi_eh(cmd); |
| 1530 | if (ret != 0) |
| 1531 | return ret; |
| 1532 | ret = FAILED; |
| 1533 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1534 | ql_log(ql_log_info, vha, 0x8012, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1535 | "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] | 1536 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1537 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1538 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1539 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1540 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1541 | } |
| 1542 | |
Saurav Kashyap | ad537689 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1543 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1544 | ret = SUCCESS; |
| 1545 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1546 | if (ret == FAILED) |
| 1547 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1548 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1549 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1550 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1551 | QLA_SUCCESS) { |
| 1552 | ql_log(ql_log_warn, vha, 0x8014, |
| 1553 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1554 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1555 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1556 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1557 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1558 | ql_log(ql_log_warn, vha, 0x802b, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1559 | "BUS RESET %s nexus=%ld:%d:%llu.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1560 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1562 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1563 | } |
| 1564 | |
| 1565 | /************************************************************************** |
| 1566 | * qla2xxx_eh_host_reset |
| 1567 | * |
| 1568 | * Description: |
| 1569 | * The reset function will reset the Adapter. |
| 1570 | * |
| 1571 | * Input: |
| 1572 | * cmd = Linux SCSI command packet of the command that cause the |
| 1573 | * adapter reset. |
| 1574 | * |
| 1575 | * Returns: |
| 1576 | * Either SUCCESS or FAILED. |
| 1577 | * |
| 1578 | * Note: |
| 1579 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1580 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1581 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1582 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1583 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1584 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1585 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1586 | unsigned int id; |
| 1587 | uint64_t lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1588 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1589 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1590 | if (qla2x00_isp_reg_stat(ha)) { |
| 1591 | ql_log(ql_log_info, vha, 0x8041, |
| 1592 | "PCI/Register disconnect, exiting.\n"); |
| 1593 | schedule_work(&ha->board_disable); |
| 1594 | return SUCCESS; |
| 1595 | } |
| 1596 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1597 | id = cmd->device->id; |
| 1598 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1599 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1600 | ql_log(ql_log_info, vha, 0x8018, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1601 | "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] | 1602 | |
Chad Dupuis | 63ee707 | 2014-04-11 16:54:46 -0400 | [diff] [blame] | 1603 | /* |
| 1604 | * No point in issuing another reset if one is active. Also do not |
| 1605 | * attempt a reset if we are updating flash. |
| 1606 | */ |
| 1607 | if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1608 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1609 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1610 | if (vha != base_vha) { |
| 1611 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1612 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1613 | } else { |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1614 | if (IS_P3P_TYPE(vha->hw)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1615 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1616 | /* Ctx reset success */ |
| 1617 | ret = SUCCESS; |
| 1618 | goto eh_host_reset_lock; |
| 1619 | } |
| 1620 | /* fall thru if ctx reset failed */ |
| 1621 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1622 | if (ha->wq) |
| 1623 | flush_workqueue(ha->wq); |
| 1624 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1625 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1626 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1627 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1628 | /* failed. schedule dpc to try */ |
| 1629 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1630 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1631 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1632 | ql_log(ql_log_warn, vha, 0x802a, |
| 1633 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1634 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1635 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1636 | } |
| 1637 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1638 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1639 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1640 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1641 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1642 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1643 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1644 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1645 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1646 | ql_log(ql_log_info, vha, 0x8017, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1647 | "ADAPTER RESET %s nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1648 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1649 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1650 | return ret; |
| 1651 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1652 | |
| 1653 | /* |
| 1654 | * qla2x00_loop_reset |
| 1655 | * Issue loop reset. |
| 1656 | * |
| 1657 | * Input: |
| 1658 | * ha = adapter block pointer. |
| 1659 | * |
| 1660 | * Returns: |
| 1661 | * 0 = success |
| 1662 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1663 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1664 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1665 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1666 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1667 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1668 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1669 | |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1670 | if (IS_QLAFX00(ha)) { |
| 1671 | return qlafx00_loop_reset(vha); |
| 1672 | } |
| 1673 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1674 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1675 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1676 | if (fcport->port_type != FCT_TARGET) |
| 1677 | continue; |
| 1678 | |
| 1679 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1680 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1681 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1682 | "Bus Reset failed: Reset=%d " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1683 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1684 | } |
| 1685 | } |
| 1686 | } |
| 1687 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1688 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1689 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Andrew Vasquez | 0b7e7c5 | 2013-02-08 01:57:42 -0500 | [diff] [blame] | 1690 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1691 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1692 | qla2x00_mark_all_devices_lost(vha, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1693 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1694 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1695 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1696 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1697 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1698 | } |
| 1699 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1700 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1701 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad537689 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1702 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1703 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1704 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1705 | } |
| 1706 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1707 | /* 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] | 1708 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1709 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1710 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1711 | } |
| 1712 | |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1713 | static void |
| 1714 | __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1715 | { |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1716 | int cnt, status; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1717 | unsigned long flags; |
| 1718 | srb_t *sp; |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1719 | scsi_qla_host_t *vha = qp->vha; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1720 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1721 | struct req_que *req; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 1722 | struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; |
| 1723 | struct qla_tgt_cmd *cmd; |
| 1724 | uint8_t trace = 0; |
Arun Easi | c0cb449 | 2014-09-25 06:14:51 -0400 | [diff] [blame] | 1725 | |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 1726 | if (!ha->req_q_map) |
| 1727 | return; |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1728 | spin_lock_irqsave(qp->qp_lock_ptr, flags); |
| 1729 | req = qp->req; |
| 1730 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
| 1731 | sp = req->outstanding_cmds[cnt]; |
| 1732 | if (sp) { |
| 1733 | req->outstanding_cmds[cnt] = NULL; |
| 1734 | if (sp->cmd_type == TYPE_SRB) { |
| 1735 | if (sp->type == SRB_NVME_CMD || |
| 1736 | sp->type == SRB_NVME_LS) { |
| 1737 | sp_get(sp); |
| 1738 | spin_unlock_irqrestore(qp->qp_lock_ptr, |
| 1739 | flags); |
Darren Trapp | 623ee824 | 2018-03-20 23:09:38 -0700 | [diff] [blame] | 1740 | qla_nvme_abort(ha, sp, res); |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1741 | spin_lock_irqsave(qp->qp_lock_ptr, |
| 1742 | flags); |
| 1743 | } else if (GET_CMD_SP(sp) && |
| 1744 | !ha->flags.eeh_busy && |
| 1745 | (!test_bit(ABORT_ISP_ACTIVE, |
| 1746 | &vha->dpc_flags)) && |
| 1747 | (sp->type == SRB_SCSI_CMD)) { |
| 1748 | /* |
| 1749 | * Don't abort commands in |
| 1750 | * adapter during EEH |
| 1751 | * recovery as it's not |
| 1752 | * accessible/responding. |
| 1753 | * |
| 1754 | * Get a reference to the sp |
| 1755 | * and drop the lock. The |
| 1756 | * reference ensures this |
| 1757 | * sp->done() call and not the |
| 1758 | * call in qla2xxx_eh_abort() |
| 1759 | * ends the SCSI command (with |
| 1760 | * result 'res'). |
| 1761 | */ |
| 1762 | sp_get(sp); |
| 1763 | spin_unlock_irqrestore(qp->qp_lock_ptr, |
| 1764 | flags); |
| 1765 | status = qla2xxx_eh_abort( |
| 1766 | GET_CMD_SP(sp)); |
| 1767 | spin_lock_irqsave(qp->qp_lock_ptr, |
| 1768 | flags); |
| 1769 | /* |
| 1770 | * Get rid of extra reference |
| 1771 | * if immediate exit from |
| 1772 | * ql2xxx_eh_abort |
| 1773 | */ |
| 1774 | if (status == FAILED && |
| 1775 | (qla2x00_isp_reg_stat(ha))) |
| 1776 | atomic_dec( |
| 1777 | &sp->ref_count); |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 1778 | } |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1779 | sp->done(sp, res); |
| 1780 | } else { |
| 1781 | if (!vha->hw->tgt.tgt_ops || !tgt || |
| 1782 | qla_ini_mode_enabled(vha)) { |
| 1783 | if (!trace) |
| 1784 | ql_dbg(ql_dbg_tgt_mgt, |
| 1785 | vha, 0xf003, |
| 1786 | "HOST-ABORT-HNDLR: dpc_flags=%lx. Target mode disabled\n", |
| 1787 | vha->dpc_flags); |
| 1788 | continue; |
| 1789 | } |
| 1790 | cmd = (struct qla_tgt_cmd *)sp; |
| 1791 | qlt_abort_cmd_on_host_reset(cmd->vha, cmd); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1792 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1793 | } |
| 1794 | } |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1795 | spin_unlock_irqrestore(qp->qp_lock_ptr, flags); |
| 1796 | } |
| 1797 | |
| 1798 | void |
| 1799 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
| 1800 | { |
| 1801 | int que; |
| 1802 | struct qla_hw_data *ha = vha->hw; |
| 1803 | |
| 1804 | __qla2x00_abort_all_cmds(ha->base_qpair, res); |
| 1805 | |
| 1806 | for (que = 0; que < ha->max_qpairs; que++) { |
| 1807 | if (!ha->queue_pair_map[que]) |
| 1808 | continue; |
| 1809 | |
| 1810 | __qla2x00_abort_all_cmds(ha->queue_pair_map[que], res); |
| 1811 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1812 | } |
| 1813 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1814 | static int |
| 1815 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1816 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1817 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1818 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1819 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1820 | return -ENXIO; |
| 1821 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1822 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1823 | |
| 1824 | return 0; |
| 1825 | } |
| 1826 | |
| 1827 | static int |
| 1828 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1829 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1830 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1831 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1832 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1833 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1834 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1835 | |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 1836 | scsi_change_queue_depth(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1837 | return 0; |
| 1838 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1839 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1840 | static void |
| 1841 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1842 | { |
| 1843 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1844 | } |
| 1845 | |
| 1846 | /** |
| 1847 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1848 | * @ha: HA context |
| 1849 | * |
| 1850 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1851 | * supported addressing method. |
| 1852 | */ |
| 1853 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1854 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1855 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1856 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1857 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1858 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1859 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1860 | /* Any upper-dword bits set? */ |
| 1861 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1862 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1863 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1864 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1865 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1866 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1867 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1868 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1869 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1870 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1871 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1872 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1873 | } |
| 1874 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1875 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1876 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1877 | { |
| 1878 | unsigned long flags = 0; |
| 1879 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1880 | |
| 1881 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1882 | ha->interrupts_on = 1; |
| 1883 | /* enable risc and host interrupts */ |
| 1884 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1885 | RD_REG_WORD(®->ictrl); |
| 1886 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1887 | |
| 1888 | } |
| 1889 | |
| 1890 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1891 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1892 | { |
| 1893 | unsigned long flags = 0; |
| 1894 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1895 | |
| 1896 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1897 | ha->interrupts_on = 0; |
| 1898 | /* disable risc and host interrupts */ |
| 1899 | WRT_REG_WORD(®->ictrl, 0); |
| 1900 | RD_REG_WORD(®->ictrl); |
| 1901 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1902 | } |
| 1903 | |
| 1904 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1905 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1906 | { |
| 1907 | unsigned long flags = 0; |
| 1908 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1909 | |
| 1910 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1911 | ha->interrupts_on = 1; |
| 1912 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1913 | RD_REG_DWORD(®->ictrl); |
| 1914 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1915 | } |
| 1916 | |
| 1917 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1918 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1919 | { |
| 1920 | unsigned long flags = 0; |
| 1921 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1922 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1923 | if (IS_NOPOLLING_TYPE(ha)) |
| 1924 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1925 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1926 | ha->interrupts_on = 0; |
| 1927 | WRT_REG_DWORD(®->ictrl, 0); |
| 1928 | RD_REG_DWORD(®->ictrl); |
| 1929 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1930 | } |
| 1931 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1932 | static int |
| 1933 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1934 | { |
| 1935 | resource_size_t pio; |
| 1936 | uint16_t msix; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1937 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1938 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1939 | QLA2XXX_DRIVER_NAME)) { |
| 1940 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1941 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1942 | pci_name(ha->pdev)); |
| 1943 | goto iospace_error_exit; |
| 1944 | } |
| 1945 | if (!(ha->bars & 1)) |
| 1946 | goto skip_pio; |
| 1947 | |
| 1948 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1949 | pio = pci_resource_start(ha->pdev, 0); |
| 1950 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1951 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1952 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1953 | "Invalid pci I/O region size (%s).\n", |
| 1954 | pci_name(ha->pdev)); |
| 1955 | pio = 0; |
| 1956 | } |
| 1957 | } else { |
| 1958 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1959 | "Region #0 no a PIO resource (%s).\n", |
| 1960 | pci_name(ha->pdev)); |
| 1961 | pio = 0; |
| 1962 | } |
| 1963 | ha->pio_address = pio; |
| 1964 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1965 | "PIO address=%llu.\n", |
| 1966 | (unsigned long long)ha->pio_address); |
| 1967 | |
| 1968 | skip_pio: |
| 1969 | /* Use MMIO operations for all accesses. */ |
| 1970 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1971 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1972 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1973 | pci_name(ha->pdev)); |
| 1974 | goto iospace_error_exit; |
| 1975 | } |
| 1976 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1977 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1978 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1979 | pci_name(ha->pdev)); |
| 1980 | goto iospace_error_exit; |
| 1981 | } |
| 1982 | |
| 1983 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1984 | if (!ha->iobase) { |
| 1985 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1986 | "Cannot remap MMIO (%s), aborting.\n", |
| 1987 | pci_name(ha->pdev)); |
| 1988 | goto iospace_error_exit; |
| 1989 | } |
| 1990 | |
| 1991 | /* Determine queue resources */ |
| 1992 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 1993 | ha->msix_count = QLA_BASE_VECTORS; |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 1994 | if (!ql2xmqsupport || !ql2xnvmeenable || |
| 1995 | (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1996 | goto mqiobase_exit; |
| 1997 | |
| 1998 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1999 | pci_resource_len(ha->pdev, 3)); |
| 2000 | if (ha->mqiobase) { |
| 2001 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 2002 | "MQIO Base=%p.\n", ha->mqiobase); |
| 2003 | /* Read MSIX vector size of the board */ |
| 2004 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2005 | ha->msix_count = msix + 1; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2006 | /* Max queues are bounded by available msix vectors */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2007 | /* MB interrupt uses 1 vector */ |
| 2008 | ha->max_req_queues = ha->msix_count - 1; |
| 2009 | ha->max_rsp_queues = ha->max_req_queues; |
| 2010 | /* Queue pairs is the max value minus the base queue pair */ |
| 2011 | ha->max_qpairs = ha->max_rsp_queues - 1; |
| 2012 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0188, |
| 2013 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
| 2014 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2015 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2016 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2017 | } else |
| 2018 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 2019 | "BAR 3 not enabled.\n"); |
| 2020 | |
| 2021 | mqiobase_exit: |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2022 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2023 | "MSIX Count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2024 | return (0); |
| 2025 | |
| 2026 | iospace_error_exit: |
| 2027 | return (-ENOMEM); |
| 2028 | } |
| 2029 | |
| 2030 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2031 | static int |
| 2032 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 2033 | { |
| 2034 | uint16_t msix; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2035 | |
| 2036 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 2037 | QLA2XXX_DRIVER_NAME)) { |
| 2038 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 2039 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 2040 | pci_name(ha->pdev)); |
| 2041 | |
| 2042 | goto iospace_error_exit; |
| 2043 | } |
| 2044 | |
| 2045 | /* Use MMIO operations for all accesses. */ |
| 2046 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 2047 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 2048 | "Invalid pci I/O region size (%s).\n", |
| 2049 | pci_name(ha->pdev)); |
| 2050 | goto iospace_error_exit; |
| 2051 | } |
| 2052 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 2053 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 2054 | "Invalid PCI mem region size (%s), aborting\n", |
| 2055 | pci_name(ha->pdev)); |
| 2056 | goto iospace_error_exit; |
| 2057 | } |
| 2058 | |
| 2059 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 2060 | if (!ha->iobase) { |
| 2061 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 2062 | "Cannot remap MMIO (%s), aborting.\n", |
| 2063 | pci_name(ha->pdev)); |
| 2064 | goto iospace_error_exit; |
| 2065 | } |
| 2066 | |
| 2067 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 2068 | /* 83XX 26XX always use MQ type access for queues |
| 2069 | * - mbar 2, a.k.a region 4 */ |
| 2070 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2071 | ha->msix_count = QLA_BASE_VECTORS; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2072 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 2073 | pci_resource_len(ha->pdev, 4)); |
| 2074 | |
| 2075 | if (!ha->mqiobase) { |
| 2076 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 2077 | "BAR2/region4 not enabled\n"); |
| 2078 | goto mqiobase_exit; |
| 2079 | } |
| 2080 | |
| 2081 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 2082 | pci_resource_len(ha->pdev, 2)); |
| 2083 | if (ha->msixbase) { |
| 2084 | /* Read MSIX vector size of the board */ |
| 2085 | pci_read_config_word(ha->pdev, |
| 2086 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 2087 | ha->msix_count = (msix & PCI_MSIX_FLAGS_QSIZE) + 1; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 2088 | /* |
| 2089 | * By default, driver uses at least two msix vectors |
| 2090 | * (default & rspq) |
| 2091 | */ |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 2092 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2093 | /* MB interrupt uses 1 vector */ |
| 2094 | ha->max_req_queues = ha->msix_count - 1; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 2095 | |
| 2096 | /* ATIOQ needs 1 vector. That's 1 less QPair */ |
| 2097 | if (QLA_TGT_MODE_ENABLED()) |
| 2098 | ha->max_req_queues--; |
| 2099 | |
Michael Hernandez | d0d2c68 | 2017-02-15 15:37:20 -0800 | [diff] [blame] | 2100 | ha->max_rsp_queues = ha->max_req_queues; |
| 2101 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2102 | /* Queue pairs is the max value minus |
| 2103 | * the base queue pair */ |
| 2104 | ha->max_qpairs = ha->max_req_queues - 1; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2105 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x00e3, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2106 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2107 | } |
| 2108 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2109 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2110 | } else |
| 2111 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 2112 | "BAR 1 not enabled.\n"); |
| 2113 | |
| 2114 | mqiobase_exit: |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2115 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2116 | "MSIX Count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2117 | return 0; |
| 2118 | |
| 2119 | iospace_error_exit: |
| 2120 | return -ENOMEM; |
| 2121 | } |
| 2122 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2123 | static struct isp_operations qla2100_isp_ops = { |
| 2124 | .pci_config = qla2100_pci_config, |
| 2125 | .reset_chip = qla2x00_reset_chip, |
| 2126 | .chip_diag = qla2x00_chip_diag, |
| 2127 | .config_rings = qla2x00_config_rings, |
| 2128 | .reset_adapter = qla2x00_reset_adapter, |
| 2129 | .nvram_config = qla2x00_nvram_config, |
| 2130 | .update_fw_options = qla2x00_update_fw_options, |
| 2131 | .load_risc = qla2x00_load_risc, |
| 2132 | .pci_info_str = qla2x00_pci_info_str, |
| 2133 | .fw_version_str = qla2x00_fw_version_str, |
| 2134 | .intr_handler = qla2100_intr_handler, |
| 2135 | .enable_intrs = qla2x00_enable_intrs, |
| 2136 | .disable_intrs = qla2x00_disable_intrs, |
| 2137 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2138 | .target_reset = qla2x00_abort_target, |
| 2139 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2140 | .fabric_login = qla2x00_login_fabric, |
| 2141 | .fabric_logout = qla2x00_fabric_logout, |
| 2142 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 2143 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 2144 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 2145 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 2146 | .read_nvram = qla2x00_read_nvram_data, |
| 2147 | .write_nvram = qla2x00_write_nvram_data, |
| 2148 | .fw_dump = qla2100_fw_dump, |
| 2149 | .beacon_on = NULL, |
| 2150 | .beacon_off = NULL, |
| 2151 | .beacon_blink = NULL, |
| 2152 | .read_optrom = qla2x00_read_optrom_data, |
| 2153 | .write_optrom = qla2x00_write_optrom_data, |
| 2154 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2155 | .start_scsi = qla2x00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2156 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2157 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2158 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2159 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2160 | }; |
| 2161 | |
| 2162 | static struct isp_operations qla2300_isp_ops = { |
| 2163 | .pci_config = qla2300_pci_config, |
| 2164 | .reset_chip = qla2x00_reset_chip, |
| 2165 | .chip_diag = qla2x00_chip_diag, |
| 2166 | .config_rings = qla2x00_config_rings, |
| 2167 | .reset_adapter = qla2x00_reset_adapter, |
| 2168 | .nvram_config = qla2x00_nvram_config, |
| 2169 | .update_fw_options = qla2x00_update_fw_options, |
| 2170 | .load_risc = qla2x00_load_risc, |
| 2171 | .pci_info_str = qla2x00_pci_info_str, |
| 2172 | .fw_version_str = qla2x00_fw_version_str, |
| 2173 | .intr_handler = qla2300_intr_handler, |
| 2174 | .enable_intrs = qla2x00_enable_intrs, |
| 2175 | .disable_intrs = qla2x00_disable_intrs, |
| 2176 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2177 | .target_reset = qla2x00_abort_target, |
| 2178 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2179 | .fabric_login = qla2x00_login_fabric, |
| 2180 | .fabric_logout = qla2x00_fabric_logout, |
| 2181 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 2182 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 2183 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 2184 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 2185 | .read_nvram = qla2x00_read_nvram_data, |
| 2186 | .write_nvram = qla2x00_write_nvram_data, |
| 2187 | .fw_dump = qla2300_fw_dump, |
| 2188 | .beacon_on = qla2x00_beacon_on, |
| 2189 | .beacon_off = qla2x00_beacon_off, |
| 2190 | .beacon_blink = qla2x00_beacon_blink, |
| 2191 | .read_optrom = qla2x00_read_optrom_data, |
| 2192 | .write_optrom = qla2x00_write_optrom_data, |
| 2193 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2194 | .start_scsi = qla2x00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2195 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2196 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2197 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2198 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2199 | }; |
| 2200 | |
| 2201 | static struct isp_operations qla24xx_isp_ops = { |
| 2202 | .pci_config = qla24xx_pci_config, |
| 2203 | .reset_chip = qla24xx_reset_chip, |
| 2204 | .chip_diag = qla24xx_chip_diag, |
| 2205 | .config_rings = qla24xx_config_rings, |
| 2206 | .reset_adapter = qla24xx_reset_adapter, |
| 2207 | .nvram_config = qla24xx_nvram_config, |
| 2208 | .update_fw_options = qla24xx_update_fw_options, |
| 2209 | .load_risc = qla24xx_load_risc, |
| 2210 | .pci_info_str = qla24xx_pci_info_str, |
| 2211 | .fw_version_str = qla24xx_fw_version_str, |
| 2212 | .intr_handler = qla24xx_intr_handler, |
| 2213 | .enable_intrs = qla24xx_enable_intrs, |
| 2214 | .disable_intrs = qla24xx_disable_intrs, |
| 2215 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2216 | .target_reset = qla24xx_abort_target, |
| 2217 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2218 | .fabric_login = qla24xx_login_fabric, |
| 2219 | .fabric_logout = qla24xx_fabric_logout, |
| 2220 | .calc_req_entries = NULL, |
| 2221 | .build_iocbs = NULL, |
| 2222 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2223 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2224 | .read_nvram = qla24xx_read_nvram_data, |
| 2225 | .write_nvram = qla24xx_write_nvram_data, |
| 2226 | .fw_dump = qla24xx_fw_dump, |
| 2227 | .beacon_on = qla24xx_beacon_on, |
| 2228 | .beacon_off = qla24xx_beacon_off, |
| 2229 | .beacon_blink = qla24xx_beacon_blink, |
| 2230 | .read_optrom = qla24xx_read_optrom_data, |
| 2231 | .write_optrom = qla24xx_write_optrom_data, |
| 2232 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2233 | .start_scsi = qla24xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2234 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2235 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2236 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2237 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2238 | }; |
| 2239 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2240 | static struct isp_operations qla25xx_isp_ops = { |
| 2241 | .pci_config = qla25xx_pci_config, |
| 2242 | .reset_chip = qla24xx_reset_chip, |
| 2243 | .chip_diag = qla24xx_chip_diag, |
| 2244 | .config_rings = qla24xx_config_rings, |
| 2245 | .reset_adapter = qla24xx_reset_adapter, |
| 2246 | .nvram_config = qla24xx_nvram_config, |
| 2247 | .update_fw_options = qla24xx_update_fw_options, |
| 2248 | .load_risc = qla24xx_load_risc, |
| 2249 | .pci_info_str = qla24xx_pci_info_str, |
| 2250 | .fw_version_str = qla24xx_fw_version_str, |
| 2251 | .intr_handler = qla24xx_intr_handler, |
| 2252 | .enable_intrs = qla24xx_enable_intrs, |
| 2253 | .disable_intrs = qla24xx_disable_intrs, |
| 2254 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2255 | .target_reset = qla24xx_abort_target, |
| 2256 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2257 | .fabric_login = qla24xx_login_fabric, |
| 2258 | .fabric_logout = qla24xx_fabric_logout, |
| 2259 | .calc_req_entries = NULL, |
| 2260 | .build_iocbs = NULL, |
| 2261 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2262 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2263 | .read_nvram = qla25xx_read_nvram_data, |
| 2264 | .write_nvram = qla25xx_write_nvram_data, |
| 2265 | .fw_dump = qla25xx_fw_dump, |
| 2266 | .beacon_on = qla24xx_beacon_on, |
| 2267 | .beacon_off = qla24xx_beacon_off, |
| 2268 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 2269 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2270 | .write_optrom = qla24xx_write_optrom_data, |
| 2271 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2272 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2273 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2274 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2275 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2276 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2277 | }; |
| 2278 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2279 | static struct isp_operations qla81xx_isp_ops = { |
| 2280 | .pci_config = qla25xx_pci_config, |
| 2281 | .reset_chip = qla24xx_reset_chip, |
| 2282 | .chip_diag = qla24xx_chip_diag, |
| 2283 | .config_rings = qla24xx_config_rings, |
| 2284 | .reset_adapter = qla24xx_reset_adapter, |
| 2285 | .nvram_config = qla81xx_nvram_config, |
| 2286 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 2287 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2288 | .pci_info_str = qla24xx_pci_info_str, |
| 2289 | .fw_version_str = qla24xx_fw_version_str, |
| 2290 | .intr_handler = qla24xx_intr_handler, |
| 2291 | .enable_intrs = qla24xx_enable_intrs, |
| 2292 | .disable_intrs = qla24xx_disable_intrs, |
| 2293 | .abort_command = qla24xx_abort_command, |
| 2294 | .target_reset = qla24xx_abort_target, |
| 2295 | .lun_reset = qla24xx_lun_reset, |
| 2296 | .fabric_login = qla24xx_login_fabric, |
| 2297 | .fabric_logout = qla24xx_fabric_logout, |
| 2298 | .calc_req_entries = NULL, |
| 2299 | .build_iocbs = NULL, |
| 2300 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2301 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 2302 | .read_nvram = NULL, |
| 2303 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2304 | .fw_dump = qla81xx_fw_dump, |
| 2305 | .beacon_on = qla24xx_beacon_on, |
| 2306 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2307 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2308 | .read_optrom = qla25xx_read_optrom_data, |
| 2309 | .write_optrom = qla24xx_write_optrom_data, |
| 2310 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 2311 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2312 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2313 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2314 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2315 | .initialize_adapter = qla2x00_initialize_adapter, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2316 | }; |
| 2317 | |
| 2318 | static struct isp_operations qla82xx_isp_ops = { |
| 2319 | .pci_config = qla82xx_pci_config, |
| 2320 | .reset_chip = qla82xx_reset_chip, |
| 2321 | .chip_diag = qla24xx_chip_diag, |
| 2322 | .config_rings = qla82xx_config_rings, |
| 2323 | .reset_adapter = qla24xx_reset_adapter, |
| 2324 | .nvram_config = qla81xx_nvram_config, |
| 2325 | .update_fw_options = qla24xx_update_fw_options, |
| 2326 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 2327 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2328 | .fw_version_str = qla24xx_fw_version_str, |
| 2329 | .intr_handler = qla82xx_intr_handler, |
| 2330 | .enable_intrs = qla82xx_enable_intrs, |
| 2331 | .disable_intrs = qla82xx_disable_intrs, |
| 2332 | .abort_command = qla24xx_abort_command, |
| 2333 | .target_reset = qla24xx_abort_target, |
| 2334 | .lun_reset = qla24xx_lun_reset, |
| 2335 | .fabric_login = qla24xx_login_fabric, |
| 2336 | .fabric_logout = qla24xx_fabric_logout, |
| 2337 | .calc_req_entries = NULL, |
| 2338 | .build_iocbs = NULL, |
| 2339 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2340 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2341 | .read_nvram = qla24xx_read_nvram_data, |
| 2342 | .write_nvram = qla24xx_write_nvram_data, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2343 | .fw_dump = qla82xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 2344 | .beacon_on = qla82xx_beacon_on, |
| 2345 | .beacon_off = qla82xx_beacon_off, |
| 2346 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2347 | .read_optrom = qla82xx_read_optrom_data, |
| 2348 | .write_optrom = qla82xx_write_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2349 | .get_flash_version = qla82xx_get_flash_version, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2350 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2351 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2352 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2353 | .iospace_config = qla82xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2354 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2355 | }; |
| 2356 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2357 | static struct isp_operations qla8044_isp_ops = { |
| 2358 | .pci_config = qla82xx_pci_config, |
| 2359 | .reset_chip = qla82xx_reset_chip, |
| 2360 | .chip_diag = qla24xx_chip_diag, |
| 2361 | .config_rings = qla82xx_config_rings, |
| 2362 | .reset_adapter = qla24xx_reset_adapter, |
| 2363 | .nvram_config = qla81xx_nvram_config, |
| 2364 | .update_fw_options = qla24xx_update_fw_options, |
| 2365 | .load_risc = qla82xx_load_risc, |
| 2366 | .pci_info_str = qla24xx_pci_info_str, |
| 2367 | .fw_version_str = qla24xx_fw_version_str, |
| 2368 | .intr_handler = qla8044_intr_handler, |
| 2369 | .enable_intrs = qla82xx_enable_intrs, |
| 2370 | .disable_intrs = qla82xx_disable_intrs, |
| 2371 | .abort_command = qla24xx_abort_command, |
| 2372 | .target_reset = qla24xx_abort_target, |
| 2373 | .lun_reset = qla24xx_lun_reset, |
| 2374 | .fabric_login = qla24xx_login_fabric, |
| 2375 | .fabric_logout = qla24xx_fabric_logout, |
| 2376 | .calc_req_entries = NULL, |
| 2377 | .build_iocbs = NULL, |
| 2378 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2379 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2380 | .read_nvram = NULL, |
| 2381 | .write_nvram = NULL, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2382 | .fw_dump = qla8044_fw_dump, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2383 | .beacon_on = qla82xx_beacon_on, |
| 2384 | .beacon_off = qla82xx_beacon_off, |
| 2385 | .beacon_blink = NULL, |
Saurav Kashyap | 888e639 | 2014-02-26 04:15:13 -0500 | [diff] [blame] | 2386 | .read_optrom = qla8044_read_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2387 | .write_optrom = qla8044_write_optrom_data, |
| 2388 | .get_flash_version = qla82xx_get_flash_version, |
| 2389 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2390 | .start_scsi_mq = NULL, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2391 | .abort_isp = qla8044_abort_isp, |
| 2392 | .iospace_config = qla82xx_iospace_config, |
| 2393 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2394 | }; |
| 2395 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2396 | static struct isp_operations qla83xx_isp_ops = { |
| 2397 | .pci_config = qla25xx_pci_config, |
| 2398 | .reset_chip = qla24xx_reset_chip, |
| 2399 | .chip_diag = qla24xx_chip_diag, |
| 2400 | .config_rings = qla24xx_config_rings, |
| 2401 | .reset_adapter = qla24xx_reset_adapter, |
| 2402 | .nvram_config = qla81xx_nvram_config, |
| 2403 | .update_fw_options = qla81xx_update_fw_options, |
| 2404 | .load_risc = qla81xx_load_risc, |
| 2405 | .pci_info_str = qla24xx_pci_info_str, |
| 2406 | .fw_version_str = qla24xx_fw_version_str, |
| 2407 | .intr_handler = qla24xx_intr_handler, |
| 2408 | .enable_intrs = qla24xx_enable_intrs, |
| 2409 | .disable_intrs = qla24xx_disable_intrs, |
| 2410 | .abort_command = qla24xx_abort_command, |
| 2411 | .target_reset = qla24xx_abort_target, |
| 2412 | .lun_reset = qla24xx_lun_reset, |
| 2413 | .fabric_login = qla24xx_login_fabric, |
| 2414 | .fabric_logout = qla24xx_fabric_logout, |
| 2415 | .calc_req_entries = NULL, |
| 2416 | .build_iocbs = NULL, |
| 2417 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2418 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2419 | .read_nvram = NULL, |
| 2420 | .write_nvram = NULL, |
| 2421 | .fw_dump = qla83xx_fw_dump, |
| 2422 | .beacon_on = qla24xx_beacon_on, |
| 2423 | .beacon_off = qla24xx_beacon_off, |
| 2424 | .beacon_blink = qla83xx_beacon_blink, |
| 2425 | .read_optrom = qla25xx_read_optrom_data, |
| 2426 | .write_optrom = qla24xx_write_optrom_data, |
| 2427 | .get_flash_version = qla24xx_get_flash_version, |
| 2428 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2429 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2430 | .abort_isp = qla2x00_abort_isp, |
| 2431 | .iospace_config = qla83xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2432 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2433 | }; |
| 2434 | |
| 2435 | static struct isp_operations qlafx00_isp_ops = { |
| 2436 | .pci_config = qlafx00_pci_config, |
| 2437 | .reset_chip = qlafx00_soft_reset, |
| 2438 | .chip_diag = qlafx00_chip_diag, |
| 2439 | .config_rings = qlafx00_config_rings, |
| 2440 | .reset_adapter = qlafx00_soft_reset, |
| 2441 | .nvram_config = NULL, |
| 2442 | .update_fw_options = NULL, |
| 2443 | .load_risc = NULL, |
| 2444 | .pci_info_str = qlafx00_pci_info_str, |
| 2445 | .fw_version_str = qlafx00_fw_version_str, |
| 2446 | .intr_handler = qlafx00_intr_handler, |
| 2447 | .enable_intrs = qlafx00_enable_intrs, |
| 2448 | .disable_intrs = qlafx00_disable_intrs, |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2449 | .abort_command = qla24xx_async_abort_command, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2450 | .target_reset = qlafx00_abort_target, |
| 2451 | .lun_reset = qlafx00_lun_reset, |
| 2452 | .fabric_login = NULL, |
| 2453 | .fabric_logout = NULL, |
| 2454 | .calc_req_entries = NULL, |
| 2455 | .build_iocbs = NULL, |
| 2456 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2457 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2458 | .read_nvram = qla24xx_read_nvram_data, |
| 2459 | .write_nvram = qla24xx_write_nvram_data, |
| 2460 | .fw_dump = NULL, |
| 2461 | .beacon_on = qla24xx_beacon_on, |
| 2462 | .beacon_off = qla24xx_beacon_off, |
| 2463 | .beacon_blink = NULL, |
| 2464 | .read_optrom = qla24xx_read_optrom_data, |
| 2465 | .write_optrom = qla24xx_write_optrom_data, |
| 2466 | .get_flash_version = qla24xx_get_flash_version, |
| 2467 | .start_scsi = qlafx00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2468 | .start_scsi_mq = NULL, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2469 | .abort_isp = qlafx00_abort_isp, |
| 2470 | .iospace_config = qlafx00_iospace_config, |
| 2471 | .initialize_adapter = qlafx00_initialize_adapter, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2472 | }; |
| 2473 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2474 | static struct isp_operations qla27xx_isp_ops = { |
| 2475 | .pci_config = qla25xx_pci_config, |
| 2476 | .reset_chip = qla24xx_reset_chip, |
| 2477 | .chip_diag = qla24xx_chip_diag, |
| 2478 | .config_rings = qla24xx_config_rings, |
| 2479 | .reset_adapter = qla24xx_reset_adapter, |
| 2480 | .nvram_config = qla81xx_nvram_config, |
| 2481 | .update_fw_options = qla81xx_update_fw_options, |
| 2482 | .load_risc = qla81xx_load_risc, |
| 2483 | .pci_info_str = qla24xx_pci_info_str, |
| 2484 | .fw_version_str = qla24xx_fw_version_str, |
| 2485 | .intr_handler = qla24xx_intr_handler, |
| 2486 | .enable_intrs = qla24xx_enable_intrs, |
| 2487 | .disable_intrs = qla24xx_disable_intrs, |
| 2488 | .abort_command = qla24xx_abort_command, |
| 2489 | .target_reset = qla24xx_abort_target, |
| 2490 | .lun_reset = qla24xx_lun_reset, |
| 2491 | .fabric_login = qla24xx_login_fabric, |
| 2492 | .fabric_logout = qla24xx_fabric_logout, |
| 2493 | .calc_req_entries = NULL, |
| 2494 | .build_iocbs = NULL, |
| 2495 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2496 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2497 | .read_nvram = NULL, |
| 2498 | .write_nvram = NULL, |
| 2499 | .fw_dump = qla27xx_fwdump, |
| 2500 | .beacon_on = qla24xx_beacon_on, |
| 2501 | .beacon_off = qla24xx_beacon_off, |
| 2502 | .beacon_blink = qla83xx_beacon_blink, |
| 2503 | .read_optrom = qla25xx_read_optrom_data, |
| 2504 | .write_optrom = qla24xx_write_optrom_data, |
| 2505 | .get_flash_version = qla24xx_get_flash_version, |
| 2506 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2507 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2508 | .abort_isp = qla2x00_abort_isp, |
| 2509 | .iospace_config = qla83xx_iospace_config, |
| 2510 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2511 | }; |
| 2512 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2513 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2514 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2515 | { |
| 2516 | ha->device_type = DT_EXTENDED_IDS; |
| 2517 | switch (ha->pdev->device) { |
| 2518 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2519 | ha->isp_type |= DT_ISP2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2520 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2521 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2522 | break; |
| 2523 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2524 | ha->isp_type |= DT_ISP2200; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2525 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2526 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2527 | break; |
| 2528 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2529 | ha->isp_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2530 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2531 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2532 | break; |
| 2533 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2534 | ha->isp_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2535 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2536 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2537 | break; |
| 2538 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2539 | ha->isp_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2540 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2541 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2542 | ha->pdev->subsystem_device == 0x0170) |
| 2543 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2544 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2545 | break; |
| 2546 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2547 | ha->isp_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2548 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2549 | break; |
| 2550 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2551 | ha->isp_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2552 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2553 | break; |
| 2554 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2555 | ha->isp_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2556 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2557 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2558 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2559 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2560 | break; |
| 2561 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2562 | ha->isp_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2563 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2564 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2565 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2566 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2567 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2568 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2569 | ha->isp_type |= DT_ISP8432; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2570 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2571 | ha->device_type |= DT_FWI2; |
| 2572 | ha->device_type |= DT_IIDMA; |
| 2573 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2574 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2575 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2576 | ha->isp_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2577 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2578 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2579 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2580 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2581 | ha->isp_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2582 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2583 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2584 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2585 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2586 | ha->isp_type |= DT_ISP2532; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2587 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2588 | ha->device_type |= DT_FWI2; |
| 2589 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2590 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2591 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2592 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2593 | ha->isp_type |= DT_ISP8001; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2594 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2595 | ha->device_type |= DT_FWI2; |
| 2596 | ha->device_type |= DT_IIDMA; |
| 2597 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2598 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2599 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2600 | ha->isp_type |= DT_ISP8021; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2601 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2602 | ha->device_type |= DT_FWI2; |
| 2603 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2604 | /* Initialize 82XX ISP flags */ |
| 2605 | qla82xx_init_flags(ha); |
| 2606 | break; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2607 | case PCI_DEVICE_ID_QLOGIC_ISP8044: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2608 | ha->isp_type |= DT_ISP8044; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2609 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2610 | ha->device_type |= DT_FWI2; |
| 2611 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2612 | /* Initialize 82XX ISP flags */ |
| 2613 | qla82xx_init_flags(ha); |
| 2614 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2615 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2616 | ha->isp_type |= DT_ISP2031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2617 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2618 | ha->device_type |= DT_FWI2; |
| 2619 | ha->device_type |= DT_IIDMA; |
| 2620 | ha->device_type |= DT_T10_PI; |
| 2621 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2622 | break; |
| 2623 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2624 | ha->isp_type |= DT_ISP8031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2625 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2626 | ha->device_type |= DT_FWI2; |
| 2627 | ha->device_type |= DT_IIDMA; |
| 2628 | ha->device_type |= DT_T10_PI; |
| 2629 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2630 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2631 | case PCI_DEVICE_ID_QLOGIC_ISPF001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2632 | ha->isp_type |= DT_ISPFX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2633 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2634 | case PCI_DEVICE_ID_QLOGIC_ISP2071: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2635 | ha->isp_type |= DT_ISP2071; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2636 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2637 | ha->device_type |= DT_FWI2; |
| 2638 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2639 | ha->device_type |= DT_T10_PI; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2640 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2641 | break; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2642 | case PCI_DEVICE_ID_QLOGIC_ISP2271: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2643 | ha->isp_type |= DT_ISP2271; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2644 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2645 | ha->device_type |= DT_FWI2; |
| 2646 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2647 | ha->device_type |= DT_T10_PI; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2648 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2649 | break; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2650 | case PCI_DEVICE_ID_QLOGIC_ISP2261: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2651 | ha->isp_type |= DT_ISP2261; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2652 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2653 | ha->device_type |= DT_FWI2; |
| 2654 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2655 | ha->device_type |= DT_T10_PI; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2656 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2657 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2658 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2659 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2660 | if (IS_QLA82XX(ha)) |
Saurav Kashyap | 43a9c38 | 2014-02-26 04:15:16 -0500 | [diff] [blame] | 2661 | ha->port_no = ha->portnum & 1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2662 | else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2663 | /* Get adapter physical port no from interrupt pin register. */ |
| 2664 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2665 | if (IS_QLA27XX(ha)) |
| 2666 | ha->port_no--; |
| 2667 | else |
| 2668 | ha->port_no = !(ha->port_no & 1); |
| 2669 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2670 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2671 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2672 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2673 | ha->device_type, ha->port_no, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2674 | } |
| 2675 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2676 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2677 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2678 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2679 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2680 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2681 | if (vha->hw->flags.running_gold_fw) |
| 2682 | return; |
| 2683 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2684 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2685 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2686 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2687 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2688 | } |
| 2689 | |
| 2690 | static int |
| 2691 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2692 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2693 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2694 | |
Bill Kuzeja | a5dd506e | 2016-10-21 16:45:27 -0400 | [diff] [blame] | 2695 | if (test_bit(UNLOADING, &vha->dpc_flags)) |
| 2696 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2697 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2698 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2699 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2700 | return 1; |
| 2701 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2702 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2703 | } |
| 2704 | |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2705 | static void qla2x00_iocb_work_fn(struct work_struct *work) |
| 2706 | { |
| 2707 | struct scsi_qla_host *vha = container_of(work, |
| 2708 | struct scsi_qla_host, iocb_work); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2709 | struct qla_hw_data *ha = vha->hw; |
| 2710 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
| 2711 | int i = 20; |
| 2712 | unsigned long flags; |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2713 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2714 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 2715 | return; |
| 2716 | |
| 2717 | while (!list_empty(&vha->work_list) && i > 0) { |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2718 | qla2x00_do_work(vha); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2719 | i--; |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2720 | } |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2721 | |
| 2722 | spin_lock_irqsave(&vha->work_lock, flags); |
| 2723 | clear_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags); |
| 2724 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2725 | } |
| 2726 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2727 | /* |
| 2728 | * PCI driver interface |
| 2729 | */ |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 2730 | static int |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2731 | 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] | 2732 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2733 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2734 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2735 | scsi_qla_host_t *base_vha = NULL; |
| 2736 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2737 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2738 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2739 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2740 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2741 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2742 | struct req_que *req = NULL; |
| 2743 | struct rsp_que *rsp = NULL; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 2744 | int i; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2745 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2746 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2747 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2748 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2749 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2750 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2751 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2752 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2753 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2754 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2755 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2756 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2757 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031 || |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2758 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISPF001 || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2759 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8044 || |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2760 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2071 || |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2761 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271 || |
| 2762 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2261) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2763 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2764 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2765 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2766 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2767 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2768 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2769 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2770 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2771 | if (mem_only) { |
| 2772 | if (pci_enable_device_mem(pdev)) |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2773 | return ret; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2774 | } else { |
| 2775 | if (pci_enable_device(pdev)) |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2776 | return ret; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2777 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2778 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2779 | /* This may fail but that's ok */ |
| 2780 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2781 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2782 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2783 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2784 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2785 | "Unable to allocate memory for ha.\n"); |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2786 | goto disable_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2787 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2788 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2789 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2790 | ha->pdev = pdev; |
Quinn Tran | 33e7997 | 2014-09-25 06:14:55 -0400 | [diff] [blame] | 2791 | INIT_LIST_HEAD(&ha->tgt.q_full_list); |
| 2792 | spin_lock_init(&ha->tgt.q_full_lock); |
Quinn Tran | 7560151 | 2015-12-17 14:57:04 -0500 | [diff] [blame] | 2793 | spin_lock_init(&ha->tgt.sess_lock); |
Quinn Tran | 2f424b9 | 2015-12-17 14:57:07 -0500 | [diff] [blame] | 2794 | spin_lock_init(&ha->tgt.atio_lock); |
| 2795 | |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 2796 | atomic_set(&ha->nvme_active_aen_cnt, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2797 | |
| 2798 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2799 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2800 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2801 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2802 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2803 | mutex_init(&ha->selflogin_lock); |
Chad Dupuis | 7a8ab9c | 2014-02-26 04:14:56 -0500 | [diff] [blame] | 2804 | mutex_init(&ha->optrom_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2805 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2806 | /* Set ISP-type information. */ |
| 2807 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2808 | |
| 2809 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2810 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2811 | IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2812 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2813 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2814 | ha->prev_topology = 0; |
| 2815 | ha->init_cb_size = sizeof(init_cb_t); |
| 2816 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2817 | ha->optrom_size = OPTROM_SIZE_2300; |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 2818 | ha->max_exchg = FW_MAX_EXCHANGES_CNT; |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 2819 | atomic_set(&ha->num_pend_mbx_stage1, 0); |
| 2820 | atomic_set(&ha->num_pend_mbx_stage2, 0); |
| 2821 | atomic_set(&ha->num_pend_mbx_stage3, 0); |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2822 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2823 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2824 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2825 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2826 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2827 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2828 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2829 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2830 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2831 | ha->flash_conf_off = ~0; |
| 2832 | ha->flash_data_off = ~0; |
| 2833 | ha->nvram_conf_off = ~0; |
| 2834 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2835 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2836 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2837 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2838 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2839 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2840 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2841 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2842 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2843 | ha->flash_conf_off = ~0; |
| 2844 | ha->flash_data_off = ~0; |
| 2845 | ha->nvram_conf_off = ~0; |
| 2846 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2847 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2848 | } else if (IS_QLA23XX(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; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2851 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2852 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2853 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2854 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2855 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2856 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2857 | ha->flash_conf_off = ~0; |
| 2858 | ha->flash_data_off = ~0; |
| 2859 | ha->nvram_conf_off = ~0; |
| 2860 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2861 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2862 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2863 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2864 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2865 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2866 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2867 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2868 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2869 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2870 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2871 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2872 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2873 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2874 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2875 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2876 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2877 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2878 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2879 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2880 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2881 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2882 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2883 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2884 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2885 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2886 | ha->gid_list_info_size = 8; |
| 2887 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2888 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2889 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2890 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2891 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2892 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2893 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2894 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2895 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2896 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2897 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2898 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 2899 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2900 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2901 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2902 | ha->gid_list_info_size = 8; |
| 2903 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2904 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2905 | ha->isp_ops = &qla81xx_isp_ops; |
| 2906 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2907 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2908 | ha->nvram_conf_off = ~0; |
| 2909 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2910 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2911 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2912 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2913 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2914 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2915 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2916 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2917 | ha->gid_list_info_size = 8; |
| 2918 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2919 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2920 | ha->isp_ops = &qla82xx_isp_ops; |
| 2921 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2922 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2923 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2924 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2925 | } else if (IS_QLA8044(ha)) { |
| 2926 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2927 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2928 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2929 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2930 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2931 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2932 | ha->gid_list_info_size = 8; |
| 2933 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2934 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2935 | ha->isp_ops = &qla8044_isp_ops; |
| 2936 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2937 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2938 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2939 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2940 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2941 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2942 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2943 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Saurav Kashyap | f2ea653 | 2014-09-25 06:14:54 -0400 | [diff] [blame] | 2944 | req_length = REQUEST_ENTRY_CNT_83XX; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2945 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Arun Easi | b8aa4bd | 2013-01-30 03:34:40 -0500 | [diff] [blame] | 2946 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2947 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2948 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2949 | ha->gid_list_info_size = 8; |
| 2950 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2951 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2952 | ha->isp_ops = &qla83xx_isp_ops; |
| 2953 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2954 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2955 | ha->nvram_conf_off = ~0; |
| 2956 | ha->nvram_data_off = ~0; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2957 | } else if (IS_QLAFX00(ha)) { |
| 2958 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_FX00; |
| 2959 | ha->mbx_count = MAILBOX_REGISTER_COUNT_FX00; |
| 2960 | ha->aen_mbx_count = AEN_MAILBOX_REGISTER_COUNT_FX00; |
| 2961 | req_length = REQUEST_ENTRY_CNT_FX00; |
| 2962 | rsp_length = RESPONSE_ENTRY_CNT_FX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2963 | ha->isp_ops = &qlafx00_isp_ops; |
| 2964 | ha->port_down_retry_count = 30; /* default value */ |
| 2965 | ha->mr.fw_hbt_cnt = QLAFX00_HEARTBEAT_INTERVAL; |
| 2966 | ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; |
Armen Baloyan | 71e5600 | 2013-08-27 01:37:38 -0400 | [diff] [blame] | 2967 | ha->mr.fw_critemp_timer_tick = QLAFX00_CRITEMP_INTERVAL; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2968 | ha->mr.fw_hbt_en = 1; |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 2969 | ha->mr.host_info_resend = false; |
| 2970 | ha->mr.hinfo_resend_timer_tick = QLAFX00_HINFO_RESEND_INTERVAL; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2971 | } else if (IS_QLA27XX(ha)) { |
| 2972 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
| 2973 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2974 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2975 | req_length = REQUEST_ENTRY_CNT_83XX; |
| 2976 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 2977 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2978 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2979 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2980 | ha->gid_list_info_size = 8; |
| 2981 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2982 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2983 | ha->isp_ops = &qla27xx_isp_ops; |
| 2984 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2985 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2986 | ha->nvram_conf_off = ~0; |
| 2987 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2988 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2989 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2990 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 2991 | "mbx_count=%d, req_length=%d, " |
| 2992 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2993 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 2994 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2995 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 2996 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2997 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2998 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 2999 | "isp_ops=%p, flash_conf_off=%d, " |
| 3000 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 3001 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 3002 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 3003 | |
| 3004 | /* Configure PCI I/O space */ |
| 3005 | ret = ha->isp_ops->iospace_config(ha); |
| 3006 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3007 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 3008 | |
| 3009 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 3010 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 3011 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 3012 | mutex_init(&ha->vport_lock); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3013 | mutex_init(&ha->mq_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 3014 | init_completion(&ha->mbx_cmd_comp); |
| 3015 | complete(&ha->mbx_cmd_comp); |
| 3016 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 3017 | init_completion(&ha->dcbx_comp); |
Chad Dupuis | f356bef | 2013-02-08 01:58:04 -0500 | [diff] [blame] | 3018 | init_completion(&ha->lb_portup_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3019 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3020 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3021 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 3022 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3023 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 3024 | "64 Bit addressing is %s.\n", |
| 3025 | ha->flags.enable_64bit_addressing ? "enable" : |
| 3026 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3027 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3028 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3029 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 3030 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3031 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3032 | goto probe_hw_failed; |
| 3033 | } |
| 3034 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3035 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3036 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3037 | req->max_q_depth = ql2xmaxqdepth; |
| 3038 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3039 | |
| 3040 | base_vha = qla2x00_create_host(sht, ha); |
| 3041 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3042 | ret = -ENOMEM; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3043 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3044 | } |
| 3045 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3046 | pci_set_drvdata(pdev, base_vha); |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 3047 | set_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3048 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3049 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3050 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3051 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Quinn Tran | f6602f3 | 2018-08-02 13:16:53 -0700 | [diff] [blame] | 3052 | base_vha->mgmt_svr_loop_id = |
| 3053 | qla2x00_reserve_mgmt_server_loop_id(base_vha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3054 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3055 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 3056 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 3057 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3058 | /* Setup fcport template structure. */ |
| 3059 | ha->mr.fcport.vha = base_vha; |
| 3060 | ha->mr.fcport.port_type = FCT_UNKNOWN; |
| 3061 | ha->mr.fcport.loop_id = FC_NO_LOOP_ID; |
| 3062 | qla2x00_set_fcport_state(&ha->mr.fcport, FCS_UNCONFIGURED); |
| 3063 | ha->mr.fcport.supported_classes = FC_COS_UNSPECIFIED; |
| 3064 | ha->mr.fcport.scan_state = 1; |
| 3065 | |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 3066 | /* Set the SG table size based on ISP type */ |
| 3067 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3068 | if (IS_QLA2100(ha)) |
| 3069 | host->sg_tablesize = 32; |
| 3070 | } else { |
| 3071 | if (!IS_QLA82XX(ha)) |
| 3072 | host->sg_tablesize = QLA_SG_ALL; |
| 3073 | } |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3074 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3075 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 3076 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 3077 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3078 | host->max_cmd_len = 32; |
| 3079 | else |
| 3080 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 3081 | host->max_channel = MAX_BUSES - 1; |
Hannes Reinecke | 755f516 | 2014-06-03 10:58:54 +0200 | [diff] [blame] | 3082 | /* Older HBAs support only 16-bit LUNs */ |
| 3083 | if (!IS_QLAFX00(ha) && !IS_FWI2_CAPABLE(ha) && |
| 3084 | ql2xmaxlun > 0xffff) |
| 3085 | host->max_lun = 0xffff; |
| 3086 | else |
| 3087 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3088 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3089 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3090 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3091 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 3092 | "max_id=%d this_id=%d " |
| 3093 | "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] | 3094 | "max_lun=%llu transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3095 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 3096 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 3097 | host->transportt, sht->vendor_id); |
| 3098 | |
Himanshu Madhani | 1010f21 | 2017-10-16 11:26:05 -0700 | [diff] [blame] | 3099 | INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn); |
| 3100 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3101 | /* Set up the irqs */ |
| 3102 | ret = qla2x00_request_irqs(ha, rsp); |
| 3103 | if (ret) |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 3104 | goto probe_failed; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3105 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3106 | /* Alloc arrays of request and response ring ptrs */ |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 3107 | ret = qla2x00_alloc_queues(ha, req, rsp); |
| 3108 | if (ret) { |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3109 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 3110 | "Failed to allocate memory for queue pointers..." |
| 3111 | "aborting.\n"); |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 3112 | goto probe_failed; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3113 | } |
| 3114 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3115 | if (ha->mqenable && shost_use_blk_mq(host)) { |
| 3116 | /* number of hardware queues supported by blk/scsi-mq*/ |
| 3117 | host->nr_hw_queues = ha->max_qpairs; |
| 3118 | |
| 3119 | ql_dbg(ql_dbg_init, base_vha, 0x0192, |
| 3120 | "blk/scsi-mq enabled, HW queues = %d.\n", host->nr_hw_queues); |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 3121 | } else { |
| 3122 | if (ql2xnvmeenable) { |
| 3123 | host->nr_hw_queues = ha->max_qpairs; |
| 3124 | ql_dbg(ql_dbg_init, base_vha, 0x0194, |
| 3125 | "FC-NVMe support is enabled, HW queues=%d\n", |
| 3126 | host->nr_hw_queues); |
| 3127 | } else { |
| 3128 | ql_dbg(ql_dbg_init, base_vha, 0x0193, |
| 3129 | "blk/scsi-mq disabled.\n"); |
| 3130 | } |
| 3131 | } |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3132 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3133 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3134 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3135 | pci_save_state(pdev); |
| 3136 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3137 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3138 | rsp->req = req; |
| 3139 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3140 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3141 | if (IS_QLAFX00(ha)) { |
| 3142 | ha->rsp_q_map[0] = rsp; |
| 3143 | ha->req_q_map[0] = req; |
| 3144 | set_bit(0, ha->req_qid_map); |
| 3145 | set_bit(0, ha->rsp_qid_map); |
| 3146 | } |
| 3147 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 3148 | /* FWI2-capable only. */ |
| 3149 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 3150 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 3151 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 3152 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3153 | if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 3154 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 3155 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 3156 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 3157 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 3158 | } |
| 3159 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3160 | if (IS_QLAFX00(ha)) { |
| 3161 | req->req_q_in = &ha->iobase->ispfx00.req_q_in; |
| 3162 | req->req_q_out = &ha->iobase->ispfx00.req_q_out; |
| 3163 | rsp->rsp_q_in = &ha->iobase->ispfx00.rsp_q_in; |
| 3164 | rsp->rsp_q_out = &ha->iobase->ispfx00.rsp_q_out; |
| 3165 | } |
| 3166 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3167 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3168 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 3169 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 3170 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 3171 | } |
| 3172 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3173 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 3174 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 3175 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 3176 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 3177 | "req->req_q_in=%p req->req_q_out=%p " |
| 3178 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 3179 | req->req_q_in, req->req_q_out, |
| 3180 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 3181 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 3182 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 3183 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 3184 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 3185 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 3186 | 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] | 3187 | |
himanshu.madhani@cavium.com | d48cc67 | 2018-07-02 13:01:59 -0700 | [diff] [blame] | 3188 | ha->wq = alloc_workqueue("qla2xxx_wq", 0, 0); |
| 3189 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3190 | if (ha->isp_ops->initialize_adapter(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3191 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 3192 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 3193 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3194 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3195 | if (IS_QLA82XX(ha)) { |
| 3196 | qla82xx_idc_lock(ha); |
| 3197 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3198 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3199 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3200 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 3201 | "HW State: FAILED.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3202 | } else if (IS_QLA8044(ha)) { |
| 3203 | qla8044_idc_lock(ha); |
| 3204 | qla8044_wr_direct(base_vha, |
| 3205 | QLA8044_CRB_DEV_STATE_INDEX, |
| 3206 | QLA8XXX_DEV_FAILED); |
| 3207 | qla8044_idc_unlock(ha); |
| 3208 | ql_log(ql_log_fatal, base_vha, 0x0150, |
| 3209 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3210 | } |
| 3211 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3212 | ret = -ENODEV; |
| 3213 | goto probe_failed; |
| 3214 | } |
| 3215 | |
Chad Dupuis | 3b1bef6 | 2014-02-26 04:15:04 -0500 | [diff] [blame] | 3216 | if (IS_QLAFX00(ha)) |
| 3217 | host->can_queue = QLAFX00_MAX_CANQUEUE; |
| 3218 | else |
| 3219 | host->can_queue = req->num_outstanding_cmds - 10; |
| 3220 | |
| 3221 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 3222 | "can_queue=%d, req=%p, mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 3223 | host->can_queue, base_vha->req, |
| 3224 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
| 3225 | |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3226 | if (ha->mqenable) { |
| 3227 | bool mq = false; |
| 3228 | bool startit = false; |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3229 | |
| 3230 | if (QLA_TGT_MODE_ENABLED()) { |
| 3231 | mq = true; |
| 3232 | startit = false; |
| 3233 | } |
| 3234 | |
| 3235 | if ((ql2x_ini_mode == QLA2XXX_INI_MODE_ENABLED) && |
| 3236 | shost_use_blk_mq(host)) { |
| 3237 | mq = true; |
| 3238 | startit = true; |
| 3239 | } |
| 3240 | |
| 3241 | if (mq) { |
| 3242 | /* Create start of day qpairs for Block MQ */ |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3243 | for (i = 0; i < ha->max_qpairs; i++) |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3244 | qla2xxx_create_qpair(base_vha, 5, 0, startit); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3245 | } |
| 3246 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3247 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3248 | if (ha->flags.running_gold_fw) |
| 3249 | goto skip_dpc; |
| 3250 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3251 | /* |
| 3252 | * Startup the kernel thread for this host adapter |
| 3253 | */ |
| 3254 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3255 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3256 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3257 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 3258 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3259 | ret = PTR_ERR(ha->dpc_thread); |
Douglas Miller | e2532b4 | 2017-10-20 08:17:22 -0500 | [diff] [blame] | 3260 | ha->dpc_thread = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3261 | goto probe_failed; |
| 3262 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3263 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 3264 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3265 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3266 | /* |
| 3267 | * If we're not coming up in initiator mode, we might sit for |
| 3268 | * a while without waking up the dpc thread, which leads to a |
| 3269 | * stuck process warning. So just kick the dpc once here and |
| 3270 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 3271 | */ |
| 3272 | qla2xxx_wake_dpc(base_vha); |
| 3273 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 3274 | INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); |
| 3275 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3276 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 3277 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 3278 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 3279 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 3280 | |
| 3281 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 3282 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 3283 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 3284 | INIT_WORK(&ha->idc_state_handler, |
| 3285 | qla83xx_idc_state_handler_work); |
| 3286 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 3287 | qla83xx_nic_core_unrecoverable_work); |
| 3288 | } |
| 3289 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3290 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3291 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 3292 | base_vha->host->irq = ha->pdev->irq; |
| 3293 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3294 | /* Initialized the timer */ |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 3295 | qla2x00_start_timer(base_vha, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3296 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 3297 | "Started qla2x00_timer with " |
| 3298 | "interval=%d.\n", WATCH_INTERVAL); |
| 3299 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 3300 | "Detected hba at address=%p.\n", |
| 3301 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3302 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 3303 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3304 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3305 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3306 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3307 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 3308 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3309 | if (ql2xenabledif == 1) |
| 3310 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3311 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3312 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3313 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3314 | | SHOST_DIF_TYPE3_PROTECTION |
| 3315 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3316 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3317 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3318 | |
| 3319 | guard = SHOST_DIX_GUARD_CRC; |
| 3320 | |
| 3321 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 3322 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 3323 | guard |= SHOST_DIX_GUARD_IP; |
| 3324 | |
| 3325 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3326 | } else |
| 3327 | base_vha->flags.difdix_supported = 0; |
| 3328 | } |
| 3329 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3330 | ha->isp_ops->enable_intrs(ha); |
| 3331 | |
Armen Baloyan | 1fe19ee | 2013-08-27 01:37:41 -0400 | [diff] [blame] | 3332 | if (IS_QLAFX00(ha)) { |
| 3333 | ret = qlafx00_fx_disc(base_vha, |
| 3334 | &base_vha->hw->mr.fcport, FXDISC_GET_CONFIG_INFO); |
| 3335 | host->sg_tablesize = (ha->mr.extended_io_enabled) ? |
| 3336 | QLA_SG_ALL : 128; |
| 3337 | } |
| 3338 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3339 | ret = scsi_add_host(host, &pdev->dev); |
| 3340 | if (ret) |
| 3341 | goto probe_failed; |
| 3342 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3343 | base_vha->flags.init_done = 1; |
| 3344 | base_vha->flags.online = 1; |
Saurav Kashyap | edaa5c7 | 2014-04-11 16:54:14 -0400 | [diff] [blame] | 3345 | ha->prev_minidump_failed = 0; |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3346 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3347 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 3348 | "Init done and hba is online.\n"); |
| 3349 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3350 | if (qla_ini_mode_enabled(base_vha) || |
| 3351 | qla_dual_mode_enabled(base_vha)) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3352 | scsi_scan_host(host); |
| 3353 | else |
| 3354 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 3355 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 3356 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3357 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3358 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3359 | if (IS_QLAFX00(ha)) { |
| 3360 | ret = qlafx00_fx_disc(base_vha, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3361 | &base_vha->hw->mr.fcport, FXDISC_GET_PORT_INFO); |
| 3362 | |
| 3363 | /* Register system information */ |
| 3364 | ret = qlafx00_fx_disc(base_vha, |
| 3365 | &base_vha->hw->mr.fcport, FXDISC_REG_HOST_INFO); |
| 3366 | } |
| 3367 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3368 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3369 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3370 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3371 | |
Armen Baloyan | 03eb912 | 2013-10-30 03:38:22 -0400 | [diff] [blame] | 3372 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 3373 | "QLogic %s - %s.\n", ha->model_number, ha->model_desc); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3374 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 3375 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 3376 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 3377 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 3378 | base_vha->host_no, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 3379 | 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] | 3380 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3381 | qlt_add_target(ha, base_vha); |
| 3382 | |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 3383 | clear_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 3384 | |
| 3385 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3386 | return -ENODEV; |
| 3387 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 3388 | if (ha->flags.detected_lr_sfp) { |
| 3389 | ql_log(ql_log_info, base_vha, 0xffff, |
| 3390 | "Reset chip to pick up LR SFP setting\n"); |
| 3391 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 3392 | qla2xxx_wake_dpc(base_vha); |
| 3393 | } |
| 3394 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3395 | return 0; |
| 3396 | |
| 3397 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3398 | if (base_vha->timer_active) |
| 3399 | qla2x00_stop_timer(base_vha); |
| 3400 | base_vha->flags.online = 0; |
| 3401 | if (ha->dpc_thread) { |
| 3402 | struct task_struct *t = ha->dpc_thread; |
| 3403 | |
| 3404 | ha->dpc_thread = NULL; |
| 3405 | kthread_stop(t); |
| 3406 | } |
| 3407 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3408 | qla2x00_free_device(base_vha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3409 | scsi_host_put(base_vha->host); |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 3410 | /* |
| 3411 | * Need to NULL out local req/rsp after |
| 3412 | * qla2x00_free_device => qla2x00_free_queues frees |
| 3413 | * what these are pointing to. Or else we'll |
| 3414 | * fall over below in qla2x00_free_req/rsp_que. |
| 3415 | */ |
| 3416 | req = NULL; |
| 3417 | rsp = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3418 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3419 | probe_hw_failed: |
himanshu.madhani@cavium.com | d64d6c5 | 2018-01-15 20:46:46 -0800 | [diff] [blame] | 3420 | qla2x00_mem_free(ha); |
| 3421 | qla2x00_free_req_que(ha, req); |
| 3422 | qla2x00_free_rsp_que(ha, rsp); |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 3423 | qla2x00_clear_drv_active(ha); |
| 3424 | |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3425 | iospace_config_failed: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3426 | if (IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3427 | if (!ha->nx_pcibase) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3428 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3429 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3430 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3431 | } else { |
| 3432 | if (ha->iobase) |
| 3433 | iounmap(ha->iobase); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3434 | if (ha->cregbase) |
| 3435 | iounmap(ha->cregbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3436 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3437 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3438 | kfree(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3439 | |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 3440 | disable_device: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3441 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3442 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3443 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3444 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 3445 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3446 | qla2x00_shutdown(struct pci_dev *pdev) |
| 3447 | { |
| 3448 | scsi_qla_host_t *vha; |
| 3449 | struct qla_hw_data *ha; |
| 3450 | |
| 3451 | vha = pci_get_drvdata(pdev); |
| 3452 | ha = vha->hw; |
| 3453 | |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 3454 | ql_log(ql_log_info, vha, 0xfffa, |
| 3455 | "Adapter shutdown\n"); |
| 3456 | |
| 3457 | /* |
| 3458 | * Prevent future board_disable and wait |
| 3459 | * until any pending board_disable has completed. |
| 3460 | */ |
| 3461 | set_bit(PFLG_DRIVER_REMOVING, &vha->pci_flags); |
| 3462 | cancel_work_sync(&ha->board_disable); |
| 3463 | |
| 3464 | if (!atomic_read(&pdev->enable_cnt)) |
| 3465 | return; |
| 3466 | |
Armen Baloyan | 4247934 | 2013-08-27 01:37:37 -0400 | [diff] [blame] | 3467 | /* Notify ISPFX00 firmware */ |
| 3468 | if (IS_QLAFX00(ha)) |
| 3469 | qlafx00_driver_shutdown(vha, 20); |
| 3470 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3471 | /* Turn-off FCE trace */ |
| 3472 | if (ha->flags.fce_enabled) { |
| 3473 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 3474 | ha->flags.fce_enabled = 0; |
| 3475 | } |
| 3476 | |
| 3477 | /* Turn-off EFT trace */ |
| 3478 | if (ha->eft) |
| 3479 | qla2x00_disable_eft_trace(vha); |
| 3480 | |
Quinn Tran | 3407fc3 | 2017-12-28 12:33:11 -0800 | [diff] [blame] | 3481 | if (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
| 3482 | if (ha->flags.fw_started) |
| 3483 | qla2x00_abort_isp_cleanup(vha); |
| 3484 | } else { |
| 3485 | /* Stop currently executing firmware. */ |
| 3486 | qla2x00_try_to_stop_firmware(vha); |
| 3487 | } |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3488 | |
| 3489 | /* Turn adapter off line */ |
| 3490 | vha->flags.online = 0; |
| 3491 | |
| 3492 | /* turn-off interrupts on the card */ |
| 3493 | if (ha->interrupts_on) { |
| 3494 | vha->flags.init_done = 0; |
| 3495 | ha->isp_ops->disable_intrs(ha); |
| 3496 | } |
| 3497 | |
| 3498 | qla2x00_free_irqs(vha); |
| 3499 | |
| 3500 | qla2x00_free_fw_dump(ha); |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3501 | |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3502 | pci_disable_device(pdev); |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 3503 | ql_log(ql_log_info, vha, 0xfffe, |
| 3504 | "Adapter shutdown successfully.\n"); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3505 | } |
| 3506 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3507 | /* Deletes all the virtual ports for a given ha */ |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3508 | static void |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3509 | 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] | 3510 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3511 | scsi_qla_host_t *vha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3512 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3513 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3514 | mutex_lock(&ha->vport_lock); |
| 3515 | while (ha->cur_vport_count) { |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3516 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3517 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3518 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 3519 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 3520 | 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] | 3521 | scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3522 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3523 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3524 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3525 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3526 | fc_vport_terminate(vha->fc_vport); |
| 3527 | scsi_host_put(vha->host); |
| 3528 | |
| 3529 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3530 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3531 | mutex_unlock(&ha->vport_lock); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3532 | } |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3533 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3534 | /* Stops all deferred work threads */ |
| 3535 | static void |
| 3536 | qla2x00_destroy_deferred_work(struct qla_hw_data *ha) |
| 3537 | { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3538 | /* Cancel all work and destroy DPC workqueues */ |
| 3539 | if (ha->dpc_lp_wq) { |
| 3540 | cancel_work_sync(&ha->idc_aen); |
| 3541 | destroy_workqueue(ha->dpc_lp_wq); |
| 3542 | ha->dpc_lp_wq = NULL; |
| 3543 | } |
| 3544 | |
| 3545 | if (ha->dpc_hp_wq) { |
| 3546 | cancel_work_sync(&ha->nic_core_reset); |
| 3547 | cancel_work_sync(&ha->idc_state_handler); |
| 3548 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 3549 | destroy_workqueue(ha->dpc_hp_wq); |
| 3550 | ha->dpc_hp_wq = NULL; |
| 3551 | } |
| 3552 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3553 | /* Kill the kernel thread for this host */ |
| 3554 | if (ha->dpc_thread) { |
| 3555 | struct task_struct *t = ha->dpc_thread; |
| 3556 | |
| 3557 | /* |
| 3558 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 3559 | * so we need to zero it out. |
| 3560 | */ |
| 3561 | ha->dpc_thread = NULL; |
| 3562 | kthread_stop(t); |
| 3563 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3564 | } |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3565 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3566 | static void |
| 3567 | qla2x00_unmap_iobases(struct qla_hw_data *ha) |
| 3568 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3569 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 3570 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3571 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3572 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3573 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3574 | } else { |
| 3575 | if (ha->iobase) |
| 3576 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3577 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3578 | if (ha->cregbase) |
| 3579 | iounmap(ha->cregbase); |
| 3580 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3581 | if (ha->mqiobase) |
| 3582 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3583 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3584 | if ((IS_QLA83XX(ha) || IS_QLA27XX(ha)) && ha->msixbase) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3585 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3586 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3587 | } |
| 3588 | |
| 3589 | static void |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3590 | qla2x00_clear_drv_active(struct qla_hw_data *ha) |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3591 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3592 | if (IS_QLA8044(ha)) { |
| 3593 | qla8044_idc_lock(ha); |
Saurav Kashyap | c41afc9 | 2013-11-07 02:54:56 -0500 | [diff] [blame] | 3594 | qla8044_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3595 | qla8044_idc_unlock(ha); |
| 3596 | } else if (IS_QLA82XX(ha)) { |
| 3597 | qla82xx_idc_lock(ha); |
| 3598 | qla82xx_clear_drv_active(ha); |
| 3599 | qla82xx_idc_unlock(ha); |
| 3600 | } |
| 3601 | } |
| 3602 | |
| 3603 | static void |
| 3604 | qla2x00_remove_one(struct pci_dev *pdev) |
| 3605 | { |
| 3606 | scsi_qla_host_t *base_vha; |
| 3607 | struct qla_hw_data *ha; |
| 3608 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3609 | base_vha = pci_get_drvdata(pdev); |
| 3610 | ha = base_vha->hw; |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 3611 | ql_log(ql_log_info, base_vha, 0xb079, |
| 3612 | "Removing driver\n"); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3613 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3614 | /* Indicate device removal to prevent future board_disable and wait |
| 3615 | * until any pending board_disable has completed. */ |
| 3616 | set_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags); |
| 3617 | cancel_work_sync(&ha->board_disable); |
| 3618 | |
| 3619 | /* |
| 3620 | * If the PCI device is disabled then there was a PCI-disconnect and |
| 3621 | * qla2x00_disable_board_on_pci_error has taken care of most of the |
| 3622 | * resources. |
| 3623 | */ |
| 3624 | if (!atomic_read(&pdev->enable_cnt)) { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3625 | dma_free_coherent(&ha->pdev->dev, base_vha->gnl.size, |
| 3626 | base_vha->gnl.l, base_vha->gnl.ldma); |
| 3627 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3628 | scsi_host_put(base_vha->host); |
| 3629 | kfree(ha); |
| 3630 | pci_set_drvdata(pdev, NULL); |
| 3631 | return; |
| 3632 | } |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 3633 | qla2x00_wait_for_hba_ready(base_vha); |
| 3634 | |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 3635 | if (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
| 3636 | if (ha->flags.fw_started) |
| 3637 | qla2x00_abort_isp_cleanup(base_vha); |
| 3638 | } else if (!IS_QLAFX00(ha)) { |
| 3639 | if (IS_QLA8031(ha)) { |
| 3640 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 3641 | "Clearing fcoe driver presence.\n"); |
| 3642 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 3643 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 3644 | "Error while clearing DRV-Presence.\n"); |
| 3645 | } |
| 3646 | |
| 3647 | qla2x00_try_to_stop_firmware(base_vha); |
| 3648 | } |
| 3649 | |
Quinn Tran | 2ce87cc | 2018-01-23 11:05:21 -0800 | [diff] [blame] | 3650 | qla2x00_wait_for_sess_deletion(base_vha); |
| 3651 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3652 | /* |
| 3653 | * if UNLOAD flag is already set, then continue unload, |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 3654 | * where it was set first. |
| 3655 | */ |
| 3656 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3657 | return; |
| 3658 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3659 | set_bit(UNLOADING, &base_vha->dpc_flags); |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 3660 | |
| 3661 | qla_nvme_delete(base_vha); |
| 3662 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3663 | dma_free_coherent(&ha->pdev->dev, |
| 3664 | base_vha->gnl.size, base_vha->gnl.l, base_vha->gnl.ldma); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3665 | |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 3666 | vfree(base_vha->scan.l); |
| 3667 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3668 | if (IS_QLAFX00(ha)) |
| 3669 | qlafx00_driver_shutdown(base_vha, 20); |
| 3670 | |
| 3671 | qla2x00_delete_all_vps(ha, base_vha); |
| 3672 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3673 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 3674 | |
| 3675 | qla2x00_dfs_remove(base_vha); |
| 3676 | |
| 3677 | qla84xx_put_chip(base_vha); |
| 3678 | |
| 3679 | /* Disable timer */ |
| 3680 | if (base_vha->timer_active) |
| 3681 | qla2x00_stop_timer(base_vha); |
| 3682 | |
| 3683 | base_vha->flags.online = 0; |
| 3684 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3685 | /* free DMA memory */ |
| 3686 | if (ha->exlogin_buf) |
| 3687 | qla2x00_free_exlogin_buffer(ha); |
| 3688 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3689 | /* free DMA memory */ |
| 3690 | if (ha->exchoffld_buf) |
| 3691 | qla2x00_free_exchoffld_buffer(ha); |
| 3692 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3693 | qla2x00_destroy_deferred_work(ha); |
| 3694 | |
| 3695 | qlt_remove_target(ha, base_vha); |
| 3696 | |
| 3697 | qla2x00_free_sysfs_attr(base_vha, true); |
| 3698 | |
| 3699 | fc_remove_host(base_vha->host); |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3700 | qlt_remove_target_resources(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3701 | |
| 3702 | scsi_remove_host(base_vha->host); |
| 3703 | |
| 3704 | qla2x00_free_device(base_vha); |
| 3705 | |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3706 | qla2x00_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3707 | |
Arun Easi | d2749ff | 2014-09-25 05:16:51 -0400 | [diff] [blame] | 3708 | scsi_host_put(base_vha->host); |
| 3709 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3710 | qla2x00_unmap_iobases(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3711 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3712 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3713 | kfree(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3714 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3715 | pci_disable_pcie_error_reporting(pdev); |
| 3716 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 3717 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3718 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3719 | |
| 3720 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3721 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3722 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3723 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3724 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3725 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 3726 | |
| 3727 | /* Disable timer */ |
| 3728 | if (vha->timer_active) |
| 3729 | qla2x00_stop_timer(vha); |
| 3730 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3731 | qla25xx_delete_queues(vha); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3732 | vha->flags.online = 0; |
| 3733 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3734 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3735 | if (ha->interrupts_on) { |
| 3736 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 3737 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3738 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3739 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3740 | qla2x00_free_fcports(vha); |
| 3741 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3742 | qla2x00_free_irqs(vha); |
| 3743 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3744 | /* Flush the work queue and remove it */ |
| 3745 | if (ha->wq) { |
| 3746 | flush_workqueue(ha->wq); |
| 3747 | destroy_workqueue(ha->wq); |
| 3748 | ha->wq = NULL; |
| 3749 | } |
| 3750 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3751 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3752 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3753 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 3754 | qla82xx_md_free(vha); |
| 3755 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3756 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3757 | } |
| 3758 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3759 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 3760 | { |
| 3761 | fc_port_t *fcport, *tfcport; |
| 3762 | |
| 3763 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 3764 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3765 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3766 | kfree(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3767 | } |
| 3768 | } |
| 3769 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3770 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3771 | 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] | 3772 | int defer) |
| 3773 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3774 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3775 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3776 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3777 | |
| 3778 | if (!fcport->rport) |
| 3779 | return; |
| 3780 | |
| 3781 | rport = fcport->rport; |
| 3782 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3783 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3784 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3785 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3786 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3787 | qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3788 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 3789 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3790 | } else { |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3791 | int now; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3792 | if (rport) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3793 | ql_dbg(ql_dbg_disc, fcport->vha, 0x2109, |
| 3794 | "%s %8phN. rport %p roles %x\n", |
| 3795 | __func__, fcport->port_name, rport, |
| 3796 | rport->roles); |
Alexei Potashnik | d20ed91 | 2015-07-14 16:00:47 -0400 | [diff] [blame] | 3797 | fc_remote_port_delete(rport); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3798 | } |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3799 | qlt_do_generation_tick(vha, &now); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3800 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3801 | } |
| 3802 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3803 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3804 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 3805 | * |
| 3806 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 3807 | * |
| 3808 | * Return: None. |
| 3809 | * |
| 3810 | * Context: |
| 3811 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3812 | 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] | 3813 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3814 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3815 | if (IS_QLAFX00(vha->hw)) { |
| 3816 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
| 3817 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3818 | return; |
| 3819 | } |
| 3820 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3821 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3822 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3823 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3824 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3825 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3826 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3827 | * We may need to retry the login, so don't change the state of the |
| 3828 | * port but do the retries. |
| 3829 | */ |
| 3830 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3831 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3832 | |
| 3833 | if (!do_login) |
| 3834 | return; |
| 3835 | |
Arun Easi | a1d0285 | 2015-08-04 13:38:02 -0400 | [diff] [blame] | 3836 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3837 | } |
| 3838 | |
| 3839 | /* |
| 3840 | * qla2x00_mark_all_devices_lost |
| 3841 | * Updates fcport state when device goes offline. |
| 3842 | * |
| 3843 | * Input: |
| 3844 | * ha = adapter block pointer. |
| 3845 | * fcport = port structure pointer. |
| 3846 | * |
| 3847 | * Return: |
| 3848 | * None. |
| 3849 | * |
| 3850 | * Context: |
| 3851 | */ |
| 3852 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3853 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3854 | { |
| 3855 | fc_port_t *fcport; |
| 3856 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3857 | ql_dbg(ql_dbg_disc, vha, 0x20f1, |
| 3858 | "Mark all dev lost\n"); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3859 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3860 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3861 | fcport->scan_state = 0; |
Quinn Tran | d8630bb | 2017-12-28 12:33:43 -0800 | [diff] [blame] | 3862 | qlt_schedule_sess_for_deletion(fcport); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3863 | |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3864 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3865 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3866 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3867 | /* |
| 3868 | * No point in marking the device as lost, if the device is |
| 3869 | * already DEAD. |
| 3870 | */ |
| 3871 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3872 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3873 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3874 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3875 | if (defer) |
| 3876 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3877 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3878 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3879 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3880 | } |
| 3881 | } |
| 3882 | |
| 3883 | /* |
| 3884 | * qla2x00_mem_alloc |
| 3885 | * Allocates adapter memory. |
| 3886 | * |
| 3887 | * Returns: |
| 3888 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3889 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3890 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3891 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3892 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3893 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3894 | { |
| 3895 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3896 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3897 | 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] | 3898 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3899 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3900 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3901 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3902 | if (qlt_mem_alloc(ha) < 0) |
| 3903 | goto fail_free_init_cb; |
| 3904 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3905 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3906 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3907 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3908 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3909 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3910 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3911 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3912 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3913 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3914 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3915 | /* Allocate cache for CT6 Ctx. */ |
| 3916 | if (!ctx_cachep) { |
| 3917 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3918 | sizeof(struct ct6_dsd), 0, |
| 3919 | SLAB_HWCACHE_ALIGN, NULL); |
| 3920 | if (!ctx_cachep) |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3921 | goto fail_free_srb_mempool; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3922 | } |
| 3923 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3924 | ctx_cachep); |
| 3925 | if (!ha->ctx_mempool) |
| 3926 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3927 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3928 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3929 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3930 | } |
| 3931 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3932 | /* Get memory for cached NVRAM */ |
| 3933 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3934 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3935 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3936 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3937 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3938 | ha->pdev->device); |
| 3939 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3940 | DMA_POOL_SIZE, 8, 0); |
| 3941 | if (!ha->s_dma_pool) |
| 3942 | goto fail_free_nvram; |
| 3943 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3944 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3945 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3946 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3947 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3948 | if (IS_P3P_TYPE(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3949 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3950 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3951 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3952 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3953 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3954 | goto fail_s_dma_pool; |
| 3955 | } |
| 3956 | |
| 3957 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3958 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3959 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3960 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3961 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3962 | goto fail_dl_dma_pool; |
| 3963 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3964 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3965 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3966 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3967 | } |
| 3968 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3969 | /* Allocate memory for SNS commands */ |
| 3970 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3971 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3972 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3973 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3974 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3975 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3976 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 3977 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3978 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3979 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3980 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3981 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3982 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3983 | goto fail_dma_pool; |
| 3984 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3985 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3986 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3987 | if (!ha->ct_sns) |
| 3988 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3989 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 3990 | "ms_iocb=%p ct_sns=%p.\n", |
| 3991 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3992 | } |
| 3993 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3994 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3995 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 3996 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3997 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 3998 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3999 | goto fail_req; |
| 4000 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4001 | (*req)->length = req_len; |
| 4002 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 4003 | ((*req)->length + 1) * sizeof(request_t), |
| 4004 | &(*req)->dma, GFP_KERNEL); |
| 4005 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4006 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 4007 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4008 | goto fail_req_ring; |
| 4009 | } |
| 4010 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4011 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 4012 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4013 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 4014 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4015 | goto fail_rsp; |
| 4016 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4017 | (*rsp)->hw = ha; |
| 4018 | (*rsp)->length = rsp_len; |
| 4019 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 4020 | ((*rsp)->length + 1) * sizeof(response_t), |
| 4021 | &(*rsp)->dma, GFP_KERNEL); |
| 4022 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4023 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 4024 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4025 | goto fail_rsp_ring; |
| 4026 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4027 | (*req)->rsp = *rsp; |
| 4028 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4029 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 4030 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 4031 | "rsp->length=%d rsp->ring=%p.\n", |
| 4032 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 4033 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4034 | /* Allocate memory for NVRAM data for vports */ |
| 4035 | if (ha->nvram_npiv_size) { |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 4036 | ha->npiv_info = kcalloc(ha->nvram_npiv_size, |
| 4037 | sizeof(struct qla_npiv_entry), |
| 4038 | GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4039 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4040 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 4041 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4042 | goto fail_npiv_info; |
| 4043 | } |
| 4044 | } else |
| 4045 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4046 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4047 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4048 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4049 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 4050 | &ha->ex_init_cb_dma); |
| 4051 | if (!ha->ex_init_cb) |
| 4052 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4053 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 4054 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4055 | } |
| 4056 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4057 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 4058 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4059 | /* Get consistent memory allocated for Async Port-Database. */ |
| 4060 | if (!IS_FWI2_CAPABLE(ha)) { |
| 4061 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 4062 | &ha->async_pd_dma); |
| 4063 | if (!ha->async_pd) |
| 4064 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4065 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 4066 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4067 | } |
| 4068 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4069 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4070 | |
| 4071 | /* Allocate memory for our loop_id bitmap */ |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 4072 | ha->loop_id_map = kcalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE), |
| 4073 | sizeof(long), |
| 4074 | GFP_KERNEL); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4075 | if (!ha->loop_id_map) |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4076 | goto fail_loop_id_map; |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4077 | else { |
| 4078 | qla2x00_set_reserved_loop_ids(ha); |
| 4079 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 4080 | "loop_id_map=%p.\n", ha->loop_id_map); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4081 | } |
| 4082 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4083 | ha->sfp_data = dma_alloc_coherent(&ha->pdev->dev, |
| 4084 | SFP_DEV_SIZE, &ha->sfp_data_dma, GFP_KERNEL); |
| 4085 | if (!ha->sfp_data) { |
| 4086 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b, |
| 4087 | "Unable to allocate memory for SFP read-data.\n"); |
| 4088 | goto fail_sfp_data; |
| 4089 | } |
| 4090 | |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 4091 | return 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4092 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4093 | fail_sfp_data: |
| 4094 | kfree(ha->loop_id_map); |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4095 | fail_loop_id_map: |
| 4096 | 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] | 4097 | fail_async_pd: |
| 4098 | 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] | 4099 | fail_ex_init_cb: |
| 4100 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4101 | fail_npiv_info: |
| 4102 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 4103 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 4104 | (*rsp)->ring = NULL; |
| 4105 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4106 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4107 | kfree(*rsp); |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 4108 | *rsp = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4109 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4110 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 4111 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 4112 | (*req)->ring = NULL; |
| 4113 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4114 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4115 | kfree(*req); |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 4116 | *req = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4117 | fail_req: |
| 4118 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 4119 | ha->ct_sns, ha->ct_sns_dma); |
| 4120 | ha->ct_sns = NULL; |
| 4121 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4122 | fail_free_ms_iocb: |
| 4123 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 4124 | ha->ms_iocb = NULL; |
| 4125 | ha->ms_iocb_dma = 0; |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4126 | |
| 4127 | if (ha->sns_cmd) |
| 4128 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
| 4129 | ha->sns_cmd, ha->sns_cmd_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4130 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 4131 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4132 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 4133 | ha->fcp_cmnd_dma_pool = NULL; |
| 4134 | } |
| 4135 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 4136 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4137 | dma_pool_destroy(ha->dl_dma_pool); |
| 4138 | ha->dl_dma_pool = NULL; |
| 4139 | } |
| 4140 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4141 | dma_pool_destroy(ha->s_dma_pool); |
| 4142 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4143 | fail_free_nvram: |
| 4144 | kfree(ha->nvram); |
| 4145 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4146 | fail_free_ctx_mempool: |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4147 | if (ha->ctx_mempool) |
| 4148 | mempool_destroy(ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4149 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4150 | fail_free_srb_mempool: |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4151 | if (ha->srb_mempool) |
| 4152 | mempool_destroy(ha->srb_mempool); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4153 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4154 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 4155 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 4156 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4157 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4158 | ha->gid_list = NULL; |
| 4159 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4160 | fail_free_tgt_mem: |
| 4161 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4162 | fail_free_init_cb: |
| 4163 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 4164 | ha->init_cb_dma); |
| 4165 | ha->init_cb = NULL; |
| 4166 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4167 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4168 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 4169 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4170 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4171 | } |
| 4172 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4173 | int |
| 4174 | qla2x00_set_exlogins_buffer(scsi_qla_host_t *vha) |
| 4175 | { |
| 4176 | int rval; |
| 4177 | uint16_t size, max_cnt, temp; |
| 4178 | struct qla_hw_data *ha = vha->hw; |
| 4179 | |
| 4180 | /* Return if we don't need to alloacate any extended logins */ |
| 4181 | if (!ql2xexlogins) |
| 4182 | return QLA_SUCCESS; |
| 4183 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4184 | if (!IS_EXLOGIN_OFFLD_CAPABLE(ha)) |
| 4185 | return QLA_SUCCESS; |
| 4186 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4187 | ql_log(ql_log_info, vha, 0xd021, "EXLOGIN count: %d.\n", ql2xexlogins); |
| 4188 | max_cnt = 0; |
| 4189 | rval = qla_get_exlogin_status(vha, &size, &max_cnt); |
| 4190 | if (rval != QLA_SUCCESS) { |
| 4191 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd029, |
| 4192 | "Failed to get exlogin status.\n"); |
| 4193 | return rval; |
| 4194 | } |
| 4195 | |
| 4196 | temp = (ql2xexlogins > max_cnt) ? max_cnt : ql2xexlogins; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4197 | temp *= size; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4198 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4199 | if (temp != ha->exlogin_size) { |
| 4200 | qla2x00_free_exlogin_buffer(ha); |
| 4201 | ha->exlogin_size = temp; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4202 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4203 | ql_log(ql_log_info, vha, 0xd024, |
| 4204 | "EXLOGIN: max_logins=%d, portdb=0x%x, total=%d.\n", |
| 4205 | max_cnt, size, temp); |
| 4206 | |
| 4207 | ql_log(ql_log_info, vha, 0xd025, |
| 4208 | "EXLOGIN: requested size=0x%x\n", ha->exlogin_size); |
| 4209 | |
| 4210 | /* Get consistent memory for extended logins */ |
| 4211 | ha->exlogin_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 4212 | ha->exlogin_size, &ha->exlogin_buf_dma, GFP_KERNEL); |
| 4213 | if (!ha->exlogin_buf) { |
| 4214 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd02a, |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4215 | "Failed to allocate memory for exlogin_buf_dma.\n"); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4216 | return -ENOMEM; |
| 4217 | } |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4218 | } |
| 4219 | |
| 4220 | /* Now configure the dma buffer */ |
| 4221 | rval = qla_set_exlogin_mem_cfg(vha, ha->exlogin_buf_dma); |
| 4222 | if (rval) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4223 | ql_log(ql_log_fatal, vha, 0xd033, |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4224 | "Setup extended login buffer ****FAILED****.\n"); |
| 4225 | qla2x00_free_exlogin_buffer(ha); |
| 4226 | } |
| 4227 | |
| 4228 | return rval; |
| 4229 | } |
| 4230 | |
| 4231 | /* |
| 4232 | * qla2x00_free_exlogin_buffer |
| 4233 | * |
| 4234 | * Input: |
| 4235 | * ha = adapter block pointer |
| 4236 | */ |
| 4237 | void |
| 4238 | qla2x00_free_exlogin_buffer(struct qla_hw_data *ha) |
| 4239 | { |
| 4240 | if (ha->exlogin_buf) { |
| 4241 | dma_free_coherent(&ha->pdev->dev, ha->exlogin_size, |
| 4242 | ha->exlogin_buf, ha->exlogin_buf_dma); |
| 4243 | ha->exlogin_buf = NULL; |
| 4244 | ha->exlogin_size = 0; |
| 4245 | } |
| 4246 | } |
| 4247 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4248 | static void |
| 4249 | qla2x00_number_of_exch(scsi_qla_host_t *vha, u32 *ret_cnt, u16 max_cnt) |
| 4250 | { |
| 4251 | u32 temp; |
| 4252 | *ret_cnt = FW_DEF_EXCHANGES_CNT; |
| 4253 | |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4254 | if (max_cnt > vha->hw->max_exchg) |
| 4255 | max_cnt = vha->hw->max_exchg; |
| 4256 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4257 | if (qla_ini_mode_enabled(vha)) { |
| 4258 | if (ql2xiniexchg > max_cnt) |
| 4259 | ql2xiniexchg = max_cnt; |
| 4260 | |
| 4261 | if (ql2xiniexchg > FW_DEF_EXCHANGES_CNT) |
| 4262 | *ret_cnt = ql2xiniexchg; |
| 4263 | } else if (qla_tgt_mode_enabled(vha)) { |
| 4264 | if (ql2xexchoffld > max_cnt) |
| 4265 | ql2xexchoffld = max_cnt; |
| 4266 | |
| 4267 | if (ql2xexchoffld > FW_DEF_EXCHANGES_CNT) |
| 4268 | *ret_cnt = ql2xexchoffld; |
| 4269 | } else if (qla_dual_mode_enabled(vha)) { |
| 4270 | temp = ql2xiniexchg + ql2xexchoffld; |
| 4271 | if (temp > max_cnt) { |
| 4272 | ql2xiniexchg -= (temp - max_cnt)/2; |
| 4273 | ql2xexchoffld -= (((temp - max_cnt)/2) + 1); |
| 4274 | temp = max_cnt; |
| 4275 | } |
| 4276 | |
| 4277 | if (temp > FW_DEF_EXCHANGES_CNT) |
| 4278 | *ret_cnt = temp; |
| 4279 | } |
| 4280 | } |
| 4281 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4282 | int |
| 4283 | qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) |
| 4284 | { |
| 4285 | int rval; |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4286 | u16 size, max_cnt; |
| 4287 | u32 actual_cnt, totsz; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4288 | struct qla_hw_data *ha = vha->hw; |
| 4289 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4290 | if (!ha->flags.exchoffld_enabled) |
| 4291 | return QLA_SUCCESS; |
| 4292 | |
| 4293 | if (!IS_EXCHG_OFFLD_CAPABLE(ha)) |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4294 | return QLA_SUCCESS; |
| 4295 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4296 | max_cnt = 0; |
| 4297 | rval = qla_get_exchoffld_status(vha, &size, &max_cnt); |
| 4298 | if (rval != QLA_SUCCESS) { |
| 4299 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd012, |
| 4300 | "Failed to get exlogin status.\n"); |
| 4301 | return rval; |
| 4302 | } |
| 4303 | |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4304 | qla2x00_number_of_exch(vha, &actual_cnt, max_cnt); |
| 4305 | ql_log(ql_log_info, vha, 0xd014, |
| 4306 | "Actual exchange offload count: %d.\n", actual_cnt); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4307 | |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4308 | totsz = actual_cnt * size; |
| 4309 | |
| 4310 | if (totsz != ha->exchoffld_size) { |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4311 | qla2x00_free_exchoffld_buffer(ha); |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4312 | ha->exchoffld_size = totsz; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4313 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4314 | ql_log(ql_log_info, vha, 0xd016, |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4315 | "Exchange offload: max_count=%d, actual count=%d entry sz=0x%x, total sz=0x%x\n", |
| 4316 | max_cnt, actual_cnt, size, totsz); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4317 | |
| 4318 | ql_log(ql_log_info, vha, 0xd017, |
| 4319 | "Exchange Buffers requested size = 0x%x\n", |
| 4320 | ha->exchoffld_size); |
| 4321 | |
| 4322 | /* Get consistent memory for extended logins */ |
| 4323 | ha->exchoffld_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 4324 | ha->exchoffld_size, &ha->exchoffld_buf_dma, GFP_KERNEL); |
| 4325 | if (!ha->exchoffld_buf) { |
| 4326 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4327 | "Failed to allocate memory for Exchange Offload.\n"); |
| 4328 | |
| 4329 | if (ha->max_exchg > |
| 4330 | (FW_DEF_EXCHANGES_CNT + REDUCE_EXCHANGES_CNT)) { |
| 4331 | ha->max_exchg -= REDUCE_EXCHANGES_CNT; |
| 4332 | } else if (ha->max_exchg > |
| 4333 | (FW_DEF_EXCHANGES_CNT + 512)) { |
| 4334 | ha->max_exchg -= 512; |
| 4335 | } else { |
| 4336 | ha->flags.exchoffld_enabled = 0; |
| 4337 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
| 4338 | "Disabling Exchange offload due to lack of memory\n"); |
| 4339 | } |
| 4340 | ha->exchoffld_size = 0; |
| 4341 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4342 | return -ENOMEM; |
| 4343 | } |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4344 | } |
| 4345 | |
| 4346 | /* Now configure the dma buffer */ |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4347 | rval = qla_set_exchoffld_mem_cfg(vha); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4348 | if (rval) { |
| 4349 | ql_log(ql_log_fatal, vha, 0xd02e, |
| 4350 | "Setup exchange offload buffer ****FAILED****.\n"); |
| 4351 | qla2x00_free_exchoffld_buffer(ha); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4352 | } else { |
| 4353 | /* re-adjust number of target exchange */ |
| 4354 | struct init_cb_81xx *icb = (struct init_cb_81xx *)ha->init_cb; |
| 4355 | |
| 4356 | if (qla_ini_mode_enabled(vha)) |
| 4357 | icb->exchange_count = 0; |
| 4358 | else |
| 4359 | icb->exchange_count = cpu_to_le16(ql2xexchoffld); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4360 | } |
| 4361 | |
| 4362 | return rval; |
| 4363 | } |
| 4364 | |
| 4365 | /* |
| 4366 | * qla2x00_free_exchoffld_buffer |
| 4367 | * |
| 4368 | * Input: |
| 4369 | * ha = adapter block pointer |
| 4370 | */ |
| 4371 | void |
| 4372 | qla2x00_free_exchoffld_buffer(struct qla_hw_data *ha) |
| 4373 | { |
| 4374 | if (ha->exchoffld_buf) { |
| 4375 | dma_free_coherent(&ha->pdev->dev, ha->exchoffld_size, |
| 4376 | ha->exchoffld_buf, ha->exchoffld_buf_dma); |
| 4377 | ha->exchoffld_buf = NULL; |
| 4378 | ha->exchoffld_size = 0; |
| 4379 | } |
| 4380 | } |
| 4381 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4382 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4383 | * qla2x00_free_fw_dump |
| 4384 | * Frees fw dump stuff. |
| 4385 | * |
| 4386 | * Input: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 4387 | * ha = adapter block pointer |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4388 | */ |
| 4389 | static void |
| 4390 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 4391 | { |
| 4392 | if (ha->fce) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4393 | dma_free_coherent(&ha->pdev->dev, |
| 4394 | FCE_SIZE, ha->fce, ha->fce_dma); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4395 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4396 | if (ha->eft) |
| 4397 | dma_free_coherent(&ha->pdev->dev, |
| 4398 | EFT_SIZE, ha->eft, ha->eft_dma); |
| 4399 | |
| 4400 | if (ha->fw_dump) |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4401 | vfree(ha->fw_dump); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4402 | if (ha->fw_dump_template) |
| 4403 | vfree(ha->fw_dump_template); |
| 4404 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4405 | ha->fce = NULL; |
| 4406 | ha->fce_dma = 0; |
| 4407 | ha->eft = NULL; |
| 4408 | ha->eft_dma = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4409 | ha->fw_dumped = 0; |
Hiral Patel | 61f098d | 2014-04-11 16:54:21 -0400 | [diff] [blame] | 4410 | ha->fw_dump_cap_flags = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4411 | ha->fw_dump_reading = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4412 | ha->fw_dump = NULL; |
| 4413 | ha->fw_dump_len = 0; |
| 4414 | ha->fw_dump_template = NULL; |
| 4415 | ha->fw_dump_template_len = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4416 | } |
| 4417 | |
| 4418 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4419 | * qla2x00_mem_free |
| 4420 | * Frees all adapter allocated memory. |
| 4421 | * |
| 4422 | * Input: |
| 4423 | * ha = adapter block pointer. |
| 4424 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 4425 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4426 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4427 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4428 | qla2x00_free_fw_dump(ha); |
| 4429 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4430 | if (ha->mctp_dump) |
| 4431 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 4432 | ha->mctp_dump_dma); |
| 4433 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4434 | if (ha->srb_mempool) |
| 4435 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4436 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4437 | if (ha->dcbx_tlv) |
| 4438 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 4439 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 4440 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4441 | if (ha->xgmac_data) |
| 4442 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 4443 | ha->xgmac_data, ha->xgmac_data_dma); |
| 4444 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4445 | if (ha->sns_cmd) |
| 4446 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4447 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4448 | |
| 4449 | if (ha->ct_sns) |
| 4450 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4451 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4452 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 4453 | if (ha->sfp_data) |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4454 | dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE, ha->sfp_data, |
| 4455 | ha->sfp_data_dma); |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 4456 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4457 | if (ha->ms_iocb) |
| 4458 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 4459 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4460 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4461 | dma_pool_free(ha->s_dma_pool, |
| 4462 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4463 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4464 | if (ha->async_pd) |
| 4465 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 4466 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4467 | if (ha->s_dma_pool) |
| 4468 | dma_pool_destroy(ha->s_dma_pool); |
| 4469 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4470 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 4471 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 4472 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4473 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4474 | if (IS_QLA82XX(ha)) { |
| 4475 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 4476 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 4477 | |
| 4478 | /* clean up allocated prev pool */ |
| 4479 | list_for_each_entry_safe(dsd_ptr, |
| 4480 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 4481 | dma_pool_free(ha->dl_dma_pool, |
| 4482 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 4483 | list_del(&dsd_ptr->list); |
| 4484 | kfree(dsd_ptr); |
| 4485 | } |
| 4486 | } |
| 4487 | } |
| 4488 | |
| 4489 | if (ha->dl_dma_pool) |
| 4490 | dma_pool_destroy(ha->dl_dma_pool); |
| 4491 | |
| 4492 | if (ha->fcp_cmnd_dma_pool) |
| 4493 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 4494 | |
| 4495 | if (ha->ctx_mempool) |
| 4496 | mempool_destroy(ha->ctx_mempool); |
| 4497 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4498 | qlt_mem_free(ha); |
| 4499 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4500 | if (ha->init_cb) |
| 4501 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4502 | ha->init_cb, ha->init_cb_dma); |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 4503 | |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 4504 | vfree(ha->optrom_buffer); |
| 4505 | kfree(ha->nvram); |
| 4506 | kfree(ha->npiv_info); |
| 4507 | kfree(ha->swl); |
| 4508 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4509 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4510 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4511 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4512 | ha->sns_cmd = NULL; |
| 4513 | ha->sns_cmd_dma = 0; |
| 4514 | ha->ct_sns = NULL; |
| 4515 | ha->ct_sns_dma = 0; |
| 4516 | ha->ms_iocb = NULL; |
| 4517 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4518 | ha->init_cb = NULL; |
| 4519 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4520 | ha->ex_init_cb = NULL; |
| 4521 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4522 | ha->async_pd = NULL; |
| 4523 | ha->async_pd_dma = 0; |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 4524 | ha->loop_id_map = NULL; |
| 4525 | ha->npiv_info = NULL; |
| 4526 | ha->optrom_buffer = NULL; |
| 4527 | ha->swl = NULL; |
| 4528 | ha->nvram = NULL; |
| 4529 | ha->mctp_dump = NULL; |
| 4530 | ha->dcbx_tlv = NULL; |
| 4531 | ha->xgmac_data = NULL; |
| 4532 | ha->sfp_data = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4533 | |
| 4534 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4535 | ha->dl_dma_pool = NULL; |
| 4536 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4537 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4538 | ha->gid_list = NULL; |
| 4539 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4540 | |
| 4541 | ha->tgt.atio_ring = NULL; |
| 4542 | ha->tgt.atio_dma = 0; |
| 4543 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4544 | } |
| 4545 | |
| 4546 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 4547 | struct qla_hw_data *ha) |
| 4548 | { |
| 4549 | struct Scsi_Host *host; |
| 4550 | struct scsi_qla_host *vha = NULL; |
| 4551 | |
| 4552 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4553 | if (!host) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4554 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 4555 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4556 | return NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4557 | } |
| 4558 | |
| 4559 | /* Clear our data area */ |
| 4560 | vha = shost_priv(host); |
| 4561 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 4562 | |
| 4563 | vha->host = host; |
| 4564 | vha->host_no = host->host_no; |
| 4565 | vha->hw = ha; |
| 4566 | |
| 4567 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 4568 | INIT_LIST_HEAD(&vha->work_list); |
| 4569 | INIT_LIST_HEAD(&vha->list); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4570 | INIT_LIST_HEAD(&vha->qla_cmd_list); |
| 4571 | INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list); |
Alexei Potashnik | 71cdc07 | 2015-12-17 14:57:01 -0500 | [diff] [blame] | 4572 | INIT_LIST_HEAD(&vha->logo_list); |
Alexei Potashnik | b7bd104 | 2015-12-17 14:57:02 -0500 | [diff] [blame] | 4573 | INIT_LIST_HEAD(&vha->plogi_ack_list); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 4574 | INIT_LIST_HEAD(&vha->qp_list); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4575 | INIT_LIST_HEAD(&vha->gnl.fcports); |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 4576 | INIT_LIST_HEAD(&vha->nvme_rport_list); |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame] | 4577 | INIT_LIST_HEAD(&vha->gpnid_list); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4578 | INIT_WORK(&vha->iocb_work, qla2x00_iocb_work_fn); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4579 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4580 | spin_lock_init(&vha->work_lock); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4581 | spin_lock_init(&vha->cmd_list_lock); |
Hannes Reinecke | 1c6cacf | 2018-02-22 09:49:35 +0100 | [diff] [blame] | 4582 | spin_lock_init(&vha->gnl.fcports_lock); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4583 | init_waitqueue_head(&vha->fcport_waitQ); |
Joe Carnuccio | c4a9b53 | 2017-03-15 09:48:43 -0700 | [diff] [blame] | 4584 | init_waitqueue_head(&vha->vref_waitq); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4585 | |
Bart Van Assche | 2fdbc65 | 2017-01-20 13:31:13 -0800 | [diff] [blame] | 4586 | vha->gnl.size = sizeof(struct get_name_list_extended) * |
| 4587 | (ha->max_loop_id + 1); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4588 | vha->gnl.l = dma_alloc_coherent(&ha->pdev->dev, |
| 4589 | vha->gnl.size, &vha->gnl.ldma, GFP_KERNEL); |
| 4590 | if (!vha->gnl.l) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4591 | ql_log(ql_log_fatal, vha, 0xd04a, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4592 | "Alloc failed for name list.\n"); |
| 4593 | scsi_remove_host(vha->host); |
| 4594 | return NULL; |
| 4595 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4596 | |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4597 | /* todo: what about ext login? */ |
| 4598 | vha->scan.size = ha->max_fibre_devices * sizeof(struct fab_scan_rp); |
| 4599 | vha->scan.l = vmalloc(vha->scan.size); |
| 4600 | if (!vha->scan.l) { |
| 4601 | ql_log(ql_log_fatal, vha, 0xd04a, |
| 4602 | "Alloc failed for scan database.\n"); |
| 4603 | dma_free_coherent(&ha->pdev->dev, vha->gnl.size, |
| 4604 | vha->gnl.l, vha->gnl.ldma); |
| 4605 | scsi_remove_host(vha->host); |
| 4606 | return NULL; |
| 4607 | } |
Quinn Tran | f352eeb | 2017-12-28 12:33:35 -0800 | [diff] [blame] | 4608 | INIT_DELAYED_WORK(&vha->scan.scan_work, qla_scan_work_fn); |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4609 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4610 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4611 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 4612 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 4613 | vha->host, vha->hw, vha, |
| 4614 | dev_name(&(ha->pdev->dev))); |
| 4615 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4616 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4617 | } |
| 4618 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4619 | struct qla_work_evt * |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4620 | 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] | 4621 | { |
| 4622 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4623 | uint8_t bail; |
| 4624 | |
| 4625 | QLA_VHA_MARK_BUSY(vha, bail); |
| 4626 | if (bail) |
| 4627 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4628 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4629 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4630 | if (!e) { |
| 4631 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4632 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4633 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4634 | |
| 4635 | INIT_LIST_HEAD(&e->list); |
| 4636 | e->type = type; |
| 4637 | e->flags = QLA_EVT_FLAG_FREE; |
| 4638 | return e; |
| 4639 | } |
| 4640 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4641 | int |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4642 | 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] | 4643 | { |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4644 | unsigned long flags; |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4645 | bool q = false; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4646 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4647 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4648 | list_add_tail(&e->list, &vha->work_list); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4649 | |
| 4650 | if (!test_and_set_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags)) |
| 4651 | q = true; |
| 4652 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4653 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 4654 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4655 | if (q) |
| 4656 | queue_work(vha->hw->wq, &vha->iocb_work); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4657 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4658 | return QLA_SUCCESS; |
| 4659 | } |
| 4660 | |
| 4661 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4662 | 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] | 4663 | u32 data) |
| 4664 | { |
| 4665 | struct qla_work_evt *e; |
| 4666 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4667 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4668 | if (!e) |
| 4669 | return QLA_FUNCTION_FAILED; |
| 4670 | |
| 4671 | e->u.aen.code = code; |
| 4672 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4673 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4674 | } |
| 4675 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4676 | int |
| 4677 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 4678 | { |
| 4679 | struct qla_work_evt *e; |
| 4680 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4681 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4682 | if (!e) |
| 4683 | return QLA_FUNCTION_FAILED; |
| 4684 | |
| 4685 | 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] | 4686 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4687 | } |
| 4688 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4689 | #define qla2x00_post_async_work(name, type) \ |
| 4690 | int qla2x00_post_async_##name##_work( \ |
| 4691 | struct scsi_qla_host *vha, \ |
| 4692 | fc_port_t *fcport, uint16_t *data) \ |
| 4693 | { \ |
| 4694 | struct qla_work_evt *e; \ |
| 4695 | \ |
| 4696 | e = qla2x00_alloc_work(vha, type); \ |
| 4697 | if (!e) \ |
| 4698 | return QLA_FUNCTION_FAILED; \ |
| 4699 | \ |
| 4700 | e->u.logio.fcport = fcport; \ |
| 4701 | if (data) { \ |
| 4702 | e->u.logio.data[0] = data[0]; \ |
| 4703 | e->u.logio.data[1] = data[1]; \ |
| 4704 | } \ |
Quinn Tran | 6d674927 | 2017-12-28 12:33:41 -0800 | [diff] [blame] | 4705 | fcport->flags |= FCF_ASYNC_ACTIVE; \ |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4706 | return qla2x00_post_work(vha, e); \ |
| 4707 | } |
| 4708 | |
| 4709 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4710 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 4711 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4712 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 4713 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Quinn Tran | 11aea16 | 2017-12-28 12:33:20 -0800 | [diff] [blame] | 4714 | qla2x00_post_async_work(prlo, QLA_EVT_ASYNC_PRLO); |
| 4715 | qla2x00_post_async_work(prlo_done, QLA_EVT_ASYNC_PRLO_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4716 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4717 | int |
| 4718 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 4719 | { |
| 4720 | struct qla_work_evt *e; |
| 4721 | |
| 4722 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 4723 | if (!e) |
| 4724 | return QLA_FUNCTION_FAILED; |
| 4725 | |
| 4726 | e->u.uevent.code = code; |
| 4727 | return qla2x00_post_work(vha, e); |
| 4728 | } |
| 4729 | |
| 4730 | static void |
| 4731 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 4732 | { |
| 4733 | char event_string[40]; |
| 4734 | char *envp[] = { event_string, NULL }; |
| 4735 | |
| 4736 | switch (code) { |
| 4737 | case QLA_UEVENT_CODE_FW_DUMP: |
| 4738 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 4739 | vha->host_no); |
| 4740 | break; |
| 4741 | default: |
| 4742 | /* do nothing */ |
| 4743 | break; |
| 4744 | } |
| 4745 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 4746 | } |
| 4747 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4748 | int |
| 4749 | qlafx00_post_aenfx_work(struct scsi_qla_host *vha, uint32_t evtcode, |
| 4750 | uint32_t *data, int cnt) |
| 4751 | { |
| 4752 | struct qla_work_evt *e; |
| 4753 | |
| 4754 | e = qla2x00_alloc_work(vha, QLA_EVT_AENFX); |
| 4755 | if (!e) |
| 4756 | return QLA_FUNCTION_FAILED; |
| 4757 | |
| 4758 | e->u.aenfx.evtcode = evtcode; |
| 4759 | e->u.aenfx.count = cnt; |
| 4760 | memcpy(e->u.aenfx.mbx, data, sizeof(*data) * cnt); |
| 4761 | return qla2x00_post_work(vha, e); |
| 4762 | } |
| 4763 | |
Quinn Tran | cd4ed6b | 2018-08-31 11:24:31 -0700 | [diff] [blame] | 4764 | void qla24xx_sched_upd_fcport(fc_port_t *fcport) |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4765 | { |
Quinn Tran | cd4ed6b | 2018-08-31 11:24:31 -0700 | [diff] [blame] | 4766 | unsigned long flags; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4767 | |
Quinn Tran | cd4ed6b | 2018-08-31 11:24:31 -0700 | [diff] [blame] | 4768 | if (IS_SW_RESV_ADDR(fcport->d_id)) |
| 4769 | return; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4770 | |
Quinn Tran | cd4ed6b | 2018-08-31 11:24:31 -0700 | [diff] [blame] | 4771 | spin_lock_irqsave(&fcport->vha->work_lock, flags); |
| 4772 | if (fcport->disc_state == DSC_UPD_FCPORT) { |
| 4773 | spin_unlock_irqrestore(&fcport->vha->work_lock, flags); |
| 4774 | return; |
| 4775 | } |
| 4776 | fcport->jiffies_at_registration = jiffies; |
| 4777 | fcport->sec_since_registration = 0; |
| 4778 | fcport->next_disc_state = DSC_DELETED; |
| 4779 | fcport->disc_state = DSC_UPD_FCPORT; |
| 4780 | spin_unlock_irqrestore(&fcport->vha->work_lock, flags); |
| 4781 | |
| 4782 | queue_work(system_unbound_wq, &fcport->reg_work); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4783 | } |
| 4784 | |
| 4785 | static |
| 4786 | void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) |
| 4787 | { |
| 4788 | unsigned long flags; |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4789 | fc_port_t *fcport = NULL, *tfcp; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4790 | struct qlt_plogi_ack_t *pla = |
| 4791 | (struct qlt_plogi_ack_t *)e->u.new_sess.pla; |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4792 | uint8_t free_fcport = 0; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4793 | |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4794 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 4795 | "%s %d %8phC enter\n", |
| 4796 | __func__, __LINE__, e->u.new_sess.port_name); |
| 4797 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4798 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 4799 | fcport = qla2x00_find_fcport_by_wwpn(vha, e->u.new_sess.port_name, 1); |
| 4800 | if (fcport) { |
| 4801 | fcport->d_id = e->u.new_sess.id; |
| 4802 | if (pla) { |
| 4803 | fcport->fw_login_state = DSC_LS_PLOGI_PEND; |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4804 | memcpy(fcport->node_name, |
| 4805 | pla->iocb.u.isp24.u.plogi.node_name, |
| 4806 | WWN_SIZE); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4807 | qlt_plogi_ack_link(vha, pla, fcport, QLT_PLOGI_LINK_SAME_WWN); |
| 4808 | /* we took an extra ref_count to prevent PLOGI ACK when |
| 4809 | * fcport/sess has not been created. |
| 4810 | */ |
| 4811 | pla->ref_count--; |
| 4812 | } |
| 4813 | } else { |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4814 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4815 | fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
| 4816 | if (fcport) { |
| 4817 | fcport->d_id = e->u.new_sess.id; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4818 | fcport->flags |= FCF_FABRIC_DEVICE; |
| 4819 | fcport->fw_login_state = DSC_LS_PLOGI_PEND; |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 4820 | if (e->u.new_sess.fc4_type == FS_FC4TYPE_FCP) |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4821 | fcport->fc4_type = FC4_TYPE_FCP_SCSI; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4822 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 4823 | if (e->u.new_sess.fc4_type == FS_FC4TYPE_NVME) { |
Darren Trapp | 2b5b964 | 2018-02-27 16:31:12 -0800 | [diff] [blame] | 4824 | fcport->fc4_type = FC4_TYPE_OTHER; |
| 4825 | fcport->fc4f_nvme = FC4_TYPE_NVME; |
| 4826 | } |
Quinn Tran | 33b2835 | 2018-03-20 23:09:40 -0700 | [diff] [blame] | 4827 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4828 | memcpy(fcport->port_name, e->u.new_sess.port_name, |
| 4829 | WWN_SIZE); |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4830 | } else { |
| 4831 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 4832 | "%s %8phC mem alloc fail.\n", |
| 4833 | __func__, e->u.new_sess.port_name); |
| 4834 | |
| 4835 | if (pla) |
| 4836 | kmem_cache_free(qla_tgt_plogi_cachep, pla); |
| 4837 | return; |
| 4838 | } |
| 4839 | |
| 4840 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4841 | /* search again to make sure no one else got ahead */ |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4842 | tfcp = qla2x00_find_fcport_by_wwpn(vha, |
| 4843 | e->u.new_sess.port_name, 1); |
| 4844 | if (tfcp) { |
| 4845 | /* should rarily happen */ |
| 4846 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 4847 | "%s %8phC found existing fcport b4 add. DS %d LS %d\n", |
| 4848 | __func__, tfcp->port_name, tfcp->disc_state, |
| 4849 | tfcp->fw_login_state); |
| 4850 | |
| 4851 | free_fcport = 1; |
| 4852 | } else { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4853 | list_add_tail(&fcport->list, &vha->vp_fcports); |
| 4854 | |
Quinn Tran | 1975903 | 2017-12-04 14:45:15 -0800 | [diff] [blame] | 4855 | } |
| 4856 | if (pla) { |
| 4857 | qlt_plogi_ack_link(vha, pla, fcport, |
| 4858 | QLT_PLOGI_LINK_SAME_WWN); |
| 4859 | pla->ref_count--; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4860 | } |
| 4861 | } |
| 4862 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 4863 | |
| 4864 | if (fcport) { |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4865 | fcport->id_changed = 1; |
| 4866 | fcport->scan_state = QLA_FCPORT_FOUND; |
| 4867 | memcpy(fcport->node_name, e->u.new_sess.node_name, WWN_SIZE); |
| 4868 | |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 4869 | if (pla) { |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 4870 | if (pla->iocb.u.isp24.status_subcode == ELS_PRLI) { |
| 4871 | u16 wd3_lo; |
| 4872 | |
| 4873 | fcport->fw_login_state = DSC_LS_PRLI_PEND; |
| 4874 | fcport->local = 0; |
| 4875 | fcport->loop_id = |
| 4876 | le16_to_cpu( |
| 4877 | pla->iocb.u.isp24.nport_handle); |
| 4878 | fcport->fw_login_state = DSC_LS_PRLI_PEND; |
| 4879 | wd3_lo = |
| 4880 | le16_to_cpu( |
| 4881 | pla->iocb.u.isp24.u.prli.wd3_lo); |
| 4882 | |
| 4883 | if (wd3_lo & BIT_7) |
| 4884 | fcport->conf_compl_supported = 1; |
| 4885 | |
| 4886 | if ((wd3_lo & BIT_4) == 0) |
| 4887 | fcport->port_type = FCT_INITIATOR; |
| 4888 | else |
| 4889 | fcport->port_type = FCT_TARGET; |
| 4890 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4891 | qlt_plogi_ack_unref(vha, pla); |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 4892 | } else { |
Hannes Reinecke | 1c6cacf | 2018-02-22 09:49:35 +0100 | [diff] [blame] | 4893 | fc_port_t *dfcp = NULL; |
| 4894 | |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 4895 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 4896 | tfcp = qla2x00_find_fcport_by_nportid(vha, |
| 4897 | &e->u.new_sess.id, 1); |
| 4898 | if (tfcp && (tfcp != fcport)) { |
| 4899 | /* |
| 4900 | * We have a conflict fcport with same NportID. |
| 4901 | */ |
| 4902 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 4903 | "%s %8phC found conflict b4 add. DS %d LS %d\n", |
| 4904 | __func__, tfcp->port_name, tfcp->disc_state, |
| 4905 | tfcp->fw_login_state); |
| 4906 | |
| 4907 | switch (tfcp->disc_state) { |
| 4908 | case DSC_DELETED: |
| 4909 | break; |
| 4910 | case DSC_DELETE_PEND: |
| 4911 | fcport->login_pause = 1; |
| 4912 | tfcp->conflict = fcport; |
| 4913 | break; |
| 4914 | default: |
| 4915 | fcport->login_pause = 1; |
| 4916 | tfcp->conflict = fcport; |
Hannes Reinecke | 1c6cacf | 2018-02-22 09:49:35 +0100 | [diff] [blame] | 4917 | dfcp = tfcp; |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 4918 | break; |
| 4919 | } |
| 4920 | } |
| 4921 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
Hannes Reinecke | 1c6cacf | 2018-02-22 09:49:35 +0100 | [diff] [blame] | 4922 | if (dfcp) |
| 4923 | qlt_schedule_sess_for_deletion(tfcp); |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4924 | |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4925 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 4926 | if (N2N_TOPO(vha->hw)) |
| 4927 | fcport->flags &= ~FCF_FABRIC_DEVICE; |
| 4928 | |
| 4929 | if (N2N_TOPO(vha->hw)) { |
| 4930 | if (vha->flags.nvme_enabled) { |
| 4931 | fcport->fc4f_nvme = 1; |
| 4932 | fcport->n2n_flag = 1; |
| 4933 | } |
| 4934 | fcport->fw_login_state = 0; |
| 4935 | /* |
| 4936 | * wait link init done before sending login |
| 4937 | */ |
| 4938 | } else { |
| 4939 | qla24xx_fcport_handle_login(vha, fcport); |
| 4940 | } |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 4941 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4942 | } |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 4943 | |
| 4944 | if (free_fcport) { |
| 4945 | qla2x00_free_fcport(fcport); |
| 4946 | if (pla) |
| 4947 | kmem_cache_free(qla_tgt_plogi_cachep, pla); |
| 4948 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4949 | } |
| 4950 | |
Quinn Tran | e374f9f | 2017-12-28 12:33:31 -0800 | [diff] [blame] | 4951 | static void qla_sp_retry(struct scsi_qla_host *vha, struct qla_work_evt *e) |
| 4952 | { |
| 4953 | struct srb *sp = e->u.iosb.sp; |
| 4954 | int rval; |
| 4955 | |
| 4956 | rval = qla2x00_start_sp(sp); |
| 4957 | if (rval != QLA_SUCCESS) { |
| 4958 | ql_dbg(ql_dbg_disc, vha, 0x2043, |
| 4959 | "%s: %s: Re-issue IOCB failed (%d).\n", |
| 4960 | __func__, sp->name, rval); |
| 4961 | qla24xx_sp_unmap(vha, sp); |
| 4962 | } |
| 4963 | } |
| 4964 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4965 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4966 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4967 | { |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4968 | struct qla_work_evt *e, *tmp; |
| 4969 | unsigned long flags; |
| 4970 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4971 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4972 | spin_lock_irqsave(&vha->work_lock, flags); |
| 4973 | list_splice_init(&vha->work_list, &work); |
| 4974 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 4975 | |
| 4976 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4977 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4978 | |
| 4979 | switch (e->type) { |
| 4980 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4981 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4982 | e->u.aen.code, e->u.aen.data); |
| 4983 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4984 | case QLA_EVT_IDC_ACK: |
| 4985 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 4986 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4987 | case QLA_EVT_ASYNC_LOGIN: |
| 4988 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 4989 | e->u.logio.data); |
| 4990 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4991 | case QLA_EVT_ASYNC_LOGOUT: |
| 4992 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 4993 | break; |
| 4994 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 4995 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 4996 | e->u.logio.data); |
| 4997 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4998 | case QLA_EVT_ASYNC_ADISC: |
| 4999 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 5000 | e->u.logio.data); |
| 5001 | break; |
| 5002 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 5003 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 5004 | e->u.logio.data); |
| 5005 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 5006 | case QLA_EVT_UEVENT: |
| 5007 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 5008 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5009 | case QLA_EVT_AENFX: |
| 5010 | qlafx00_process_aen(vha, e); |
| 5011 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5012 | case QLA_EVT_GIDPN: |
| 5013 | qla24xx_async_gidpn(vha, e->u.fcport.fcport); |
| 5014 | break; |
| 5015 | case QLA_EVT_GPNID: |
| 5016 | qla24xx_async_gpnid(vha, &e->u.gpnid.id); |
| 5017 | break; |
Quinn Tran | e374f9f | 2017-12-28 12:33:31 -0800 | [diff] [blame] | 5018 | case QLA_EVT_UNMAP: |
| 5019 | qla24xx_sp_unmap(vha, e->u.iosb.sp); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5020 | break; |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5021 | case QLA_EVT_RELOGIN: |
| 5022 | qla2x00_relogin(vha); |
| 5023 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5024 | case QLA_EVT_NEW_SESS: |
| 5025 | qla24xx_create_new_sess(vha, e); |
| 5026 | break; |
| 5027 | case QLA_EVT_GPDB: |
| 5028 | qla24xx_async_gpdb(vha, e->u.fcport.fcport, |
| 5029 | e->u.fcport.opt); |
| 5030 | break; |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 5031 | case QLA_EVT_PRLI: |
| 5032 | qla24xx_async_prli(vha, e->u.fcport.fcport); |
| 5033 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5034 | case QLA_EVT_GPSC: |
| 5035 | qla24xx_async_gpsc(vha, e->u.fcport.fcport); |
| 5036 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5037 | case QLA_EVT_GNL: |
| 5038 | qla24xx_async_gnl(vha, e->u.fcport.fcport); |
| 5039 | break; |
| 5040 | case QLA_EVT_NACK: |
| 5041 | qla24xx_do_nack_work(vha, e); |
| 5042 | break; |
Quinn Tran | 11aea16 | 2017-12-28 12:33:20 -0800 | [diff] [blame] | 5043 | case QLA_EVT_ASYNC_PRLO: |
| 5044 | qla2x00_async_prlo(vha, e->u.logio.fcport); |
| 5045 | break; |
| 5046 | case QLA_EVT_ASYNC_PRLO_DONE: |
| 5047 | qla2x00_async_prlo_done(vha, e->u.logio.fcport, |
| 5048 | e->u.logio.data); |
| 5049 | break; |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 5050 | case QLA_EVT_GPNFT: |
Quinn Tran | 33b2835 | 2018-03-20 23:09:40 -0700 | [diff] [blame] | 5051 | qla24xx_async_gpnft(vha, e->u.gpnft.fc4_type, |
| 5052 | e->u.gpnft.sp); |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 5053 | break; |
| 5054 | case QLA_EVT_GPNFT_DONE: |
| 5055 | qla24xx_async_gpnft_done(vha, e->u.iosb.sp); |
| 5056 | break; |
| 5057 | case QLA_EVT_GNNFT_DONE: |
| 5058 | qla24xx_async_gnnft_done(vha, e->u.iosb.sp); |
| 5059 | break; |
| 5060 | case QLA_EVT_GNNID: |
| 5061 | qla24xx_async_gnnid(vha, e->u.fcport.fcport); |
| 5062 | break; |
| 5063 | case QLA_EVT_GFPNID: |
| 5064 | qla24xx_async_gfpnid(vha, e->u.fcport.fcport); |
| 5065 | break; |
Quinn Tran | e374f9f | 2017-12-28 12:33:31 -0800 | [diff] [blame] | 5066 | case QLA_EVT_SP_RETRY: |
| 5067 | qla_sp_retry(vha, e); |
Quinn Tran | cc28e0a | 2018-05-01 09:01:48 -0700 | [diff] [blame] | 5068 | break; |
| 5069 | case QLA_EVT_IIDMA: |
| 5070 | qla_do_iidma_work(vha, e->u.fcport.fcport); |
| 5071 | break; |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 5072 | case QLA_EVT_ELS_PLOGI: |
| 5073 | qla24xx_els_dcmd2_iocb(vha, ELS_DCMD_PLOGI, |
| 5074 | e->u.fcport.fcport, false); |
| 5075 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5076 | } |
| 5077 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 5078 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 5079 | |
| 5080 | /* For each work completed decrement vha ref count */ |
| 5081 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5082 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5083 | } |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 5084 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5085 | int qla24xx_post_relogin_work(struct scsi_qla_host *vha) |
| 5086 | { |
| 5087 | struct qla_work_evt *e; |
| 5088 | |
| 5089 | e = qla2x00_alloc_work(vha, QLA_EVT_RELOGIN); |
| 5090 | |
| 5091 | if (!e) { |
| 5092 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 5093 | return QLA_FUNCTION_FAILED; |
| 5094 | } |
| 5095 | |
| 5096 | return qla2x00_post_work(vha, e); |
| 5097 | } |
| 5098 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5099 | /* Relogins all the fcports of a vport |
| 5100 | * Context: dpc thread |
| 5101 | */ |
| 5102 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 5103 | { |
| 5104 | fc_port_t *fcport; |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 5105 | int status, relogin_needed = 0; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5106 | struct event_arg ea; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5107 | |
| 5108 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 5109 | /* |
| 5110 | * If the port is not ONLINE then try to login |
| 5111 | * to it if we haven't run out of retries. |
| 5112 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 5113 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 5114 | fcport->login_retry) { |
| 5115 | if (fcport->scan_state != QLA_FCPORT_FOUND || |
| 5116 | fcport->disc_state == DSC_LOGIN_COMPLETE) |
| 5117 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5118 | |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 5119 | if (fcport->flags & (FCF_ASYNC_SENT|FCF_ASYNC_ACTIVE) || |
| 5120 | fcport->disc_state == DSC_DELETE_PEND) { |
| 5121 | relogin_needed = 1; |
| 5122 | } else { |
| 5123 | if (vha->hw->current_topology != ISP_CFG_NL) { |
| 5124 | memset(&ea, 0, sizeof(ea)); |
| 5125 | ea.event = FCME_RELOGIN; |
| 5126 | ea.fcport = fcport; |
| 5127 | qla2x00_fcport_event_handler(vha, &ea); |
| 5128 | } else if (vha->hw->current_topology == |
| 5129 | ISP_CFG_NL) { |
| 5130 | fcport->login_retry--; |
| 5131 | status = |
| 5132 | qla2x00_local_device_login(vha, |
| 5133 | fcport); |
| 5134 | if (status == QLA_SUCCESS) { |
| 5135 | fcport->old_loop_id = |
| 5136 | fcport->loop_id; |
| 5137 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 5138 | "Port login OK: logged in ID 0x%x.\n", |
| 5139 | fcport->loop_id); |
| 5140 | qla2x00_update_fcport |
| 5141 | (vha, fcport); |
| 5142 | } else if (status == 1) { |
| 5143 | set_bit(RELOGIN_NEEDED, |
| 5144 | &vha->dpc_flags); |
| 5145 | /* retry the login again */ |
| 5146 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 5147 | "Retrying %d login again loop_id 0x%x.\n", |
| 5148 | fcport->login_retry, |
| 5149 | fcport->loop_id); |
| 5150 | } else { |
| 5151 | fcport->login_retry = 0; |
| 5152 | } |
| 5153 | |
| 5154 | if (fcport->login_retry == 0 && |
| 5155 | status != QLA_SUCCESS) |
| 5156 | qla2x00_clear_loop_id(fcport); |
| 5157 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5158 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5159 | } |
| 5160 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 5161 | break; |
| 5162 | } |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5163 | |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 5164 | if (relogin_needed) |
| 5165 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 5166 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5167 | ql_dbg(ql_dbg_disc, vha, 0x400e, |
| 5168 | "Relogin end.\n"); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5169 | } |
| 5170 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5171 | /* Schedule work on any of the dpc-workqueues */ |
| 5172 | void |
| 5173 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 5174 | { |
| 5175 | struct qla_hw_data *ha = base_vha->hw; |
| 5176 | |
| 5177 | switch (work_code) { |
| 5178 | case MBA_IDC_AEN: /* 0x8200 */ |
| 5179 | if (ha->dpc_lp_wq) |
| 5180 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 5181 | break; |
| 5182 | |
| 5183 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 5184 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 5185 | if (ha->dpc_hp_wq) |
| 5186 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 5187 | } else |
| 5188 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 5189 | "NIC Core reset is already active. Skip " |
| 5190 | "scheduling it again.\n"); |
| 5191 | break; |
| 5192 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 5193 | if (ha->dpc_hp_wq) |
| 5194 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 5195 | break; |
| 5196 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 5197 | if (ha->dpc_hp_wq) |
| 5198 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 5199 | break; |
| 5200 | default: |
| 5201 | ql_log(ql_log_warn, base_vha, 0xb05f, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 5202 | "Unknown work-code=0x%x.\n", work_code); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5203 | } |
| 5204 | |
| 5205 | return; |
| 5206 | } |
| 5207 | |
| 5208 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 5209 | void |
| 5210 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 5211 | { |
| 5212 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 5213 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5214 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5215 | uint32_t dev_state = 0; |
| 5216 | |
| 5217 | qla83xx_idc_lock(base_vha, 0); |
| 5218 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5219 | qla83xx_reset_ownership(base_vha); |
| 5220 | if (ha->flags.nic_core_reset_owner) { |
| 5221 | ha->flags.nic_core_reset_owner = 0; |
| 5222 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5223 | QLA8XXX_DEV_FAILED); |
| 5224 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 5225 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 5226 | } |
| 5227 | qla83xx_idc_unlock(base_vha, 0); |
| 5228 | } |
| 5229 | |
| 5230 | /* Work: Execute IDC state handler */ |
| 5231 | void |
| 5232 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 5233 | { |
| 5234 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 5235 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5236 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5237 | uint32_t dev_state = 0; |
| 5238 | |
| 5239 | qla83xx_idc_lock(base_vha, 0); |
| 5240 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5241 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 5242 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 5243 | qla83xx_idc_state_handler(base_vha); |
| 5244 | qla83xx_idc_unlock(base_vha, 0); |
| 5245 | } |
| 5246 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5247 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5248 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 5249 | { |
| 5250 | int rval = QLA_SUCCESS; |
| 5251 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 5252 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 5253 | |
| 5254 | do { |
| 5255 | if (time_after(jiffies, heart_beat_wait)) { |
| 5256 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 5257 | "Nic Core f/w is not alive.\n"); |
| 5258 | rval = QLA_FUNCTION_FAILED; |
| 5259 | break; |
| 5260 | } |
| 5261 | |
| 5262 | qla83xx_idc_lock(base_vha, 0); |
| 5263 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 5264 | &heart_beat_counter1); |
| 5265 | qla83xx_idc_unlock(base_vha, 0); |
| 5266 | msleep(100); |
| 5267 | qla83xx_idc_lock(base_vha, 0); |
| 5268 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 5269 | &heart_beat_counter2); |
| 5270 | qla83xx_idc_unlock(base_vha, 0); |
| 5271 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 5272 | |
| 5273 | return rval; |
| 5274 | } |
| 5275 | |
| 5276 | /* Work: Perform NIC Core Reset handling */ |
| 5277 | void |
| 5278 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 5279 | { |
| 5280 | struct qla_hw_data *ha = |
| 5281 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 5282 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5283 | uint32_t dev_state = 0; |
| 5284 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 5285 | if (IS_QLA2031(ha)) { |
| 5286 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 5287 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 5288 | "Failed to dump mctp\n"); |
| 5289 | return; |
| 5290 | } |
| 5291 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5292 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 5293 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 5294 | qla83xx_idc_lock(base_vha, 0); |
| 5295 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5296 | &dev_state); |
| 5297 | qla83xx_idc_unlock(base_vha, 0); |
| 5298 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 5299 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 5300 | "Nic Core f/w is alive.\n"); |
| 5301 | return; |
| 5302 | } |
| 5303 | } |
| 5304 | |
| 5305 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 5306 | if (qla83xx_nic_core_reset(base_vha)) { |
| 5307 | /* NIC Core reset failed. */ |
| 5308 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 5309 | "NIC Core reset failed.\n"); |
| 5310 | } |
| 5311 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 5312 | } |
| 5313 | } |
| 5314 | |
| 5315 | /* Work: Handle 8200 IDC aens */ |
| 5316 | void |
| 5317 | qla83xx_service_idc_aen(struct work_struct *work) |
| 5318 | { |
| 5319 | struct qla_hw_data *ha = |
| 5320 | container_of(work, struct qla_hw_data, idc_aen); |
| 5321 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5322 | uint32_t dev_state, idc_control; |
| 5323 | |
| 5324 | qla83xx_idc_lock(base_vha, 0); |
| 5325 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5326 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 5327 | qla83xx_idc_unlock(base_vha, 0); |
| 5328 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 5329 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 5330 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 5331 | "Application requested NIC Core Reset.\n"); |
| 5332 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 5333 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 5334 | QLA_SUCCESS) { |
| 5335 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 5336 | "Other protocol driver requested NIC Core Reset.\n"); |
| 5337 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 5338 | } |
| 5339 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 5340 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 5341 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 5342 | } |
| 5343 | } |
| 5344 | |
| 5345 | static void |
| 5346 | qla83xx_wait_logic(void) |
| 5347 | { |
| 5348 | int i; |
| 5349 | |
| 5350 | /* Yield CPU */ |
| 5351 | if (!in_interrupt()) { |
| 5352 | /* |
| 5353 | * Wait about 200ms before retrying again. |
| 5354 | * This controls the number of retries for single |
| 5355 | * lock operation. |
| 5356 | */ |
| 5357 | msleep(100); |
| 5358 | schedule(); |
| 5359 | } else { |
| 5360 | for (i = 0; i < 20; i++) |
| 5361 | cpu_relax(); /* This a nop instr on i386 */ |
| 5362 | } |
| 5363 | } |
| 5364 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5365 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5366 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 5367 | { |
| 5368 | int rval; |
| 5369 | uint32_t data; |
| 5370 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 5371 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 5372 | struct qla_hw_data *ha = base_vha->hw; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5373 | ql_dbg(ql_dbg_p3p, base_vha, 0xb086, |
| 5374 | "Trying force recovery of the IDC lock.\n"); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5375 | |
| 5376 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 5377 | if (rval) |
| 5378 | return rval; |
| 5379 | |
| 5380 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 5381 | return QLA_SUCCESS; |
| 5382 | } else { |
| 5383 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 5384 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 5385 | data); |
| 5386 | if (rval) |
| 5387 | return rval; |
| 5388 | |
| 5389 | msleep(200); |
| 5390 | |
| 5391 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 5392 | &data); |
| 5393 | if (rval) |
| 5394 | return rval; |
| 5395 | |
| 5396 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 5397 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 5398 | ~(idc_lck_rcvry_stage_mask)); |
| 5399 | rval = qla83xx_wr_reg(base_vha, |
| 5400 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 5401 | if (rval) |
| 5402 | return rval; |
| 5403 | |
| 5404 | /* Forcefully perform IDC UnLock */ |
| 5405 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 5406 | &data); |
| 5407 | if (rval) |
| 5408 | return rval; |
| 5409 | /* Clear lock-id by setting 0xff */ |
| 5410 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5411 | 0xff); |
| 5412 | if (rval) |
| 5413 | return rval; |
| 5414 | /* Clear lock-recovery by setting 0x0 */ |
| 5415 | rval = qla83xx_wr_reg(base_vha, |
| 5416 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 5417 | if (rval) |
| 5418 | return rval; |
| 5419 | } else |
| 5420 | return QLA_SUCCESS; |
| 5421 | } |
| 5422 | |
| 5423 | return rval; |
| 5424 | } |
| 5425 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5426 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5427 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 5428 | { |
| 5429 | int rval = QLA_SUCCESS; |
| 5430 | uint32_t o_drv_lockid, n_drv_lockid; |
| 5431 | unsigned long lock_recovery_timeout; |
| 5432 | |
| 5433 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 5434 | retry_lockid: |
| 5435 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 5436 | if (rval) |
| 5437 | goto exit; |
| 5438 | |
| 5439 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 5440 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 5441 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 5442 | return QLA_SUCCESS; |
| 5443 | else |
| 5444 | return QLA_FUNCTION_FAILED; |
| 5445 | } |
| 5446 | |
| 5447 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 5448 | if (rval) |
| 5449 | goto exit; |
| 5450 | |
| 5451 | if (o_drv_lockid == n_drv_lockid) { |
| 5452 | qla83xx_wait_logic(); |
| 5453 | goto retry_lockid; |
| 5454 | } else |
| 5455 | return QLA_SUCCESS; |
| 5456 | |
| 5457 | exit: |
| 5458 | return rval; |
| 5459 | } |
| 5460 | |
| 5461 | void |
| 5462 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 5463 | { |
| 5464 | uint16_t options = (requester_id << 15) | BIT_6; |
| 5465 | uint32_t data; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5466 | uint32_t lock_owner; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5467 | struct qla_hw_data *ha = base_vha->hw; |
| 5468 | |
| 5469 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 5470 | retry_lock: |
| 5471 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 5472 | == QLA_SUCCESS) { |
| 5473 | if (data) { |
| 5474 | /* Setting lock-id to our function-number */ |
| 5475 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5476 | ha->portnum); |
| 5477 | } else { |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5478 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5479 | &lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5480 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5481 | "Failed to acquire IDC lock, acquired by %d, " |
| 5482 | "retrying...\n", lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5483 | |
| 5484 | /* Retry/Perform IDC-Lock recovery */ |
| 5485 | if (qla83xx_idc_lock_recovery(base_vha) |
| 5486 | == QLA_SUCCESS) { |
| 5487 | qla83xx_wait_logic(); |
| 5488 | goto retry_lock; |
| 5489 | } else |
| 5490 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 5491 | "IDC Lock recovery FAILED.\n"); |
| 5492 | } |
| 5493 | |
| 5494 | } |
| 5495 | |
| 5496 | return; |
| 5497 | |
| 5498 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 5499 | retry_lock2: |
| 5500 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 5501 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 5502 | "Failed to acquire IDC lock. retrying...\n"); |
| 5503 | /* Retry/Perform IDC-Lock recovery */ |
| 5504 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 5505 | qla83xx_wait_logic(); |
| 5506 | goto retry_lock2; |
| 5507 | } else |
| 5508 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 5509 | "IDC Lock recovery FAILED.\n"); |
| 5510 | } |
| 5511 | |
| 5512 | return; |
| 5513 | } |
| 5514 | |
| 5515 | void |
| 5516 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 5517 | { |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5518 | #if 0 |
| 5519 | uint16_t options = (requester_id << 15) | BIT_7; |
| 5520 | #endif |
| 5521 | uint16_t retry; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5522 | uint32_t data; |
| 5523 | struct qla_hw_data *ha = base_vha->hw; |
| 5524 | |
| 5525 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 5526 | * remote registers |
| 5527 | */ |
| 5528 | retry = 0; |
| 5529 | retry_unlock: |
| 5530 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 5531 | == QLA_SUCCESS) { |
| 5532 | if (data == ha->portnum) { |
| 5533 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 5534 | /* Clearing lock-id by setting 0xff */ |
| 5535 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 5536 | } else if (retry < 10) { |
| 5537 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 5538 | |
| 5539 | /* Retry for IDC-unlock */ |
| 5540 | qla83xx_wait_logic(); |
| 5541 | retry++; |
| 5542 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5543 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5544 | goto retry_unlock; |
| 5545 | } |
| 5546 | } else if (retry < 10) { |
| 5547 | /* Retry for IDC-unlock */ |
| 5548 | qla83xx_wait_logic(); |
| 5549 | retry++; |
| 5550 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5551 | "Failed to read drv-lockid, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5552 | goto retry_unlock; |
| 5553 | } |
| 5554 | |
| 5555 | return; |
| 5556 | |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5557 | #if 0 |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5558 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 5559 | retry = 0; |
| 5560 | retry_unlock2: |
| 5561 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 5562 | if (retry < 10) { |
| 5563 | /* Retry for IDC-unlock */ |
| 5564 | qla83xx_wait_logic(); |
| 5565 | retry++; |
| 5566 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5567 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5568 | goto retry_unlock2; |
| 5569 | } |
| 5570 | } |
| 5571 | |
| 5572 | return; |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5573 | #endif |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5574 | } |
| 5575 | |
| 5576 | int |
| 5577 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 5578 | { |
| 5579 | int rval = QLA_SUCCESS; |
| 5580 | struct qla_hw_data *ha = vha->hw; |
| 5581 | uint32_t drv_presence; |
| 5582 | |
| 5583 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 5584 | if (rval == QLA_SUCCESS) { |
| 5585 | drv_presence |= (1 << ha->portnum); |
| 5586 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5587 | drv_presence); |
| 5588 | } |
| 5589 | |
| 5590 | return rval; |
| 5591 | } |
| 5592 | |
| 5593 | int |
| 5594 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 5595 | { |
| 5596 | int rval = QLA_SUCCESS; |
| 5597 | |
| 5598 | qla83xx_idc_lock(vha, 0); |
| 5599 | rval = __qla83xx_set_drv_presence(vha); |
| 5600 | qla83xx_idc_unlock(vha, 0); |
| 5601 | |
| 5602 | return rval; |
| 5603 | } |
| 5604 | |
| 5605 | int |
| 5606 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 5607 | { |
| 5608 | int rval = QLA_SUCCESS; |
| 5609 | struct qla_hw_data *ha = vha->hw; |
| 5610 | uint32_t drv_presence; |
| 5611 | |
| 5612 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 5613 | if (rval == QLA_SUCCESS) { |
| 5614 | drv_presence &= ~(1 << ha->portnum); |
| 5615 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5616 | drv_presence); |
| 5617 | } |
| 5618 | |
| 5619 | return rval; |
| 5620 | } |
| 5621 | |
| 5622 | int |
| 5623 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 5624 | { |
| 5625 | int rval = QLA_SUCCESS; |
| 5626 | |
| 5627 | qla83xx_idc_lock(vha, 0); |
| 5628 | rval = __qla83xx_clear_drv_presence(vha); |
| 5629 | qla83xx_idc_unlock(vha, 0); |
| 5630 | |
| 5631 | return rval; |
| 5632 | } |
| 5633 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5634 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5635 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 5636 | { |
| 5637 | struct qla_hw_data *ha = vha->hw; |
| 5638 | uint32_t drv_ack, drv_presence; |
| 5639 | unsigned long ack_timeout; |
| 5640 | |
| 5641 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 5642 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 5643 | while (1) { |
| 5644 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 5645 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 5646 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5647 | break; |
| 5648 | |
| 5649 | if (time_after_eq(jiffies, ack_timeout)) { |
| 5650 | ql_log(ql_log_warn, vha, 0xb067, |
| 5651 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 5652 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 5653 | /* |
| 5654 | * The function(s) which did not ack in time are forced |
| 5655 | * to withdraw any further participation in the IDC |
| 5656 | * reset. |
| 5657 | */ |
| 5658 | if (drv_ack != drv_presence) |
| 5659 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5660 | drv_ack); |
| 5661 | break; |
| 5662 | } |
| 5663 | |
| 5664 | qla83xx_idc_unlock(vha, 0); |
| 5665 | msleep(1000); |
| 5666 | qla83xx_idc_lock(vha, 0); |
| 5667 | } |
| 5668 | |
| 5669 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 5670 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 5671 | } |
| 5672 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5673 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5674 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 5675 | { |
| 5676 | int rval = QLA_SUCCESS; |
| 5677 | uint32_t idc_control; |
| 5678 | |
| 5679 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 5680 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 5681 | |
| 5682 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 5683 | __qla83xx_get_idc_control(vha, &idc_control); |
| 5684 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 5685 | __qla83xx_set_idc_control(vha, 0); |
| 5686 | |
| 5687 | qla83xx_idc_unlock(vha, 0); |
| 5688 | rval = qla83xx_restart_nic_firmware(vha); |
| 5689 | qla83xx_idc_lock(vha, 0); |
| 5690 | |
| 5691 | if (rval != QLA_SUCCESS) { |
| 5692 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 5693 | "Failed to restart NIC f/w.\n"); |
| 5694 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 5695 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 5696 | } else { |
| 5697 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 5698 | "Success in restarting nic f/w.\n"); |
| 5699 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 5700 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 5701 | } |
| 5702 | |
| 5703 | return rval; |
| 5704 | } |
| 5705 | |
| 5706 | /* Assumes idc_lock always held on entry */ |
| 5707 | int |
| 5708 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 5709 | { |
| 5710 | struct qla_hw_data *ha = base_vha->hw; |
| 5711 | int rval = QLA_SUCCESS; |
| 5712 | unsigned long dev_init_timeout; |
| 5713 | uint32_t dev_state; |
| 5714 | |
| 5715 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 5716 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 5717 | |
| 5718 | while (1) { |
| 5719 | |
| 5720 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 5721 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 5722 | "Initialization TIMEOUT!\n"); |
| 5723 | /* Init timeout. Disable further NIC Core |
| 5724 | * communication. |
| 5725 | */ |
| 5726 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5727 | QLA8XXX_DEV_FAILED); |
| 5728 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 5729 | "HW State: FAILED.\n"); |
| 5730 | } |
| 5731 | |
| 5732 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5733 | switch (dev_state) { |
| 5734 | case QLA8XXX_DEV_READY: |
| 5735 | if (ha->flags.nic_core_reset_owner) |
| 5736 | qla83xx_idc_audit(base_vha, |
| 5737 | IDC_AUDIT_COMPLETION); |
| 5738 | ha->flags.nic_core_reset_owner = 0; |
| 5739 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 5740 | "Reset_owner reset by 0x%x.\n", |
| 5741 | ha->portnum); |
| 5742 | goto exit; |
| 5743 | case QLA8XXX_DEV_COLD: |
| 5744 | if (ha->flags.nic_core_reset_owner) |
| 5745 | rval = qla83xx_device_bootstrap(base_vha); |
| 5746 | else { |
| 5747 | /* Wait for AEN to change device-state */ |
| 5748 | qla83xx_idc_unlock(base_vha, 0); |
| 5749 | msleep(1000); |
| 5750 | qla83xx_idc_lock(base_vha, 0); |
| 5751 | } |
| 5752 | break; |
| 5753 | case QLA8XXX_DEV_INITIALIZING: |
| 5754 | /* Wait for AEN to change device-state */ |
| 5755 | qla83xx_idc_unlock(base_vha, 0); |
| 5756 | msleep(1000); |
| 5757 | qla83xx_idc_lock(base_vha, 0); |
| 5758 | break; |
| 5759 | case QLA8XXX_DEV_NEED_RESET: |
| 5760 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 5761 | qla83xx_need_reset_handler(base_vha); |
| 5762 | else { |
| 5763 | /* Wait for AEN to change device-state */ |
| 5764 | qla83xx_idc_unlock(base_vha, 0); |
| 5765 | msleep(1000); |
| 5766 | qla83xx_idc_lock(base_vha, 0); |
| 5767 | } |
| 5768 | /* reset timeout value after need reset handler */ |
| 5769 | dev_init_timeout = jiffies + |
| 5770 | (ha->fcoe_dev_init_timeout * HZ); |
| 5771 | break; |
| 5772 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 5773 | /* XXX: DEBUG for now */ |
| 5774 | qla83xx_idc_unlock(base_vha, 0); |
| 5775 | msleep(1000); |
| 5776 | qla83xx_idc_lock(base_vha, 0); |
| 5777 | break; |
| 5778 | case QLA8XXX_DEV_QUIESCENT: |
| 5779 | /* XXX: DEBUG for now */ |
| 5780 | if (ha->flags.quiesce_owner) |
| 5781 | goto exit; |
| 5782 | |
| 5783 | qla83xx_idc_unlock(base_vha, 0); |
| 5784 | msleep(1000); |
| 5785 | qla83xx_idc_lock(base_vha, 0); |
| 5786 | dev_init_timeout = jiffies + |
| 5787 | (ha->fcoe_dev_init_timeout * HZ); |
| 5788 | break; |
| 5789 | case QLA8XXX_DEV_FAILED: |
| 5790 | if (ha->flags.nic_core_reset_owner) |
| 5791 | qla83xx_idc_audit(base_vha, |
| 5792 | IDC_AUDIT_COMPLETION); |
| 5793 | ha->flags.nic_core_reset_owner = 0; |
| 5794 | __qla83xx_clear_drv_presence(base_vha); |
| 5795 | qla83xx_idc_unlock(base_vha, 0); |
| 5796 | qla8xxx_dev_failed_handler(base_vha); |
| 5797 | rval = QLA_FUNCTION_FAILED; |
| 5798 | qla83xx_idc_lock(base_vha, 0); |
| 5799 | goto exit; |
| 5800 | case QLA8XXX_BAD_VALUE: |
| 5801 | qla83xx_idc_unlock(base_vha, 0); |
| 5802 | msleep(1000); |
| 5803 | qla83xx_idc_lock(base_vha, 0); |
| 5804 | break; |
| 5805 | default: |
| 5806 | ql_log(ql_log_warn, base_vha, 0xb071, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 5807 | "Unknown Device State: %x.\n", dev_state); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5808 | qla83xx_idc_unlock(base_vha, 0); |
| 5809 | qla8xxx_dev_failed_handler(base_vha); |
| 5810 | rval = QLA_FUNCTION_FAILED; |
| 5811 | qla83xx_idc_lock(base_vha, 0); |
| 5812 | goto exit; |
| 5813 | } |
| 5814 | } |
| 5815 | |
| 5816 | exit: |
| 5817 | return rval; |
| 5818 | } |
| 5819 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5820 | void |
| 5821 | qla2x00_disable_board_on_pci_error(struct work_struct *work) |
| 5822 | { |
| 5823 | struct qla_hw_data *ha = container_of(work, struct qla_hw_data, |
| 5824 | board_disable); |
| 5825 | struct pci_dev *pdev = ha->pdev; |
| 5826 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5827 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5828 | /* |
| 5829 | * if UNLOAD flag is already set, then continue unload, |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 5830 | * where it was set first. |
| 5831 | */ |
| 5832 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5833 | return; |
| 5834 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5835 | ql_log(ql_log_warn, base_vha, 0x015b, |
| 5836 | "Disabling adapter.\n"); |
| 5837 | |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 5838 | if (!atomic_read(&pdev->enable_cnt)) { |
| 5839 | ql_log(ql_log_info, base_vha, 0xfffc, |
| 5840 | "PCI device disabled, no action req for PCI error=%lx\n", |
| 5841 | base_vha->pci_flags); |
| 5842 | return; |
| 5843 | } |
| 5844 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5845 | qla2x00_wait_for_sess_deletion(base_vha); |
| 5846 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5847 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 5848 | |
| 5849 | qla2x00_delete_all_vps(ha, base_vha); |
| 5850 | |
| 5851 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5852 | |
| 5853 | qla2x00_dfs_remove(base_vha); |
| 5854 | |
| 5855 | qla84xx_put_chip(base_vha); |
| 5856 | |
| 5857 | if (base_vha->timer_active) |
| 5858 | qla2x00_stop_timer(base_vha); |
| 5859 | |
| 5860 | base_vha->flags.online = 0; |
| 5861 | |
| 5862 | qla2x00_destroy_deferred_work(ha); |
| 5863 | |
| 5864 | /* |
| 5865 | * Do not try to stop beacon blink as it will issue a mailbox |
| 5866 | * command. |
| 5867 | */ |
| 5868 | qla2x00_free_sysfs_attr(base_vha, false); |
| 5869 | |
| 5870 | fc_remove_host(base_vha->host); |
| 5871 | |
| 5872 | scsi_remove_host(base_vha->host); |
| 5873 | |
| 5874 | base_vha->flags.init_done = 0; |
| 5875 | qla25xx_delete_queues(base_vha); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5876 | qla2x00_free_fcports(base_vha); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 5877 | qla2x00_free_irqs(base_vha); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5878 | qla2x00_mem_free(ha); |
| 5879 | qla82xx_md_free(base_vha); |
| 5880 | qla2x00_free_queues(ha); |
| 5881 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5882 | qla2x00_unmap_iobases(ha); |
| 5883 | |
| 5884 | pci_release_selected_regions(ha->pdev, ha->bars); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5885 | pci_disable_pcie_error_reporting(pdev); |
| 5886 | pci_disable_device(pdev); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5887 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 5888 | /* |
| 5889 | * Let qla2x00_remove_one cleanup qla_hw_data on device removal. |
| 5890 | */ |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5891 | } |
| 5892 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5893 | /************************************************************************** |
| 5894 | * qla2x00_do_dpc |
| 5895 | * This kernel thread is a task that is schedule by the interrupt handler |
| 5896 | * to perform the background processing for interrupts. |
| 5897 | * |
| 5898 | * Notes: |
| 5899 | * This task always run in the context of a kernel thread. It |
| 5900 | * is kick-off by the driver's detect code and starts up |
| 5901 | * up one per adapter. It immediately goes to sleep and waits for |
| 5902 | * some fibre event. When either the interrupt handler or |
| 5903 | * the timer routine detects a event it will one of the task |
| 5904 | * bits then wake us up. |
| 5905 | **************************************************************************/ |
| 5906 | static int |
| 5907 | qla2x00_do_dpc(void *data) |
| 5908 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5909 | scsi_qla_host_t *base_vha; |
| 5910 | struct qla_hw_data *ha; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5911 | uint32_t online; |
| 5912 | struct qla_qpair *qpair; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5913 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5914 | ha = (struct qla_hw_data *)data; |
| 5915 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5916 | |
Dongsheng Yang | 8698a74 | 2014-03-11 18:09:12 +0800 | [diff] [blame] | 5917 | set_user_nice(current, MIN_NICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5918 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5919 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5920 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5921 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 5922 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5923 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5924 | schedule(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5925 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5926 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 5927 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5928 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5929 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5930 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 5931 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5932 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5933 | } |
| 5934 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5935 | ha->dpc_active = 1; |
| 5936 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5937 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 5938 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 5939 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5940 | |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 5941 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5942 | break; |
| 5943 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5944 | if (IS_P3P_TYPE(ha)) { |
| 5945 | if (IS_QLA8044(ha)) { |
| 5946 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5947 | &base_vha->dpc_flags)) { |
| 5948 | qla8044_idc_lock(ha); |
| 5949 | qla8044_wr_direct(base_vha, |
| 5950 | QLA8044_CRB_DEV_STATE_INDEX, |
| 5951 | QLA8XXX_DEV_FAILED); |
| 5952 | qla8044_idc_unlock(ha); |
| 5953 | ql_log(ql_log_info, base_vha, 0x4004, |
| 5954 | "HW State: FAILED.\n"); |
| 5955 | qla8044_device_state_handler(base_vha); |
| 5956 | continue; |
| 5957 | } |
| 5958 | |
| 5959 | } else { |
| 5960 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5961 | &base_vha->dpc_flags)) { |
| 5962 | qla82xx_idc_lock(ha); |
| 5963 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
| 5964 | QLA8XXX_DEV_FAILED); |
| 5965 | qla82xx_idc_unlock(ha); |
| 5966 | ql_log(ql_log_info, base_vha, 0x0151, |
| 5967 | "HW State: FAILED.\n"); |
| 5968 | qla82xx_device_state_handler(base_vha); |
| 5969 | continue; |
| 5970 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5971 | } |
| 5972 | |
| 5973 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 5974 | &base_vha->dpc_flags)) { |
| 5975 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5976 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 5977 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5978 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 5979 | &base_vha->dpc_flags))) { |
| 5980 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 5981 | /* FCoE-ctx reset failed. |
| 5982 | * Escalate to chip-reset |
| 5983 | */ |
| 5984 | set_bit(ISP_ABORT_NEEDED, |
| 5985 | &base_vha->dpc_flags); |
| 5986 | } |
| 5987 | clear_bit(ABORT_ISP_ACTIVE, |
| 5988 | &base_vha->dpc_flags); |
| 5989 | } |
| 5990 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5991 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 5992 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5993 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5994 | } else if (IS_QLAFX00(ha)) { |
| 5995 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5996 | &base_vha->dpc_flags)) { |
| 5997 | ql_dbg(ql_dbg_dpc, base_vha, 0x4020, |
| 5998 | "Firmware Reset Recovery\n"); |
| 5999 | if (qlafx00_reset_initialize(base_vha)) { |
| 6000 | /* Failed. Abort isp later. */ |
| 6001 | if (!test_bit(UNLOADING, |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 6002 | &base_vha->dpc_flags)) { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6003 | set_bit(ISP_UNRECOVERABLE, |
| 6004 | &base_vha->dpc_flags); |
| 6005 | ql_dbg(ql_dbg_dpc, base_vha, |
| 6006 | 0x4021, |
| 6007 | "Reset Recovery Failed\n"); |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 6008 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6009 | } |
| 6010 | } |
| 6011 | |
| 6012 | if (test_and_clear_bit(FX00_TARGET_SCAN, |
| 6013 | &base_vha->dpc_flags)) { |
| 6014 | ql_dbg(ql_dbg_dpc, base_vha, 0x4022, |
| 6015 | "ISPFx00 Target Scan scheduled\n"); |
| 6016 | if (qlafx00_rescan_isp(base_vha)) { |
| 6017 | if (!test_bit(UNLOADING, |
| 6018 | &base_vha->dpc_flags)) |
| 6019 | set_bit(ISP_UNRECOVERABLE, |
| 6020 | &base_vha->dpc_flags); |
| 6021 | ql_dbg(ql_dbg_dpc, base_vha, 0x401e, |
| 6022 | "ISPFx00 Target Scan Failed\n"); |
| 6023 | } |
| 6024 | ql_dbg(ql_dbg_dpc, base_vha, 0x401f, |
| 6025 | "ISPFx00 Target Scan End\n"); |
| 6026 | } |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 6027 | if (test_and_clear_bit(FX00_HOST_INFO_RESEND, |
| 6028 | &base_vha->dpc_flags)) { |
| 6029 | ql_dbg(ql_dbg_dpc, base_vha, 0x4023, |
| 6030 | "ISPFx00 Host Info resend scheduled\n"); |
| 6031 | qlafx00_fx_disc(base_vha, |
| 6032 | &base_vha->hw->mr.fcport, |
| 6033 | FXDISC_REG_HOST_INFO); |
| 6034 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6035 | } |
| 6036 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 6037 | if (test_and_clear_bit(DETECT_SFP_CHANGE, |
| 6038 | &base_vha->dpc_flags) && |
| 6039 | !test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) { |
| 6040 | qla24xx_detect_sfp(base_vha); |
| 6041 | |
| 6042 | if (ha->flags.detected_lr_sfp != |
| 6043 | ha->flags.using_lr_setting) |
| 6044 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 6045 | } |
| 6046 | |
Quinn Tran | b08abbd | 2018-07-18 14:29:54 -0700 | [diff] [blame] | 6047 | if (test_and_clear_bit |
| 6048 | (ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 6049 | !test_bit(UNLOADING, &base_vha->dpc_flags)) { |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame^] | 6050 | bool do_reset = true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6051 | |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame^] | 6052 | switch (ql2x_ini_mode) { |
| 6053 | case QLA2XXX_INI_MODE_ENABLED: |
| 6054 | break; |
| 6055 | case QLA2XXX_INI_MODE_DISABLED: |
| 6056 | if (!qla_tgt_mode_enabled(base_vha)) |
| 6057 | do_reset = false; |
| 6058 | break; |
| 6059 | case QLA2XXX_INI_MODE_DUAL: |
| 6060 | if (!qla_dual_mode_enabled(base_vha)) |
| 6061 | do_reset = false; |
| 6062 | break; |
| 6063 | default: |
| 6064 | break; |
| 6065 | } |
| 6066 | |
| 6067 | if (do_reset && !(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6068 | &base_vha->dpc_flags))) { |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame^] | 6069 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 6070 | "ISP abort scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6071 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6072 | /* failed. retry later */ |
| 6073 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6074 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6075 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6076 | clear_bit(ABORT_ISP_ACTIVE, |
| 6077 | &base_vha->dpc_flags); |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame^] | 6078 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 6079 | "ISP abort end.\n"); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 6080 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6081 | } |
| 6082 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 6083 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 6084 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6085 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 6086 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 6087 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6088 | if (IS_QLAFX00(ha)) |
| 6089 | goto loop_resync_check; |
| 6090 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6091 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6092 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 6093 | "Quiescence mode scheduled.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6094 | if (IS_P3P_TYPE(ha)) { |
| 6095 | if (IS_QLA82XX(ha)) |
| 6096 | qla82xx_device_state_handler(base_vha); |
| 6097 | if (IS_QLA8044(ha)) |
| 6098 | qla8044_device_state_handler(base_vha); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 6099 | clear_bit(ISP_QUIESCE_NEEDED, |
| 6100 | &base_vha->dpc_flags); |
| 6101 | if (!ha->flags.quiesce_owner) { |
| 6102 | qla2x00_perform_loop_resync(base_vha); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6103 | if (IS_QLA82XX(ha)) { |
| 6104 | qla82xx_idc_lock(ha); |
| 6105 | qla82xx_clear_qsnt_ready( |
| 6106 | base_vha); |
| 6107 | qla82xx_idc_unlock(ha); |
| 6108 | } else if (IS_QLA8044(ha)) { |
| 6109 | qla8044_idc_lock(ha); |
| 6110 | qla8044_clear_qsnt_ready( |
| 6111 | base_vha); |
| 6112 | qla8044_idc_unlock(ha); |
| 6113 | } |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 6114 | } |
| 6115 | } else { |
| 6116 | clear_bit(ISP_QUIESCE_NEEDED, |
| 6117 | &base_vha->dpc_flags); |
| 6118 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6119 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6120 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 6121 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6122 | } |
| 6123 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6124 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6125 | &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6126 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6127 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6128 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 6129 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6130 | qla2x00_rst_aen(base_vha); |
| 6131 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6132 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 6133 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6134 | } |
| 6135 | |
| 6136 | /* Retry each device up to login retry count */ |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 6137 | if (test_bit(RELOGIN_NEEDED, &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6138 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 6139 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6140 | |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 6141 | if (!base_vha->relogin_jif || |
| 6142 | time_after_eq(jiffies, base_vha->relogin_jif)) { |
| 6143 | base_vha->relogin_jif = jiffies + HZ; |
| 6144 | clear_bit(RELOGIN_NEEDED, &base_vha->dpc_flags); |
| 6145 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 6146 | ql_dbg(ql_dbg_disc, base_vha, 0x400d, |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 6147 | "Relogin scheduled.\n"); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 6148 | qla24xx_post_relogin_work(base_vha); |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 6149 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6150 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6151 | loop_resync_check: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6152 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6153 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6154 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6155 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 6156 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6157 | |
| 6158 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6159 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6160 | |
Bart Van Assche | 52c8282 | 2015-07-09 07:23:26 -0700 | [diff] [blame] | 6161 | qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6162 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6163 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 6164 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6165 | } |
| 6166 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6167 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 6168 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6169 | } |
| 6170 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6171 | if (IS_QLAFX00(ha)) |
| 6172 | goto intr_on_check; |
| 6173 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6174 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 6175 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 6176 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 6177 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 6178 | } |
| 6179 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6180 | intr_on_check: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6181 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 6182 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6183 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6184 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
Himanshu Madani | 90b604f | 2014-04-11 16:54:40 -0400 | [diff] [blame] | 6185 | &base_vha->dpc_flags)) { |
| 6186 | if (ha->beacon_blink_led == 1) |
| 6187 | ha->isp_ops->beacon_blink(base_vha); |
| 6188 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 6189 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6190 | /* qpair online check */ |
| 6191 | if (test_and_clear_bit(QPAIR_ONLINE_CHECK_NEEDED, |
| 6192 | &base_vha->dpc_flags)) { |
| 6193 | if (ha->flags.eeh_busy || |
| 6194 | ha->flags.pci_channel_io_perm_failure) |
| 6195 | online = 0; |
| 6196 | else |
| 6197 | online = 1; |
| 6198 | |
| 6199 | mutex_lock(&ha->mq_lock); |
| 6200 | list_for_each_entry(qpair, &base_vha->qp_list, |
| 6201 | qp_list_elem) |
| 6202 | qpair->online = online; |
| 6203 | mutex_unlock(&ha->mq_lock); |
| 6204 | } |
| 6205 | |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6206 | if (test_and_clear_bit(SET_ZIO_THRESHOLD_NEEDED, &base_vha->dpc_flags)) { |
| 6207 | ql_log(ql_log_info, base_vha, 0xffffff, |
| 6208 | "nvme: SET ZIO Activity exchange threshold to %d.\n", |
| 6209 | ha->nvme_last_rptd_aen); |
| 6210 | if (qla27xx_set_zio_threshold(base_vha, ha->nvme_last_rptd_aen)) { |
| 6211 | ql_log(ql_log_info, base_vha, 0xffffff, |
| 6212 | "nvme: Unable to SET ZIO Activity exchange threshold to %d.\n", |
| 6213 | ha->nvme_last_rptd_aen); |
| 6214 | } |
| 6215 | } |
| 6216 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6217 | if (!IS_QLAFX00(ha)) |
| 6218 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6219 | |
Quinn Tran | 48acad0 | 2018-08-02 13:16:44 -0700 | [diff] [blame] | 6220 | if (test_and_clear_bit(N2N_LINK_RESET, |
| 6221 | &base_vha->dpc_flags)) { |
| 6222 | qla2x00_lip_reset(base_vha); |
| 6223 | } |
| 6224 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6225 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 6226 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 6227 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6228 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 6229 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6230 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6231 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 6232 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6233 | |
| 6234 | /* |
| 6235 | * Make sure that nobody tries to wake us up again. |
| 6236 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6237 | ha->dpc_active = 0; |
| 6238 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 6239 | /* Cleanup any residual CTX SRBs. */ |
| 6240 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 6241 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 6242 | return 0; |
| 6243 | } |
| 6244 | |
| 6245 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6246 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 6247 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6248 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 6249 | struct task_struct *t = ha->dpc_thread; |
| 6250 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6251 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 6252 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6253 | } |
| 6254 | |
| 6255 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6256 | * qla2x00_rst_aen |
| 6257 | * Processes asynchronous reset. |
| 6258 | * |
| 6259 | * Input: |
| 6260 | * ha = adapter block pointer. |
| 6261 | */ |
| 6262 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6263 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6264 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6265 | if (vha->flags.online && !vha->flags.reset_active && |
| 6266 | !atomic_read(&vha->loop_down_timer) && |
| 6267 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6268 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6269 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6270 | |
| 6271 | /* |
| 6272 | * Issue marker command only when we are going to start |
| 6273 | * the I/O. |
| 6274 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6275 | vha->marker_needed = 1; |
| 6276 | } while (!atomic_read(&vha->loop_down_timer) && |
| 6277 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6278 | } |
| 6279 | } |
| 6280 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6281 | /************************************************************************** |
| 6282 | * qla2x00_timer |
| 6283 | * |
| 6284 | * Description: |
| 6285 | * One second timer |
| 6286 | * |
| 6287 | * Context: Interrupt |
| 6288 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6289 | void |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 6290 | qla2x00_timer(struct timer_list *t) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6291 | { |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 6292 | scsi_qla_host_t *vha = from_timer(vha, t, timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6293 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6294 | int start_dpc = 0; |
| 6295 | int index; |
| 6296 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6297 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6298 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 6299 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6300 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6301 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6302 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 6303 | "EEH = %d, restarting timer.\n", |
| 6304 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6305 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 6306 | return; |
| 6307 | } |
| 6308 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6309 | /* |
| 6310 | * Hardware read to raise pending EEH errors during mailbox waits. If |
| 6311 | * the read returns -1 then disable the board. |
| 6312 | */ |
| 6313 | if (!pci_channel_offline(ha->pdev)) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6314 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Joe Lawrence | c821e0d | 2014-08-26 17:11:41 -0400 | [diff] [blame] | 6315 | qla2x00_check_reg16_for_disconnect(vha, w); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6316 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6317 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 6318 | /* Make sure qla82xx_watchdog is run only for physical port */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6319 | if (!vha->vp_idx && IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6320 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 6321 | start_dpc++; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6322 | if (IS_QLA82XX(ha)) |
| 6323 | qla82xx_watchdog(vha); |
| 6324 | else if (IS_QLA8044(ha)) |
| 6325 | qla8044_watchdog(vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6326 | } |
| 6327 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6328 | if (!vha->vp_idx && IS_QLAFX00(ha)) |
| 6329 | qlafx00_timer_routine(vha); |
| 6330 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6331 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6332 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 6333 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 6334 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6335 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6336 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6337 | if (atomic_read(&vha->loop_down_timer) == |
| 6338 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6339 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6340 | ql_log(ql_log_info, vha, 0x6008, |
| 6341 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6342 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6343 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 6344 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6345 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 6346 | /* |
| 6347 | * Schedule an ISP abort to return any FCP2-device |
| 6348 | * commands. |
| 6349 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6350 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6351 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6352 | spin_lock_irqsave(&ha->hardware_lock, |
| 6353 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 6354 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6355 | for (index = 1; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 6356 | index < req->num_outstanding_cmds; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6357 | index++) { |
| 6358 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 6359 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6360 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6361 | if (!sp) |
| 6362 | continue; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 6363 | if (sp->cmd_type != TYPE_SRB) |
| 6364 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 6365 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 6366 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6367 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 6368 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6369 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6370 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 6371 | if (IS_QLA82XX(ha)) |
| 6372 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 6373 | &vha->dpc_flags); |
| 6374 | else |
| 6375 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6376 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6377 | break; |
| 6378 | } |
| 6379 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6380 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6381 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6382 | start_dpc++; |
| 6383 | } |
| 6384 | |
| 6385 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6386 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 6387 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6388 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6389 | "Loop down - aborting ISP.\n"); |
| 6390 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 6391 | if (IS_QLA82XX(ha)) |
| 6392 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 6393 | &vha->dpc_flags); |
| 6394 | else |
| 6395 | set_bit(ISP_ABORT_NEEDED, |
| 6396 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6397 | } |
| 6398 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6399 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 6400 | "Loop down - seconds remaining %d.\n", |
| 6401 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6402 | } |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 6403 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 6404 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 6405 | /* There is no beacon_blink function for ISP82xx */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6406 | if (!IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 6407 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 6408 | start_dpc++; |
| 6409 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 6410 | } |
| 6411 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 6412 | /* Process any deferred work. */ |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 6413 | if (!list_empty(&vha->work_list)) { |
| 6414 | unsigned long flags; |
| 6415 | bool q = false; |
| 6416 | |
| 6417 | spin_lock_irqsave(&vha->work_lock, flags); |
| 6418 | if (!test_and_set_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags)) |
| 6419 | q = true; |
| 6420 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 6421 | if (q) |
| 6422 | queue_work(vha->hw->wq, &vha->iocb_work); |
| 6423 | } |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 6424 | |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 6425 | /* |
| 6426 | * FC-NVME |
| 6427 | * see if the active AEN count has changed from what was last reported. |
| 6428 | */ |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6429 | if (!vha->vp_idx && |
| 6430 | atomic_read(&ha->nvme_active_aen_cnt) != ha->nvme_last_rptd_aen && |
| 6431 | ha->zio_mode == QLA_ZIO_MODE_6) { |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 6432 | ql_log(ql_log_info, vha, 0x3002, |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6433 | "nvme: Sched: Set ZIO exchange threshold to %d.\n", |
| 6434 | ha->nvme_last_rptd_aen); |
| 6435 | ha->nvme_last_rptd_aen = atomic_read(&ha->nvme_active_aen_cnt); |
| 6436 | set_bit(SET_ZIO_THRESHOLD_NEEDED, &vha->dpc_flags); |
| 6437 | start_dpc++; |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 6438 | } |
| 6439 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6440 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6441 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 6442 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 6443 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6444 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6445 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 6446 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6447 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 6448 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6449 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 6450 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6451 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 6452 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 6453 | "fcport_update_needed=%d start_dpc=%d " |
| 6454 | "reset_marker_needed=%d", |
| 6455 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 6456 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 6457 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 6458 | start_dpc, |
| 6459 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 6460 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 6461 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 6462 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 6463 | "relogin_needed=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6464 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 6465 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 6466 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 6467 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 6468 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6469 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6470 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6471 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6472 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6473 | } |
| 6474 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6475 | /* Firmware interface routines. */ |
| 6476 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6477 | #define FW_BLOBS 11 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6478 | #define FW_ISP21XX 0 |
| 6479 | #define FW_ISP22XX 1 |
| 6480 | #define FW_ISP2300 2 |
| 6481 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6482 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6483 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6484 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6485 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6486 | #define FW_ISP2031 8 |
| 6487 | #define FW_ISP8031 9 |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6488 | #define FW_ISP27XX 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6489 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6490 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 6491 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 6492 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 6493 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 6494 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6495 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6496 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6497 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6498 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 6499 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6500 | #define FW_FILE_ISP27XX "ql2700_fw.bin" |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6501 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6502 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6503 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6504 | |
| 6505 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6506 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 6507 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 6508 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 6509 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 6510 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6511 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6512 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6513 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6514 | { .name = FW_FILE_ISP2031, }, |
| 6515 | { .name = FW_FILE_ISP8031, }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6516 | { .name = FW_FILE_ISP27XX, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6517 | }; |
| 6518 | |
| 6519 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6520 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6521 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6522 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6523 | struct fw_blob *blob; |
| 6524 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6525 | if (IS_QLA2100(ha)) { |
| 6526 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 6527 | } else if (IS_QLA2200(ha)) { |
| 6528 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6529 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6530 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6531 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6532 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 6533 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6534 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6535 | } else if (IS_QLA25XX(ha)) { |
| 6536 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6537 | } else if (IS_QLA81XX(ha)) { |
| 6538 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6539 | } else if (IS_QLA82XX(ha)) { |
| 6540 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6541 | } else if (IS_QLA2031(ha)) { |
| 6542 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 6543 | } else if (IS_QLA8031(ha)) { |
| 6544 | blob = &qla_fw_blobs[FW_ISP8031]; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6545 | } else if (IS_QLA27XX(ha)) { |
| 6546 | blob = &qla_fw_blobs[FW_ISP27XX]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 6547 | } else { |
| 6548 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6549 | } |
| 6550 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6551 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6552 | if (blob->fw) |
| 6553 | goto out; |
| 6554 | |
| 6555 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6556 | ql_log(ql_log_warn, vha, 0x0063, |
| 6557 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6558 | blob->fw = NULL; |
| 6559 | blob = NULL; |
| 6560 | goto out; |
| 6561 | } |
| 6562 | |
| 6563 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6564 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6565 | return blob; |
| 6566 | } |
| 6567 | |
| 6568 | static void |
| 6569 | qla2x00_release_firmware(void) |
| 6570 | { |
| 6571 | int idx; |
| 6572 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6573 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6574 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 6575 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6576 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6577 | } |
| 6578 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6579 | static pci_ers_result_t |
| 6580 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 6581 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6582 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 6583 | struct qla_hw_data *ha = vha->hw; |
| 6584 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6585 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 6586 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 6587 | |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 6588 | if (!atomic_read(&pdev->enable_cnt)) { |
| 6589 | ql_log(ql_log_info, vha, 0xffff, |
| 6590 | "PCI device is disabled,state %x\n", state); |
| 6591 | return PCI_ERS_RESULT_NEED_RESET; |
| 6592 | } |
| 6593 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6594 | switch (state) { |
| 6595 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6596 | ha->flags.eeh_busy = 0; |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 6597 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6598 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6599 | qla2xxx_wake_dpc(vha); |
| 6600 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6601 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 6602 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6603 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6604 | /* For ISP82XX complete any pending mailbox cmd */ |
| 6605 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6606 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 6607 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 6608 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6609 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6610 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6611 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 6612 | /* Return back all IOs */ |
| 6613 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 6614 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6615 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6616 | qla2xxx_wake_dpc(vha); |
| 6617 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6618 | return PCI_ERS_RESULT_NEED_RESET; |
| 6619 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6620 | ha->flags.pci_channel_io_perm_failure = 1; |
| 6621 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 6622 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6623 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6624 | qla2xxx_wake_dpc(vha); |
| 6625 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6626 | return PCI_ERS_RESULT_DISCONNECT; |
| 6627 | } |
| 6628 | return PCI_ERS_RESULT_NEED_RESET; |
| 6629 | } |
| 6630 | |
| 6631 | static pci_ers_result_t |
| 6632 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 6633 | { |
| 6634 | int risc_paused = 0; |
| 6635 | uint32_t stat; |
| 6636 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6637 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6638 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6639 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 6640 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 6641 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 6642 | if (IS_QLA82XX(ha)) |
| 6643 | return PCI_ERS_RESULT_RECOVERED; |
| 6644 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6645 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 6646 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 6647 | stat = RD_REG_DWORD(®->hccr); |
| 6648 | if (stat & HCCR_RISC_PAUSE) |
| 6649 | risc_paused = 1; |
| 6650 | } else if (IS_QLA23XX(ha)) { |
| 6651 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 6652 | if (stat & HSR_RISC_PAUSED) |
| 6653 | risc_paused = 1; |
| 6654 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 6655 | stat = RD_REG_DWORD(®24->host_status); |
| 6656 | if (stat & HSRX_RISC_PAUSED) |
| 6657 | risc_paused = 1; |
| 6658 | } |
| 6659 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 6660 | |
| 6661 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6662 | ql_log(ql_log_info, base_vha, 0x9003, |
| 6663 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6664 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6665 | |
| 6666 | return PCI_ERS_RESULT_NEED_RESET; |
| 6667 | } else |
| 6668 | return PCI_ERS_RESULT_RECOVERED; |
| 6669 | } |
| 6670 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 6671 | static uint32_t |
| 6672 | qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6673 | { |
| 6674 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 6675 | uint32_t drv_active = 0; |
| 6676 | struct qla_hw_data *ha = base_vha->hw; |
| 6677 | int fn; |
| 6678 | struct pci_dev *other_pdev = NULL; |
| 6679 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6680 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 6681 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6682 | |
| 6683 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 6684 | |
| 6685 | if (base_vha->flags.online) { |
| 6686 | /* Abort all outstanding commands, |
| 6687 | * so as to be requeued later */ |
| 6688 | qla2x00_abort_isp_cleanup(base_vha); |
| 6689 | } |
| 6690 | |
| 6691 | |
| 6692 | fn = PCI_FUNC(ha->pdev->devfn); |
| 6693 | while (fn > 0) { |
| 6694 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6695 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 6696 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6697 | other_pdev = |
| 6698 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 6699 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 6700 | fn)); |
| 6701 | |
| 6702 | if (!other_pdev) |
| 6703 | continue; |
| 6704 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6705 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 6706 | "Found PCI func available and enable at 0x%x.\n", |
| 6707 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6708 | pci_dev_put(other_pdev); |
| 6709 | break; |
| 6710 | } |
| 6711 | pci_dev_put(other_pdev); |
| 6712 | } |
| 6713 | |
| 6714 | if (!fn) { |
| 6715 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6716 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 6717 | "This devfn is reset owner = 0x%x.\n", |
| 6718 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6719 | qla82xx_idc_lock(ha); |
| 6720 | |
| 6721 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6722 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6723 | |
| 6724 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 6725 | QLA82XX_IDC_VERSION); |
| 6726 | |
| 6727 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6728 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 6729 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6730 | |
| 6731 | qla82xx_idc_unlock(ha); |
| 6732 | /* Reset if device is not already reset |
| 6733 | * drv_active would be 0 if a reset has already been done |
| 6734 | */ |
| 6735 | if (drv_active) |
| 6736 | rval = qla82xx_start_firmware(base_vha); |
| 6737 | else |
| 6738 | rval = QLA_SUCCESS; |
| 6739 | qla82xx_idc_lock(ha); |
| 6740 | |
| 6741 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6742 | ql_log(ql_log_info, base_vha, 0x900b, |
| 6743 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6744 | qla82xx_clear_drv_active(ha); |
| 6745 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6746 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6747 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6748 | ql_log(ql_log_info, base_vha, 0x900c, |
| 6749 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6750 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6751 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6752 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6753 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6754 | rval = qla82xx_restart_isp(base_vha); |
| 6755 | qla82xx_idc_lock(ha); |
| 6756 | /* Clear driver state register */ |
| 6757 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 6758 | qla82xx_set_drv_active(base_vha); |
| 6759 | } |
| 6760 | qla82xx_idc_unlock(ha); |
| 6761 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6762 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 6763 | "This devfn is not reset owner = 0x%x.\n", |
| 6764 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6765 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6766 | QLA8XXX_DEV_READY)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6767 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6768 | rval = qla82xx_restart_isp(base_vha); |
| 6769 | qla82xx_idc_lock(ha); |
| 6770 | qla82xx_set_drv_active(base_vha); |
| 6771 | qla82xx_idc_unlock(ha); |
| 6772 | } |
| 6773 | } |
| 6774 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 6775 | |
| 6776 | return rval; |
| 6777 | } |
| 6778 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6779 | static pci_ers_result_t |
| 6780 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 6781 | { |
| 6782 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6783 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6784 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6785 | struct rsp_que *rsp; |
| 6786 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6787 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6788 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 6789 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6790 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6791 | /* Workaround: qla2xxx driver which access hardware earlier |
| 6792 | * needs error state to be pci_channel_io_online. |
| 6793 | * Otherwise mailbox command timesout. |
| 6794 | */ |
| 6795 | pdev->error_state = pci_channel_io_normal; |
| 6796 | |
| 6797 | pci_restore_state(pdev); |
| 6798 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 6799 | /* pci_restore_state() clears the saved_state flag of the device |
| 6800 | * save restored state which resets saved_state flag |
| 6801 | */ |
| 6802 | pci_save_state(pdev); |
| 6803 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 6804 | if (ha->mem_only) |
| 6805 | rc = pci_enable_device_mem(pdev); |
| 6806 | else |
| 6807 | rc = pci_enable_device(pdev); |
| 6808 | |
| 6809 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6810 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6811 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6812 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6813 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6814 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6815 | rsp = ha->rsp_q_map[0]; |
| 6816 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6817 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6818 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6819 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6820 | goto exit_slot_reset; |
| 6821 | |
| 6822 | if (IS_QLA82XX(ha)) { |
| 6823 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 6824 | ret = PCI_ERS_RESULT_RECOVERED; |
| 6825 | goto exit_slot_reset; |
| 6826 | } else |
| 6827 | goto exit_slot_reset; |
| 6828 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6829 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6830 | while (ha->flags.mbox_busy && retries--) |
| 6831 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6832 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6833 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6834 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6835 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6836 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6837 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6838 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6839 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6840 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 6841 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6842 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6843 | return ret; |
| 6844 | } |
| 6845 | |
| 6846 | static void |
| 6847 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 6848 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6849 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6850 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6851 | int ret; |
| 6852 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6853 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 6854 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6855 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6856 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6857 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6858 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 6859 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6860 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6861 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 6862 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 6863 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6864 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6865 | } |
| 6866 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 6867 | static int qla2xxx_map_queues(struct Scsi_Host *shost) |
| 6868 | { |
Quinn Tran | d68b850 | 2017-12-04 14:44:59 -0800 | [diff] [blame] | 6869 | int rc; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 6870 | scsi_qla_host_t *vha = (scsi_qla_host_t *)shost->hostdata; |
| 6871 | |
Quinn Tran | d68b850 | 2017-12-04 14:44:59 -0800 | [diff] [blame] | 6872 | if (USER_CTRL_IRQ(vha->hw)) |
| 6873 | rc = blk_mq_map_queues(&shost->tag_set); |
| 6874 | else |
Keith Busch | f23f5bec | 2018-03-27 09:39:06 -0600 | [diff] [blame] | 6875 | 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] | 6876 | return rc; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 6877 | } |
| 6878 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 6879 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6880 | .error_detected = qla2xxx_pci_error_detected, |
| 6881 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 6882 | .slot_reset = qla2xxx_pci_slot_reset, |
| 6883 | .resume = qla2xxx_pci_resume, |
| 6884 | }; |
| 6885 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6886 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 6887 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 6888 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 6889 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 6890 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 6891 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 6892 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 6893 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 6894 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 6895 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 6896 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 6897 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 6898 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6899 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6900 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6901 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6902 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 6903 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6904 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISPF001) }, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6905 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8044) }, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6906 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2071) }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6907 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2271) }, |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 6908 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2261) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6909 | { 0 }, |
| 6910 | }; |
| 6911 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 6912 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6913 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 6914 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 6915 | .driver = { |
| 6916 | .owner = THIS_MODULE, |
| 6917 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6918 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6919 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 6920 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 6921 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6922 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6923 | }; |
| 6924 | |
Al Viro | 75ef9de | 2013-04-04 19:09:41 -0400 | [diff] [blame] | 6925 | static const struct file_operations apidev_fops = { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6926 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 6927 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6928 | }; |
| 6929 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6930 | /** |
| 6931 | * qla2x00_module_init - Module initialization. |
| 6932 | **/ |
| 6933 | static int __init |
| 6934 | qla2x00_module_init(void) |
| 6935 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6936 | int ret = 0; |
| 6937 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6938 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6939 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 6940 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6941 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6942 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 6943 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6944 | return -ENOMEM; |
| 6945 | } |
| 6946 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6947 | /* Initialize target kmem_cache and mem_pools */ |
| 6948 | ret = qlt_init(); |
| 6949 | if (ret < 0) { |
| 6950 | kmem_cache_destroy(srb_cachep); |
| 6951 | return ret; |
| 6952 | } else if (ret > 0) { |
| 6953 | /* |
| 6954 | * If initiator mode is explictly disabled by qlt_init(), |
| 6955 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 6956 | * performing scsi_scan_target() during LOOP UP event. |
| 6957 | */ |
| 6958 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 6959 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 6960 | } |
| 6961 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6962 | /* Derive version string. */ |
| 6963 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 6964 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 6965 | strcat(qla2x00_version_str, "-debug"); |
Joe Carnuccio | fed0f68 | 2017-08-23 15:05:10 -0700 | [diff] [blame] | 6966 | if (ql2xextended_error_logging == 1) |
| 6967 | ql2xextended_error_logging = QL_DBG_DEFAULT1_MASK; |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 6968 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 6969 | qla2xxx_transport_template = |
| 6970 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6971 | if (!qla2xxx_transport_template) { |
| 6972 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6973 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 6974 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6975 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6976 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6977 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6978 | |
| 6979 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 6980 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6981 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 6982 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6983 | } |
| 6984 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6985 | qla2xxx_transport_vport_template = |
| 6986 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 6987 | if (!qla2xxx_transport_vport_template) { |
| 6988 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6989 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6990 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6991 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 6992 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6993 | return -ENODEV; |
| 6994 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6995 | ql_log(ql_log_info, NULL, 0x0005, |
| 6996 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 6997 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6998 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6999 | if (ret) { |
| 7000 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 7001 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 7002 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7003 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7004 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 7005 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 7006 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 7007 | } |
| 7008 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7009 | } |
| 7010 | |
| 7011 | /** |
| 7012 | * qla2x00_module_exit - Module cleanup. |
| 7013 | **/ |
| 7014 | static void __exit |
| 7015 | qla2x00_module_exit(void) |
| 7016 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 7017 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 7018 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 7019 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 7020 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 7021 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 7022 | if (ctx_cachep) |
| 7023 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7024 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7025 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7026 | } |
| 7027 | |
| 7028 | module_init(qla2x00_module_init); |
| 7029 | module_exit(qla2x00_module_exit); |
| 7030 | |
| 7031 | MODULE_AUTHOR("QLogic Corporation"); |
| 7032 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 7033 | MODULE_LICENSE("GPL"); |
| 7034 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 7035 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 7036 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 7037 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 7038 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 7039 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 7040 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |