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> |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 17 | #include <linux/refcount.h> |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <scsi/scsi_tcq.h> |
| 20 | #include <scsi/scsicam.h> |
| 21 | #include <scsi/scsi_transport.h> |
| 22 | #include <scsi/scsi_transport_fc.h> |
| 23 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 24 | #include "qla_target.h" |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | /* |
| 27 | * Driver version |
| 28 | */ |
| 29 | char qla2x00_version_str[40]; |
| 30 | |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 31 | static int apidev_major; |
| 32 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | /* |
| 34 | * SRB allocation cache |
| 35 | */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 36 | struct kmem_cache *srb_cachep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 38 | /* |
| 39 | * CT6 CTX allocation cache |
| 40 | */ |
| 41 | static struct kmem_cache *ctx_cachep; |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 42 | /* |
| 43 | * error level for logging |
| 44 | */ |
Michael Hernandez | 3f006ac | 2019-03-12 11:08:22 -0700 | [diff] [blame] | 45 | uint ql_errlev = 0x8001; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 46 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 47 | static int ql2xenableclass2; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 48 | module_param(ql2xenableclass2, int, S_IRUGO|S_IRUSR); |
| 49 | MODULE_PARM_DESC(ql2xenableclass2, |
| 50 | "Specify if Class 2 operations are supported from the very " |
| 51 | "beginning. Default is 0 - class 2 not supported."); |
| 52 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | int ql2xlogintimeout = 20; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 55 | module_param(ql2xlogintimeout, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | MODULE_PARM_DESC(ql2xlogintimeout, |
| 57 | "Login timeout value in seconds."); |
| 58 | |
Andrew Vasquez | a7b6184 | 2007-05-07 07:42:59 -0700 | [diff] [blame] | 59 | int qlport_down_retry; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 60 | module_param(qlport_down_retry, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | MODULE_PARM_DESC(qlport_down_retry, |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 62 | "Maximum number of command retries to a port that returns " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | "a PORT-DOWN status."); |
| 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | int ql2xplogiabsentdevice; |
| 66 | module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); |
| 67 | MODULE_PARM_DESC(ql2xplogiabsentdevice, |
| 68 | "Option to enable PLOGI to devices that are not present after " |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 69 | "a Fabric scan. This is needed for several broken switches. " |
Masanari Iida | 0d52e64 | 2018-10-28 14:05:48 +0900 | [diff] [blame] | 70 | "Default is 0 - no PLOGI. 1 - perform PLOGI."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | int ql2xloginretrycount = 0; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 73 | module_param(ql2xloginretrycount, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | MODULE_PARM_DESC(ql2xloginretrycount, |
| 75 | "Specify an alternate value for the NVRAM login retry count."); |
| 76 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 77 | int ql2xallocfwdump = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 78 | module_param(ql2xallocfwdump, int, S_IRUGO); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 79 | MODULE_PARM_DESC(ql2xallocfwdump, |
| 80 | "Option to enable allocation of memory for a firmware dump " |
| 81 | "during HBA initialization. Memory allocation requirements " |
| 82 | "vary by ISP type. Default is 1 - allocate memory."); |
| 83 | |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 84 | int ql2xextended_error_logging; |
Andrew Vasquez | 27d9403 | 2007-03-12 10:41:30 -0700 | [diff] [blame] | 85 | module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 86 | module_param_named(logging, ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 87 | MODULE_PARM_DESC(ql2xextended_error_logging, |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 88 | "Option to enable extended error logging,\n" |
| 89 | "\t\tDefault is 0 - no logging. 0x40000000 - Module Init & Probe.\n" |
| 90 | "\t\t0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.\n" |
| 91 | "\t\t0x08000000 - IO tracing. 0x04000000 - DPC Thread.\n" |
| 92 | "\t\t0x02000000 - Async events. 0x01000000 - Timer routines.\n" |
| 93 | "\t\t0x00800000 - User space. 0x00400000 - Task Management.\n" |
| 94 | "\t\t0x00200000 - AER/EEH. 0x00100000 - Multi Q.\n" |
| 95 | "\t\t0x00080000 - P3P Specific. 0x00040000 - Virtual Port.\n" |
| 96 | "\t\t0x00020000 - Buffer Dump. 0x00010000 - Misc.\n" |
Chad Dupuis | 29f9f90 | 2012-11-21 02:40:41 -0500 | [diff] [blame] | 97 | "\t\t0x00008000 - Verbose. 0x00004000 - Target.\n" |
| 98 | "\t\t0x00002000 - Target Mgmt. 0x00001000 - Target TMF.\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 99 | "\t\t0x7fffffff - For enabling all logs, can be too many logs.\n" |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 100 | "\t\t0x1e400000 - Preferred value for capturing essential " |
| 101 | "debug information (equivalent to old " |
| 102 | "ql2xextended_error_logging=1).\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 103 | "\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] | 104 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 105 | int ql2xshiftctondsd = 6; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 106 | module_param(ql2xshiftctondsd, int, S_IRUGO); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 107 | MODULE_PARM_DESC(ql2xshiftctondsd, |
| 108 | "Set to control shifting of command type processing " |
| 109 | "based on total number of SG elements."); |
| 110 | |
Bart Van Assche | 58e2753 | 2019-04-11 14:53:19 -0700 | [diff] [blame] | 111 | int ql2xfdmienable = 1; |
Himanshu Madhani | de187df | 2014-09-25 05:16:50 -0400 | [diff] [blame] | 112 | module_param(ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 113 | module_param_named(fdmi, ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 114 | MODULE_PARM_DESC(ql2xfdmienable, |
Ferenc Wagner | 7794a5a | 2010-03-23 18:14:59 +0100 | [diff] [blame] | 115 | "Enables FDMI registrations. " |
| 116 | "0 - no FDMI. Default is 1 - perform FDMI."); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 117 | |
Michael Hernandez | d213a4b | 2017-08-23 15:05:20 -0700 | [diff] [blame] | 118 | #define MAX_Q_DEPTH 64 |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 119 | static int ql2xmaxqdepth = MAX_Q_DEPTH; |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 120 | module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR); |
| 121 | MODULE_PARM_DESC(ql2xmaxqdepth, |
Chad Dupuis | e92e4a8 | 2012-08-22 14:21:23 -0400 | [diff] [blame] | 122 | "Maximum queue depth to set for each LUN. " |
Michael Hernandez | d213a4b | 2017-08-23 15:05:20 -0700 | [diff] [blame] | 123 | "Default is 64."); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 124 | |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 125 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 126 | int ql2xenabledif; |
| 127 | #else |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 128 | int ql2xenabledif = 2; |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 129 | #endif |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 130 | module_param(ql2xenabledif, int, S_IRUGO); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 131 | MODULE_PARM_DESC(ql2xenabledif, |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 132 | " Enable T10-CRC-DIF:\n" |
| 133 | " Default is 2.\n" |
| 134 | " 0 -- No DIF Support\n" |
| 135 | " 1 -- Enable DIF for all types\n" |
| 136 | " 2 -- Enable DIF for all types, except Type 0.\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 137 | |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 138 | #if (IS_ENABLED(CONFIG_NVME_FC)) |
| 139 | int ql2xnvmeenable = 1; |
| 140 | #else |
| 141 | int ql2xnvmeenable; |
| 142 | #endif |
| 143 | module_param(ql2xnvmeenable, int, 0644); |
| 144 | MODULE_PARM_DESC(ql2xnvmeenable, |
| 145 | "Enables NVME support. " |
| 146 | "0 - no NVMe. Default is Y"); |
| 147 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 148 | int ql2xenablehba_err_chk = 2; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 149 | module_param(ql2xenablehba_err_chk, int, S_IRUGO|S_IWUSR); |
| 150 | MODULE_PARM_DESC(ql2xenablehba_err_chk, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 151 | " Enable T10-CRC-DIF Error isolation by HBA:\n" |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 152 | " Default is 2.\n" |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 153 | " 0 -- Error isolation disabled\n" |
| 154 | " 1 -- Error isolation enabled only for DIX Type 0\n" |
| 155 | " 2 -- Error isolation enabled for all Types\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 156 | |
Bart Van Assche | 58e2753 | 2019-04-11 14:53:19 -0700 | [diff] [blame] | 157 | int ql2xiidmaenable = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 158 | module_param(ql2xiidmaenable, int, S_IRUGO); |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 159 | MODULE_PARM_DESC(ql2xiidmaenable, |
| 160 | "Enables iIDMA settings " |
| 161 | "Default is 1 - perform iIDMA. 0 - no iIDMA."); |
| 162 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 163 | int ql2xmqsupport = 1; |
| 164 | module_param(ql2xmqsupport, int, S_IRUGO); |
| 165 | MODULE_PARM_DESC(ql2xmqsupport, |
| 166 | "Enable on demand multiple queue pairs support " |
| 167 | "Default is 1 for supported. " |
| 168 | "Set it to 0 to turn off mq qpair support."); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 169 | |
| 170 | int ql2xfwloadbin; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 171 | module_param(ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 172 | module_param_named(fwload, ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 173 | MODULE_PARM_DESC(ql2xfwloadbin, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 174 | "Option to specify location from which to load ISP firmware:.\n" |
| 175 | " 2 -- load firmware via the request_firmware() (hotplug).\n" |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 176 | " interface.\n" |
| 177 | " 1 -- load firmware from flash.\n" |
| 178 | " 0 -- use default semantics.\n"); |
| 179 | |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 180 | int ql2xetsenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 181 | module_param(ql2xetsenable, int, S_IRUGO); |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 182 | MODULE_PARM_DESC(ql2xetsenable, |
| 183 | "Enables firmware ETS burst." |
| 184 | "Default is 0 - skip ETS enablement."); |
| 185 | |
Giridhar Malavali | 6907869 | 2010-05-28 15:08:28 -0700 | [diff] [blame] | 186 | int ql2xdbwr = 1; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 187 | module_param(ql2xdbwr, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 188 | MODULE_PARM_DESC(ql2xdbwr, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 189 | "Option to specify scheme for request queue posting.\n" |
| 190 | " 0 -- Regular doorbell.\n" |
| 191 | " 1 -- CAMRAM doorbell (faster).\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 192 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 193 | int ql2xtargetreset = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 194 | module_param(ql2xtargetreset, int, S_IRUGO); |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 195 | MODULE_PARM_DESC(ql2xtargetreset, |
| 196 | "Enable target reset." |
| 197 | "Default is 1 - use hw defaults."); |
| 198 | |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 199 | int ql2xgffidenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 200 | module_param(ql2xgffidenable, int, S_IRUGO); |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 201 | MODULE_PARM_DESC(ql2xgffidenable, |
| 202 | "Enables GFF_ID checks of port type. " |
| 203 | "Default is 0 - Do not use GFF_ID information."); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 204 | |
himanshu.madhani@cavium.com | 043dc1d | 2017-08-23 15:05:19 -0700 | [diff] [blame] | 205 | int ql2xasynctmfenable = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 206 | module_param(ql2xasynctmfenable, int, S_IRUGO); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 207 | MODULE_PARM_DESC(ql2xasynctmfenable, |
| 208 | "Enables issue of TM IOCBs asynchronously via IOCB mechanism" |
Masanari Iida | 84e13c4 | 2018-09-11 18:48:11 +0900 | [diff] [blame] | 209 | "Default is 1 - Issue TM IOCBs via mailbox mechanism."); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 210 | |
| 211 | int ql2xdontresethba; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 212 | module_param(ql2xdontresethba, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 213 | MODULE_PARM_DESC(ql2xdontresethba, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 214 | "Option to specify reset behaviour.\n" |
| 215 | " 0 (Default) -- Reset on failure.\n" |
| 216 | " 1 -- Do not reset on failure.\n"); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 217 | |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 218 | uint64_t ql2xmaxlun = MAX_LUNS; |
| 219 | module_param(ql2xmaxlun, ullong, S_IRUGO); |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 220 | MODULE_PARM_DESC(ql2xmaxlun, |
| 221 | "Defines the maximum LU number to register with the SCSI " |
| 222 | "midlayer. Default is 65535."); |
| 223 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 224 | int ql2xmdcapmask = 0x1F; |
| 225 | module_param(ql2xmdcapmask, int, S_IRUGO); |
| 226 | MODULE_PARM_DESC(ql2xmdcapmask, |
| 227 | "Set the Minidump driver capture mask level. " |
Giridhar Malavali | 6e96fa7 | 2011-11-18 09:03:14 -0800 | [diff] [blame] | 228 | "Default is 0x1F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 229 | |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 230 | int ql2xmdenable = 1; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 231 | module_param(ql2xmdenable, int, S_IRUGO); |
| 232 | MODULE_PARM_DESC(ql2xmdenable, |
| 233 | "Enable/disable MiniDump. " |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 234 | "0 - MiniDump disabled. " |
| 235 | "1 (Default) - MiniDump enabled."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 236 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 237 | int ql2xexlogins = 0; |
| 238 | module_param(ql2xexlogins, uint, S_IRUGO|S_IWUSR); |
| 239 | MODULE_PARM_DESC(ql2xexlogins, |
| 240 | "Number of extended Logins. " |
| 241 | "0 (Default)- Disabled."); |
| 242 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 243 | int ql2xexchoffld = 1024; |
| 244 | module_param(ql2xexchoffld, uint, 0644); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 245 | MODULE_PARM_DESC(ql2xexchoffld, |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 246 | "Number of target exchanges."); |
| 247 | |
| 248 | int ql2xiniexchg = 1024; |
| 249 | module_param(ql2xiniexchg, uint, 0644); |
| 250 | MODULE_PARM_DESC(ql2xiniexchg, |
| 251 | "Number of initiator exchanges."); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 252 | |
Himanshu Madhani | f198caf | 2016-01-27 12:03:30 -0500 | [diff] [blame] | 253 | int ql2xfwholdabts = 0; |
| 254 | module_param(ql2xfwholdabts, int, S_IRUGO); |
| 255 | MODULE_PARM_DESC(ql2xfwholdabts, |
| 256 | "Allow FW to hold status IOCB until ABTS rsp received. " |
| 257 | "0 (Default) Do not set fw option. " |
| 258 | "1 - Set fw option to hold ABTS."); |
| 259 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 260 | int ql2xmvasynctoatio = 1; |
| 261 | module_param(ql2xmvasynctoatio, int, S_IRUGO|S_IWUSR); |
| 262 | MODULE_PARM_DESC(ql2xmvasynctoatio, |
| 263 | "Move PUREX, ABTS RX and RIDA IOCBs to ATIOQ" |
| 264 | "0 (Default). Do not move IOCBs" |
| 265 | "1 - Move IOCBs."); |
| 266 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 267 | int ql2xautodetectsfp = 1; |
| 268 | module_param(ql2xautodetectsfp, int, 0444); |
| 269 | MODULE_PARM_DESC(ql2xautodetectsfp, |
| 270 | "Detect SFP range and set appropriate distance.\n" |
| 271 | "1 (Default): Enable\n"); |
| 272 | |
Himanshu Madhani | e7240af | 2017-10-13 09:34:03 -0700 | [diff] [blame] | 273 | int ql2xenablemsix = 1; |
| 274 | module_param(ql2xenablemsix, int, 0444); |
| 275 | MODULE_PARM_DESC(ql2xenablemsix, |
| 276 | "Set to enable MSI or MSI-X interrupt mechanism.\n" |
| 277 | " Default is 1, enable MSI-X interrupt mechanism.\n" |
| 278 | " 0 -- enable traditional pin-based mechanism.\n" |
| 279 | " 1 -- enable MSI-X interrupt mechanism.\n" |
| 280 | " 2 -- enable MSI interrupt mechanism.\n"); |
| 281 | |
Quinn Tran | 9ecf0b0 | 2017-12-28 12:33:19 -0800 | [diff] [blame] | 282 | int qla2xuseresexchforels; |
| 283 | module_param(qla2xuseresexchforels, int, 0444); |
| 284 | MODULE_PARM_DESC(qla2xuseresexchforels, |
| 285 | "Reserve 1/2 of emergency exchanges for ELS.\n" |
| 286 | " 0 (default): disabled"); |
| 287 | |
Bart Van Assche | b3ede8e | 2019-04-04 12:44:42 -0700 | [diff] [blame] | 288 | static int ql2xprotmask; |
Martin K. Petersen | 7855d2b | 2018-12-21 09:33:44 -0800 | [diff] [blame] | 289 | module_param(ql2xprotmask, int, 0644); |
| 290 | MODULE_PARM_DESC(ql2xprotmask, |
| 291 | "Override DIF/DIX protection capabilities mask\n" |
| 292 | "Default is 0 which sets protection mask based on " |
| 293 | "capabilities reported by HBA firmware.\n"); |
| 294 | |
Bart Van Assche | b3ede8e | 2019-04-04 12:44:42 -0700 | [diff] [blame] | 295 | static int ql2xprotguard; |
Martin K. Petersen | 7855d2b | 2018-12-21 09:33:44 -0800 | [diff] [blame] | 296 | module_param(ql2xprotguard, int, 0644); |
| 297 | MODULE_PARM_DESC(ql2xprotguard, "Override choice of DIX checksum\n" |
| 298 | " 0 -- Let HBA firmware decide\n" |
| 299 | " 1 -- Force T10 CRC\n" |
| 300 | " 2 -- Force IP checksum\n"); |
| 301 | |
Giridhar Malavali | 50b8127 | 2018-12-21 09:33:45 -0800 | [diff] [blame] | 302 | int ql2xdifbundlinginternalbuffers; |
| 303 | module_param(ql2xdifbundlinginternalbuffers, int, 0644); |
| 304 | MODULE_PARM_DESC(ql2xdifbundlinginternalbuffers, |
| 305 | "Force using internal buffers for DIF information\n" |
| 306 | "0 (Default). Based on check.\n" |
| 307 | "1 Force using internal buffers\n"); |
| 308 | |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 309 | static void qla2x00_clear_drv_active(struct qla_hw_data *); |
Saurav Kashyap | 3491255 | 2013-06-25 11:27:18 -0400 | [diff] [blame] | 310 | static void qla2x00_free_device(scsi_qla_host_t *); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 311 | static int qla2xxx_map_queues(struct Scsi_Host *shost); |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 312 | static void qla2x00_destroy_deferred_work(struct qla_hw_data *); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 313 | |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 314 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 316 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | /* TODO Convert to inlines |
| 319 | * |
| 320 | * Timer routines |
| 321 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 323 | __inline__ void |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 324 | qla2x00_start_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | { |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 326 | timer_setup(&vha->timer, qla2x00_timer, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 327 | vha->timer.expires = jiffies + interval * HZ; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 328 | add_timer(&vha->timer); |
| 329 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 333 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 335 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 336 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 337 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 338 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 339 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 340 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 341 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 342 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 345 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 346 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 348 | del_timer_sync(&vha->timer); |
| 349 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | } |
| 351 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | static int qla2x00_do_dpc(void *data); |
| 353 | |
| 354 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 355 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 356 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 357 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 358 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 359 | static void qla2x00_mem_free(struct qla_hw_data *); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 360 | int qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 361 | struct qla_qpair *qpair); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | /* -------------------------------------------------------------------------- */ |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 364 | static void qla_init_base_qpair(struct scsi_qla_host *vha, struct req_que *req, |
| 365 | struct rsp_que *rsp) |
| 366 | { |
| 367 | struct qla_hw_data *ha = vha->hw; |
Bart Van Assche | bd432bb | 2019-04-11 14:53:17 -0700 | [diff] [blame] | 368 | |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 369 | rsp->qpair = ha->base_qpair; |
| 370 | rsp->req = req; |
Quinn Tran | 0691094 | 2018-09-04 14:19:12 -0700 | [diff] [blame] | 371 | ha->base_qpair->hw = ha; |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 372 | ha->base_qpair->req = req; |
| 373 | ha->base_qpair->rsp = rsp; |
| 374 | ha->base_qpair->vha = vha; |
| 375 | ha->base_qpair->qp_lock_ptr = &ha->hardware_lock; |
| 376 | ha->base_qpair->use_shadow_reg = IS_SHADOW_REG_CAPABLE(ha) ? 1 : 0; |
| 377 | ha->base_qpair->msix = &ha->msix_entries[QLA_MSIX_RSP_Q]; |
Quinn Tran | 6a62946 | 2018-09-04 14:19:15 -0700 | [diff] [blame] | 378 | ha->base_qpair->srb_mempool = ha->srb_mempool; |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 379 | INIT_LIST_HEAD(&ha->base_qpair->hints_list); |
| 380 | ha->base_qpair->enable_class_2 = ql2xenableclass2; |
| 381 | /* init qpair to this cpu. Will adjust at run time. */ |
Bart Van Assche | 8653188 | 2017-11-06 11:59:05 -0800 | [diff] [blame] | 382 | qla_cpu_update(rsp->qpair, raw_smp_processor_id()); |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 383 | ha->base_qpair->pdev = ha->pdev; |
| 384 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 385 | if (IS_QLA27XX(ha) || IS_QLA83XX(ha) || IS_QLA28XX(ha)) |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 386 | ha->base_qpair->reqq_start_iocbs = qla_83xx_start_iocbs; |
| 387 | } |
| 388 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 389 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 390 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 391 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 392 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Bart Van Assche | bd432bb | 2019-04-11 14:53:17 -0700 | [diff] [blame] | 393 | |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 394 | 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] | 395 | GFP_KERNEL); |
| 396 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 397 | ql_log(ql_log_fatal, vha, 0x003b, |
| 398 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 399 | goto fail_req_map; |
| 400 | } |
| 401 | |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 402 | 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] | 403 | GFP_KERNEL); |
| 404 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 405 | ql_log(ql_log_fatal, vha, 0x003c, |
| 406 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 407 | goto fail_rsp_map; |
| 408 | } |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 409 | |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 410 | ha->base_qpair = kzalloc(sizeof(struct qla_qpair), GFP_KERNEL); |
| 411 | if (ha->base_qpair == NULL) { |
| 412 | ql_log(ql_log_warn, vha, 0x00e0, |
| 413 | "Failed to allocate base queue pair memory.\n"); |
| 414 | goto fail_base_qpair; |
| 415 | } |
| 416 | |
Quinn Tran | 8abfa9e | 2017-06-13 20:47:24 -0700 | [diff] [blame] | 417 | qla_init_base_qpair(vha, req, rsp); |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 418 | |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 419 | if ((ql2xmqsupport || ql2xnvmeenable) && ha->max_qpairs) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 420 | ha->queue_pair_map = kcalloc(ha->max_qpairs, sizeof(struct qla_qpair *), |
| 421 | GFP_KERNEL); |
| 422 | if (!ha->queue_pair_map) { |
| 423 | ql_log(ql_log_fatal, vha, 0x0180, |
| 424 | "Unable to allocate memory for queue pair ptrs.\n"); |
| 425 | goto fail_qpair_map; |
| 426 | } |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 427 | } |
| 428 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 429 | /* |
| 430 | * Make sure we record at least the request and response queue zero in |
| 431 | * case we need to free them if part of the probe fails. |
| 432 | */ |
| 433 | ha->rsp_q_map[0] = rsp; |
| 434 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 435 | set_bit(0, ha->rsp_qid_map); |
| 436 | set_bit(0, ha->req_qid_map); |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 437 | return 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 438 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 439 | fail_qpair_map: |
Quinn Tran | 82de802 | 2017-06-13 20:47:17 -0700 | [diff] [blame] | 440 | kfree(ha->base_qpair); |
| 441 | ha->base_qpair = NULL; |
| 442 | fail_base_qpair: |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 443 | kfree(ha->rsp_q_map); |
| 444 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 445 | fail_rsp_map: |
| 446 | kfree(ha->req_q_map); |
| 447 | ha->req_q_map = NULL; |
| 448 | fail_req_map: |
| 449 | return -ENOMEM; |
| 450 | } |
| 451 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 452 | 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] | 453 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 454 | if (IS_QLAFX00(ha)) { |
| 455 | if (req && req->ring_fx00) |
| 456 | dma_free_coherent(&ha->pdev->dev, |
| 457 | (req->length_fx00 + 1) * sizeof(request_t), |
| 458 | req->ring_fx00, req->dma_fx00); |
| 459 | } else if (req && req->ring) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 460 | dma_free_coherent(&ha->pdev->dev, |
| 461 | (req->length + 1) * sizeof(request_t), |
| 462 | req->ring, req->dma); |
| 463 | |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 464 | if (req) |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 465 | kfree(req->outstanding_cmds); |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 466 | |
| 467 | kfree(req); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 468 | } |
| 469 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 470 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 471 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 472 | if (IS_QLAFX00(ha)) { |
Meelis Roos | 3f6c9be | 2018-03-08 15:44:37 +0200 | [diff] [blame] | 473 | if (rsp && rsp->ring_fx00) |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 474 | dma_free_coherent(&ha->pdev->dev, |
| 475 | (rsp->length_fx00 + 1) * sizeof(request_t), |
| 476 | rsp->ring_fx00, rsp->dma_fx00); |
| 477 | } else if (rsp && rsp->ring) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 478 | dma_free_coherent(&ha->pdev->dev, |
| 479 | (rsp->length + 1) * sizeof(response_t), |
| 480 | rsp->ring, rsp->dma); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 481 | } |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 482 | kfree(rsp); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 483 | } |
| 484 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 485 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 486 | { |
| 487 | struct req_que *req; |
| 488 | struct rsp_que *rsp; |
| 489 | int cnt; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 490 | unsigned long flags; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 491 | |
Quinn Tran | 82de802 | 2017-06-13 20:47:17 -0700 | [diff] [blame] | 492 | if (ha->queue_pair_map) { |
| 493 | kfree(ha->queue_pair_map); |
| 494 | ha->queue_pair_map = NULL; |
| 495 | } |
| 496 | if (ha->base_qpair) { |
| 497 | kfree(ha->base_qpair); |
| 498 | ha->base_qpair = NULL; |
| 499 | } |
| 500 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 501 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 502 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 503 | if (!test_bit(cnt, ha->req_qid_map)) |
| 504 | continue; |
| 505 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 506 | req = ha->req_q_map[cnt]; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 507 | clear_bit(cnt, ha->req_qid_map); |
| 508 | ha->req_q_map[cnt] = NULL; |
| 509 | |
| 510 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 511 | qla2x00_free_req_que(ha, req); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 512 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 513 | } |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 514 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 515 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 516 | kfree(ha->req_q_map); |
| 517 | ha->req_q_map = NULL; |
| 518 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 519 | |
| 520 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 521 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 522 | if (!test_bit(cnt, ha->rsp_qid_map)) |
| 523 | continue; |
| 524 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 525 | rsp = ha->rsp_q_map[cnt]; |
Dave Jones | c3c4239 | 2016-12-27 13:13:21 -0500 | [diff] [blame] | 526 | clear_bit(cnt, ha->rsp_qid_map); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 527 | ha->rsp_q_map[cnt] = NULL; |
| 528 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 529 | qla2x00_free_rsp_que(ha, rsp); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 530 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 531 | } |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 532 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 533 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 534 | kfree(ha->rsp_q_map); |
| 535 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 536 | } |
| 537 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 539 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 541 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | static char *pci_bus_modes[] = { |
| 543 | "33", "66", "100", "133", |
| 544 | }; |
| 545 | uint16_t pci_bus; |
| 546 | |
| 547 | strcpy(str, "PCI"); |
| 548 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 549 | if (pci_bus) { |
| 550 | strcat(str, "-X ("); |
| 551 | strcat(str, pci_bus_modes[pci_bus]); |
| 552 | } else { |
| 553 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 554 | strcat(str, " ("); |
| 555 | strcat(str, pci_bus_modes[pci_bus]); |
| 556 | } |
| 557 | strcat(str, " MHz)"); |
| 558 | |
| 559 | return (str); |
| 560 | } |
| 561 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 562 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 563 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 564 | { |
| 565 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 566 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 567 | uint32_t pci_bus; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 568 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 569 | if (pci_is_pcie(ha->pdev)) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 570 | char lwstr[6]; |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 571 | uint32_t lstat, lspeed, lwidth; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 572 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 573 | pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); |
| 574 | lspeed = lstat & PCI_EXP_LNKCAP_SLS; |
| 575 | lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 576 | |
| 577 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 578 | switch (lspeed) { |
| 579 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 580 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 581 | break; |
| 582 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 583 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 584 | break; |
| 585 | case 3: |
| 586 | strcat(str, "8.0GT/s "); |
| 587 | break; |
| 588 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 589 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 590 | break; |
| 591 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 592 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 593 | strcat(str, lwstr); |
| 594 | |
| 595 | return str; |
| 596 | } |
| 597 | |
| 598 | strcpy(str, "PCI"); |
| 599 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 600 | if (pci_bus == 0 || pci_bus == 8) { |
| 601 | strcat(str, " ("); |
| 602 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 603 | } else { |
| 604 | strcat(str, "-X "); |
| 605 | if (pci_bus & BIT_2) |
| 606 | strcat(str, "Mode 2"); |
| 607 | else |
| 608 | strcat(str, "Mode 1"); |
| 609 | strcat(str, " ("); |
| 610 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 611 | } |
| 612 | strcat(str, " MHz)"); |
| 613 | |
| 614 | return str; |
| 615 | } |
| 616 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 617 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 618 | 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] | 619 | { |
| 620 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 621 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 622 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 623 | snprintf(str, size, "%d.%02d.%02d ", ha->fw_major_version, |
| 624 | ha->fw_minor_version, ha->fw_subminor_version); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | |
| 626 | if (ha->fw_attributes & BIT_9) { |
| 627 | strcat(str, "FLX"); |
| 628 | return (str); |
| 629 | } |
| 630 | |
| 631 | switch (ha->fw_attributes & 0xFF) { |
| 632 | case 0x7: |
| 633 | strcat(str, "EF"); |
| 634 | break; |
| 635 | case 0x17: |
| 636 | strcat(str, "TP"); |
| 637 | break; |
| 638 | case 0x37: |
| 639 | strcat(str, "IP"); |
| 640 | break; |
| 641 | case 0x77: |
| 642 | strcat(str, "VI"); |
| 643 | break; |
| 644 | default: |
| 645 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 646 | strcat(str, un_str); |
| 647 | break; |
| 648 | } |
| 649 | if (ha->fw_attributes & 0x100) |
| 650 | strcat(str, "X"); |
| 651 | |
| 652 | return (str); |
| 653 | } |
| 654 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 655 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 656 | 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] | 657 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 658 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 659 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 660 | snprintf(str, size, "%d.%02d.%02d (%x)", ha->fw_major_version, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 661 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 662 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 663 | } |
| 664 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 665 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 666 | qla2x00_sp_free_dma(void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 667 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 668 | srb_t *sp = ptr; |
| 669 | struct qla_hw_data *ha = sp->vha->hw; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 670 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 671 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 672 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 673 | if (sp->flags & SRB_DMA_VALID) { |
| 674 | scsi_dma_unmap(cmd); |
| 675 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 676 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 677 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 678 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 679 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 680 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 681 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 682 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 683 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 684 | if (!ctx) |
Giridhar Malavali | 711a08d | 2019-04-02 14:24:33 -0700 | [diff] [blame] | 685 | return; |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 686 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 687 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 688 | /* List assured to be having elements */ |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 689 | qla2x00_clean_dsd_pool(ha, ctx); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 690 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 691 | } |
| 692 | |
| 693 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 694 | struct crc_context *ctx0 = ctx; |
| 695 | |
| 696 | dma_pool_free(ha->dl_dma_pool, ctx0, ctx0->crc_ctx_dma); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 697 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 698 | } |
| 699 | |
| 700 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 701 | struct ct6_dsd *ctx1 = ctx; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 702 | |
| 703 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 704 | ctx1->fcp_cmnd_dma); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 705 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 706 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 707 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 708 | mempool_free(ctx1, ha->ctx_mempool); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 709 | } |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 710 | } |
| 711 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 712 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 713 | qla2x00_sp_compl(void *ptr, int res) |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 714 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 715 | srb_t *sp = ptr; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 716 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 717 | struct completion *comp = sp->comp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 718 | |
Bart Van Assche | db4bf82 | 2019-04-17 14:44:40 -0700 | [diff] [blame] | 719 | if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0)) |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 720 | return; |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 721 | |
| 722 | atomic_dec(&sp->ref_count); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 723 | |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 724 | sp->free(sp); |
Giridhar Malavali | 740e293 | 2019-04-02 14:24:20 -0700 | [diff] [blame] | 725 | cmd->result = res; |
Giridhar Malavali | 711a08d | 2019-04-02 14:24:33 -0700 | [diff] [blame] | 726 | CMD_SP(cmd) = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 727 | cmd->scsi_done(cmd); |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 728 | if (comp) |
| 729 | complete(comp); |
Giridhar Malavali | 711a08d | 2019-04-02 14:24:33 -0700 | [diff] [blame] | 730 | qla2x00_rel_sp(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 731 | } |
| 732 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 733 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 734 | qla2xxx_qpair_sp_free_dma(void *ptr) |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 735 | { |
| 736 | srb_t *sp = (srb_t *)ptr; |
| 737 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 738 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 739 | void *ctx = GET_CMD_CTX_SP(sp); |
| 740 | |
| 741 | if (sp->flags & SRB_DMA_VALID) { |
| 742 | scsi_dma_unmap(cmd); |
| 743 | sp->flags &= ~SRB_DMA_VALID; |
| 744 | } |
| 745 | |
| 746 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 747 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 748 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 749 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 750 | } |
| 751 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 752 | if (!ctx) |
Giridhar Malavali | 711a08d | 2019-04-02 14:24:33 -0700 | [diff] [blame] | 753 | return; |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 754 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 755 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 756 | /* List assured to be having elements */ |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 757 | qla2x00_clean_dsd_pool(ha, ctx); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 758 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 759 | } |
| 760 | |
Giridhar Malavali | 50b8127 | 2018-12-21 09:33:45 -0800 | [diff] [blame] | 761 | if (sp->flags & SRB_DIF_BUNDL_DMA_VALID) { |
Bart Van Assche | d8f945b | 2019-04-17 14:44:25 -0700 | [diff] [blame] | 762 | struct crc_context *difctx = ctx; |
Giridhar Malavali | 50b8127 | 2018-12-21 09:33:45 -0800 | [diff] [blame] | 763 | struct dsd_dma *dif_dsd, *nxt_dsd; |
| 764 | |
| 765 | list_for_each_entry_safe(dif_dsd, nxt_dsd, |
| 766 | &difctx->ldif_dma_hndl_list, list) { |
| 767 | list_del(&dif_dsd->list); |
| 768 | dma_pool_free(ha->dif_bundl_pool, dif_dsd->dsd_addr, |
| 769 | dif_dsd->dsd_list_dma); |
| 770 | kfree(dif_dsd); |
| 771 | difctx->no_dif_bundl--; |
| 772 | } |
| 773 | |
| 774 | list_for_each_entry_safe(dif_dsd, nxt_dsd, |
| 775 | &difctx->ldif_dsd_list, list) { |
| 776 | list_del(&dif_dsd->list); |
| 777 | dma_pool_free(ha->dl_dma_pool, dif_dsd->dsd_addr, |
| 778 | dif_dsd->dsd_list_dma); |
| 779 | kfree(dif_dsd); |
| 780 | difctx->no_ldif_dsd--; |
| 781 | } |
| 782 | |
| 783 | if (difctx->no_ldif_dsd) { |
| 784 | ql_dbg(ql_dbg_tgt+ql_dbg_verbose, sp->vha, 0xe022, |
| 785 | "%s: difctx->no_ldif_dsd=%x\n", |
| 786 | __func__, difctx->no_ldif_dsd); |
| 787 | } |
| 788 | |
| 789 | if (difctx->no_dif_bundl) { |
| 790 | ql_dbg(ql_dbg_tgt+ql_dbg_verbose, sp->vha, 0xe022, |
| 791 | "%s: difctx->no_dif_bundl=%x\n", |
| 792 | __func__, difctx->no_dif_bundl); |
| 793 | } |
| 794 | sp->flags &= ~SRB_DIF_BUNDL_DMA_VALID; |
| 795 | } |
Bart Van Assche | d8f945b | 2019-04-17 14:44:25 -0700 | [diff] [blame] | 796 | |
| 797 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
| 798 | struct ct6_dsd *ctx1 = ctx; |
| 799 | |
| 800 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 801 | ctx1->fcp_cmnd_dma); |
| 802 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 803 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 804 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 805 | mempool_free(ctx1, ha->ctx_mempool); |
| 806 | sp->flags &= ~SRB_FCP_CMND_DMA_VALID; |
| 807 | } |
| 808 | |
| 809 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
| 810 | struct crc_context *ctx0 = ctx; |
| 811 | |
| 812 | dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma); |
| 813 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 814 | } |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 815 | } |
| 816 | |
| 817 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 818 | qla2xxx_qpair_sp_compl(void *ptr, int res) |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 819 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 820 | srb_t *sp = ptr; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 821 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 822 | struct completion *comp = sp->comp; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 823 | |
Bart Van Assche | db4bf82 | 2019-04-17 14:44:40 -0700 | [diff] [blame] | 824 | if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0)) |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 825 | return; |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 826 | |
| 827 | atomic_dec(&sp->ref_count); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 828 | |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 829 | sp->free(sp); |
Giridhar Malavali | 711a08d | 2019-04-02 14:24:33 -0700 | [diff] [blame] | 830 | cmd->result = res; |
| 831 | CMD_SP(cmd) = NULL; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 832 | cmd->scsi_done(cmd); |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 833 | if (comp) |
| 834 | complete(comp); |
Giridhar Malavali | 711a08d | 2019-04-02 14:24:33 -0700 | [diff] [blame] | 835 | qla2xxx_rel_qpair_sp(sp->qpair, sp); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 836 | } |
| 837 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 839 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 840 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 841 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 842 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 843 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 844 | struct qla_hw_data *ha = vha->hw; |
| 845 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 846 | srb_t *sp; |
| 847 | int rval; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 848 | struct qla_qpair *qpair = NULL; |
| 849 | uint32_t tag; |
| 850 | uint16_t hwq; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 851 | |
Bart Van Assche | 2dbb02f | 2019-04-17 14:44:19 -0700 | [diff] [blame] | 852 | if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags)) || |
| 853 | WARN_ON_ONCE(!rport)) { |
Mauricio Faria de Oliveira | 04dfaa5 | 2016-11-07 17:53:30 -0200 | [diff] [blame] | 854 | cmd->result = DID_NO_CONNECT << 16; |
| 855 | goto qc24_fail_command; |
| 856 | } |
| 857 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 858 | if (ha->mqenable) { |
Jens Axboe | f664a3c | 2018-11-01 16:36:27 -0600 | [diff] [blame] | 859 | tag = blk_mq_unique_tag(cmd->request); |
| 860 | hwq = blk_mq_unique_tag_to_hwq(tag); |
| 861 | qpair = ha->queue_pair_map[hwq]; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 862 | |
| 863 | if (qpair) |
| 864 | return qla2xxx_mqueuecommand(host, cmd, qpair); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 865 | } |
| 866 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 867 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 868 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 869 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 870 | "PCI Channel IO permanent failure, exiting " |
| 871 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 872 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 873 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 874 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 875 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 876 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 877 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 878 | goto qc24_fail_command; |
| 879 | } |
| 880 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 881 | rval = fc_remote_port_chkready(rport); |
| 882 | if (rval) { |
| 883 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 884 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 885 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 886 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 887 | goto qc24_fail_command; |
| 888 | } |
| 889 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 890 | if (!vha->flags.difdix_supported && |
| 891 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 892 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 893 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 894 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 895 | cmd->result = DID_NO_CONNECT << 16; |
| 896 | goto qc24_fail_command; |
| 897 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 898 | |
| 899 | if (!fcport) { |
| 900 | cmd->result = DID_NO_CONNECT << 16; |
| 901 | goto qc24_fail_command; |
| 902 | } |
| 903 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 904 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 905 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 906 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 907 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 908 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 909 | atomic_read(&fcport->state), |
| 910 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 911 | cmd->result = DID_NO_CONNECT << 16; |
| 912 | goto qc24_fail_command; |
| 913 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 914 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 915 | } |
| 916 | |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 917 | /* |
| 918 | * Return target busy if we've received a non-zero retry_delay_timer |
| 919 | * in a FCP_RSP. |
| 920 | */ |
Bruno Prémont | 975f7d4 | 2014-12-19 10:29:16 +0100 | [diff] [blame] | 921 | if (fcport->retry_delay_timestamp == 0) { |
| 922 | /* retry delay not set */ |
| 923 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 924 | fcport->retry_delay_timestamp = 0; |
| 925 | else |
| 926 | goto qc24_target_busy; |
| 927 | |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 928 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 929 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 930 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 931 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 932 | sp->u.scmd.cmd = cmd; |
| 933 | sp->type = SRB_SCSI_CMD; |
| 934 | atomic_set(&sp->ref_count, 1); |
| 935 | CMD_SP(cmd) = (void *)sp; |
| 936 | sp->free = qla2x00_sp_free_dma; |
| 937 | sp->done = qla2x00_sp_compl; |
| 938 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 939 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 940 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 941 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 942 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 943 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 944 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 945 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 946 | return 0; |
| 947 | |
| 948 | qc24_host_busy_free_sp: |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 949 | sp->free(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 950 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 951 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 952 | return SCSI_MLQUEUE_HOST_BUSY; |
| 953 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 954 | qc24_target_busy: |
| 955 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 956 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 957 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 958 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 959 | |
| 960 | return 0; |
| 961 | } |
| 962 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 963 | /* For MQ supported I/O */ |
| 964 | int |
| 965 | qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 966 | struct qla_qpair *qpair) |
| 967 | { |
| 968 | scsi_qla_host_t *vha = shost_priv(host); |
| 969 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 970 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
| 971 | struct qla_hw_data *ha = vha->hw; |
| 972 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
| 973 | srb_t *sp; |
| 974 | int rval; |
| 975 | |
Bart Van Assche | 2dbb02f | 2019-04-17 14:44:19 -0700 | [diff] [blame] | 976 | rval = rport ? fc_remote_port_chkready(rport) : FC_PORTSTATE_OFFLINE; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 977 | if (rval) { |
| 978 | cmd->result = rval; |
| 979 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3076, |
| 980 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 981 | cmd, rval); |
| 982 | goto qc24_fail_command; |
| 983 | } |
| 984 | |
| 985 | if (!fcport) { |
| 986 | cmd->result = DID_NO_CONNECT << 16; |
| 987 | goto qc24_fail_command; |
| 988 | } |
| 989 | |
| 990 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 991 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
| 992 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
| 993 | ql_dbg(ql_dbg_io, vha, 0x3077, |
| 994 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 995 | atomic_read(&fcport->state), |
| 996 | atomic_read(&base_vha->loop_state)); |
| 997 | cmd->result = DID_NO_CONNECT << 16; |
| 998 | goto qc24_fail_command; |
| 999 | } |
| 1000 | goto qc24_target_busy; |
| 1001 | } |
| 1002 | |
| 1003 | /* |
| 1004 | * Return target busy if we've received a non-zero retry_delay_timer |
| 1005 | * in a FCP_RSP. |
| 1006 | */ |
| 1007 | if (fcport->retry_delay_timestamp == 0) { |
| 1008 | /* retry delay not set */ |
| 1009 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
| 1010 | fcport->retry_delay_timestamp = 0; |
| 1011 | else |
| 1012 | goto qc24_target_busy; |
| 1013 | |
Quinn Tran | 6a62946 | 2018-09-04 14:19:15 -0700 | [diff] [blame] | 1014 | sp = qla2xxx_get_qpair_sp(vha, qpair, fcport, GFP_ATOMIC); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1015 | if (!sp) |
| 1016 | goto qc24_host_busy; |
| 1017 | |
| 1018 | sp->u.scmd.cmd = cmd; |
| 1019 | sp->type = SRB_SCSI_CMD; |
| 1020 | atomic_set(&sp->ref_count, 1); |
| 1021 | CMD_SP(cmd) = (void *)sp; |
| 1022 | sp->free = qla2xxx_qpair_sp_free_dma; |
| 1023 | sp->done = qla2xxx_qpair_sp_compl; |
| 1024 | sp->qpair = qpair; |
| 1025 | |
| 1026 | rval = ha->isp_ops->start_scsi_mq(sp); |
| 1027 | if (rval != QLA_SUCCESS) { |
| 1028 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3078, |
| 1029 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
| 1030 | if (rval == QLA_INTERFACE_ERROR) |
| 1031 | goto qc24_fail_command; |
| 1032 | goto qc24_host_busy_free_sp; |
| 1033 | } |
| 1034 | |
| 1035 | return 0; |
| 1036 | |
| 1037 | qc24_host_busy_free_sp: |
Joe Carnuccio | f3caa99 | 2017-08-23 15:05:09 -0700 | [diff] [blame] | 1038 | sp->free(sp); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1039 | |
| 1040 | qc24_host_busy: |
| 1041 | return SCSI_MLQUEUE_HOST_BUSY; |
| 1042 | |
| 1043 | qc24_target_busy: |
| 1044 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 1045 | |
| 1046 | qc24_fail_command: |
| 1047 | cmd->scsi_done(cmd); |
| 1048 | |
| 1049 | return 0; |
| 1050 | } |
| 1051 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | /* |
| 1053 | * qla2x00_eh_wait_on_command |
| 1054 | * Waits for the command to be returned by the Firmware for some |
| 1055 | * max time. |
| 1056 | * |
| 1057 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1058 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | * |
| 1060 | * Return: |
| 1061 | * Not Found : 0 |
| 1062 | * Found : 1 |
| 1063 | */ |
| 1064 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1065 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 1067 | #define ABORT_POLLING_PERIOD 1000 |
Chad Dupuis | 478c3b0 | 2014-04-11 16:54:35 -0400 | [diff] [blame] | 1068 | #define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1069 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1070 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1071 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1072 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1074 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1075 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 1076 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1077 | return ret; |
| 1078 | } |
| 1079 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 1080 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 1081 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1082 | } |
| 1083 | if (CMD_SP(cmd)) |
| 1084 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1086 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1087 | } |
| 1088 | |
| 1089 | /* |
| 1090 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1091 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1092 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 1093 | * finally HBA is disabled ie marked offline |
| 1094 | * |
| 1095 | * Input: |
| 1096 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1097 | * |
| 1098 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | * Does context switching-Release SPIN_LOCK |
| 1100 | * (if any) before calling this routine. |
| 1101 | * |
| 1102 | * Return: |
| 1103 | * Success (Adapter is online) : 0 |
| 1104 | * Failed (Adapter is offline/disabled) : 1 |
| 1105 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 1106 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1107 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1108 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 1109 | int return_status; |
| 1110 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1111 | struct qla_hw_data *ha = vha->hw; |
| 1112 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1113 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1114 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1115 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1116 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1117 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1118 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1119 | |
| 1120 | msleep(1000); |
| 1121 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1122 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1123 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | else |
| 1125 | return_status = QLA_FUNCTION_FAILED; |
| 1126 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | return (return_status); |
| 1128 | } |
| 1129 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1130 | static inline int test_fcport_count(scsi_qla_host_t *vha) |
| 1131 | { |
| 1132 | struct qla_hw_data *ha = vha->hw; |
| 1133 | unsigned long flags; |
| 1134 | int res; |
| 1135 | |
| 1136 | spin_lock_irqsave(&ha->tgt.sess_lock, flags); |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 1137 | ql_dbg(ql_dbg_init, vha, 0x00ec, |
| 1138 | "tgt %p, fcport_count=%d\n", |
| 1139 | vha, vha->fcport_count); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1140 | res = (vha->fcport_count == 0); |
| 1141 | spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); |
| 1142 | |
| 1143 | return res; |
| 1144 | } |
| 1145 | |
| 1146 | /* |
| 1147 | * qla2x00_wait_for_sess_deletion can only be called from remove_one. |
| 1148 | * it has dependency on UNLOADING flag to stop device discovery |
| 1149 | */ |
Quinn Tran | efa93f4 | 2018-07-18 14:29:52 -0700 | [diff] [blame] | 1150 | void |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1151 | qla2x00_wait_for_sess_deletion(scsi_qla_host_t *vha) |
| 1152 | { |
| 1153 | qla2x00_mark_all_devices_lost(vha, 0); |
| 1154 | |
Joe Carnuccio | b85e095 | 2017-08-23 15:05:11 -0700 | [diff] [blame] | 1155 | wait_event_timeout(vha->fcport_waitQ, test_fcport_count(vha), 10*HZ); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1156 | } |
| 1157 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1158 | /* |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1159 | * qla2x00_wait_for_hba_ready |
| 1160 | * Wait till the HBA is ready before doing driver unload |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1161 | * |
| 1162 | * Input: |
| 1163 | * ha - pointer to host adapter structure |
| 1164 | * |
| 1165 | * Note: |
| 1166 | * Does context switching-Release SPIN_LOCK |
| 1167 | * (if any) before calling this routine. |
| 1168 | * |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1169 | */ |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1170 | static void |
| 1171 | qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1172 | { |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1173 | struct qla_hw_data *ha = vha->hw; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1174 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1175 | |
Dan Carpenter | 1d48390 | 2016-08-03 21:42:32 +0300 | [diff] [blame] | 1176 | while ((qla2x00_reset_active(vha) || ha->dpc_active || |
| 1177 | ha->flags.mbox_busy) || |
| 1178 | test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags) || |
| 1179 | test_bit(FX00_TARGET_SCAN, &vha->dpc_flags)) { |
| 1180 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 1181 | break; |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1182 | msleep(1000); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1183 | } |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1184 | } |
| 1185 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 1186 | int |
| 1187 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 1188 | { |
| 1189 | int return_status; |
| 1190 | unsigned long wait_reset; |
| 1191 | struct qla_hw_data *ha = vha->hw; |
| 1192 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 1193 | |
| 1194 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 1195 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1196 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1197 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1198 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 1199 | |
| 1200 | msleep(1000); |
| 1201 | |
| 1202 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 1203 | ha->flags.chip_reset_done) |
| 1204 | break; |
| 1205 | } |
| 1206 | if (ha->flags.chip_reset_done) |
| 1207 | return_status = QLA_SUCCESS; |
| 1208 | else |
| 1209 | return_status = QLA_FUNCTION_FAILED; |
| 1210 | |
| 1211 | return return_status; |
| 1212 | } |
| 1213 | |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 1214 | static int |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 1215 | sp_get(struct srb *sp) |
| 1216 | { |
Bart Van Assche | 845bbb0 | 2019-04-11 14:53:18 -0700 | [diff] [blame] | 1217 | if (!refcount_inc_not_zero((refcount_t *)&sp->ref_count)) |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 1218 | /* kref get fail */ |
| 1219 | return ENXIO; |
| 1220 | else |
| 1221 | return 0; |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 1222 | } |
| 1223 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1224 | #define ISP_REG_DISCONNECT 0xffffffffU |
| 1225 | /************************************************************************** |
| 1226 | * qla2x00_isp_reg_stat |
| 1227 | * |
| 1228 | * Description: |
| 1229 | * Read the host status register of ISP before aborting the command. |
| 1230 | * |
| 1231 | * Input: |
| 1232 | * ha = pointer to host adapter structure. |
| 1233 | * |
| 1234 | * |
| 1235 | * Returns: |
| 1236 | * Either true or false. |
| 1237 | * |
| 1238 | * Note: Return true if there is register disconnect. |
| 1239 | **************************************************************************/ |
| 1240 | static inline |
| 1241 | uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) |
| 1242 | { |
| 1243 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
Sawan Chandak | bf6061b1 | 2017-03-31 14:37:03 -0700 | [diff] [blame] | 1244 | struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1245 | |
Sawan Chandak | bf6061b1 | 2017-03-31 14:37:03 -0700 | [diff] [blame] | 1246 | if (IS_P3P_TYPE(ha)) |
| 1247 | return ((RD_REG_DWORD(®82->host_int)) == ISP_REG_DISCONNECT); |
| 1248 | else |
| 1249 | return ((RD_REG_DWORD(®->host_status)) == |
| 1250 | ISP_REG_DISCONNECT); |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1251 | } |
| 1252 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1253 | /************************************************************************** |
| 1254 | * qla2xxx_eh_abort |
| 1255 | * |
| 1256 | * Description: |
| 1257 | * The abort function will abort the specified command. |
| 1258 | * |
| 1259 | * Input: |
| 1260 | * cmd = Linux SCSI command packet to be aborted. |
| 1261 | * |
| 1262 | * Returns: |
| 1263 | * Either SUCCESS or FAILED. |
| 1264 | * |
| 1265 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1266 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1268 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1269 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 1270 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1271 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1272 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1273 | int ret; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1274 | unsigned int id; |
| 1275 | uint64_t lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1276 | unsigned long flags; |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1277 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1278 | struct qla_hw_data *ha = vha->hw; |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 1279 | struct qla_qpair *qpair; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1280 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1281 | if (qla2x00_isp_reg_stat(ha)) { |
| 1282 | ql_log(ql_log_info, vha, 0x8042, |
| 1283 | "PCI/Register disconnect, exiting.\n"); |
| 1284 | return FAILED; |
| 1285 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1286 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1287 | ret = fc_block_scsi_eh(cmd); |
| 1288 | if (ret != 0) |
| 1289 | return ret; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1290 | |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1291 | sp = (srb_t *) CMD_SP(cmd); |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 1292 | if (!sp) |
| 1293 | return SUCCESS; |
| 1294 | |
| 1295 | qpair = sp->qpair; |
| 1296 | if (!qpair) |
| 1297 | return SUCCESS; |
| 1298 | |
Quinn Tran | 7f4374e | 2019-07-26 09:07:31 -0700 | [diff] [blame] | 1299 | if (sp->fcport && sp->fcport->deleted) |
| 1300 | return SUCCESS; |
| 1301 | |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 1302 | spin_lock_irqsave(qpair->qp_lock_ptr, flags); |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1303 | if (sp->type != SRB_SCSI_CMD || GET_CMD_SP(sp) != cmd) { |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 1304 | /* there's a chance an interrupt could clear |
| 1305 | the ptr as part of done & free */ |
| 1306 | spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1307 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1308 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1309 | |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 1310 | if (sp_get(sp)){ |
| 1311 | /* ref_count is already 0 */ |
| 1312 | spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); |
| 1313 | return SUCCESS; |
| 1314 | } |
| 1315 | spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); |
| 1316 | |
| 1317 | id = cmd->device->id; |
| 1318 | lun = cmd->device->lun; |
| 1319 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1320 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | c7bc4ca | 2015-08-04 13:37:57 -0400 | [diff] [blame] | 1321 | "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n", |
| 1322 | vha->host_no, id, lun, sp, cmd, sp->handle); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1323 | |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1324 | rval = ha->isp_ops->abort_command(sp); |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1325 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
| 1326 | "Abort command mbx cmd=%p, rval=%x.\n", cmd, rval); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1327 | |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1328 | switch (rval) { |
| 1329 | case QLA_SUCCESS: |
Giridhar Malavali | 711a08d | 2019-04-02 14:24:33 -0700 | [diff] [blame] | 1330 | /* |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1331 | * The command has been aborted. That means that the firmware |
| 1332 | * won't report a completion. |
Giridhar Malavali | 711a08d | 2019-04-02 14:24:33 -0700 | [diff] [blame] | 1333 | */ |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1334 | sp->done(sp, DID_ABORT << 16); |
| 1335 | ret = SUCCESS; |
| 1336 | break; |
| 1337 | default: |
| 1338 | /* |
| 1339 | * Either abort failed or abort and completion raced. Let |
| 1340 | * the SCSI core retry the abort in the former case. |
| 1341 | */ |
| 1342 | ret = FAILED; |
| 1343 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | } |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1345 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1346 | ql_log(ql_log_info, vha, 0x801c, |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1347 | "Abort command issued nexus=%ld:%d:%llu -- %x.\n", |
| 1348 | vha->host_no, id, lun, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1349 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1350 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1351 | } |
| 1352 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1353 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1354 | 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] | 1355 | uint64_t l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1356 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1357 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1358 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1359 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1360 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1361 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1362 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1363 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1364 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1365 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1366 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1367 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1368 | for (cnt = 1; status == QLA_SUCCESS && |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1369 | cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1370 | sp = req->outstanding_cmds[cnt]; |
| 1371 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1372 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1373 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1374 | continue; |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 1375 | if (vha->vp_idx != sp->vha->vp_idx) |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1376 | continue; |
| 1377 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1378 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1379 | switch (type) { |
| 1380 | case WAIT_HOST: |
| 1381 | match = 1; |
| 1382 | break; |
| 1383 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1384 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1385 | break; |
| 1386 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1387 | match = (cmd->device->id == t && |
| 1388 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1389 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1390 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1391 | if (!match) |
| 1392 | continue; |
| 1393 | |
| 1394 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1395 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1396 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1397 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1398 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1399 | |
| 1400 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1401 | } |
| 1402 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1403 | static char *reset_errors[] = { |
| 1404 | "HBA not online", |
| 1405 | "HBA not ready", |
| 1406 | "Task management failed", |
| 1407 | "Waiting for command completions", |
| 1408 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1409 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1410 | static int |
| 1411 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1412 | 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] | 1413 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1414 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1415 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1416 | int err; |
| 1417 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1418 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1419 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1420 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1421 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1422 | err = fc_block_scsi_eh(cmd); |
| 1423 | if (err != 0) |
| 1424 | return err; |
| 1425 | |
Quinn Tran | 7f4374e | 2019-07-26 09:07:31 -0700 | [diff] [blame] | 1426 | if (fcport->deleted) |
| 1427 | return SUCCESS; |
| 1428 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1429 | ql_log(ql_log_info, vha, 0x8009, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1430 | "%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] | 1431 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1432 | |
| 1433 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1434 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1435 | ql_log(ql_log_warn, vha, 0x800a, |
| 1436 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1437 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1438 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1439 | err = 2; |
Himanshu Madhani | ac444b4 | 2019-03-15 15:04:19 -0700 | [diff] [blame] | 1440 | if (do_reset(fcport, cmd->device->lun, 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1441 | != QLA_SUCCESS) { |
| 1442 | ql_log(ql_log_warn, vha, 0x800c, |
| 1443 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1444 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1445 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1446 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1447 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1448 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1449 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1450 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1451 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1452 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1453 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1454 | ql_log(ql_log_info, vha, 0x800e, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1455 | "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1456 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1457 | |
| 1458 | return SUCCESS; |
| 1459 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1460 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1461 | ql_log(ql_log_info, vha, 0x800f, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1462 | "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1463 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1464 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1465 | return FAILED; |
| 1466 | } |
| 1467 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1468 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1469 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1470 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1471 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1472 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1474 | if (qla2x00_isp_reg_stat(ha)) { |
| 1475 | ql_log(ql_log_info, vha, 0x803e, |
| 1476 | "PCI/Register disconnect, exiting.\n"); |
| 1477 | return FAILED; |
| 1478 | } |
| 1479 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1480 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1481 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1482 | } |
| 1483 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1484 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1485 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1487 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1488 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1490 | if (qla2x00_isp_reg_stat(ha)) { |
| 1491 | ql_log(ql_log_info, vha, 0x803f, |
| 1492 | "PCI/Register disconnect, exiting.\n"); |
| 1493 | return FAILED; |
| 1494 | } |
| 1495 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1496 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1497 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | } |
| 1499 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1500 | /************************************************************************** |
| 1501 | * qla2xxx_eh_bus_reset |
| 1502 | * |
| 1503 | * Description: |
| 1504 | * The bus reset function will reset the bus and abort any executing |
| 1505 | * commands. |
| 1506 | * |
| 1507 | * Input: |
| 1508 | * cmd = Linux SCSI command packet of the command that cause the |
| 1509 | * bus reset. |
| 1510 | * |
| 1511 | * Returns: |
| 1512 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1513 | * |
| 1514 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1515 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1516 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1517 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1518 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1519 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1520 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1521 | unsigned int id; |
| 1522 | uint64_t lun; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1523 | struct qla_hw_data *ha = vha->hw; |
| 1524 | |
| 1525 | if (qla2x00_isp_reg_stat(ha)) { |
| 1526 | ql_log(ql_log_info, vha, 0x8040, |
| 1527 | "PCI/Register disconnect, exiting.\n"); |
| 1528 | return FAILED; |
| 1529 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1531 | id = cmd->device->id; |
| 1532 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1533 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1534 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1535 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1536 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1538 | ret = fc_block_scsi_eh(cmd); |
| 1539 | if (ret != 0) |
| 1540 | return ret; |
| 1541 | ret = FAILED; |
| 1542 | |
Quinn Tran | 7f4374e | 2019-07-26 09:07:31 -0700 | [diff] [blame] | 1543 | if (qla2x00_chip_is_down(vha)) |
| 1544 | return ret; |
| 1545 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1546 | ql_log(ql_log_info, vha, 0x8012, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1547 | "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] | 1548 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1549 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1550 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1551 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1552 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1553 | } |
| 1554 | |
Saurav Kashyap | ad537689 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1555 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1556 | ret = SUCCESS; |
| 1557 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1558 | if (ret == FAILED) |
| 1559 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1560 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1561 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1562 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1563 | QLA_SUCCESS) { |
| 1564 | ql_log(ql_log_warn, vha, 0x8014, |
| 1565 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1566 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1567 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1568 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1569 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1570 | ql_log(ql_log_warn, vha, 0x802b, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1571 | "BUS RESET %s nexus=%ld:%d:%llu.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1572 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1573 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1574 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1575 | } |
| 1576 | |
| 1577 | /************************************************************************** |
| 1578 | * qla2xxx_eh_host_reset |
| 1579 | * |
| 1580 | * Description: |
| 1581 | * The reset function will reset the Adapter. |
| 1582 | * |
| 1583 | * Input: |
| 1584 | * cmd = Linux SCSI command packet of the command that cause the |
| 1585 | * adapter reset. |
| 1586 | * |
| 1587 | * Returns: |
| 1588 | * Either SUCCESS or FAILED. |
| 1589 | * |
| 1590 | * Note: |
| 1591 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1592 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1593 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1594 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1595 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1596 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1597 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1598 | unsigned int id; |
| 1599 | uint64_t lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1600 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1601 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1602 | if (qla2x00_isp_reg_stat(ha)) { |
| 1603 | ql_log(ql_log_info, vha, 0x8041, |
| 1604 | "PCI/Register disconnect, exiting.\n"); |
| 1605 | schedule_work(&ha->board_disable); |
| 1606 | return SUCCESS; |
| 1607 | } |
| 1608 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1609 | id = cmd->device->id; |
| 1610 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1611 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1612 | ql_log(ql_log_info, vha, 0x8018, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1613 | "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] | 1614 | |
Chad Dupuis | 63ee707 | 2014-04-11 16:54:46 -0400 | [diff] [blame] | 1615 | /* |
| 1616 | * No point in issuing another reset if one is active. Also do not |
| 1617 | * attempt a reset if we are updating flash. |
| 1618 | */ |
| 1619 | if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1620 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1622 | if (vha != base_vha) { |
| 1623 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1624 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1625 | } else { |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1626 | if (IS_P3P_TYPE(vha->hw)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1627 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1628 | /* Ctx reset success */ |
| 1629 | ret = SUCCESS; |
| 1630 | goto eh_host_reset_lock; |
| 1631 | } |
| 1632 | /* fall thru if ctx reset failed */ |
| 1633 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1634 | if (ha->wq) |
| 1635 | flush_workqueue(ha->wq); |
| 1636 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1637 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1638 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1639 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1640 | /* failed. schedule dpc to try */ |
| 1641 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1642 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1643 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1644 | ql_log(ql_log_warn, vha, 0x802a, |
| 1645 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1646 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1647 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1648 | } |
| 1649 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1650 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1651 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1652 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1653 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1654 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1655 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1656 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1657 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1658 | ql_log(ql_log_info, vha, 0x8017, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1659 | "ADAPTER RESET %s nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1660 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1661 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1662 | return ret; |
| 1663 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1664 | |
| 1665 | /* |
| 1666 | * qla2x00_loop_reset |
| 1667 | * Issue loop reset. |
| 1668 | * |
| 1669 | * Input: |
| 1670 | * ha = adapter block pointer. |
| 1671 | * |
| 1672 | * Returns: |
| 1673 | * 0 = success |
| 1674 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1675 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1676 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1677 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1678 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1679 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1680 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1681 | |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1682 | if (IS_QLAFX00(ha)) { |
| 1683 | return qlafx00_loop_reset(vha); |
| 1684 | } |
| 1685 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1686 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1687 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1688 | if (fcport->port_type != FCT_TARGET) |
| 1689 | continue; |
| 1690 | |
| 1691 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1692 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1693 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1694 | "Bus Reset failed: Reset=%d " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1695 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1696 | } |
| 1697 | } |
| 1698 | } |
| 1699 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1700 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1701 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Andrew Vasquez | 0b7e7c5 | 2013-02-08 01:57:42 -0500 | [diff] [blame] | 1702 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1703 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1704 | qla2x00_mark_all_devices_lost(vha, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1705 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1706 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1707 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1708 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1709 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1710 | } |
| 1711 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1712 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1713 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad537689 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1714 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1715 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1716 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1717 | } |
| 1718 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1719 | /* 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] | 1720 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1721 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1722 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1723 | } |
| 1724 | |
Bart Van Assche | c4e521b | 2018-11-29 10:25:11 -0800 | [diff] [blame] | 1725 | static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res, |
| 1726 | unsigned long *flags) |
| 1727 | __releases(qp->qp_lock_ptr) |
| 1728 | __acquires(qp->qp_lock_ptr) |
| 1729 | { |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1730 | DECLARE_COMPLETION_ONSTACK(comp); |
Bart Van Assche | c4e521b | 2018-11-29 10:25:11 -0800 | [diff] [blame] | 1731 | scsi_qla_host_t *vha = qp->vha; |
| 1732 | struct qla_hw_data *ha = vha->hw; |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1733 | int rval; |
Bart Van Assche | c4e521b | 2018-11-29 10:25:11 -0800 | [diff] [blame] | 1734 | |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1735 | if (sp_get(sp)) |
| 1736 | return; |
Linus Torvalds | 938edb8 | 2018-12-28 14:48:06 -0800 | [diff] [blame] | 1737 | |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1738 | if (sp->type == SRB_NVME_CMD || sp->type == SRB_NVME_LS || |
| 1739 | (sp->type == SRB_SCSI_CMD && !ha->flags.eeh_busy && |
| 1740 | !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && |
| 1741 | !qla2x00_isp_reg_stat(ha))) { |
| 1742 | sp->comp = ∁ |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1743 | spin_unlock_irqrestore(qp->qp_lock_ptr, *flags); |
Arun Easi | 5589b08 | 2019-06-14 07:36:27 -0700 | [diff] [blame] | 1744 | rval = ha->isp_ops->abort_command(sp); |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1745 | |
| 1746 | switch (rval) { |
| 1747 | case QLA_SUCCESS: |
| 1748 | sp->done(sp, res); |
| 1749 | break; |
| 1750 | case QLA_FUNCTION_PARAMETER_ERROR: |
| 1751 | wait_for_completion(&comp); |
| 1752 | break; |
Bart Van Assche | c4e521b | 2018-11-29 10:25:11 -0800 | [diff] [blame] | 1753 | } |
Bart Van Assche | 219d27d | 2019-04-17 14:44:35 -0700 | [diff] [blame] | 1754 | |
| 1755 | spin_lock_irqsave(qp->qp_lock_ptr, *flags); |
| 1756 | sp->comp = NULL; |
Bart Van Assche | c4e521b | 2018-11-29 10:25:11 -0800 | [diff] [blame] | 1757 | } |
Bart Van Assche | c4e521b | 2018-11-29 10:25:11 -0800 | [diff] [blame] | 1758 | } |
| 1759 | |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1760 | static void |
| 1761 | __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1762 | { |
Bart Van Assche | eb02322 | 2018-10-18 15:45:44 -0700 | [diff] [blame] | 1763 | int cnt; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1764 | unsigned long flags; |
| 1765 | srb_t *sp; |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1766 | scsi_qla_host_t *vha = qp->vha; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1767 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1768 | struct req_que *req; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 1769 | struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; |
| 1770 | struct qla_tgt_cmd *cmd; |
Arun Easi | c0cb449 | 2014-09-25 06:14:51 -0400 | [diff] [blame] | 1771 | |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 1772 | if (!ha->req_q_map) |
| 1773 | return; |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1774 | spin_lock_irqsave(qp->qp_lock_ptr, flags); |
| 1775 | req = qp->req; |
| 1776 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
| 1777 | sp = req->outstanding_cmds[cnt]; |
| 1778 | if (sp) { |
| 1779 | req->outstanding_cmds[cnt] = NULL; |
Quinn Tran | 6b0431d | 2018-09-04 14:19:13 -0700 | [diff] [blame] | 1780 | switch (sp->cmd_type) { |
| 1781 | case TYPE_SRB: |
Bart Van Assche | c4e521b | 2018-11-29 10:25:11 -0800 | [diff] [blame] | 1782 | qla2x00_abort_srb(qp, sp, res, &flags); |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 1783 | break; |
| 1784 | case TYPE_TGT_CMD: |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1785 | if (!vha->hw->tgt.tgt_ops || !tgt || |
| 1786 | qla_ini_mode_enabled(vha)) { |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 1787 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf003, |
| 1788 | "HOST-ABORT-HNDLR: dpc_flags=%lx. Target mode disabled\n", |
| 1789 | vha->dpc_flags); |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1790 | continue; |
| 1791 | } |
| 1792 | cmd = (struct qla_tgt_cmd *)sp; |
Bart Van Assche | aefed3e | 2019-04-17 14:44:29 -0700 | [diff] [blame] | 1793 | cmd->aborted = 1; |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 1794 | break; |
| 1795 | case TYPE_TGT_TMCMD: |
Bart Van Assche | aefed3e | 2019-04-17 14:44:29 -0700 | [diff] [blame] | 1796 | /* Skip task management functions. */ |
Quinn Tran | 585def9 | 2018-09-04 14:19:20 -0700 | [diff] [blame] | 1797 | break; |
| 1798 | default: |
| 1799 | break; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1800 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1801 | } |
| 1802 | } |
Quinn Tran | bbead49 | 2017-12-28 12:33:13 -0800 | [diff] [blame] | 1803 | spin_unlock_irqrestore(qp->qp_lock_ptr, flags); |
| 1804 | } |
| 1805 | |
| 1806 | void |
| 1807 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
| 1808 | { |
| 1809 | int que; |
| 1810 | struct qla_hw_data *ha = vha->hw; |
| 1811 | |
| 1812 | __qla2x00_abort_all_cmds(ha->base_qpair, res); |
| 1813 | |
| 1814 | for (que = 0; que < ha->max_qpairs; que++) { |
| 1815 | if (!ha->queue_pair_map[que]) |
| 1816 | continue; |
| 1817 | |
| 1818 | __qla2x00_abort_all_cmds(ha->queue_pair_map[que], res); |
| 1819 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1820 | } |
| 1821 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1822 | static int |
| 1823 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1824 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1825 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1826 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1827 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1828 | return -ENXIO; |
| 1829 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1830 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1831 | |
| 1832 | return 0; |
| 1833 | } |
| 1834 | |
| 1835 | static int |
| 1836 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1837 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1838 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1839 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1840 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1841 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1842 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1843 | |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 1844 | scsi_change_queue_depth(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1845 | return 0; |
| 1846 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1847 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1848 | static void |
| 1849 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1850 | { |
| 1851 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1852 | } |
| 1853 | |
| 1854 | /** |
| 1855 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1856 | * @ha: HA context |
| 1857 | * |
| 1858 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1859 | * supported addressing method. |
| 1860 | */ |
| 1861 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1862 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1863 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1864 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1865 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1866 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1867 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1868 | /* Any upper-dword bits set? */ |
| 1869 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1870 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1871 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1872 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1873 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1874 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1875 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1876 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1877 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1878 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1879 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1880 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1881 | } |
| 1882 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1883 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1884 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1885 | { |
| 1886 | unsigned long flags = 0; |
| 1887 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1888 | |
| 1889 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1890 | ha->interrupts_on = 1; |
| 1891 | /* enable risc and host interrupts */ |
| 1892 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1893 | RD_REG_WORD(®->ictrl); |
| 1894 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1895 | |
| 1896 | } |
| 1897 | |
| 1898 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1899 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1900 | { |
| 1901 | unsigned long flags = 0; |
| 1902 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1903 | |
| 1904 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1905 | ha->interrupts_on = 0; |
| 1906 | /* disable risc and host interrupts */ |
| 1907 | WRT_REG_WORD(®->ictrl, 0); |
| 1908 | RD_REG_WORD(®->ictrl); |
| 1909 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1910 | } |
| 1911 | |
| 1912 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1913 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1914 | { |
| 1915 | unsigned long flags = 0; |
| 1916 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1917 | |
| 1918 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1919 | ha->interrupts_on = 1; |
| 1920 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1921 | RD_REG_DWORD(®->ictrl); |
| 1922 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1923 | } |
| 1924 | |
| 1925 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1926 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1927 | { |
| 1928 | unsigned long flags = 0; |
| 1929 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1930 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1931 | if (IS_NOPOLLING_TYPE(ha)) |
| 1932 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1933 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1934 | ha->interrupts_on = 0; |
| 1935 | WRT_REG_DWORD(®->ictrl, 0); |
| 1936 | RD_REG_DWORD(®->ictrl); |
| 1937 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1938 | } |
| 1939 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1940 | static int |
| 1941 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1942 | { |
| 1943 | resource_size_t pio; |
| 1944 | uint16_t msix; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1945 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1946 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1947 | QLA2XXX_DRIVER_NAME)) { |
| 1948 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1949 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1950 | pci_name(ha->pdev)); |
| 1951 | goto iospace_error_exit; |
| 1952 | } |
| 1953 | if (!(ha->bars & 1)) |
| 1954 | goto skip_pio; |
| 1955 | |
| 1956 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1957 | pio = pci_resource_start(ha->pdev, 0); |
| 1958 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1959 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1960 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1961 | "Invalid pci I/O region size (%s).\n", |
| 1962 | pci_name(ha->pdev)); |
| 1963 | pio = 0; |
| 1964 | } |
| 1965 | } else { |
| 1966 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1967 | "Region #0 no a PIO resource (%s).\n", |
| 1968 | pci_name(ha->pdev)); |
| 1969 | pio = 0; |
| 1970 | } |
| 1971 | ha->pio_address = pio; |
| 1972 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1973 | "PIO address=%llu.\n", |
| 1974 | (unsigned long long)ha->pio_address); |
| 1975 | |
| 1976 | skip_pio: |
| 1977 | /* Use MMIO operations for all accesses. */ |
| 1978 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1979 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1980 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1981 | pci_name(ha->pdev)); |
| 1982 | goto iospace_error_exit; |
| 1983 | } |
| 1984 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1985 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1986 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1987 | pci_name(ha->pdev)); |
| 1988 | goto iospace_error_exit; |
| 1989 | } |
| 1990 | |
| 1991 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1992 | if (!ha->iobase) { |
| 1993 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1994 | "Cannot remap MMIO (%s), aborting.\n", |
| 1995 | pci_name(ha->pdev)); |
| 1996 | goto iospace_error_exit; |
| 1997 | } |
| 1998 | |
| 1999 | /* Determine queue resources */ |
| 2000 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2001 | ha->msix_count = QLA_BASE_VECTORS; |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 2002 | if (!ql2xmqsupport || !ql2xnvmeenable || |
| 2003 | (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2004 | goto mqiobase_exit; |
| 2005 | |
| 2006 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 2007 | pci_resource_len(ha->pdev, 3)); |
| 2008 | if (ha->mqiobase) { |
| 2009 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 2010 | "MQIO Base=%p.\n", ha->mqiobase); |
| 2011 | /* Read MSIX vector size of the board */ |
| 2012 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2013 | ha->msix_count = msix + 1; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2014 | /* Max queues are bounded by available msix vectors */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2015 | /* MB interrupt uses 1 vector */ |
| 2016 | ha->max_req_queues = ha->msix_count - 1; |
| 2017 | ha->max_rsp_queues = ha->max_req_queues; |
| 2018 | /* Queue pairs is the max value minus the base queue pair */ |
| 2019 | ha->max_qpairs = ha->max_rsp_queues - 1; |
| 2020 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0188, |
| 2021 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
| 2022 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2023 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2024 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2025 | } else |
| 2026 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 2027 | "BAR 3 not enabled.\n"); |
| 2028 | |
| 2029 | mqiobase_exit: |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2030 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2031 | "MSIX Count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2032 | return (0); |
| 2033 | |
| 2034 | iospace_error_exit: |
| 2035 | return (-ENOMEM); |
| 2036 | } |
| 2037 | |
| 2038 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2039 | static int |
| 2040 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 2041 | { |
| 2042 | uint16_t msix; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2043 | |
| 2044 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 2045 | QLA2XXX_DRIVER_NAME)) { |
| 2046 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 2047 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 2048 | pci_name(ha->pdev)); |
| 2049 | |
| 2050 | goto iospace_error_exit; |
| 2051 | } |
| 2052 | |
| 2053 | /* Use MMIO operations for all accesses. */ |
| 2054 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 2055 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 2056 | "Invalid pci I/O region size (%s).\n", |
| 2057 | pci_name(ha->pdev)); |
| 2058 | goto iospace_error_exit; |
| 2059 | } |
| 2060 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 2061 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 2062 | "Invalid PCI mem region size (%s), aborting\n", |
| 2063 | pci_name(ha->pdev)); |
| 2064 | goto iospace_error_exit; |
| 2065 | } |
| 2066 | |
| 2067 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 2068 | if (!ha->iobase) { |
| 2069 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 2070 | "Cannot remap MMIO (%s), aborting.\n", |
| 2071 | pci_name(ha->pdev)); |
| 2072 | goto iospace_error_exit; |
| 2073 | } |
| 2074 | |
| 2075 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 2076 | /* 83XX 26XX always use MQ type access for queues |
| 2077 | * - mbar 2, a.k.a region 4 */ |
| 2078 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2079 | ha->msix_count = QLA_BASE_VECTORS; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2080 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 2081 | pci_resource_len(ha->pdev, 4)); |
| 2082 | |
| 2083 | if (!ha->mqiobase) { |
| 2084 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 2085 | "BAR2/region4 not enabled\n"); |
| 2086 | goto mqiobase_exit; |
| 2087 | } |
| 2088 | |
| 2089 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 2090 | pci_resource_len(ha->pdev, 2)); |
| 2091 | if (ha->msixbase) { |
| 2092 | /* Read MSIX vector size of the board */ |
| 2093 | pci_read_config_word(ha->pdev, |
| 2094 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 2095 | ha->msix_count = (msix & PCI_MSIX_FLAGS_QSIZE) + 1; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 2096 | /* |
| 2097 | * By default, driver uses at least two msix vectors |
| 2098 | * (default & rspq) |
| 2099 | */ |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 2100 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2101 | /* MB interrupt uses 1 vector */ |
| 2102 | ha->max_req_queues = ha->msix_count - 1; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 2103 | |
| 2104 | /* ATIOQ needs 1 vector. That's 1 less QPair */ |
| 2105 | if (QLA_TGT_MODE_ENABLED()) |
| 2106 | ha->max_req_queues--; |
| 2107 | |
Michael Hernandez | d0d2c68 | 2017-02-15 15:37:20 -0800 | [diff] [blame] | 2108 | ha->max_rsp_queues = ha->max_req_queues; |
| 2109 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2110 | /* Queue pairs is the max value minus |
| 2111 | * the base queue pair */ |
| 2112 | ha->max_qpairs = ha->max_req_queues - 1; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2113 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x00e3, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2114 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2115 | } |
| 2116 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2117 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2118 | } else |
| 2119 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 2120 | "BAR 1 not enabled.\n"); |
| 2121 | |
| 2122 | mqiobase_exit: |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2123 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2124 | "MSIX Count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2125 | return 0; |
| 2126 | |
| 2127 | iospace_error_exit: |
| 2128 | return -ENOMEM; |
| 2129 | } |
| 2130 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2131 | static struct isp_operations qla2100_isp_ops = { |
| 2132 | .pci_config = qla2100_pci_config, |
| 2133 | .reset_chip = qla2x00_reset_chip, |
| 2134 | .chip_diag = qla2x00_chip_diag, |
| 2135 | .config_rings = qla2x00_config_rings, |
| 2136 | .reset_adapter = qla2x00_reset_adapter, |
| 2137 | .nvram_config = qla2x00_nvram_config, |
| 2138 | .update_fw_options = qla2x00_update_fw_options, |
| 2139 | .load_risc = qla2x00_load_risc, |
| 2140 | .pci_info_str = qla2x00_pci_info_str, |
| 2141 | .fw_version_str = qla2x00_fw_version_str, |
| 2142 | .intr_handler = qla2100_intr_handler, |
| 2143 | .enable_intrs = qla2x00_enable_intrs, |
| 2144 | .disable_intrs = qla2x00_disable_intrs, |
| 2145 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2146 | .target_reset = qla2x00_abort_target, |
| 2147 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2148 | .fabric_login = qla2x00_login_fabric, |
| 2149 | .fabric_logout = qla2x00_fabric_logout, |
| 2150 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 2151 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 2152 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 2153 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 2154 | .read_nvram = qla2x00_read_nvram_data, |
| 2155 | .write_nvram = qla2x00_write_nvram_data, |
| 2156 | .fw_dump = qla2100_fw_dump, |
| 2157 | .beacon_on = NULL, |
| 2158 | .beacon_off = NULL, |
| 2159 | .beacon_blink = NULL, |
| 2160 | .read_optrom = qla2x00_read_optrom_data, |
| 2161 | .write_optrom = qla2x00_write_optrom_data, |
| 2162 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2163 | .start_scsi = qla2x00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2164 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2165 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2166 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2167 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2168 | }; |
| 2169 | |
| 2170 | static struct isp_operations qla2300_isp_ops = { |
| 2171 | .pci_config = qla2300_pci_config, |
| 2172 | .reset_chip = qla2x00_reset_chip, |
| 2173 | .chip_diag = qla2x00_chip_diag, |
| 2174 | .config_rings = qla2x00_config_rings, |
| 2175 | .reset_adapter = qla2x00_reset_adapter, |
| 2176 | .nvram_config = qla2x00_nvram_config, |
| 2177 | .update_fw_options = qla2x00_update_fw_options, |
| 2178 | .load_risc = qla2x00_load_risc, |
| 2179 | .pci_info_str = qla2x00_pci_info_str, |
| 2180 | .fw_version_str = qla2x00_fw_version_str, |
| 2181 | .intr_handler = qla2300_intr_handler, |
| 2182 | .enable_intrs = qla2x00_enable_intrs, |
| 2183 | .disable_intrs = qla2x00_disable_intrs, |
| 2184 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2185 | .target_reset = qla2x00_abort_target, |
| 2186 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2187 | .fabric_login = qla2x00_login_fabric, |
| 2188 | .fabric_logout = qla2x00_fabric_logout, |
| 2189 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 2190 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 2191 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 2192 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 2193 | .read_nvram = qla2x00_read_nvram_data, |
| 2194 | .write_nvram = qla2x00_write_nvram_data, |
| 2195 | .fw_dump = qla2300_fw_dump, |
| 2196 | .beacon_on = qla2x00_beacon_on, |
| 2197 | .beacon_off = qla2x00_beacon_off, |
| 2198 | .beacon_blink = qla2x00_beacon_blink, |
| 2199 | .read_optrom = qla2x00_read_optrom_data, |
| 2200 | .write_optrom = qla2x00_write_optrom_data, |
| 2201 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2202 | .start_scsi = qla2x00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2203 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2204 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2205 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2206 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2207 | }; |
| 2208 | |
| 2209 | static struct isp_operations qla24xx_isp_ops = { |
| 2210 | .pci_config = qla24xx_pci_config, |
| 2211 | .reset_chip = qla24xx_reset_chip, |
| 2212 | .chip_diag = qla24xx_chip_diag, |
| 2213 | .config_rings = qla24xx_config_rings, |
| 2214 | .reset_adapter = qla24xx_reset_adapter, |
| 2215 | .nvram_config = qla24xx_nvram_config, |
| 2216 | .update_fw_options = qla24xx_update_fw_options, |
| 2217 | .load_risc = qla24xx_load_risc, |
| 2218 | .pci_info_str = qla24xx_pci_info_str, |
| 2219 | .fw_version_str = qla24xx_fw_version_str, |
| 2220 | .intr_handler = qla24xx_intr_handler, |
| 2221 | .enable_intrs = qla24xx_enable_intrs, |
| 2222 | .disable_intrs = qla24xx_disable_intrs, |
| 2223 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2224 | .target_reset = qla24xx_abort_target, |
| 2225 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2226 | .fabric_login = qla24xx_login_fabric, |
| 2227 | .fabric_logout = qla24xx_fabric_logout, |
| 2228 | .calc_req_entries = NULL, |
| 2229 | .build_iocbs = NULL, |
| 2230 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2231 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2232 | .read_nvram = qla24xx_read_nvram_data, |
| 2233 | .write_nvram = qla24xx_write_nvram_data, |
| 2234 | .fw_dump = qla24xx_fw_dump, |
| 2235 | .beacon_on = qla24xx_beacon_on, |
| 2236 | .beacon_off = qla24xx_beacon_off, |
| 2237 | .beacon_blink = qla24xx_beacon_blink, |
| 2238 | .read_optrom = qla24xx_read_optrom_data, |
| 2239 | .write_optrom = qla24xx_write_optrom_data, |
| 2240 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2241 | .start_scsi = qla24xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2242 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2243 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2244 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2245 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2246 | }; |
| 2247 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2248 | static struct isp_operations qla25xx_isp_ops = { |
| 2249 | .pci_config = qla25xx_pci_config, |
| 2250 | .reset_chip = qla24xx_reset_chip, |
| 2251 | .chip_diag = qla24xx_chip_diag, |
| 2252 | .config_rings = qla24xx_config_rings, |
| 2253 | .reset_adapter = qla24xx_reset_adapter, |
| 2254 | .nvram_config = qla24xx_nvram_config, |
| 2255 | .update_fw_options = qla24xx_update_fw_options, |
| 2256 | .load_risc = qla24xx_load_risc, |
| 2257 | .pci_info_str = qla24xx_pci_info_str, |
| 2258 | .fw_version_str = qla24xx_fw_version_str, |
| 2259 | .intr_handler = qla24xx_intr_handler, |
| 2260 | .enable_intrs = qla24xx_enable_intrs, |
| 2261 | .disable_intrs = qla24xx_disable_intrs, |
| 2262 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2263 | .target_reset = qla24xx_abort_target, |
| 2264 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2265 | .fabric_login = qla24xx_login_fabric, |
| 2266 | .fabric_logout = qla24xx_fabric_logout, |
| 2267 | .calc_req_entries = NULL, |
| 2268 | .build_iocbs = NULL, |
| 2269 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2270 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2271 | .read_nvram = qla25xx_read_nvram_data, |
| 2272 | .write_nvram = qla25xx_write_nvram_data, |
| 2273 | .fw_dump = qla25xx_fw_dump, |
| 2274 | .beacon_on = qla24xx_beacon_on, |
| 2275 | .beacon_off = qla24xx_beacon_off, |
| 2276 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 2277 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2278 | .write_optrom = qla24xx_write_optrom_data, |
| 2279 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2280 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2281 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2282 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2283 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2284 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2285 | }; |
| 2286 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2287 | static struct isp_operations qla81xx_isp_ops = { |
| 2288 | .pci_config = qla25xx_pci_config, |
| 2289 | .reset_chip = qla24xx_reset_chip, |
| 2290 | .chip_diag = qla24xx_chip_diag, |
| 2291 | .config_rings = qla24xx_config_rings, |
| 2292 | .reset_adapter = qla24xx_reset_adapter, |
| 2293 | .nvram_config = qla81xx_nvram_config, |
| 2294 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 2295 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2296 | .pci_info_str = qla24xx_pci_info_str, |
| 2297 | .fw_version_str = qla24xx_fw_version_str, |
| 2298 | .intr_handler = qla24xx_intr_handler, |
| 2299 | .enable_intrs = qla24xx_enable_intrs, |
| 2300 | .disable_intrs = qla24xx_disable_intrs, |
| 2301 | .abort_command = qla24xx_abort_command, |
| 2302 | .target_reset = qla24xx_abort_target, |
| 2303 | .lun_reset = qla24xx_lun_reset, |
| 2304 | .fabric_login = qla24xx_login_fabric, |
| 2305 | .fabric_logout = qla24xx_fabric_logout, |
| 2306 | .calc_req_entries = NULL, |
| 2307 | .build_iocbs = NULL, |
| 2308 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2309 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 2310 | .read_nvram = NULL, |
| 2311 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2312 | .fw_dump = qla81xx_fw_dump, |
| 2313 | .beacon_on = qla24xx_beacon_on, |
| 2314 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2315 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2316 | .read_optrom = qla25xx_read_optrom_data, |
| 2317 | .write_optrom = qla24xx_write_optrom_data, |
| 2318 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 2319 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2320 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2321 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2322 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2323 | .initialize_adapter = qla2x00_initialize_adapter, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2324 | }; |
| 2325 | |
| 2326 | static struct isp_operations qla82xx_isp_ops = { |
| 2327 | .pci_config = qla82xx_pci_config, |
| 2328 | .reset_chip = qla82xx_reset_chip, |
| 2329 | .chip_diag = qla24xx_chip_diag, |
| 2330 | .config_rings = qla82xx_config_rings, |
| 2331 | .reset_adapter = qla24xx_reset_adapter, |
| 2332 | .nvram_config = qla81xx_nvram_config, |
| 2333 | .update_fw_options = qla24xx_update_fw_options, |
| 2334 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 2335 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2336 | .fw_version_str = qla24xx_fw_version_str, |
| 2337 | .intr_handler = qla82xx_intr_handler, |
| 2338 | .enable_intrs = qla82xx_enable_intrs, |
| 2339 | .disable_intrs = qla82xx_disable_intrs, |
| 2340 | .abort_command = qla24xx_abort_command, |
| 2341 | .target_reset = qla24xx_abort_target, |
| 2342 | .lun_reset = qla24xx_lun_reset, |
| 2343 | .fabric_login = qla24xx_login_fabric, |
| 2344 | .fabric_logout = qla24xx_fabric_logout, |
| 2345 | .calc_req_entries = NULL, |
| 2346 | .build_iocbs = NULL, |
| 2347 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2348 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2349 | .read_nvram = qla24xx_read_nvram_data, |
| 2350 | .write_nvram = qla24xx_write_nvram_data, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2351 | .fw_dump = qla82xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 2352 | .beacon_on = qla82xx_beacon_on, |
| 2353 | .beacon_off = qla82xx_beacon_off, |
| 2354 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2355 | .read_optrom = qla82xx_read_optrom_data, |
| 2356 | .write_optrom = qla82xx_write_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2357 | .get_flash_version = qla82xx_get_flash_version, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2358 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2359 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2360 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2361 | .iospace_config = qla82xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2362 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2363 | }; |
| 2364 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2365 | static struct isp_operations qla8044_isp_ops = { |
| 2366 | .pci_config = qla82xx_pci_config, |
| 2367 | .reset_chip = qla82xx_reset_chip, |
| 2368 | .chip_diag = qla24xx_chip_diag, |
| 2369 | .config_rings = qla82xx_config_rings, |
| 2370 | .reset_adapter = qla24xx_reset_adapter, |
| 2371 | .nvram_config = qla81xx_nvram_config, |
| 2372 | .update_fw_options = qla24xx_update_fw_options, |
| 2373 | .load_risc = qla82xx_load_risc, |
| 2374 | .pci_info_str = qla24xx_pci_info_str, |
| 2375 | .fw_version_str = qla24xx_fw_version_str, |
| 2376 | .intr_handler = qla8044_intr_handler, |
| 2377 | .enable_intrs = qla82xx_enable_intrs, |
| 2378 | .disable_intrs = qla82xx_disable_intrs, |
| 2379 | .abort_command = qla24xx_abort_command, |
| 2380 | .target_reset = qla24xx_abort_target, |
| 2381 | .lun_reset = qla24xx_lun_reset, |
| 2382 | .fabric_login = qla24xx_login_fabric, |
| 2383 | .fabric_logout = qla24xx_fabric_logout, |
| 2384 | .calc_req_entries = NULL, |
| 2385 | .build_iocbs = NULL, |
| 2386 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2387 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2388 | .read_nvram = NULL, |
| 2389 | .write_nvram = NULL, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2390 | .fw_dump = qla8044_fw_dump, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2391 | .beacon_on = qla82xx_beacon_on, |
| 2392 | .beacon_off = qla82xx_beacon_off, |
| 2393 | .beacon_blink = NULL, |
Saurav Kashyap | 888e639 | 2014-02-26 04:15:13 -0500 | [diff] [blame] | 2394 | .read_optrom = qla8044_read_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2395 | .write_optrom = qla8044_write_optrom_data, |
| 2396 | .get_flash_version = qla82xx_get_flash_version, |
| 2397 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2398 | .start_scsi_mq = NULL, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2399 | .abort_isp = qla8044_abort_isp, |
| 2400 | .iospace_config = qla82xx_iospace_config, |
| 2401 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2402 | }; |
| 2403 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2404 | static struct isp_operations qla83xx_isp_ops = { |
| 2405 | .pci_config = qla25xx_pci_config, |
| 2406 | .reset_chip = qla24xx_reset_chip, |
| 2407 | .chip_diag = qla24xx_chip_diag, |
| 2408 | .config_rings = qla24xx_config_rings, |
| 2409 | .reset_adapter = qla24xx_reset_adapter, |
| 2410 | .nvram_config = qla81xx_nvram_config, |
| 2411 | .update_fw_options = qla81xx_update_fw_options, |
| 2412 | .load_risc = qla81xx_load_risc, |
| 2413 | .pci_info_str = qla24xx_pci_info_str, |
| 2414 | .fw_version_str = qla24xx_fw_version_str, |
| 2415 | .intr_handler = qla24xx_intr_handler, |
| 2416 | .enable_intrs = qla24xx_enable_intrs, |
| 2417 | .disable_intrs = qla24xx_disable_intrs, |
| 2418 | .abort_command = qla24xx_abort_command, |
| 2419 | .target_reset = qla24xx_abort_target, |
| 2420 | .lun_reset = qla24xx_lun_reset, |
| 2421 | .fabric_login = qla24xx_login_fabric, |
| 2422 | .fabric_logout = qla24xx_fabric_logout, |
| 2423 | .calc_req_entries = NULL, |
| 2424 | .build_iocbs = NULL, |
| 2425 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2426 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2427 | .read_nvram = NULL, |
| 2428 | .write_nvram = NULL, |
| 2429 | .fw_dump = qla83xx_fw_dump, |
| 2430 | .beacon_on = qla24xx_beacon_on, |
| 2431 | .beacon_off = qla24xx_beacon_off, |
| 2432 | .beacon_blink = qla83xx_beacon_blink, |
| 2433 | .read_optrom = qla25xx_read_optrom_data, |
| 2434 | .write_optrom = qla24xx_write_optrom_data, |
| 2435 | .get_flash_version = qla24xx_get_flash_version, |
| 2436 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2437 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2438 | .abort_isp = qla2x00_abort_isp, |
| 2439 | .iospace_config = qla83xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2440 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2441 | }; |
| 2442 | |
| 2443 | static struct isp_operations qlafx00_isp_ops = { |
| 2444 | .pci_config = qlafx00_pci_config, |
| 2445 | .reset_chip = qlafx00_soft_reset, |
| 2446 | .chip_diag = qlafx00_chip_diag, |
| 2447 | .config_rings = qlafx00_config_rings, |
| 2448 | .reset_adapter = qlafx00_soft_reset, |
| 2449 | .nvram_config = NULL, |
| 2450 | .update_fw_options = NULL, |
| 2451 | .load_risc = NULL, |
| 2452 | .pci_info_str = qlafx00_pci_info_str, |
| 2453 | .fw_version_str = qlafx00_fw_version_str, |
| 2454 | .intr_handler = qlafx00_intr_handler, |
| 2455 | .enable_intrs = qlafx00_enable_intrs, |
| 2456 | .disable_intrs = qlafx00_disable_intrs, |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2457 | .abort_command = qla24xx_async_abort_command, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2458 | .target_reset = qlafx00_abort_target, |
| 2459 | .lun_reset = qlafx00_lun_reset, |
| 2460 | .fabric_login = NULL, |
| 2461 | .fabric_logout = NULL, |
| 2462 | .calc_req_entries = NULL, |
| 2463 | .build_iocbs = NULL, |
| 2464 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2465 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2466 | .read_nvram = qla24xx_read_nvram_data, |
| 2467 | .write_nvram = qla24xx_write_nvram_data, |
| 2468 | .fw_dump = NULL, |
| 2469 | .beacon_on = qla24xx_beacon_on, |
| 2470 | .beacon_off = qla24xx_beacon_off, |
| 2471 | .beacon_blink = NULL, |
| 2472 | .read_optrom = qla24xx_read_optrom_data, |
| 2473 | .write_optrom = qla24xx_write_optrom_data, |
| 2474 | .get_flash_version = qla24xx_get_flash_version, |
| 2475 | .start_scsi = qlafx00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2476 | .start_scsi_mq = NULL, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2477 | .abort_isp = qlafx00_abort_isp, |
| 2478 | .iospace_config = qlafx00_iospace_config, |
| 2479 | .initialize_adapter = qlafx00_initialize_adapter, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2480 | }; |
| 2481 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2482 | static struct isp_operations qla27xx_isp_ops = { |
| 2483 | .pci_config = qla25xx_pci_config, |
| 2484 | .reset_chip = qla24xx_reset_chip, |
| 2485 | .chip_diag = qla24xx_chip_diag, |
| 2486 | .config_rings = qla24xx_config_rings, |
| 2487 | .reset_adapter = qla24xx_reset_adapter, |
| 2488 | .nvram_config = qla81xx_nvram_config, |
| 2489 | .update_fw_options = qla81xx_update_fw_options, |
| 2490 | .load_risc = qla81xx_load_risc, |
| 2491 | .pci_info_str = qla24xx_pci_info_str, |
| 2492 | .fw_version_str = qla24xx_fw_version_str, |
| 2493 | .intr_handler = qla24xx_intr_handler, |
| 2494 | .enable_intrs = qla24xx_enable_intrs, |
| 2495 | .disable_intrs = qla24xx_disable_intrs, |
| 2496 | .abort_command = qla24xx_abort_command, |
| 2497 | .target_reset = qla24xx_abort_target, |
| 2498 | .lun_reset = qla24xx_lun_reset, |
| 2499 | .fabric_login = qla24xx_login_fabric, |
| 2500 | .fabric_logout = qla24xx_fabric_logout, |
| 2501 | .calc_req_entries = NULL, |
| 2502 | .build_iocbs = NULL, |
| 2503 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2504 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2505 | .read_nvram = NULL, |
| 2506 | .write_nvram = NULL, |
| 2507 | .fw_dump = qla27xx_fwdump, |
| 2508 | .beacon_on = qla24xx_beacon_on, |
| 2509 | .beacon_off = qla24xx_beacon_off, |
| 2510 | .beacon_blink = qla83xx_beacon_blink, |
| 2511 | .read_optrom = qla25xx_read_optrom_data, |
| 2512 | .write_optrom = qla24xx_write_optrom_data, |
| 2513 | .get_flash_version = qla24xx_get_flash_version, |
| 2514 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2515 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2516 | .abort_isp = qla2x00_abort_isp, |
| 2517 | .iospace_config = qla83xx_iospace_config, |
| 2518 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2519 | }; |
| 2520 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2521 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2522 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2523 | { |
| 2524 | ha->device_type = DT_EXTENDED_IDS; |
| 2525 | switch (ha->pdev->device) { |
| 2526 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2527 | ha->isp_type |= DT_ISP2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2528 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2529 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2530 | break; |
| 2531 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2532 | ha->isp_type |= DT_ISP2200; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2533 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2534 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2535 | break; |
| 2536 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2537 | ha->isp_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2538 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2539 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2540 | break; |
| 2541 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2542 | ha->isp_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2543 | ha->device_type |= DT_ZIO_SUPPORTED; |
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_ISP2322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2547 | ha->isp_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2548 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2549 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2550 | ha->pdev->subsystem_device == 0x0170) |
| 2551 | ha->device_type |= DT_OEM_001; |
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_ISP6312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2555 | ha->isp_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2556 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2557 | break; |
| 2558 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2559 | ha->isp_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2560 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2561 | break; |
| 2562 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2563 | ha->isp_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2564 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2565 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2566 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2567 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2568 | break; |
| 2569 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2570 | ha->isp_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2571 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2572 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2573 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2574 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2575 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2576 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2577 | ha->isp_type |= DT_ISP8432; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2578 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2579 | ha->device_type |= DT_FWI2; |
| 2580 | ha->device_type |= DT_IIDMA; |
| 2581 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2582 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2583 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2584 | ha->isp_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2585 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2586 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2587 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2588 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2589 | ha->isp_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2590 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2591 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2592 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2593 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2594 | ha->isp_type |= DT_ISP2532; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2595 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2596 | ha->device_type |= DT_FWI2; |
| 2597 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2598 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2599 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2600 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2601 | ha->isp_type |= DT_ISP8001; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2602 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2603 | ha->device_type |= DT_FWI2; |
| 2604 | ha->device_type |= DT_IIDMA; |
| 2605 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2606 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2607 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2608 | ha->isp_type |= DT_ISP8021; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [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; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2615 | case PCI_DEVICE_ID_QLOGIC_ISP8044: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2616 | ha->isp_type |= DT_ISP8044; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2617 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2618 | ha->device_type |= DT_FWI2; |
| 2619 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2620 | /* Initialize 82XX ISP flags */ |
| 2621 | qla82xx_init_flags(ha); |
| 2622 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2623 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2624 | ha->isp_type |= DT_ISP2031; |
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; |
| 2631 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2632 | ha->isp_type |= DT_ISP8031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2633 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2634 | ha->device_type |= DT_FWI2; |
| 2635 | ha->device_type |= DT_IIDMA; |
| 2636 | ha->device_type |= DT_T10_PI; |
| 2637 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2638 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2639 | case PCI_DEVICE_ID_QLOGIC_ISPF001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2640 | ha->isp_type |= DT_ISPFX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2641 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2642 | case PCI_DEVICE_ID_QLOGIC_ISP2071: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2643 | ha->isp_type |= DT_ISP2071; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [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; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2648 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2649 | break; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2650 | case PCI_DEVICE_ID_QLOGIC_ISP2271: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2651 | ha->isp_type |= DT_ISP2271; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -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; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2656 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2657 | break; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2658 | case PCI_DEVICE_ID_QLOGIC_ISP2261: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2659 | ha->isp_type |= DT_ISP2261; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2660 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2661 | ha->device_type |= DT_FWI2; |
| 2662 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2663 | ha->device_type |= DT_T10_PI; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2664 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2665 | break; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 2666 | case PCI_DEVICE_ID_QLOGIC_ISP2081: |
| 2667 | case PCI_DEVICE_ID_QLOGIC_ISP2089: |
| 2668 | ha->isp_type |= DT_ISP2081; |
| 2669 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2670 | ha->device_type |= DT_FWI2; |
| 2671 | ha->device_type |= DT_IIDMA; |
| 2672 | ha->device_type |= DT_T10_PI; |
| 2673 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2674 | break; |
| 2675 | case PCI_DEVICE_ID_QLOGIC_ISP2281: |
| 2676 | case PCI_DEVICE_ID_QLOGIC_ISP2289: |
| 2677 | ha->isp_type |= DT_ISP2281; |
| 2678 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2679 | ha->device_type |= DT_FWI2; |
| 2680 | ha->device_type |= DT_IIDMA; |
| 2681 | ha->device_type |= DT_T10_PI; |
| 2682 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2683 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2684 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2685 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2686 | if (IS_QLA82XX(ha)) |
Saurav Kashyap | 43a9c38 | 2014-02-26 04:15:16 -0500 | [diff] [blame] | 2687 | ha->port_no = ha->portnum & 1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2688 | else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2689 | /* Get adapter physical port no from interrupt pin register. */ |
| 2690 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 2691 | if (IS_QLA25XX(ha) || IS_QLA2031(ha) || |
| 2692 | IS_QLA27XX(ha) || IS_QLA28XX(ha)) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2693 | ha->port_no--; |
| 2694 | else |
| 2695 | ha->port_no = !(ha->port_no & 1); |
| 2696 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2697 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2698 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2699 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2700 | ha->device_type, ha->port_no, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2701 | } |
| 2702 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2703 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2704 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2705 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2706 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2707 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2708 | if (vha->hw->flags.running_gold_fw) |
| 2709 | return; |
| 2710 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2711 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2712 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2713 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2714 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2715 | } |
| 2716 | |
| 2717 | static int |
| 2718 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2719 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2720 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2721 | |
Bill Kuzeja | a5dd506e | 2016-10-21 16:45:27 -0400 | [diff] [blame] | 2722 | if (test_bit(UNLOADING, &vha->dpc_flags)) |
| 2723 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2724 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2725 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2726 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2727 | return 1; |
| 2728 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2729 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2730 | } |
| 2731 | |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2732 | static void qla2x00_iocb_work_fn(struct work_struct *work) |
| 2733 | { |
| 2734 | struct scsi_qla_host *vha = container_of(work, |
| 2735 | struct scsi_qla_host, iocb_work); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2736 | struct qla_hw_data *ha = vha->hw; |
| 2737 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Quinn Tran | 0aca778 | 2018-09-04 14:19:16 -0700 | [diff] [blame] | 2738 | int i = 2; |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2739 | unsigned long flags; |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2740 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2741 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 2742 | return; |
| 2743 | |
| 2744 | while (!list_empty(&vha->work_list) && i > 0) { |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2745 | qla2x00_do_work(vha); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2746 | i--; |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2747 | } |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 2748 | |
| 2749 | spin_lock_irqsave(&vha->work_lock, flags); |
| 2750 | clear_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags); |
| 2751 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2752 | } |
| 2753 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2754 | /* |
| 2755 | * PCI driver interface |
| 2756 | */ |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 2757 | static int |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2758 | 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] | 2759 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2760 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2761 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2762 | scsi_qla_host_t *base_vha = NULL; |
| 2763 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2764 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2765 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2766 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2767 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2768 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2769 | struct req_que *req = NULL; |
| 2770 | struct rsp_que *rsp = NULL; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 2771 | int i; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2772 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2773 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2774 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2775 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2776 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2777 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2778 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2779 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2780 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2781 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2782 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2783 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2784 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031 || |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2785 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISPF001 || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2786 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8044 || |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2787 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2071 || |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2788 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271 || |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 2789 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2261 || |
| 2790 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2081 || |
| 2791 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2281 || |
| 2792 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2089 || |
| 2793 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2289) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2794 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2795 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2796 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2797 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2798 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2799 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2800 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2801 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2802 | if (mem_only) { |
| 2803 | if (pci_enable_device_mem(pdev)) |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2804 | return ret; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2805 | } else { |
| 2806 | if (pci_enable_device(pdev)) |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2807 | return ret; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2808 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2809 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2810 | /* This may fail but that's ok */ |
| 2811 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2812 | |
Giridhar Malavali | 5da05a2 | 2019-04-02 14:24:24 -0700 | [diff] [blame] | 2813 | /* Turn off T10-DIF when FC-NVMe is enabled */ |
| 2814 | if (ql2xnvmeenable) |
| 2815 | ql2xenabledif = 0; |
| 2816 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2817 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2818 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2819 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2820 | "Unable to allocate memory for ha.\n"); |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2821 | goto disable_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2822 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2823 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2824 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2825 | ha->pdev = pdev; |
Quinn Tran | 33e7997 | 2014-09-25 06:14:55 -0400 | [diff] [blame] | 2826 | INIT_LIST_HEAD(&ha->tgt.q_full_list); |
| 2827 | spin_lock_init(&ha->tgt.q_full_lock); |
Quinn Tran | 7560151 | 2015-12-17 14:57:04 -0500 | [diff] [blame] | 2828 | spin_lock_init(&ha->tgt.sess_lock); |
Quinn Tran | 2f424b9 | 2015-12-17 14:57:07 -0500 | [diff] [blame] | 2829 | spin_lock_init(&ha->tgt.atio_lock); |
| 2830 | |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 2831 | atomic_set(&ha->nvme_active_aen_cnt, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2832 | |
| 2833 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2834 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2835 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2836 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2837 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2838 | mutex_init(&ha->selflogin_lock); |
Chad Dupuis | 7a8ab9c | 2014-02-26 04:14:56 -0500 | [diff] [blame] | 2839 | mutex_init(&ha->optrom_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2840 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2841 | /* Set ISP-type information. */ |
| 2842 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2843 | |
| 2844 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2845 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 2846 | IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2847 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2848 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2849 | ha->prev_topology = 0; |
| 2850 | ha->init_cb_size = sizeof(init_cb_t); |
| 2851 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2852 | ha->optrom_size = OPTROM_SIZE_2300; |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 2853 | ha->max_exchg = FW_MAX_EXCHANGES_CNT; |
Quinn Tran | b200080 | 2018-08-02 13:16:52 -0700 | [diff] [blame] | 2854 | atomic_set(&ha->num_pend_mbx_stage1, 0); |
| 2855 | atomic_set(&ha->num_pend_mbx_stage2, 0); |
| 2856 | atomic_set(&ha->num_pend_mbx_stage3, 0); |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 2857 | atomic_set(&ha->zio_threshold, DEFAULT_ZIO_THRESHOLD); |
| 2858 | ha->last_zio_threshold = DEFAULT_ZIO_THRESHOLD; |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2859 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2860 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2861 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2862 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2863 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2864 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2865 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2866 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2867 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2868 | ha->flash_conf_off = ~0; |
| 2869 | ha->flash_data_off = ~0; |
| 2870 | ha->nvram_conf_off = ~0; |
| 2871 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2872 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2873 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2874 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2875 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2876 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2877 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2878 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2879 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2880 | ha->flash_conf_off = ~0; |
| 2881 | ha->flash_data_off = ~0; |
| 2882 | ha->nvram_conf_off = ~0; |
| 2883 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2884 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2885 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2886 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2887 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2888 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2889 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2890 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2891 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2892 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2893 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2894 | ha->flash_conf_off = ~0; |
| 2895 | ha->flash_data_off = ~0; |
| 2896 | ha->nvram_conf_off = ~0; |
| 2897 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2898 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2899 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2900 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2901 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2902 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2903 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2904 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2905 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2906 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2907 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2908 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2909 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2910 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2911 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2912 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2913 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2914 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2915 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2916 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2917 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2918 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2919 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2920 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2921 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2922 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2923 | ha->gid_list_info_size = 8; |
| 2924 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2925 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2926 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2927 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2928 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2929 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2930 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2931 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2932 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2933 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2934 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2935 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 2936 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2937 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2938 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2939 | ha->gid_list_info_size = 8; |
| 2940 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2941 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2942 | ha->isp_ops = &qla81xx_isp_ops; |
| 2943 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2944 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2945 | ha->nvram_conf_off = ~0; |
| 2946 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2947 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2948 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2949 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2950 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2951 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2952 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2953 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2954 | ha->gid_list_info_size = 8; |
| 2955 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2956 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2957 | ha->isp_ops = &qla82xx_isp_ops; |
| 2958 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2959 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2960 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2961 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2962 | } else if (IS_QLA8044(ha)) { |
| 2963 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2964 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2965 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2966 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2967 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2968 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2969 | ha->gid_list_info_size = 8; |
| 2970 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2971 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2972 | ha->isp_ops = &qla8044_isp_ops; |
| 2973 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2974 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2975 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2976 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2977 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2978 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2979 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2980 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Saurav Kashyap | f2ea653 | 2014-09-25 06:14:54 -0400 | [diff] [blame] | 2981 | req_length = REQUEST_ENTRY_CNT_83XX; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2982 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Arun Easi | b8aa4bd | 2013-01-30 03:34:40 -0500 | [diff] [blame] | 2983 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2984 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2985 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2986 | ha->gid_list_info_size = 8; |
| 2987 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2988 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2989 | ha->isp_ops = &qla83xx_isp_ops; |
| 2990 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2991 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2992 | ha->nvram_conf_off = ~0; |
| 2993 | ha->nvram_data_off = ~0; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2994 | } else if (IS_QLAFX00(ha)) { |
| 2995 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_FX00; |
| 2996 | ha->mbx_count = MAILBOX_REGISTER_COUNT_FX00; |
| 2997 | ha->aen_mbx_count = AEN_MAILBOX_REGISTER_COUNT_FX00; |
| 2998 | req_length = REQUEST_ENTRY_CNT_FX00; |
| 2999 | rsp_length = RESPONSE_ENTRY_CNT_FX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3000 | ha->isp_ops = &qlafx00_isp_ops; |
| 3001 | ha->port_down_retry_count = 30; /* default value */ |
| 3002 | ha->mr.fw_hbt_cnt = QLAFX00_HEARTBEAT_INTERVAL; |
| 3003 | ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; |
Armen Baloyan | 71e5600 | 2013-08-27 01:37:38 -0400 | [diff] [blame] | 3004 | ha->mr.fw_critemp_timer_tick = QLAFX00_CRITEMP_INTERVAL; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3005 | ha->mr.fw_hbt_en = 1; |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 3006 | ha->mr.host_info_resend = false; |
| 3007 | ha->mr.hinfo_resend_timer_tick = QLAFX00_HINFO_RESEND_INTERVAL; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3008 | } else if (IS_QLA27XX(ha)) { |
| 3009 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
| 3010 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 3011 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 3012 | req_length = REQUEST_ENTRY_CNT_83XX; |
| 3013 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 3014 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3015 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 3016 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 3017 | ha->gid_list_info_size = 8; |
| 3018 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 3019 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 3020 | ha->isp_ops = &qla27xx_isp_ops; |
| 3021 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 3022 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 3023 | ha->nvram_conf_off = ~0; |
| 3024 | ha->nvram_data_off = ~0; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 3025 | } else if (IS_QLA28XX(ha)) { |
| 3026 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
| 3027 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 3028 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 3029 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 3030 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 3031 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
| 3032 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 3033 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 3034 | ha->gid_list_info_size = 8; |
| 3035 | ha->optrom_size = OPTROM_SIZE_28XX; |
| 3036 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 3037 | ha->isp_ops = &qla27xx_isp_ops; |
| 3038 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_28XX; |
| 3039 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_28XX; |
| 3040 | ha->nvram_conf_off = ~0; |
| 3041 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3042 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3043 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3044 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 3045 | "mbx_count=%d, req_length=%d, " |
| 3046 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3047 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 3048 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3049 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 3050 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3051 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3052 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 3053 | "isp_ops=%p, flash_conf_off=%d, " |
| 3054 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 3055 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 3056 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 3057 | |
| 3058 | /* Configure PCI I/O space */ |
| 3059 | ret = ha->isp_ops->iospace_config(ha); |
| 3060 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3061 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 3062 | |
| 3063 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 3064 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 3065 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 3066 | mutex_init(&ha->vport_lock); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3067 | mutex_init(&ha->mq_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 3068 | init_completion(&ha->mbx_cmd_comp); |
| 3069 | complete(&ha->mbx_cmd_comp); |
| 3070 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 3071 | init_completion(&ha->dcbx_comp); |
Chad Dupuis | f356bef | 2013-02-08 01:58:04 -0500 | [diff] [blame] | 3072 | init_completion(&ha->lb_portup_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3073 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3074 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3075 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 3076 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3077 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 3078 | "64 Bit addressing is %s.\n", |
| 3079 | ha->flags.enable_64bit_addressing ? "enable" : |
| 3080 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3081 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3082 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3083 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 3084 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3085 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3086 | goto probe_hw_failed; |
| 3087 | } |
| 3088 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3089 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3090 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3091 | req->max_q_depth = ql2xmaxqdepth; |
| 3092 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3093 | |
| 3094 | base_vha = qla2x00_create_host(sht, ha); |
| 3095 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3096 | ret = -ENOMEM; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3097 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3098 | } |
| 3099 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3100 | pci_set_drvdata(pdev, base_vha); |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 3101 | set_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3102 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3103 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3104 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3105 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Quinn Tran | f6602f3 | 2018-08-02 13:16:53 -0700 | [diff] [blame] | 3106 | base_vha->mgmt_svr_loop_id = |
| 3107 | qla2x00_reserve_mgmt_server_loop_id(base_vha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3108 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3109 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 3110 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 3111 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3112 | /* Setup fcport template structure. */ |
| 3113 | ha->mr.fcport.vha = base_vha; |
| 3114 | ha->mr.fcport.port_type = FCT_UNKNOWN; |
| 3115 | ha->mr.fcport.loop_id = FC_NO_LOOP_ID; |
| 3116 | qla2x00_set_fcport_state(&ha->mr.fcport, FCS_UNCONFIGURED); |
| 3117 | ha->mr.fcport.supported_classes = FC_COS_UNSPECIFIED; |
| 3118 | ha->mr.fcport.scan_state = 1; |
| 3119 | |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 3120 | /* Set the SG table size based on ISP type */ |
| 3121 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3122 | if (IS_QLA2100(ha)) |
| 3123 | host->sg_tablesize = 32; |
| 3124 | } else { |
| 3125 | if (!IS_QLA82XX(ha)) |
| 3126 | host->sg_tablesize = QLA_SG_ALL; |
| 3127 | } |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3128 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3129 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 3130 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 3131 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3132 | host->max_cmd_len = 32; |
| 3133 | else |
| 3134 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 3135 | host->max_channel = MAX_BUSES - 1; |
Hannes Reinecke | 755f516 | 2014-06-03 10:58:54 +0200 | [diff] [blame] | 3136 | /* Older HBAs support only 16-bit LUNs */ |
| 3137 | if (!IS_QLAFX00(ha) && !IS_FWI2_CAPABLE(ha) && |
| 3138 | ql2xmaxlun > 0xffff) |
| 3139 | host->max_lun = 0xffff; |
| 3140 | else |
| 3141 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3142 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3143 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3144 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3145 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 3146 | "max_id=%d this_id=%d " |
| 3147 | "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] | 3148 | "max_lun=%llu transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3149 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 3150 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 3151 | host->transportt, sht->vendor_id); |
| 3152 | |
Himanshu Madhani | 1010f21 | 2017-10-16 11:26:05 -0700 | [diff] [blame] | 3153 | INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn); |
| 3154 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3155 | /* Set up the irqs */ |
| 3156 | ret = qla2x00_request_irqs(ha, rsp); |
| 3157 | if (ret) |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 3158 | goto probe_failed; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3159 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3160 | /* Alloc arrays of request and response ring ptrs */ |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 3161 | ret = qla2x00_alloc_queues(ha, req, rsp); |
| 3162 | if (ret) { |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3163 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 3164 | "Failed to allocate memory for queue pointers..." |
| 3165 | "aborting.\n"); |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 3166 | goto probe_failed; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3167 | } |
| 3168 | |
Jens Axboe | f664a3c | 2018-11-01 16:36:27 -0600 | [diff] [blame] | 3169 | if (ha->mqenable) { |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3170 | /* number of hardware queues supported by blk/scsi-mq*/ |
| 3171 | host->nr_hw_queues = ha->max_qpairs; |
| 3172 | |
| 3173 | ql_dbg(ql_dbg_init, base_vha, 0x0192, |
| 3174 | "blk/scsi-mq enabled, HW queues = %d.\n", host->nr_hw_queues); |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 3175 | } else { |
| 3176 | if (ql2xnvmeenable) { |
| 3177 | host->nr_hw_queues = ha->max_qpairs; |
| 3178 | ql_dbg(ql_dbg_init, base_vha, 0x0194, |
| 3179 | "FC-NVMe support is enabled, HW queues=%d\n", |
| 3180 | host->nr_hw_queues); |
| 3181 | } else { |
| 3182 | ql_dbg(ql_dbg_init, base_vha, 0x0193, |
| 3183 | "blk/scsi-mq disabled.\n"); |
| 3184 | } |
| 3185 | } |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3186 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3187 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3188 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3189 | pci_save_state(pdev); |
| 3190 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3191 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3192 | rsp->req = req; |
| 3193 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3194 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3195 | if (IS_QLAFX00(ha)) { |
| 3196 | ha->rsp_q_map[0] = rsp; |
| 3197 | ha->req_q_map[0] = req; |
| 3198 | set_bit(0, ha->req_qid_map); |
| 3199 | set_bit(0, ha->rsp_qid_map); |
| 3200 | } |
| 3201 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 3202 | /* FWI2-capable only. */ |
| 3203 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 3204 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 3205 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 3206 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 3207 | if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha) || |
| 3208 | IS_QLA28XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 3209 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 3210 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 3211 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 3212 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 3213 | } |
| 3214 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3215 | if (IS_QLAFX00(ha)) { |
| 3216 | req->req_q_in = &ha->iobase->ispfx00.req_q_in; |
| 3217 | req->req_q_out = &ha->iobase->ispfx00.req_q_out; |
| 3218 | rsp->rsp_q_in = &ha->iobase->ispfx00.rsp_q_in; |
| 3219 | rsp->rsp_q_out = &ha->iobase->ispfx00.rsp_q_out; |
| 3220 | } |
| 3221 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3222 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3223 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 3224 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 3225 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 3226 | } |
| 3227 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3228 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 3229 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 3230 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 3231 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 3232 | "req->req_q_in=%p req->req_q_out=%p " |
| 3233 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 3234 | req->req_q_in, req->req_q_out, |
| 3235 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 3236 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 3237 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 3238 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 3239 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 3240 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 3241 | 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] | 3242 | |
himanshu.madhani@cavium.com | d48cc67 | 2018-07-02 13:01:59 -0700 | [diff] [blame] | 3243 | ha->wq = alloc_workqueue("qla2xxx_wq", 0, 0); |
| 3244 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3245 | if (ha->isp_ops->initialize_adapter(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3246 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 3247 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 3248 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3249 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3250 | if (IS_QLA82XX(ha)) { |
| 3251 | qla82xx_idc_lock(ha); |
| 3252 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3253 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3254 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3255 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 3256 | "HW State: FAILED.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3257 | } else if (IS_QLA8044(ha)) { |
| 3258 | qla8044_idc_lock(ha); |
| 3259 | qla8044_wr_direct(base_vha, |
| 3260 | QLA8044_CRB_DEV_STATE_INDEX, |
| 3261 | QLA8XXX_DEV_FAILED); |
| 3262 | qla8044_idc_unlock(ha); |
| 3263 | ql_log(ql_log_fatal, base_vha, 0x0150, |
| 3264 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3265 | } |
| 3266 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3267 | ret = -ENODEV; |
| 3268 | goto probe_failed; |
| 3269 | } |
| 3270 | |
Chad Dupuis | 3b1bef6 | 2014-02-26 04:15:04 -0500 | [diff] [blame] | 3271 | if (IS_QLAFX00(ha)) |
| 3272 | host->can_queue = QLAFX00_MAX_CANQUEUE; |
| 3273 | else |
| 3274 | host->can_queue = req->num_outstanding_cmds - 10; |
| 3275 | |
| 3276 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 3277 | "can_queue=%d, req=%p, mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 3278 | host->can_queue, base_vha->req, |
| 3279 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
| 3280 | |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3281 | if (ha->mqenable) { |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3282 | bool startit = false; |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3283 | |
Jens Axboe | f664a3c | 2018-11-01 16:36:27 -0600 | [diff] [blame] | 3284 | if (QLA_TGT_MODE_ENABLED()) |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3285 | startit = false; |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3286 | |
Jens Axboe | f664a3c | 2018-11-01 16:36:27 -0600 | [diff] [blame] | 3287 | if (ql2x_ini_mode == QLA2XXX_INI_MODE_ENABLED) |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3288 | startit = true; |
Quinn Tran | e326d22 | 2017-06-13 20:47:18 -0700 | [diff] [blame] | 3289 | |
Jens Axboe | f664a3c | 2018-11-01 16:36:27 -0600 | [diff] [blame] | 3290 | /* Create start of day qpairs for Block MQ */ |
| 3291 | for (i = 0; i < ha->max_qpairs; i++) |
| 3292 | qla2xxx_create_qpair(base_vha, 5, 0, startit); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3293 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3294 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3295 | if (ha->flags.running_gold_fw) |
| 3296 | goto skip_dpc; |
| 3297 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3298 | /* |
| 3299 | * Startup the kernel thread for this host adapter |
| 3300 | */ |
| 3301 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3302 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3303 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3304 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 3305 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3306 | ret = PTR_ERR(ha->dpc_thread); |
Douglas Miller | e2532b4 | 2017-10-20 08:17:22 -0500 | [diff] [blame] | 3307 | ha->dpc_thread = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3308 | goto probe_failed; |
| 3309 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3310 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 3311 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3312 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3313 | /* |
| 3314 | * If we're not coming up in initiator mode, we might sit for |
| 3315 | * a while without waking up the dpc thread, which leads to a |
| 3316 | * stuck process warning. So just kick the dpc once here and |
| 3317 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 3318 | */ |
| 3319 | qla2xxx_wake_dpc(base_vha); |
| 3320 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 3321 | INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); |
| 3322 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3323 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 3324 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 3325 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 3326 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 3327 | |
| 3328 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 3329 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 3330 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 3331 | INIT_WORK(&ha->idc_state_handler, |
| 3332 | qla83xx_idc_state_handler_work); |
| 3333 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 3334 | qla83xx_nic_core_unrecoverable_work); |
| 3335 | } |
| 3336 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3337 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3338 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 3339 | base_vha->host->irq = ha->pdev->irq; |
| 3340 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3341 | /* Initialized the timer */ |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 3342 | qla2x00_start_timer(base_vha, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3343 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 3344 | "Started qla2x00_timer with " |
| 3345 | "interval=%d.\n", WATCH_INTERVAL); |
| 3346 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 3347 | "Detected hba at address=%p.\n", |
| 3348 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3349 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 3350 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3351 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3352 | int prot = 0, guard; |
Bart Van Assche | bd432bb | 2019-04-11 14:53:17 -0700 | [diff] [blame] | 3353 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3354 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3355 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 3356 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3357 | if (ql2xenabledif == 1) |
| 3358 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Martin K. Petersen | 7855d2b | 2018-12-21 09:33:44 -0800 | [diff] [blame] | 3359 | if (ql2xprotmask) |
| 3360 | scsi_host_set_prot(host, ql2xprotmask); |
| 3361 | else |
| 3362 | scsi_host_set_prot(host, |
| 3363 | prot | SHOST_DIF_TYPE1_PROTECTION |
| 3364 | | SHOST_DIF_TYPE2_PROTECTION |
| 3365 | | SHOST_DIF_TYPE3_PROTECTION |
| 3366 | | SHOST_DIX_TYPE1_PROTECTION |
| 3367 | | SHOST_DIX_TYPE2_PROTECTION |
| 3368 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3369 | |
| 3370 | guard = SHOST_DIX_GUARD_CRC; |
| 3371 | |
| 3372 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 3373 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 3374 | guard |= SHOST_DIX_GUARD_IP; |
| 3375 | |
Martin K. Petersen | 7855d2b | 2018-12-21 09:33:44 -0800 | [diff] [blame] | 3376 | if (ql2xprotguard) |
| 3377 | scsi_host_set_guard(host, ql2xprotguard); |
| 3378 | else |
| 3379 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3380 | } else |
| 3381 | base_vha->flags.difdix_supported = 0; |
| 3382 | } |
| 3383 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3384 | ha->isp_ops->enable_intrs(ha); |
| 3385 | |
Armen Baloyan | 1fe19ee | 2013-08-27 01:37:41 -0400 | [diff] [blame] | 3386 | if (IS_QLAFX00(ha)) { |
| 3387 | ret = qlafx00_fx_disc(base_vha, |
| 3388 | &base_vha->hw->mr.fcport, FXDISC_GET_CONFIG_INFO); |
| 3389 | host->sg_tablesize = (ha->mr.extended_io_enabled) ? |
| 3390 | QLA_SG_ALL : 128; |
| 3391 | } |
| 3392 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3393 | ret = scsi_add_host(host, &pdev->dev); |
| 3394 | if (ret) |
| 3395 | goto probe_failed; |
| 3396 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3397 | base_vha->flags.init_done = 1; |
| 3398 | base_vha->flags.online = 1; |
Saurav Kashyap | edaa5c7 | 2014-04-11 16:54:14 -0400 | [diff] [blame] | 3399 | ha->prev_minidump_failed = 0; |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3400 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3401 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 3402 | "Init done and hba is online.\n"); |
| 3403 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3404 | if (qla_ini_mode_enabled(base_vha) || |
| 3405 | qla_dual_mode_enabled(base_vha)) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3406 | scsi_scan_host(host); |
| 3407 | else |
| 3408 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 3409 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 3410 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3411 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3412 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3413 | if (IS_QLAFX00(ha)) { |
| 3414 | ret = qlafx00_fx_disc(base_vha, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3415 | &base_vha->hw->mr.fcport, FXDISC_GET_PORT_INFO); |
| 3416 | |
| 3417 | /* Register system information */ |
| 3418 | ret = qlafx00_fx_disc(base_vha, |
| 3419 | &base_vha->hw->mr.fcport, FXDISC_REG_HOST_INFO); |
| 3420 | } |
| 3421 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3422 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3423 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3424 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3425 | |
Armen Baloyan | 03eb912 | 2013-10-30 03:38:22 -0400 | [diff] [blame] | 3426 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 3427 | "QLogic %s - %s.\n", ha->model_number, ha->model_desc); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3428 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 3429 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 3430 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 3431 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 3432 | base_vha->host_no, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 3433 | 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] | 3434 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3435 | qlt_add_target(ha, base_vha); |
| 3436 | |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 3437 | clear_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 3438 | |
| 3439 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3440 | return -ENODEV; |
| 3441 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 3442 | if (ha->flags.detected_lr_sfp) { |
| 3443 | ql_log(ql_log_info, base_vha, 0xffff, |
| 3444 | "Reset chip to pick up LR SFP setting\n"); |
| 3445 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 3446 | qla2xxx_wake_dpc(base_vha); |
| 3447 | } |
| 3448 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3449 | return 0; |
| 3450 | |
| 3451 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3452 | if (base_vha->timer_active) |
| 3453 | qla2x00_stop_timer(base_vha); |
| 3454 | base_vha->flags.online = 0; |
| 3455 | if (ha->dpc_thread) { |
| 3456 | struct task_struct *t = ha->dpc_thread; |
| 3457 | |
| 3458 | ha->dpc_thread = NULL; |
| 3459 | kthread_stop(t); |
| 3460 | } |
| 3461 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3462 | qla2x00_free_device(base_vha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3463 | scsi_host_put(base_vha->host); |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 3464 | /* |
| 3465 | * Need to NULL out local req/rsp after |
| 3466 | * qla2x00_free_device => qla2x00_free_queues frees |
| 3467 | * what these are pointing to. Or else we'll |
| 3468 | * fall over below in qla2x00_free_req/rsp_que. |
| 3469 | */ |
| 3470 | req = NULL; |
| 3471 | rsp = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3472 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3473 | probe_hw_failed: |
himanshu.madhani@cavium.com | d64d6c5 | 2018-01-15 20:46:46 -0800 | [diff] [blame] | 3474 | qla2x00_mem_free(ha); |
| 3475 | qla2x00_free_req_que(ha, req); |
| 3476 | qla2x00_free_rsp_que(ha, rsp); |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 3477 | qla2x00_clear_drv_active(ha); |
| 3478 | |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3479 | iospace_config_failed: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3480 | if (IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3481 | if (!ha->nx_pcibase) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3482 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3483 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3484 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3485 | } else { |
| 3486 | if (ha->iobase) |
| 3487 | iounmap(ha->iobase); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3488 | if (ha->cregbase) |
| 3489 | iounmap(ha->cregbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3490 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3491 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3492 | kfree(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3493 | |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 3494 | disable_device: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3495 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3496 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3497 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3498 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 3499 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3500 | qla2x00_shutdown(struct pci_dev *pdev) |
| 3501 | { |
| 3502 | scsi_qla_host_t *vha; |
| 3503 | struct qla_hw_data *ha; |
| 3504 | |
| 3505 | vha = pci_get_drvdata(pdev); |
| 3506 | ha = vha->hw; |
| 3507 | |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 3508 | ql_log(ql_log_info, vha, 0xfffa, |
| 3509 | "Adapter shutdown\n"); |
| 3510 | |
| 3511 | /* |
| 3512 | * Prevent future board_disable and wait |
| 3513 | * until any pending board_disable has completed. |
| 3514 | */ |
| 3515 | set_bit(PFLG_DRIVER_REMOVING, &vha->pci_flags); |
| 3516 | cancel_work_sync(&ha->board_disable); |
| 3517 | |
| 3518 | if (!atomic_read(&pdev->enable_cnt)) |
| 3519 | return; |
| 3520 | |
Armen Baloyan | 4247934 | 2013-08-27 01:37:37 -0400 | [diff] [blame] | 3521 | /* Notify ISPFX00 firmware */ |
| 3522 | if (IS_QLAFX00(ha)) |
| 3523 | qlafx00_driver_shutdown(vha, 20); |
| 3524 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3525 | /* Turn-off FCE trace */ |
| 3526 | if (ha->flags.fce_enabled) { |
| 3527 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 3528 | ha->flags.fce_enabled = 0; |
| 3529 | } |
| 3530 | |
| 3531 | /* Turn-off EFT trace */ |
| 3532 | if (ha->eft) |
| 3533 | qla2x00_disable_eft_trace(vha); |
| 3534 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 3535 | if (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha) || |
| 3536 | IS_QLA28XX(ha)) { |
Quinn Tran | 3407fc3 | 2017-12-28 12:33:11 -0800 | [diff] [blame] | 3537 | if (ha->flags.fw_started) |
| 3538 | qla2x00_abort_isp_cleanup(vha); |
| 3539 | } else { |
| 3540 | /* Stop currently executing firmware. */ |
| 3541 | qla2x00_try_to_stop_firmware(vha); |
| 3542 | } |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3543 | |
| 3544 | /* Turn adapter off line */ |
| 3545 | vha->flags.online = 0; |
| 3546 | |
| 3547 | /* turn-off interrupts on the card */ |
| 3548 | if (ha->interrupts_on) { |
| 3549 | vha->flags.init_done = 0; |
| 3550 | ha->isp_ops->disable_intrs(ha); |
| 3551 | } |
| 3552 | |
| 3553 | qla2x00_free_irqs(vha); |
| 3554 | |
| 3555 | qla2x00_free_fw_dump(ha); |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3556 | |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3557 | pci_disable_device(pdev); |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 3558 | ql_log(ql_log_info, vha, 0xfffe, |
| 3559 | "Adapter shutdown successfully.\n"); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3560 | } |
| 3561 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3562 | /* Deletes all the virtual ports for a given ha */ |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3563 | static void |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3564 | 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] | 3565 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3566 | scsi_qla_host_t *vha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3567 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3568 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3569 | mutex_lock(&ha->vport_lock); |
| 3570 | while (ha->cur_vport_count) { |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3571 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3572 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3573 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 3574 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 3575 | 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] | 3576 | scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3577 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3578 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3579 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3580 | |
Himanshu Madhani | 5e6803b | 2018-12-10 12:36:23 -0800 | [diff] [blame] | 3581 | qla_nvme_delete(vha); |
| 3582 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3583 | fc_vport_terminate(vha->fc_vport); |
| 3584 | scsi_host_put(vha->host); |
| 3585 | |
| 3586 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3587 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3588 | mutex_unlock(&ha->vport_lock); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3589 | } |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3590 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3591 | /* Stops all deferred work threads */ |
| 3592 | static void |
| 3593 | qla2x00_destroy_deferred_work(struct qla_hw_data *ha) |
| 3594 | { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3595 | /* Cancel all work and destroy DPC workqueues */ |
| 3596 | if (ha->dpc_lp_wq) { |
| 3597 | cancel_work_sync(&ha->idc_aen); |
| 3598 | destroy_workqueue(ha->dpc_lp_wq); |
| 3599 | ha->dpc_lp_wq = NULL; |
| 3600 | } |
| 3601 | |
| 3602 | if (ha->dpc_hp_wq) { |
| 3603 | cancel_work_sync(&ha->nic_core_reset); |
| 3604 | cancel_work_sync(&ha->idc_state_handler); |
| 3605 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 3606 | destroy_workqueue(ha->dpc_hp_wq); |
| 3607 | ha->dpc_hp_wq = NULL; |
| 3608 | } |
| 3609 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3610 | /* Kill the kernel thread for this host */ |
| 3611 | if (ha->dpc_thread) { |
| 3612 | struct task_struct *t = ha->dpc_thread; |
| 3613 | |
| 3614 | /* |
| 3615 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 3616 | * so we need to zero it out. |
| 3617 | */ |
| 3618 | ha->dpc_thread = NULL; |
| 3619 | kthread_stop(t); |
| 3620 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3621 | } |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3622 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3623 | static void |
| 3624 | qla2x00_unmap_iobases(struct qla_hw_data *ha) |
| 3625 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3626 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 3627 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3628 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3629 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3630 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3631 | } else { |
| 3632 | if (ha->iobase) |
| 3633 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3634 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3635 | if (ha->cregbase) |
| 3636 | iounmap(ha->cregbase); |
| 3637 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3638 | if (ha->mqiobase) |
| 3639 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3640 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 3641 | if ((IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) && |
| 3642 | ha->msixbase) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3643 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3644 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3645 | } |
| 3646 | |
| 3647 | static void |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3648 | qla2x00_clear_drv_active(struct qla_hw_data *ha) |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3649 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3650 | if (IS_QLA8044(ha)) { |
| 3651 | qla8044_idc_lock(ha); |
Saurav Kashyap | c41afc9 | 2013-11-07 02:54:56 -0500 | [diff] [blame] | 3652 | qla8044_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3653 | qla8044_idc_unlock(ha); |
| 3654 | } else if (IS_QLA82XX(ha)) { |
| 3655 | qla82xx_idc_lock(ha); |
| 3656 | qla82xx_clear_drv_active(ha); |
| 3657 | qla82xx_idc_unlock(ha); |
| 3658 | } |
| 3659 | } |
| 3660 | |
| 3661 | static void |
| 3662 | qla2x00_remove_one(struct pci_dev *pdev) |
| 3663 | { |
| 3664 | scsi_qla_host_t *base_vha; |
| 3665 | struct qla_hw_data *ha; |
| 3666 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3667 | base_vha = pci_get_drvdata(pdev); |
| 3668 | ha = base_vha->hw; |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 3669 | ql_log(ql_log_info, base_vha, 0xb079, |
| 3670 | "Removing driver\n"); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3671 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3672 | /* Indicate device removal to prevent future board_disable and wait |
| 3673 | * until any pending board_disable has completed. */ |
| 3674 | set_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags); |
| 3675 | cancel_work_sync(&ha->board_disable); |
| 3676 | |
| 3677 | /* |
| 3678 | * If the PCI device is disabled then there was a PCI-disconnect and |
| 3679 | * qla2x00_disable_board_on_pci_error has taken care of most of the |
| 3680 | * resources. |
| 3681 | */ |
| 3682 | if (!atomic_read(&pdev->enable_cnt)) { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3683 | dma_free_coherent(&ha->pdev->dev, base_vha->gnl.size, |
| 3684 | base_vha->gnl.l, base_vha->gnl.ldma); |
| 3685 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3686 | scsi_host_put(base_vha->host); |
| 3687 | kfree(ha); |
| 3688 | pci_set_drvdata(pdev, NULL); |
| 3689 | return; |
| 3690 | } |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 3691 | qla2x00_wait_for_hba_ready(base_vha); |
| 3692 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 3693 | if (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha) || |
| 3694 | IS_QLA28XX(ha)) { |
Quinn Tran | 4523502 | 2018-07-18 14:29:53 -0700 | [diff] [blame] | 3695 | if (ha->flags.fw_started) |
| 3696 | qla2x00_abort_isp_cleanup(base_vha); |
| 3697 | } else if (!IS_QLAFX00(ha)) { |
| 3698 | if (IS_QLA8031(ha)) { |
| 3699 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 3700 | "Clearing fcoe driver presence.\n"); |
| 3701 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 3702 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 3703 | "Error while clearing DRV-Presence.\n"); |
| 3704 | } |
| 3705 | |
| 3706 | qla2x00_try_to_stop_firmware(base_vha); |
| 3707 | } |
| 3708 | |
Quinn Tran | 2ce87cc | 2018-01-23 11:05:21 -0800 | [diff] [blame] | 3709 | qla2x00_wait_for_sess_deletion(base_vha); |
| 3710 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3711 | /* |
| 3712 | * if UNLOAD flag is already set, then continue unload, |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 3713 | * where it was set first. |
| 3714 | */ |
| 3715 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3716 | return; |
| 3717 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3718 | set_bit(UNLOADING, &base_vha->dpc_flags); |
Duane Grigsby | e84067d | 2017-06-21 13:48:43 -0700 | [diff] [blame] | 3719 | |
| 3720 | qla_nvme_delete(base_vha); |
| 3721 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3722 | dma_free_coherent(&ha->pdev->dev, |
| 3723 | base_vha->gnl.size, base_vha->gnl.l, base_vha->gnl.ldma); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3724 | |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 3725 | vfree(base_vha->scan.l); |
| 3726 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3727 | if (IS_QLAFX00(ha)) |
| 3728 | qlafx00_driver_shutdown(base_vha, 20); |
| 3729 | |
| 3730 | qla2x00_delete_all_vps(ha, base_vha); |
| 3731 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3732 | qla2x00_dfs_remove(base_vha); |
| 3733 | |
| 3734 | qla84xx_put_chip(base_vha); |
| 3735 | |
| 3736 | /* Disable timer */ |
| 3737 | if (base_vha->timer_active) |
| 3738 | qla2x00_stop_timer(base_vha); |
| 3739 | |
| 3740 | base_vha->flags.online = 0; |
| 3741 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3742 | /* free DMA memory */ |
| 3743 | if (ha->exlogin_buf) |
| 3744 | qla2x00_free_exlogin_buffer(ha); |
| 3745 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3746 | /* free DMA memory */ |
| 3747 | if (ha->exchoffld_buf) |
| 3748 | qla2x00_free_exchoffld_buffer(ha); |
| 3749 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3750 | qla2x00_destroy_deferred_work(ha); |
| 3751 | |
| 3752 | qlt_remove_target(ha, base_vha); |
| 3753 | |
| 3754 | qla2x00_free_sysfs_attr(base_vha, true); |
| 3755 | |
| 3756 | fc_remove_host(base_vha->host); |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3757 | qlt_remove_target_resources(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3758 | |
| 3759 | scsi_remove_host(base_vha->host); |
| 3760 | |
| 3761 | qla2x00_free_device(base_vha); |
| 3762 | |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3763 | qla2x00_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3764 | |
Arun Easi | d2749ff | 2014-09-25 05:16:51 -0400 | [diff] [blame] | 3765 | scsi_host_put(base_vha->host); |
| 3766 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3767 | qla2x00_unmap_iobases(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3768 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3769 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3770 | kfree(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3771 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3772 | pci_disable_pcie_error_reporting(pdev); |
| 3773 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 3774 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3775 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3776 | |
| 3777 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3778 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3779 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3780 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3781 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3782 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 3783 | |
| 3784 | /* Disable timer */ |
| 3785 | if (vha->timer_active) |
| 3786 | qla2x00_stop_timer(vha); |
| 3787 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3788 | qla25xx_delete_queues(vha); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3789 | vha->flags.online = 0; |
| 3790 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3791 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3792 | if (ha->interrupts_on) { |
| 3793 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 3794 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3795 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3796 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3797 | qla2x00_free_fcports(vha); |
| 3798 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3799 | qla2x00_free_irqs(vha); |
| 3800 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3801 | /* Flush the work queue and remove it */ |
| 3802 | if (ha->wq) { |
| 3803 | flush_workqueue(ha->wq); |
| 3804 | destroy_workqueue(ha->wq); |
| 3805 | ha->wq = NULL; |
| 3806 | } |
| 3807 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3808 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3809 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3810 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 3811 | qla82xx_md_free(vha); |
| 3812 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3813 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3814 | } |
| 3815 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3816 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 3817 | { |
| 3818 | fc_port_t *fcport, *tfcport; |
| 3819 | |
Quinn Tran | ffbc647 | 2019-04-02 14:24:29 -0700 | [diff] [blame] | 3820 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) |
| 3821 | qla2x00_free_fcport(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3822 | } |
| 3823 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3824 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3825 | 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] | 3826 | int defer) |
| 3827 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3828 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3829 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3830 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3831 | |
| 3832 | if (!fcport->rport) |
| 3833 | return; |
| 3834 | |
| 3835 | rport = fcport->rport; |
| 3836 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3837 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3838 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3839 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3840 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3841 | qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3842 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 3843 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3844 | } else { |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3845 | int now; |
Bart Van Assche | bd432bb | 2019-04-11 14:53:17 -0700 | [diff] [blame] | 3846 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3847 | if (rport) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3848 | ql_dbg(ql_dbg_disc, fcport->vha, 0x2109, |
| 3849 | "%s %8phN. rport %p roles %x\n", |
| 3850 | __func__, fcport->port_name, rport, |
| 3851 | rport->roles); |
Alexei Potashnik | d20ed91 | 2015-07-14 16:00:47 -0400 | [diff] [blame] | 3852 | fc_remote_port_delete(rport); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3853 | } |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3854 | qlt_do_generation_tick(vha, &now); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3855 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3856 | } |
| 3857 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3858 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3859 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 3860 | * |
| 3861 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 3862 | * |
| 3863 | * Return: None. |
| 3864 | * |
| 3865 | * Context: |
| 3866 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3867 | 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] | 3868 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3869 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3870 | if (IS_QLAFX00(vha->hw)) { |
| 3871 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
| 3872 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3873 | return; |
| 3874 | } |
| 3875 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3876 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3877 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3878 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3879 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3880 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3881 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3882 | * We may need to retry the login, so don't change the state of the |
| 3883 | * port but do the retries. |
| 3884 | */ |
| 3885 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3886 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3887 | |
| 3888 | if (!do_login) |
| 3889 | return; |
| 3890 | |
Arun Easi | a1d0285 | 2015-08-04 13:38:02 -0400 | [diff] [blame] | 3891 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3892 | } |
| 3893 | |
| 3894 | /* |
| 3895 | * qla2x00_mark_all_devices_lost |
| 3896 | * Updates fcport state when device goes offline. |
| 3897 | * |
| 3898 | * Input: |
| 3899 | * ha = adapter block pointer. |
| 3900 | * fcport = port structure pointer. |
| 3901 | * |
| 3902 | * Return: |
| 3903 | * None. |
| 3904 | * |
| 3905 | * Context: |
| 3906 | */ |
| 3907 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3908 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3909 | { |
| 3910 | fc_port_t *fcport; |
| 3911 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3912 | ql_dbg(ql_dbg_disc, vha, 0x20f1, |
| 3913 | "Mark all dev lost\n"); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3914 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3915 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3916 | fcport->scan_state = 0; |
Quinn Tran | d8630bb | 2017-12-28 12:33:43 -0800 | [diff] [blame] | 3917 | qlt_schedule_sess_for_deletion(fcport); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3918 | |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3919 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3920 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3921 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3922 | /* |
| 3923 | * No point in marking the device as lost, if the device is |
| 3924 | * already DEAD. |
| 3925 | */ |
| 3926 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3927 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3928 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3929 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3930 | if (defer) |
| 3931 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3932 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3933 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3934 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3935 | } |
| 3936 | } |
| 3937 | |
Bart Van Assche | 0e145a5 | 2019-04-17 14:44:12 -0700 | [diff] [blame] | 3938 | static void qla2x00_set_reserved_loop_ids(struct qla_hw_data *ha) |
| 3939 | { |
| 3940 | int i; |
| 3941 | |
| 3942 | if (IS_FWI2_CAPABLE(ha)) |
| 3943 | return; |
| 3944 | |
| 3945 | for (i = 0; i < SNS_FIRST_LOOP_ID; i++) |
| 3946 | set_bit(i, ha->loop_id_map); |
| 3947 | set_bit(MANAGEMENT_SERVER, ha->loop_id_map); |
| 3948 | set_bit(BROADCAST, ha->loop_id_map); |
| 3949 | } |
| 3950 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3951 | /* |
| 3952 | * qla2x00_mem_alloc |
| 3953 | * Allocates adapter memory. |
| 3954 | * |
| 3955 | * Returns: |
| 3956 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3957 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3958 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3959 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3960 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3961 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3962 | { |
| 3963 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3964 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3965 | 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] | 3966 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3967 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3968 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3969 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3970 | if (qlt_mem_alloc(ha) < 0) |
| 3971 | goto fail_free_init_cb; |
| 3972 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3973 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3974 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3975 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3976 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3977 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3978 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3979 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3980 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3981 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3982 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3983 | /* Allocate cache for CT6 Ctx. */ |
| 3984 | if (!ctx_cachep) { |
| 3985 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3986 | sizeof(struct ct6_dsd), 0, |
| 3987 | SLAB_HWCACHE_ALIGN, NULL); |
| 3988 | if (!ctx_cachep) |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3989 | goto fail_free_srb_mempool; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3990 | } |
| 3991 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3992 | ctx_cachep); |
| 3993 | if (!ha->ctx_mempool) |
| 3994 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3995 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3996 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3997 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3998 | } |
| 3999 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4000 | /* Get memory for cached NVRAM */ |
| 4001 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 4002 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4003 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4004 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4005 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 4006 | ha->pdev->device); |
| 4007 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 4008 | DMA_POOL_SIZE, 8, 0); |
| 4009 | if (!ha->s_dma_pool) |
| 4010 | goto fail_free_nvram; |
| 4011 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4012 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 4013 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 4014 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 4015 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 4016 | if (IS_P3P_TYPE(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4017 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 4018 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 4019 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4020 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 4021 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4022 | goto fail_s_dma_pool; |
| 4023 | } |
| 4024 | |
| 4025 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 4026 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 4027 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4028 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 4029 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4030 | goto fail_dl_dma_pool; |
| 4031 | } |
Giridhar Malavali | 50b8127 | 2018-12-21 09:33:45 -0800 | [diff] [blame] | 4032 | |
| 4033 | if (ql2xenabledif) { |
| 4034 | u64 bufsize = DIF_BUNDLING_DMA_POOL_SIZE; |
| 4035 | struct dsd_dma *dsd, *nxt; |
| 4036 | uint i; |
| 4037 | /* Creata a DMA pool of buffers for DIF bundling */ |
| 4038 | ha->dif_bundl_pool = dma_pool_create(name, |
| 4039 | &ha->pdev->dev, DIF_BUNDLING_DMA_POOL_SIZE, 8, 0); |
| 4040 | if (!ha->dif_bundl_pool) { |
| 4041 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0024, |
| 4042 | "%s: failed create dif_bundl_pool\n", |
| 4043 | __func__); |
| 4044 | goto fail_dif_bundl_dma_pool; |
| 4045 | } |
| 4046 | |
| 4047 | INIT_LIST_HEAD(&ha->pool.good.head); |
| 4048 | INIT_LIST_HEAD(&ha->pool.unusable.head); |
| 4049 | ha->pool.good.count = 0; |
| 4050 | ha->pool.unusable.count = 0; |
| 4051 | for (i = 0; i < 128; i++) { |
| 4052 | dsd = kzalloc(sizeof(*dsd), GFP_ATOMIC); |
| 4053 | if (!dsd) { |
| 4054 | ql_dbg_pci(ql_dbg_init, ha->pdev, |
| 4055 | 0xe0ee, "%s: failed alloc dsd\n", |
| 4056 | __func__); |
| 4057 | return 1; |
| 4058 | } |
| 4059 | ha->dif_bundle_kallocs++; |
| 4060 | |
| 4061 | dsd->dsd_addr = dma_pool_alloc( |
| 4062 | ha->dif_bundl_pool, GFP_ATOMIC, |
| 4063 | &dsd->dsd_list_dma); |
| 4064 | if (!dsd->dsd_addr) { |
| 4065 | ql_dbg_pci(ql_dbg_init, ha->pdev, |
| 4066 | 0xe0ee, |
| 4067 | "%s: failed alloc ->dsd_addr\n", |
| 4068 | __func__); |
| 4069 | kfree(dsd); |
| 4070 | ha->dif_bundle_kallocs--; |
| 4071 | continue; |
| 4072 | } |
| 4073 | ha->dif_bundle_dma_allocs++; |
| 4074 | |
| 4075 | /* |
| 4076 | * if DMA buffer crosses 4G boundary, |
| 4077 | * put it on bad list |
| 4078 | */ |
| 4079 | if (MSD(dsd->dsd_list_dma) ^ |
| 4080 | MSD(dsd->dsd_list_dma + bufsize)) { |
| 4081 | list_add_tail(&dsd->list, |
| 4082 | &ha->pool.unusable.head); |
| 4083 | ha->pool.unusable.count++; |
| 4084 | } else { |
| 4085 | list_add_tail(&dsd->list, |
| 4086 | &ha->pool.good.head); |
| 4087 | ha->pool.good.count++; |
| 4088 | } |
| 4089 | } |
| 4090 | |
| 4091 | /* return the good ones back to the pool */ |
| 4092 | list_for_each_entry_safe(dsd, nxt, |
| 4093 | &ha->pool.good.head, list) { |
| 4094 | list_del(&dsd->list); |
| 4095 | dma_pool_free(ha->dif_bundl_pool, |
| 4096 | dsd->dsd_addr, dsd->dsd_list_dma); |
| 4097 | ha->dif_bundle_dma_allocs--; |
| 4098 | kfree(dsd); |
| 4099 | ha->dif_bundle_kallocs--; |
| 4100 | } |
| 4101 | |
| 4102 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0024, |
| 4103 | "%s: dif dma pool (good=%u unusable=%u)\n", |
| 4104 | __func__, ha->pool.good.count, |
| 4105 | ha->pool.unusable.count); |
| 4106 | } |
| 4107 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4108 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
Giridhar Malavali | 50b8127 | 2018-12-21 09:33:45 -0800 | [diff] [blame] | 4109 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p dif_bundl_pool=%p.\n", |
| 4110 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool, |
| 4111 | ha->dif_bundl_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4112 | } |
| 4113 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4114 | /* Allocate memory for SNS commands */ |
| 4115 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4116 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4117 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4118 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4119 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4120 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4121 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 4122 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4123 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4124 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4125 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4126 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4127 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4128 | goto fail_dma_pool; |
| 4129 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4130 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4131 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4132 | if (!ha->ct_sns) |
| 4133 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4134 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 4135 | "ms_iocb=%p ct_sns=%p.\n", |
| 4136 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4137 | } |
| 4138 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4139 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4140 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 4141 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4142 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 4143 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4144 | goto fail_req; |
| 4145 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4146 | (*req)->length = req_len; |
| 4147 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 4148 | ((*req)->length + 1) * sizeof(request_t), |
| 4149 | &(*req)->dma, GFP_KERNEL); |
| 4150 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4151 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 4152 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4153 | goto fail_req_ring; |
| 4154 | } |
| 4155 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4156 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 4157 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4158 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 4159 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4160 | goto fail_rsp; |
| 4161 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4162 | (*rsp)->hw = ha; |
| 4163 | (*rsp)->length = rsp_len; |
| 4164 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 4165 | ((*rsp)->length + 1) * sizeof(response_t), |
| 4166 | &(*rsp)->dma, GFP_KERNEL); |
| 4167 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4168 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 4169 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4170 | goto fail_rsp_ring; |
| 4171 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4172 | (*req)->rsp = *rsp; |
| 4173 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4174 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 4175 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 4176 | "rsp->length=%d rsp->ring=%p.\n", |
| 4177 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 4178 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4179 | /* Allocate memory for NVRAM data for vports */ |
| 4180 | if (ha->nvram_npiv_size) { |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 4181 | ha->npiv_info = kcalloc(ha->nvram_npiv_size, |
| 4182 | sizeof(struct qla_npiv_entry), |
| 4183 | GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4184 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4185 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 4186 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4187 | goto fail_npiv_info; |
| 4188 | } |
| 4189 | } else |
| 4190 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4191 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4192 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 4193 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha) || |
| 4194 | IS_QLA28XX(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4195 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 4196 | &ha->ex_init_cb_dma); |
| 4197 | if (!ha->ex_init_cb) |
| 4198 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4199 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 4200 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4201 | } |
| 4202 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4203 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 4204 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4205 | /* Get consistent memory allocated for Async Port-Database. */ |
| 4206 | if (!IS_FWI2_CAPABLE(ha)) { |
| 4207 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 4208 | &ha->async_pd_dma); |
| 4209 | if (!ha->async_pd) |
| 4210 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4211 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 4212 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4213 | } |
| 4214 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4215 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4216 | |
| 4217 | /* Allocate memory for our loop_id bitmap */ |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 4218 | ha->loop_id_map = kcalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE), |
| 4219 | sizeof(long), |
| 4220 | GFP_KERNEL); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4221 | if (!ha->loop_id_map) |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4222 | goto fail_loop_id_map; |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4223 | else { |
| 4224 | qla2x00_set_reserved_loop_ids(ha); |
| 4225 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 4226 | "loop_id_map=%p.\n", ha->loop_id_map); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4227 | } |
| 4228 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4229 | ha->sfp_data = dma_alloc_coherent(&ha->pdev->dev, |
| 4230 | SFP_DEV_SIZE, &ha->sfp_data_dma, GFP_KERNEL); |
| 4231 | if (!ha->sfp_data) { |
| 4232 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b, |
| 4233 | "Unable to allocate memory for SFP read-data.\n"); |
| 4234 | goto fail_sfp_data; |
| 4235 | } |
| 4236 | |
Michael Hernandez | 3f006ac | 2019-03-12 11:08:22 -0700 | [diff] [blame] | 4237 | ha->flt = dma_alloc_coherent(&ha->pdev->dev, |
| 4238 | sizeof(struct qla_flt_header) + FLT_REGIONS_SIZE, &ha->flt_dma, |
| 4239 | GFP_KERNEL); |
| 4240 | if (!ha->flt) { |
| 4241 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b, |
| 4242 | "Unable to allocate memory for FLT.\n"); |
| 4243 | goto fail_flt_buffer; |
| 4244 | } |
| 4245 | |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 4246 | return 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4247 | |
Michael Hernandez | 3f006ac | 2019-03-12 11:08:22 -0700 | [diff] [blame] | 4248 | fail_flt_buffer: |
| 4249 | dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE, |
| 4250 | ha->sfp_data, ha->sfp_data_dma); |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4251 | fail_sfp_data: |
| 4252 | kfree(ha->loop_id_map); |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4253 | fail_loop_id_map: |
| 4254 | 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] | 4255 | fail_async_pd: |
| 4256 | 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] | 4257 | fail_ex_init_cb: |
| 4258 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4259 | fail_npiv_info: |
| 4260 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 4261 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 4262 | (*rsp)->ring = NULL; |
| 4263 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4264 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4265 | kfree(*rsp); |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 4266 | *rsp = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4267 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4268 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 4269 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 4270 | (*req)->ring = NULL; |
| 4271 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4272 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4273 | kfree(*req); |
Bill Kuzeja | 6d63406 | 2018-03-23 10:37:25 -0400 | [diff] [blame] | 4274 | *req = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4275 | fail_req: |
| 4276 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 4277 | ha->ct_sns, ha->ct_sns_dma); |
| 4278 | ha->ct_sns = NULL; |
| 4279 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4280 | fail_free_ms_iocb: |
| 4281 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 4282 | ha->ms_iocb = NULL; |
| 4283 | ha->ms_iocb_dma = 0; |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4284 | |
| 4285 | if (ha->sns_cmd) |
| 4286 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
| 4287 | ha->sns_cmd, ha->sns_cmd_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4288 | fail_dma_pool: |
Giridhar Malavali | 50b8127 | 2018-12-21 09:33:45 -0800 | [diff] [blame] | 4289 | if (ql2xenabledif) { |
| 4290 | struct dsd_dma *dsd, *nxt; |
| 4291 | |
| 4292 | list_for_each_entry_safe(dsd, nxt, &ha->pool.unusable.head, |
| 4293 | list) { |
| 4294 | list_del(&dsd->list); |
| 4295 | dma_pool_free(ha->dif_bundl_pool, dsd->dsd_addr, |
| 4296 | dsd->dsd_list_dma); |
| 4297 | ha->dif_bundle_dma_allocs--; |
| 4298 | kfree(dsd); |
| 4299 | ha->dif_bundle_kallocs--; |
| 4300 | ha->pool.unusable.count--; |
| 4301 | } |
| 4302 | dma_pool_destroy(ha->dif_bundl_pool); |
| 4303 | ha->dif_bundl_pool = NULL; |
| 4304 | } |
| 4305 | |
| 4306 | fail_dif_bundl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 4307 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4308 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 4309 | ha->fcp_cmnd_dma_pool = NULL; |
| 4310 | } |
| 4311 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 4312 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4313 | dma_pool_destroy(ha->dl_dma_pool); |
| 4314 | ha->dl_dma_pool = NULL; |
| 4315 | } |
| 4316 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4317 | dma_pool_destroy(ha->s_dma_pool); |
| 4318 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4319 | fail_free_nvram: |
| 4320 | kfree(ha->nvram); |
| 4321 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4322 | fail_free_ctx_mempool: |
Thomas Meyer | 75c1d48 | 2018-12-02 21:52:11 +0100 | [diff] [blame] | 4323 | mempool_destroy(ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4324 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4325 | fail_free_srb_mempool: |
Thomas Meyer | 75c1d48 | 2018-12-02 21:52:11 +0100 | [diff] [blame] | 4326 | mempool_destroy(ha->srb_mempool); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4327 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4328 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 4329 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 4330 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4331 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4332 | ha->gid_list = NULL; |
| 4333 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4334 | fail_free_tgt_mem: |
| 4335 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4336 | fail_free_init_cb: |
| 4337 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 4338 | ha->init_cb_dma); |
| 4339 | ha->init_cb = NULL; |
| 4340 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4341 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4342 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 4343 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4344 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4345 | } |
| 4346 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4347 | int |
| 4348 | qla2x00_set_exlogins_buffer(scsi_qla_host_t *vha) |
| 4349 | { |
| 4350 | int rval; |
| 4351 | uint16_t size, max_cnt, temp; |
| 4352 | struct qla_hw_data *ha = vha->hw; |
| 4353 | |
| 4354 | /* Return if we don't need to alloacate any extended logins */ |
| 4355 | if (!ql2xexlogins) |
| 4356 | return QLA_SUCCESS; |
| 4357 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4358 | if (!IS_EXLOGIN_OFFLD_CAPABLE(ha)) |
| 4359 | return QLA_SUCCESS; |
| 4360 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4361 | ql_log(ql_log_info, vha, 0xd021, "EXLOGIN count: %d.\n", ql2xexlogins); |
| 4362 | max_cnt = 0; |
| 4363 | rval = qla_get_exlogin_status(vha, &size, &max_cnt); |
| 4364 | if (rval != QLA_SUCCESS) { |
| 4365 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd029, |
| 4366 | "Failed to get exlogin status.\n"); |
| 4367 | return rval; |
| 4368 | } |
| 4369 | |
| 4370 | temp = (ql2xexlogins > max_cnt) ? max_cnt : ql2xexlogins; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4371 | temp *= size; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4372 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4373 | if (temp != ha->exlogin_size) { |
| 4374 | qla2x00_free_exlogin_buffer(ha); |
| 4375 | ha->exlogin_size = temp; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4376 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4377 | ql_log(ql_log_info, vha, 0xd024, |
| 4378 | "EXLOGIN: max_logins=%d, portdb=0x%x, total=%d.\n", |
| 4379 | max_cnt, size, temp); |
| 4380 | |
| 4381 | ql_log(ql_log_info, vha, 0xd025, |
| 4382 | "EXLOGIN: requested size=0x%x\n", ha->exlogin_size); |
| 4383 | |
| 4384 | /* Get consistent memory for extended logins */ |
| 4385 | ha->exlogin_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 4386 | ha->exlogin_size, &ha->exlogin_buf_dma, GFP_KERNEL); |
| 4387 | if (!ha->exlogin_buf) { |
| 4388 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd02a, |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4389 | "Failed to allocate memory for exlogin_buf_dma.\n"); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4390 | return -ENOMEM; |
| 4391 | } |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4392 | } |
| 4393 | |
| 4394 | /* Now configure the dma buffer */ |
| 4395 | rval = qla_set_exlogin_mem_cfg(vha, ha->exlogin_buf_dma); |
| 4396 | if (rval) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4397 | ql_log(ql_log_fatal, vha, 0xd033, |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4398 | "Setup extended login buffer ****FAILED****.\n"); |
| 4399 | qla2x00_free_exlogin_buffer(ha); |
| 4400 | } |
| 4401 | |
| 4402 | return rval; |
| 4403 | } |
| 4404 | |
| 4405 | /* |
| 4406 | * qla2x00_free_exlogin_buffer |
| 4407 | * |
| 4408 | * Input: |
| 4409 | * ha = adapter block pointer |
| 4410 | */ |
| 4411 | void |
| 4412 | qla2x00_free_exlogin_buffer(struct qla_hw_data *ha) |
| 4413 | { |
| 4414 | if (ha->exlogin_buf) { |
| 4415 | dma_free_coherent(&ha->pdev->dev, ha->exlogin_size, |
| 4416 | ha->exlogin_buf, ha->exlogin_buf_dma); |
| 4417 | ha->exlogin_buf = NULL; |
| 4418 | ha->exlogin_size = 0; |
| 4419 | } |
| 4420 | } |
| 4421 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4422 | static void |
| 4423 | qla2x00_number_of_exch(scsi_qla_host_t *vha, u32 *ret_cnt, u16 max_cnt) |
| 4424 | { |
| 4425 | u32 temp; |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 4426 | struct init_cb_81xx *icb = (struct init_cb_81xx *)&vha->hw->init_cb; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4427 | *ret_cnt = FW_DEF_EXCHANGES_CNT; |
| 4428 | |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4429 | if (max_cnt > vha->hw->max_exchg) |
| 4430 | max_cnt = vha->hw->max_exchg; |
| 4431 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4432 | if (qla_ini_mode_enabled(vha)) { |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 4433 | if (vha->ql2xiniexchg > max_cnt) |
| 4434 | vha->ql2xiniexchg = max_cnt; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4435 | |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 4436 | if (vha->ql2xiniexchg > FW_DEF_EXCHANGES_CNT) |
| 4437 | *ret_cnt = vha->ql2xiniexchg; |
| 4438 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4439 | } else if (qla_tgt_mode_enabled(vha)) { |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 4440 | if (vha->ql2xexchoffld > max_cnt) { |
| 4441 | vha->ql2xexchoffld = max_cnt; |
| 4442 | icb->exchange_count = cpu_to_le16(vha->ql2xexchoffld); |
| 4443 | } |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4444 | |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 4445 | if (vha->ql2xexchoffld > FW_DEF_EXCHANGES_CNT) |
| 4446 | *ret_cnt = vha->ql2xexchoffld; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4447 | } else if (qla_dual_mode_enabled(vha)) { |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 4448 | temp = vha->ql2xiniexchg + vha->ql2xexchoffld; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4449 | if (temp > max_cnt) { |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 4450 | vha->ql2xiniexchg -= (temp - max_cnt)/2; |
| 4451 | vha->ql2xexchoffld -= (((temp - max_cnt)/2) + 1); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4452 | temp = max_cnt; |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 4453 | icb->exchange_count = cpu_to_le16(vha->ql2xexchoffld); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4454 | } |
| 4455 | |
| 4456 | if (temp > FW_DEF_EXCHANGES_CNT) |
| 4457 | *ret_cnt = temp; |
| 4458 | } |
| 4459 | } |
| 4460 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4461 | int |
| 4462 | qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) |
| 4463 | { |
| 4464 | int rval; |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4465 | u16 size, max_cnt; |
| 4466 | u32 actual_cnt, totsz; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4467 | struct qla_hw_data *ha = vha->hw; |
| 4468 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4469 | if (!ha->flags.exchoffld_enabled) |
| 4470 | return QLA_SUCCESS; |
| 4471 | |
| 4472 | if (!IS_EXCHG_OFFLD_CAPABLE(ha)) |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4473 | return QLA_SUCCESS; |
| 4474 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4475 | max_cnt = 0; |
| 4476 | rval = qla_get_exchoffld_status(vha, &size, &max_cnt); |
| 4477 | if (rval != QLA_SUCCESS) { |
| 4478 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd012, |
| 4479 | "Failed to get exlogin status.\n"); |
| 4480 | return rval; |
| 4481 | } |
| 4482 | |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4483 | qla2x00_number_of_exch(vha, &actual_cnt, max_cnt); |
| 4484 | ql_log(ql_log_info, vha, 0xd014, |
| 4485 | "Actual exchange offload count: %d.\n", actual_cnt); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4486 | |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4487 | totsz = actual_cnt * size; |
| 4488 | |
| 4489 | if (totsz != ha->exchoffld_size) { |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4490 | qla2x00_free_exchoffld_buffer(ha); |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 4491 | if (actual_cnt <= FW_DEF_EXCHANGES_CNT) { |
| 4492 | ha->exchoffld_size = 0; |
| 4493 | ha->flags.exchoffld_enabled = 0; |
| 4494 | return QLA_SUCCESS; |
| 4495 | } |
| 4496 | |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4497 | ha->exchoffld_size = totsz; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4498 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4499 | ql_log(ql_log_info, vha, 0xd016, |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4500 | "Exchange offload: max_count=%d, actual count=%d entry sz=0x%x, total sz=0x%x\n", |
| 4501 | max_cnt, actual_cnt, size, totsz); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4502 | |
| 4503 | ql_log(ql_log_info, vha, 0xd017, |
| 4504 | "Exchange Buffers requested size = 0x%x\n", |
| 4505 | ha->exchoffld_size); |
| 4506 | |
| 4507 | /* Get consistent memory for extended logins */ |
| 4508 | ha->exchoffld_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 4509 | ha->exchoffld_size, &ha->exchoffld_buf_dma, GFP_KERNEL); |
| 4510 | if (!ha->exchoffld_buf) { |
| 4511 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
Quinn Tran | d1e3635 | 2017-12-28 12:33:12 -0800 | [diff] [blame] | 4512 | "Failed to allocate memory for Exchange Offload.\n"); |
| 4513 | |
| 4514 | if (ha->max_exchg > |
| 4515 | (FW_DEF_EXCHANGES_CNT + REDUCE_EXCHANGES_CNT)) { |
| 4516 | ha->max_exchg -= REDUCE_EXCHANGES_CNT; |
| 4517 | } else if (ha->max_exchg > |
| 4518 | (FW_DEF_EXCHANGES_CNT + 512)) { |
| 4519 | ha->max_exchg -= 512; |
| 4520 | } else { |
| 4521 | ha->flags.exchoffld_enabled = 0; |
| 4522 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
| 4523 | "Disabling Exchange offload due to lack of memory\n"); |
| 4524 | } |
| 4525 | ha->exchoffld_size = 0; |
| 4526 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4527 | return -ENOMEM; |
| 4528 | } |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 4529 | } else if (!ha->exchoffld_buf || (actual_cnt <= FW_DEF_EXCHANGES_CNT)) { |
| 4530 | /* pathological case */ |
| 4531 | qla2x00_free_exchoffld_buffer(ha); |
| 4532 | ha->exchoffld_size = 0; |
| 4533 | ha->flags.exchoffld_enabled = 0; |
| 4534 | ql_log(ql_log_info, vha, 0xd016, |
| 4535 | "Exchange offload not enable: offld size=%d, actual count=%d entry sz=0x%x, total sz=0x%x.\n", |
| 4536 | ha->exchoffld_size, actual_cnt, size, totsz); |
| 4537 | return 0; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4538 | } |
| 4539 | |
| 4540 | /* Now configure the dma buffer */ |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4541 | rval = qla_set_exchoffld_mem_cfg(vha); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4542 | if (rval) { |
| 4543 | ql_log(ql_log_fatal, vha, 0xd02e, |
| 4544 | "Setup exchange offload buffer ****FAILED****.\n"); |
| 4545 | qla2x00_free_exchoffld_buffer(ha); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4546 | } else { |
| 4547 | /* re-adjust number of target exchange */ |
| 4548 | struct init_cb_81xx *icb = (struct init_cb_81xx *)ha->init_cb; |
| 4549 | |
| 4550 | if (qla_ini_mode_enabled(vha)) |
| 4551 | icb->exchange_count = 0; |
| 4552 | else |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 4553 | icb->exchange_count = cpu_to_le16(vha->ql2xexchoffld); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4554 | } |
| 4555 | |
| 4556 | return rval; |
| 4557 | } |
| 4558 | |
| 4559 | /* |
| 4560 | * qla2x00_free_exchoffld_buffer |
| 4561 | * |
| 4562 | * Input: |
| 4563 | * ha = adapter block pointer |
| 4564 | */ |
| 4565 | void |
| 4566 | qla2x00_free_exchoffld_buffer(struct qla_hw_data *ha) |
| 4567 | { |
| 4568 | if (ha->exchoffld_buf) { |
| 4569 | dma_free_coherent(&ha->pdev->dev, ha->exchoffld_size, |
| 4570 | ha->exchoffld_buf, ha->exchoffld_buf_dma); |
| 4571 | ha->exchoffld_buf = NULL; |
| 4572 | ha->exchoffld_size = 0; |
| 4573 | } |
| 4574 | } |
| 4575 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4576 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4577 | * qla2x00_free_fw_dump |
| 4578 | * Frees fw dump stuff. |
| 4579 | * |
| 4580 | * Input: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 4581 | * ha = adapter block pointer |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4582 | */ |
| 4583 | static void |
| 4584 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 4585 | { |
Joe Carnuccio | a28d9e4 | 2019-03-12 11:08:17 -0700 | [diff] [blame] | 4586 | struct fwdt *fwdt = ha->fwdt; |
| 4587 | uint j; |
| 4588 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4589 | if (ha->fce) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4590 | dma_free_coherent(&ha->pdev->dev, |
| 4591 | FCE_SIZE, ha->fce, ha->fce_dma); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4592 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4593 | if (ha->eft) |
| 4594 | dma_free_coherent(&ha->pdev->dev, |
| 4595 | EFT_SIZE, ha->eft, ha->eft_dma); |
| 4596 | |
| 4597 | if (ha->fw_dump) |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4598 | vfree(ha->fw_dump); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4599 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4600 | ha->fce = NULL; |
| 4601 | ha->fce_dma = 0; |
| 4602 | ha->eft = NULL; |
| 4603 | ha->eft_dma = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4604 | ha->fw_dumped = 0; |
Hiral Patel | 61f098d | 2014-04-11 16:54:21 -0400 | [diff] [blame] | 4605 | ha->fw_dump_cap_flags = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4606 | ha->fw_dump_reading = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4607 | ha->fw_dump = NULL; |
| 4608 | ha->fw_dump_len = 0; |
Joe Carnuccio | a28d9e4 | 2019-03-12 11:08:17 -0700 | [diff] [blame] | 4609 | |
| 4610 | for (j = 0; j < 2; j++, fwdt++) { |
| 4611 | if (fwdt->template) |
| 4612 | vfree(fwdt->template); |
| 4613 | fwdt->template = NULL; |
| 4614 | fwdt->length = 0; |
| 4615 | } |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4616 | } |
| 4617 | |
| 4618 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4619 | * qla2x00_mem_free |
| 4620 | * Frees all adapter allocated memory. |
| 4621 | * |
| 4622 | * Input: |
| 4623 | * ha = adapter block pointer. |
| 4624 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 4625 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4626 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4627 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4628 | qla2x00_free_fw_dump(ha); |
| 4629 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4630 | if (ha->mctp_dump) |
| 4631 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 4632 | ha->mctp_dump_dma); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4633 | ha->mctp_dump = NULL; |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4634 | |
Thomas Meyer | 75c1d48 | 2018-12-02 21:52:11 +0100 | [diff] [blame] | 4635 | mempool_destroy(ha->srb_mempool); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4636 | ha->srb_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4637 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4638 | if (ha->dcbx_tlv) |
| 4639 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 4640 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4641 | ha->dcbx_tlv = NULL; |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4642 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4643 | if (ha->xgmac_data) |
| 4644 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 4645 | ha->xgmac_data, ha->xgmac_data_dma); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4646 | ha->xgmac_data = NULL; |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4647 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4648 | if (ha->sns_cmd) |
| 4649 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4650 | ha->sns_cmd, ha->sns_cmd_dma); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4651 | ha->sns_cmd = NULL; |
| 4652 | ha->sns_cmd_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4653 | |
| 4654 | if (ha->ct_sns) |
| 4655 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4656 | ha->ct_sns, ha->ct_sns_dma); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4657 | ha->ct_sns = NULL; |
| 4658 | ha->ct_sns_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4659 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 4660 | if (ha->sfp_data) |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 4661 | dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE, ha->sfp_data, |
| 4662 | ha->sfp_data_dma); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4663 | ha->sfp_data = NULL; |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 4664 | |
Michael Hernandez | 3f006ac | 2019-03-12 11:08:22 -0700 | [diff] [blame] | 4665 | if (ha->flt) |
| 4666 | dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE, |
| 4667 | ha->flt, ha->flt_dma); |
Bart Van Assche | dc035d4 | 2019-04-17 14:44:23 -0700 | [diff] [blame] | 4668 | ha->flt = NULL; |
| 4669 | ha->flt_dma = 0; |
Michael Hernandez | 3f006ac | 2019-03-12 11:08:22 -0700 | [diff] [blame] | 4670 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4671 | if (ha->ms_iocb) |
| 4672 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4673 | ha->ms_iocb = NULL; |
| 4674 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4675 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4676 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4677 | dma_pool_free(ha->s_dma_pool, |
| 4678 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4679 | ha->ex_init_cb = NULL; |
| 4680 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4681 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4682 | if (ha->async_pd) |
| 4683 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4684 | ha->async_pd = NULL; |
| 4685 | ha->async_pd_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4686 | |
Thomas Meyer | 75c1d48 | 2018-12-02 21:52:11 +0100 | [diff] [blame] | 4687 | dma_pool_destroy(ha->s_dma_pool); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4688 | ha->s_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4689 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4690 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 4691 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 4692 | ha->gid_list, ha->gid_list_dma); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4693 | ha->gid_list = NULL; |
| 4694 | ha->gid_list_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4695 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4696 | if (IS_QLA82XX(ha)) { |
| 4697 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 4698 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 4699 | |
| 4700 | /* clean up allocated prev pool */ |
| 4701 | list_for_each_entry_safe(dsd_ptr, |
| 4702 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 4703 | dma_pool_free(ha->dl_dma_pool, |
| 4704 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 4705 | list_del(&dsd_ptr->list); |
| 4706 | kfree(dsd_ptr); |
| 4707 | } |
| 4708 | } |
| 4709 | } |
| 4710 | |
Thomas Meyer | 75c1d48 | 2018-12-02 21:52:11 +0100 | [diff] [blame] | 4711 | dma_pool_destroy(ha->dl_dma_pool); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4712 | ha->dl_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4713 | |
Thomas Meyer | 75c1d48 | 2018-12-02 21:52:11 +0100 | [diff] [blame] | 4714 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4715 | ha->fcp_cmnd_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4716 | |
Thomas Meyer | 75c1d48 | 2018-12-02 21:52:11 +0100 | [diff] [blame] | 4717 | mempool_destroy(ha->ctx_mempool); |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4718 | ha->ctx_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4719 | |
Giridhar Malavali | 50b8127 | 2018-12-21 09:33:45 -0800 | [diff] [blame] | 4720 | if (ql2xenabledif) { |
| 4721 | struct dsd_dma *dsd, *nxt; |
| 4722 | |
| 4723 | list_for_each_entry_safe(dsd, nxt, &ha->pool.unusable.head, |
| 4724 | list) { |
| 4725 | list_del(&dsd->list); |
| 4726 | dma_pool_free(ha->dif_bundl_pool, dsd->dsd_addr, |
| 4727 | dsd->dsd_list_dma); |
| 4728 | ha->dif_bundle_dma_allocs--; |
| 4729 | kfree(dsd); |
| 4730 | ha->dif_bundle_kallocs--; |
| 4731 | ha->pool.unusable.count--; |
| 4732 | } |
| 4733 | list_for_each_entry_safe(dsd, nxt, &ha->pool.good.head, list) { |
| 4734 | list_del(&dsd->list); |
| 4735 | dma_pool_free(ha->dif_bundl_pool, dsd->dsd_addr, |
| 4736 | dsd->dsd_list_dma); |
| 4737 | ha->dif_bundle_dma_allocs--; |
| 4738 | kfree(dsd); |
| 4739 | ha->dif_bundle_kallocs--; |
| 4740 | } |
| 4741 | } |
| 4742 | |
YueHaibing | 0b3b6fe | 2019-07-11 22:13:17 +0800 | [diff] [blame] | 4743 | dma_pool_destroy(ha->dif_bundl_pool); |
Bart Van Assche | dc035d4 | 2019-04-17 14:44:23 -0700 | [diff] [blame] | 4744 | ha->dif_bundl_pool = NULL; |
Giridhar Malavali | 50b8127 | 2018-12-21 09:33:45 -0800 | [diff] [blame] | 4745 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4746 | qlt_mem_free(ha); |
| 4747 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4748 | if (ha->init_cb) |
| 4749 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4750 | ha->init_cb, ha->init_cb_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4751 | ha->init_cb = NULL; |
| 4752 | ha->init_cb_dma = 0; |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4753 | |
| 4754 | vfree(ha->optrom_buffer); |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 4755 | ha->optrom_buffer = NULL; |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4756 | kfree(ha->nvram); |
Bill Kuzeja | 6a2cf8d | 2018-03-05 00:02:55 -0500 | [diff] [blame] | 4757 | ha->nvram = NULL; |
Bart Van Assche | 5365bf9 | 2019-04-17 14:44:22 -0700 | [diff] [blame] | 4758 | kfree(ha->npiv_info); |
| 4759 | ha->npiv_info = NULL; |
| 4760 | kfree(ha->swl); |
| 4761 | ha->swl = NULL; |
| 4762 | kfree(ha->loop_id_map); |
| 4763 | ha->loop_id_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4764 | } |
| 4765 | |
| 4766 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 4767 | struct qla_hw_data *ha) |
| 4768 | { |
| 4769 | struct Scsi_Host *host; |
| 4770 | struct scsi_qla_host *vha = NULL; |
| 4771 | |
| 4772 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4773 | if (!host) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4774 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 4775 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4776 | return NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4777 | } |
| 4778 | |
| 4779 | /* Clear our data area */ |
| 4780 | vha = shost_priv(host); |
| 4781 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 4782 | |
| 4783 | vha->host = host; |
| 4784 | vha->host_no = host->host_no; |
| 4785 | vha->hw = ha; |
| 4786 | |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 4787 | vha->qlini_mode = ql2x_ini_mode; |
| 4788 | vha->ql2xexchoffld = ql2xexchoffld; |
| 4789 | vha->ql2xiniexchg = ql2xiniexchg; |
| 4790 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4791 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 4792 | INIT_LIST_HEAD(&vha->work_list); |
| 4793 | INIT_LIST_HEAD(&vha->list); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4794 | INIT_LIST_HEAD(&vha->qla_cmd_list); |
| 4795 | INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list); |
Alexei Potashnik | 71cdc07 | 2015-12-17 14:57:01 -0500 | [diff] [blame] | 4796 | INIT_LIST_HEAD(&vha->logo_list); |
Alexei Potashnik | b7bd104 | 2015-12-17 14:57:02 -0500 | [diff] [blame] | 4797 | INIT_LIST_HEAD(&vha->plogi_ack_list); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 4798 | INIT_LIST_HEAD(&vha->qp_list); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4799 | INIT_LIST_HEAD(&vha->gnl.fcports); |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame] | 4800 | INIT_LIST_HEAD(&vha->gpnid_list); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4801 | INIT_WORK(&vha->iocb_work, qla2x00_iocb_work_fn); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4802 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4803 | spin_lock_init(&vha->work_lock); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4804 | spin_lock_init(&vha->cmd_list_lock); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4805 | init_waitqueue_head(&vha->fcport_waitQ); |
Joe Carnuccio | c4a9b53 | 2017-03-15 09:48:43 -0700 | [diff] [blame] | 4806 | init_waitqueue_head(&vha->vref_waitq); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4807 | |
Bart Van Assche | 2fdbc65 | 2017-01-20 13:31:13 -0800 | [diff] [blame] | 4808 | vha->gnl.size = sizeof(struct get_name_list_extended) * |
| 4809 | (ha->max_loop_id + 1); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4810 | vha->gnl.l = dma_alloc_coherent(&ha->pdev->dev, |
| 4811 | vha->gnl.size, &vha->gnl.ldma, GFP_KERNEL); |
| 4812 | if (!vha->gnl.l) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4813 | ql_log(ql_log_fatal, vha, 0xd04a, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4814 | "Alloc failed for name list.\n"); |
| 4815 | scsi_remove_host(vha->host); |
| 4816 | return NULL; |
| 4817 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4818 | |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4819 | /* todo: what about ext login? */ |
| 4820 | vha->scan.size = ha->max_fibre_devices * sizeof(struct fab_scan_rp); |
| 4821 | vha->scan.l = vmalloc(vha->scan.size); |
| 4822 | if (!vha->scan.l) { |
| 4823 | ql_log(ql_log_fatal, vha, 0xd04a, |
| 4824 | "Alloc failed for scan database.\n"); |
| 4825 | dma_free_coherent(&ha->pdev->dev, vha->gnl.size, |
| 4826 | vha->gnl.l, vha->gnl.ldma); |
| 4827 | scsi_remove_host(vha->host); |
| 4828 | return NULL; |
| 4829 | } |
Quinn Tran | f352eeb | 2017-12-28 12:33:35 -0800 | [diff] [blame] | 4830 | INIT_DELAYED_WORK(&vha->scan.scan_work, qla_scan_work_fn); |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 4831 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4832 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4833 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 4834 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 4835 | vha->host, vha->hw, vha, |
| 4836 | dev_name(&(ha->pdev->dev))); |
| 4837 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4838 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4839 | } |
| 4840 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4841 | struct qla_work_evt * |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4842 | 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] | 4843 | { |
| 4844 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4845 | uint8_t bail; |
| 4846 | |
| 4847 | QLA_VHA_MARK_BUSY(vha, bail); |
| 4848 | if (bail) |
| 4849 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4850 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4851 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4852 | if (!e) { |
| 4853 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4854 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4855 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4856 | |
| 4857 | INIT_LIST_HEAD(&e->list); |
| 4858 | e->type = type; |
| 4859 | e->flags = QLA_EVT_FLAG_FREE; |
| 4860 | return e; |
| 4861 | } |
| 4862 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4863 | int |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4864 | 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] | 4865 | { |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4866 | unsigned long flags; |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4867 | bool q = false; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4868 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4869 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4870 | list_add_tail(&e->list, &vha->work_list); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4871 | |
| 4872 | if (!test_and_set_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags)) |
| 4873 | q = true; |
| 4874 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4875 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 4876 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 4877 | if (q) |
| 4878 | queue_work(vha->hw->wq, &vha->iocb_work); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4879 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4880 | return QLA_SUCCESS; |
| 4881 | } |
| 4882 | |
| 4883 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4884 | 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] | 4885 | u32 data) |
| 4886 | { |
| 4887 | struct qla_work_evt *e; |
| 4888 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4889 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4890 | if (!e) |
| 4891 | return QLA_FUNCTION_FAILED; |
| 4892 | |
| 4893 | e->u.aen.code = code; |
| 4894 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4895 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4896 | } |
| 4897 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4898 | int |
| 4899 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 4900 | { |
| 4901 | struct qla_work_evt *e; |
| 4902 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4903 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4904 | if (!e) |
| 4905 | return QLA_FUNCTION_FAILED; |
| 4906 | |
| 4907 | 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] | 4908 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4909 | } |
| 4910 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4911 | #define qla2x00_post_async_work(name, type) \ |
| 4912 | int qla2x00_post_async_##name##_work( \ |
| 4913 | struct scsi_qla_host *vha, \ |
| 4914 | fc_port_t *fcport, uint16_t *data) \ |
| 4915 | { \ |
| 4916 | struct qla_work_evt *e; \ |
| 4917 | \ |
| 4918 | e = qla2x00_alloc_work(vha, type); \ |
| 4919 | if (!e) \ |
| 4920 | return QLA_FUNCTION_FAILED; \ |
| 4921 | \ |
| 4922 | e->u.logio.fcport = fcport; \ |
| 4923 | if (data) { \ |
| 4924 | e->u.logio.data[0] = data[0]; \ |
| 4925 | e->u.logio.data[1] = data[1]; \ |
| 4926 | } \ |
Quinn Tran | 6d674927 | 2017-12-28 12:33:41 -0800 | [diff] [blame] | 4927 | fcport->flags |= FCF_ASYNC_ACTIVE; \ |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4928 | return qla2x00_post_work(vha, e); \ |
| 4929 | } |
| 4930 | |
| 4931 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4932 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 4933 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4934 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
Quinn Tran | 11aea16 | 2017-12-28 12:33:20 -0800 | [diff] [blame] | 4935 | qla2x00_post_async_work(prlo, QLA_EVT_ASYNC_PRLO); |
| 4936 | qla2x00_post_async_work(prlo_done, QLA_EVT_ASYNC_PRLO_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4937 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4938 | int |
| 4939 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 4940 | { |
| 4941 | struct qla_work_evt *e; |
| 4942 | |
| 4943 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 4944 | if (!e) |
| 4945 | return QLA_FUNCTION_FAILED; |
| 4946 | |
| 4947 | e->u.uevent.code = code; |
| 4948 | return qla2x00_post_work(vha, e); |
| 4949 | } |
| 4950 | |
| 4951 | static void |
| 4952 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 4953 | { |
| 4954 | char event_string[40]; |
| 4955 | char *envp[] = { event_string, NULL }; |
| 4956 | |
| 4957 | switch (code) { |
| 4958 | case QLA_UEVENT_CODE_FW_DUMP: |
| 4959 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 4960 | vha->host_no); |
| 4961 | break; |
| 4962 | default: |
| 4963 | /* do nothing */ |
| 4964 | break; |
| 4965 | } |
| 4966 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 4967 | } |
| 4968 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4969 | int |
| 4970 | qlafx00_post_aenfx_work(struct scsi_qla_host *vha, uint32_t evtcode, |
| 4971 | uint32_t *data, int cnt) |
| 4972 | { |
| 4973 | struct qla_work_evt *e; |
| 4974 | |
| 4975 | e = qla2x00_alloc_work(vha, QLA_EVT_AENFX); |
| 4976 | if (!e) |
| 4977 | return QLA_FUNCTION_FAILED; |
| 4978 | |
| 4979 | e->u.aenfx.evtcode = evtcode; |
| 4980 | e->u.aenfx.count = cnt; |
| 4981 | memcpy(e->u.aenfx.mbx, data, sizeof(*data) * cnt); |
| 4982 | return qla2x00_post_work(vha, e); |
| 4983 | } |
| 4984 | |
Quinn Tran | cd4ed6b | 2018-08-31 11:24:31 -0700 | [diff] [blame] | 4985 | void qla24xx_sched_upd_fcport(fc_port_t *fcport) |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4986 | { |
Quinn Tran | cd4ed6b | 2018-08-31 11:24:31 -0700 | [diff] [blame] | 4987 | unsigned long flags; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4988 | |
Quinn Tran | cd4ed6b | 2018-08-31 11:24:31 -0700 | [diff] [blame] | 4989 | if (IS_SW_RESV_ADDR(fcport->d_id)) |
| 4990 | return; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4991 | |
Quinn Tran | cd4ed6b | 2018-08-31 11:24:31 -0700 | [diff] [blame] | 4992 | spin_lock_irqsave(&fcport->vha->work_lock, flags); |
| 4993 | if (fcport->disc_state == DSC_UPD_FCPORT) { |
| 4994 | spin_unlock_irqrestore(&fcport->vha->work_lock, flags); |
| 4995 | return; |
| 4996 | } |
| 4997 | fcport->jiffies_at_registration = jiffies; |
| 4998 | fcport->sec_since_registration = 0; |
| 4999 | fcport->next_disc_state = DSC_DELETED; |
| 5000 | fcport->disc_state = DSC_UPD_FCPORT; |
| 5001 | spin_unlock_irqrestore(&fcport->vha->work_lock, flags); |
| 5002 | |
| 5003 | queue_work(system_unbound_wq, &fcport->reg_work); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5004 | } |
| 5005 | |
| 5006 | static |
| 5007 | void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) |
| 5008 | { |
| 5009 | unsigned long flags; |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 5010 | fc_port_t *fcport = NULL, *tfcp; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5011 | struct qlt_plogi_ack_t *pla = |
| 5012 | (struct qlt_plogi_ack_t *)e->u.new_sess.pla; |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 5013 | uint8_t free_fcport = 0; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5014 | |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 5015 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 5016 | "%s %d %8phC enter\n", |
| 5017 | __func__, __LINE__, e->u.new_sess.port_name); |
| 5018 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5019 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 5020 | fcport = qla2x00_find_fcport_by_wwpn(vha, e->u.new_sess.port_name, 1); |
| 5021 | if (fcport) { |
| 5022 | fcport->d_id = e->u.new_sess.id; |
| 5023 | if (pla) { |
| 5024 | fcport->fw_login_state = DSC_LS_PLOGI_PEND; |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5025 | memcpy(fcport->node_name, |
| 5026 | pla->iocb.u.isp24.u.plogi.node_name, |
| 5027 | WWN_SIZE); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5028 | qlt_plogi_ack_link(vha, pla, fcport, QLT_PLOGI_LINK_SAME_WWN); |
| 5029 | /* we took an extra ref_count to prevent PLOGI ACK when |
| 5030 | * fcport/sess has not been created. |
| 5031 | */ |
| 5032 | pla->ref_count--; |
| 5033 | } |
| 5034 | } else { |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 5035 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5036 | fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
| 5037 | if (fcport) { |
| 5038 | fcport->d_id = e->u.new_sess.id; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5039 | fcport->flags |= FCF_FABRIC_DEVICE; |
| 5040 | fcport->fw_login_state = DSC_LS_PLOGI_PEND; |
Himanshu Madhani | c64a87f | 2018-12-06 21:49:42 -0800 | [diff] [blame] | 5041 | if (e->u.new_sess.fc4_type == FS_FC4TYPE_FCP) |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 5042 | fcport->fc4_type = FC4_TYPE_FCP_SCSI; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5043 | |
Himanshu Madhani | c64a87f | 2018-12-06 21:49:42 -0800 | [diff] [blame] | 5044 | if (e->u.new_sess.fc4_type == FS_FC4TYPE_NVME) { |
Darren Trapp | 2b5b964 | 2018-02-27 16:31:12 -0800 | [diff] [blame] | 5045 | fcport->fc4_type = FC4_TYPE_OTHER; |
| 5046 | fcport->fc4f_nvme = FC4_TYPE_NVME; |
| 5047 | } |
Quinn Tran | 33b2835 | 2018-03-20 23:09:40 -0700 | [diff] [blame] | 5048 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5049 | memcpy(fcport->port_name, e->u.new_sess.port_name, |
| 5050 | WWN_SIZE); |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 5051 | } else { |
| 5052 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 5053 | "%s %8phC mem alloc fail.\n", |
| 5054 | __func__, e->u.new_sess.port_name); |
| 5055 | |
| 5056 | if (pla) |
| 5057 | kmem_cache_free(qla_tgt_plogi_cachep, pla); |
| 5058 | return; |
| 5059 | } |
| 5060 | |
| 5061 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 5062 | /* search again to make sure no one else got ahead */ |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 5063 | tfcp = qla2x00_find_fcport_by_wwpn(vha, |
| 5064 | e->u.new_sess.port_name, 1); |
| 5065 | if (tfcp) { |
| 5066 | /* should rarily happen */ |
| 5067 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 5068 | "%s %8phC found existing fcport b4 add. DS %d LS %d\n", |
| 5069 | __func__, tfcp->port_name, tfcp->disc_state, |
| 5070 | tfcp->fw_login_state); |
| 5071 | |
| 5072 | free_fcport = 1; |
| 5073 | } else { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5074 | list_add_tail(&fcport->list, &vha->vp_fcports); |
| 5075 | |
Quinn Tran | 1975903 | 2017-12-04 14:45:15 -0800 | [diff] [blame] | 5076 | } |
| 5077 | if (pla) { |
| 5078 | qlt_plogi_ack_link(vha, pla, fcport, |
| 5079 | QLT_PLOGI_LINK_SAME_WWN); |
| 5080 | pla->ref_count--; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5081 | } |
| 5082 | } |
| 5083 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 5084 | |
| 5085 | if (fcport) { |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 5086 | fcport->id_changed = 1; |
| 5087 | fcport->scan_state = QLA_FCPORT_FOUND; |
Quinn Tran | 8b5292bc | 2019-07-26 09:07:32 -0700 | [diff] [blame^] | 5088 | fcport->chip_reset = vha->hw->base_qpair->chip_reset; |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 5089 | memcpy(fcport->node_name, e->u.new_sess.node_name, WWN_SIZE); |
| 5090 | |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 5091 | if (pla) { |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 5092 | if (pla->iocb.u.isp24.status_subcode == ELS_PRLI) { |
| 5093 | u16 wd3_lo; |
| 5094 | |
| 5095 | fcport->fw_login_state = DSC_LS_PRLI_PEND; |
| 5096 | fcport->local = 0; |
| 5097 | fcport->loop_id = |
| 5098 | le16_to_cpu( |
| 5099 | pla->iocb.u.isp24.nport_handle); |
| 5100 | fcport->fw_login_state = DSC_LS_PRLI_PEND; |
| 5101 | wd3_lo = |
| 5102 | le16_to_cpu( |
| 5103 | pla->iocb.u.isp24.u.prli.wd3_lo); |
| 5104 | |
| 5105 | if (wd3_lo & BIT_7) |
| 5106 | fcport->conf_compl_supported = 1; |
| 5107 | |
| 5108 | if ((wd3_lo & BIT_4) == 0) |
| 5109 | fcport->port_type = FCT_INITIATOR; |
| 5110 | else |
| 5111 | fcport->port_type = FCT_TARGET; |
| 5112 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5113 | qlt_plogi_ack_unref(vha, pla); |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 5114 | } else { |
Hannes Reinecke | 1c6cacf | 2018-02-22 09:49:35 +0100 | [diff] [blame] | 5115 | fc_port_t *dfcp = NULL; |
| 5116 | |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 5117 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 5118 | tfcp = qla2x00_find_fcport_by_nportid(vha, |
| 5119 | &e->u.new_sess.id, 1); |
| 5120 | if (tfcp && (tfcp != fcport)) { |
| 5121 | /* |
| 5122 | * We have a conflict fcport with same NportID. |
| 5123 | */ |
| 5124 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
| 5125 | "%s %8phC found conflict b4 add. DS %d LS %d\n", |
| 5126 | __func__, tfcp->port_name, tfcp->disc_state, |
| 5127 | tfcp->fw_login_state); |
| 5128 | |
| 5129 | switch (tfcp->disc_state) { |
| 5130 | case DSC_DELETED: |
| 5131 | break; |
| 5132 | case DSC_DELETE_PEND: |
| 5133 | fcport->login_pause = 1; |
| 5134 | tfcp->conflict = fcport; |
| 5135 | break; |
| 5136 | default: |
| 5137 | fcport->login_pause = 1; |
| 5138 | tfcp->conflict = fcport; |
Hannes Reinecke | 1c6cacf | 2018-02-22 09:49:35 +0100 | [diff] [blame] | 5139 | dfcp = tfcp; |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 5140 | break; |
| 5141 | } |
| 5142 | } |
| 5143 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
Hannes Reinecke | 1c6cacf | 2018-02-22 09:49:35 +0100 | [diff] [blame] | 5144 | if (dfcp) |
| 5145 | qlt_schedule_sess_for_deletion(tfcp); |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 5146 | |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 5147 | |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 5148 | if (N2N_TOPO(vha->hw)) |
| 5149 | fcport->flags &= ~FCF_FABRIC_DEVICE; |
| 5150 | |
| 5151 | if (N2N_TOPO(vha->hw)) { |
| 5152 | if (vha->flags.nvme_enabled) { |
| 5153 | fcport->fc4f_nvme = 1; |
| 5154 | fcport->n2n_flag = 1; |
| 5155 | } |
| 5156 | fcport->fw_login_state = 0; |
| 5157 | /* |
| 5158 | * wait link init done before sending login |
| 5159 | */ |
| 5160 | } else { |
| 5161 | qla24xx_fcport_handle_login(vha, fcport); |
| 5162 | } |
Quinn Tran | 5ef696a | 2017-12-04 14:45:05 -0800 | [diff] [blame] | 5163 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5164 | } |
Quinn Tran | b5d1531 | 2017-08-30 10:16:49 -0700 | [diff] [blame] | 5165 | |
| 5166 | if (free_fcport) { |
| 5167 | qla2x00_free_fcport(fcport); |
| 5168 | if (pla) |
| 5169 | kmem_cache_free(qla_tgt_plogi_cachep, pla); |
| 5170 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5171 | } |
| 5172 | |
Quinn Tran | e374f9f | 2017-12-28 12:33:31 -0800 | [diff] [blame] | 5173 | static void qla_sp_retry(struct scsi_qla_host *vha, struct qla_work_evt *e) |
| 5174 | { |
| 5175 | struct srb *sp = e->u.iosb.sp; |
| 5176 | int rval; |
| 5177 | |
| 5178 | rval = qla2x00_start_sp(sp); |
| 5179 | if (rval != QLA_SUCCESS) { |
| 5180 | ql_dbg(ql_dbg_disc, vha, 0x2043, |
| 5181 | "%s: %s: Re-issue IOCB failed (%d).\n", |
| 5182 | __func__, sp->name, rval); |
| 5183 | qla24xx_sp_unmap(vha, sp); |
| 5184 | } |
| 5185 | } |
| 5186 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5187 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5188 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5189 | { |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 5190 | struct qla_work_evt *e, *tmp; |
| 5191 | unsigned long flags; |
| 5192 | LIST_HEAD(work); |
Quinn Tran | 80676d0 | 2019-01-24 23:23:42 -0800 | [diff] [blame] | 5193 | int rc; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5194 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 5195 | spin_lock_irqsave(&vha->work_lock, flags); |
| 5196 | list_splice_init(&vha->work_list, &work); |
| 5197 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 5198 | |
| 5199 | list_for_each_entry_safe(e, tmp, &work, list) { |
Quinn Tran | 80676d0 | 2019-01-24 23:23:42 -0800 | [diff] [blame] | 5200 | rc = QLA_SUCCESS; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5201 | switch (e->type) { |
| 5202 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5203 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5204 | e->u.aen.code, e->u.aen.data); |
| 5205 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 5206 | case QLA_EVT_IDC_ACK: |
| 5207 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 5208 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5209 | case QLA_EVT_ASYNC_LOGIN: |
| 5210 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 5211 | e->u.logio.data); |
| 5212 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5213 | case QLA_EVT_ASYNC_LOGOUT: |
Quinn Tran | 80676d0 | 2019-01-24 23:23:42 -0800 | [diff] [blame] | 5214 | rc = qla2x00_async_logout(vha, e->u.logio.fcport); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5215 | break; |
| 5216 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 5217 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 5218 | e->u.logio.data); |
| 5219 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 5220 | case QLA_EVT_ASYNC_ADISC: |
| 5221 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 5222 | e->u.logio.data); |
| 5223 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 5224 | case QLA_EVT_UEVENT: |
| 5225 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 5226 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5227 | case QLA_EVT_AENFX: |
| 5228 | qlafx00_process_aen(vha, e); |
| 5229 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5230 | case QLA_EVT_GPNID: |
| 5231 | qla24xx_async_gpnid(vha, &e->u.gpnid.id); |
| 5232 | break; |
Quinn Tran | e374f9f | 2017-12-28 12:33:31 -0800 | [diff] [blame] | 5233 | case QLA_EVT_UNMAP: |
| 5234 | qla24xx_sp_unmap(vha, e->u.iosb.sp); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5235 | break; |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5236 | case QLA_EVT_RELOGIN: |
| 5237 | qla2x00_relogin(vha); |
| 5238 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5239 | case QLA_EVT_NEW_SESS: |
| 5240 | qla24xx_create_new_sess(vha, e); |
| 5241 | break; |
| 5242 | case QLA_EVT_GPDB: |
| 5243 | qla24xx_async_gpdb(vha, e->u.fcport.fcport, |
| 5244 | e->u.fcport.opt); |
| 5245 | break; |
Duane Grigsby | a5d42f4 | 2017-06-21 13:48:41 -0700 | [diff] [blame] | 5246 | case QLA_EVT_PRLI: |
| 5247 | qla24xx_async_prli(vha, e->u.fcport.fcport); |
| 5248 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5249 | case QLA_EVT_GPSC: |
| 5250 | qla24xx_async_gpsc(vha, e->u.fcport.fcport); |
| 5251 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5252 | case QLA_EVT_GNL: |
| 5253 | qla24xx_async_gnl(vha, e->u.fcport.fcport); |
| 5254 | break; |
| 5255 | case QLA_EVT_NACK: |
| 5256 | qla24xx_do_nack_work(vha, e); |
| 5257 | break; |
Quinn Tran | 11aea16 | 2017-12-28 12:33:20 -0800 | [diff] [blame] | 5258 | case QLA_EVT_ASYNC_PRLO: |
Quinn Tran | 80676d0 | 2019-01-24 23:23:42 -0800 | [diff] [blame] | 5259 | rc = qla2x00_async_prlo(vha, e->u.logio.fcport); |
Quinn Tran | 11aea16 | 2017-12-28 12:33:20 -0800 | [diff] [blame] | 5260 | break; |
| 5261 | case QLA_EVT_ASYNC_PRLO_DONE: |
| 5262 | qla2x00_async_prlo_done(vha, e->u.logio.fcport, |
| 5263 | e->u.logio.data); |
| 5264 | break; |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 5265 | case QLA_EVT_GPNFT: |
Quinn Tran | 33b2835 | 2018-03-20 23:09:40 -0700 | [diff] [blame] | 5266 | qla24xx_async_gpnft(vha, e->u.gpnft.fc4_type, |
| 5267 | e->u.gpnft.sp); |
Quinn Tran | a423994 | 2017-12-28 12:33:26 -0800 | [diff] [blame] | 5268 | break; |
| 5269 | case QLA_EVT_GPNFT_DONE: |
| 5270 | qla24xx_async_gpnft_done(vha, e->u.iosb.sp); |
| 5271 | break; |
| 5272 | case QLA_EVT_GNNFT_DONE: |
| 5273 | qla24xx_async_gnnft_done(vha, e->u.iosb.sp); |
| 5274 | break; |
| 5275 | case QLA_EVT_GNNID: |
| 5276 | qla24xx_async_gnnid(vha, e->u.fcport.fcport); |
| 5277 | break; |
| 5278 | case QLA_EVT_GFPNID: |
| 5279 | qla24xx_async_gfpnid(vha, e->u.fcport.fcport); |
| 5280 | break; |
Quinn Tran | e374f9f | 2017-12-28 12:33:31 -0800 | [diff] [blame] | 5281 | case QLA_EVT_SP_RETRY: |
| 5282 | qla_sp_retry(vha, e); |
Quinn Tran | cc28e0a | 2018-05-01 09:01:48 -0700 | [diff] [blame] | 5283 | break; |
| 5284 | case QLA_EVT_IIDMA: |
| 5285 | qla_do_iidma_work(vha, e->u.fcport.fcport); |
| 5286 | break; |
Quinn Tran | 8777e43 | 2018-08-02 13:16:57 -0700 | [diff] [blame] | 5287 | case QLA_EVT_ELS_PLOGI: |
| 5288 | qla24xx_els_dcmd2_iocb(vha, ELS_DCMD_PLOGI, |
| 5289 | e->u.fcport.fcport, false); |
| 5290 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5291 | } |
Quinn Tran | 80676d0 | 2019-01-24 23:23:42 -0800 | [diff] [blame] | 5292 | |
| 5293 | if (rc == EAGAIN) { |
| 5294 | /* put 'work' at head of 'vha->work_list' */ |
| 5295 | spin_lock_irqsave(&vha->work_lock, flags); |
| 5296 | list_splice(&work, &vha->work_list); |
| 5297 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 5298 | break; |
| 5299 | } |
| 5300 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5301 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 5302 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 5303 | |
| 5304 | /* For each work completed decrement vha ref count */ |
| 5305 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5306 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5307 | } |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 5308 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5309 | int qla24xx_post_relogin_work(struct scsi_qla_host *vha) |
| 5310 | { |
| 5311 | struct qla_work_evt *e; |
| 5312 | |
| 5313 | e = qla2x00_alloc_work(vha, QLA_EVT_RELOGIN); |
| 5314 | |
| 5315 | if (!e) { |
| 5316 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 5317 | return QLA_FUNCTION_FAILED; |
| 5318 | } |
| 5319 | |
| 5320 | return qla2x00_post_work(vha, e); |
| 5321 | } |
| 5322 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5323 | /* Relogins all the fcports of a vport |
| 5324 | * Context: dpc thread |
| 5325 | */ |
| 5326 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 5327 | { |
| 5328 | fc_port_t *fcport; |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 5329 | int status, relogin_needed = 0; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5330 | struct event_arg ea; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5331 | |
| 5332 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Quinn Tran | 9cd883f | 2017-12-28 12:33:24 -0800 | [diff] [blame] | 5333 | /* |
| 5334 | * If the port is not ONLINE then try to login |
| 5335 | * to it if we haven't run out of retries. |
| 5336 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 5337 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 5338 | fcport->login_retry) { |
| 5339 | if (fcport->scan_state != QLA_FCPORT_FOUND || |
| 5340 | fcport->disc_state == DSC_LOGIN_COMPLETE) |
| 5341 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5342 | |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 5343 | if (fcport->flags & (FCF_ASYNC_SENT|FCF_ASYNC_ACTIVE) || |
| 5344 | fcport->disc_state == DSC_DELETE_PEND) { |
| 5345 | relogin_needed = 1; |
| 5346 | } else { |
| 5347 | if (vha->hw->current_topology != ISP_CFG_NL) { |
| 5348 | memset(&ea, 0, sizeof(ea)); |
| 5349 | ea.event = FCME_RELOGIN; |
| 5350 | ea.fcport = fcport; |
| 5351 | qla2x00_fcport_event_handler(vha, &ea); |
| 5352 | } else if (vha->hw->current_topology == |
| 5353 | ISP_CFG_NL) { |
| 5354 | fcport->login_retry--; |
| 5355 | status = |
| 5356 | qla2x00_local_device_login(vha, |
| 5357 | fcport); |
| 5358 | if (status == QLA_SUCCESS) { |
| 5359 | fcport->old_loop_id = |
| 5360 | fcport->loop_id; |
| 5361 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 5362 | "Port login OK: logged in ID 0x%x.\n", |
| 5363 | fcport->loop_id); |
| 5364 | qla2x00_update_fcport |
| 5365 | (vha, fcport); |
| 5366 | } else if (status == 1) { |
| 5367 | set_bit(RELOGIN_NEEDED, |
| 5368 | &vha->dpc_flags); |
| 5369 | /* retry the login again */ |
| 5370 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 5371 | "Retrying %d login again loop_id 0x%x.\n", |
| 5372 | fcport->login_retry, |
| 5373 | fcport->loop_id); |
| 5374 | } else { |
| 5375 | fcport->login_retry = 0; |
| 5376 | } |
| 5377 | |
| 5378 | if (fcport->login_retry == 0 && |
| 5379 | status != QLA_SUCCESS) |
| 5380 | qla2x00_clear_loop_id(fcport); |
| 5381 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5382 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5383 | } |
| 5384 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 5385 | break; |
| 5386 | } |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5387 | |
Quinn Tran | 23dd98a | 2018-08-02 13:16:45 -0700 | [diff] [blame] | 5388 | if (relogin_needed) |
| 5389 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 5390 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 5391 | ql_dbg(ql_dbg_disc, vha, 0x400e, |
| 5392 | "Relogin end.\n"); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5393 | } |
| 5394 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5395 | /* Schedule work on any of the dpc-workqueues */ |
| 5396 | void |
| 5397 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 5398 | { |
| 5399 | struct qla_hw_data *ha = base_vha->hw; |
| 5400 | |
| 5401 | switch (work_code) { |
| 5402 | case MBA_IDC_AEN: /* 0x8200 */ |
| 5403 | if (ha->dpc_lp_wq) |
| 5404 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 5405 | break; |
| 5406 | |
| 5407 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 5408 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 5409 | if (ha->dpc_hp_wq) |
| 5410 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 5411 | } else |
| 5412 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 5413 | "NIC Core reset is already active. Skip " |
| 5414 | "scheduling it again.\n"); |
| 5415 | break; |
| 5416 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 5417 | if (ha->dpc_hp_wq) |
| 5418 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 5419 | break; |
| 5420 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 5421 | if (ha->dpc_hp_wq) |
| 5422 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 5423 | break; |
| 5424 | default: |
| 5425 | ql_log(ql_log_warn, base_vha, 0xb05f, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 5426 | "Unknown work-code=0x%x.\n", work_code); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5427 | } |
| 5428 | |
| 5429 | return; |
| 5430 | } |
| 5431 | |
| 5432 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 5433 | void |
| 5434 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 5435 | { |
| 5436 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 5437 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5438 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5439 | uint32_t dev_state = 0; |
| 5440 | |
| 5441 | qla83xx_idc_lock(base_vha, 0); |
| 5442 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5443 | qla83xx_reset_ownership(base_vha); |
| 5444 | if (ha->flags.nic_core_reset_owner) { |
| 5445 | ha->flags.nic_core_reset_owner = 0; |
| 5446 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5447 | QLA8XXX_DEV_FAILED); |
| 5448 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 5449 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 5450 | } |
| 5451 | qla83xx_idc_unlock(base_vha, 0); |
| 5452 | } |
| 5453 | |
| 5454 | /* Work: Execute IDC state handler */ |
| 5455 | void |
| 5456 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 5457 | { |
| 5458 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 5459 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5460 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5461 | uint32_t dev_state = 0; |
| 5462 | |
| 5463 | qla83xx_idc_lock(base_vha, 0); |
| 5464 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5465 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 5466 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 5467 | qla83xx_idc_state_handler(base_vha); |
| 5468 | qla83xx_idc_unlock(base_vha, 0); |
| 5469 | } |
| 5470 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5471 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5472 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 5473 | { |
| 5474 | int rval = QLA_SUCCESS; |
| 5475 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 5476 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 5477 | |
| 5478 | do { |
| 5479 | if (time_after(jiffies, heart_beat_wait)) { |
| 5480 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 5481 | "Nic Core f/w is not alive.\n"); |
| 5482 | rval = QLA_FUNCTION_FAILED; |
| 5483 | break; |
| 5484 | } |
| 5485 | |
| 5486 | qla83xx_idc_lock(base_vha, 0); |
| 5487 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 5488 | &heart_beat_counter1); |
| 5489 | qla83xx_idc_unlock(base_vha, 0); |
| 5490 | msleep(100); |
| 5491 | qla83xx_idc_lock(base_vha, 0); |
| 5492 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 5493 | &heart_beat_counter2); |
| 5494 | qla83xx_idc_unlock(base_vha, 0); |
| 5495 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 5496 | |
| 5497 | return rval; |
| 5498 | } |
| 5499 | |
| 5500 | /* Work: Perform NIC Core Reset handling */ |
| 5501 | void |
| 5502 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 5503 | { |
| 5504 | struct qla_hw_data *ha = |
| 5505 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 5506 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5507 | uint32_t dev_state = 0; |
| 5508 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 5509 | if (IS_QLA2031(ha)) { |
| 5510 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 5511 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 5512 | "Failed to dump mctp\n"); |
| 5513 | return; |
| 5514 | } |
| 5515 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5516 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 5517 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 5518 | qla83xx_idc_lock(base_vha, 0); |
| 5519 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5520 | &dev_state); |
| 5521 | qla83xx_idc_unlock(base_vha, 0); |
| 5522 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 5523 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 5524 | "Nic Core f/w is alive.\n"); |
| 5525 | return; |
| 5526 | } |
| 5527 | } |
| 5528 | |
| 5529 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 5530 | if (qla83xx_nic_core_reset(base_vha)) { |
| 5531 | /* NIC Core reset failed. */ |
| 5532 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 5533 | "NIC Core reset failed.\n"); |
| 5534 | } |
| 5535 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 5536 | } |
| 5537 | } |
| 5538 | |
| 5539 | /* Work: Handle 8200 IDC aens */ |
| 5540 | void |
| 5541 | qla83xx_service_idc_aen(struct work_struct *work) |
| 5542 | { |
| 5543 | struct qla_hw_data *ha = |
| 5544 | container_of(work, struct qla_hw_data, idc_aen); |
| 5545 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5546 | uint32_t dev_state, idc_control; |
| 5547 | |
| 5548 | qla83xx_idc_lock(base_vha, 0); |
| 5549 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5550 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 5551 | qla83xx_idc_unlock(base_vha, 0); |
| 5552 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 5553 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 5554 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 5555 | "Application requested NIC Core Reset.\n"); |
| 5556 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 5557 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 5558 | QLA_SUCCESS) { |
| 5559 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 5560 | "Other protocol driver requested NIC Core Reset.\n"); |
| 5561 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 5562 | } |
| 5563 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 5564 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 5565 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 5566 | } |
| 5567 | } |
| 5568 | |
| 5569 | static void |
| 5570 | qla83xx_wait_logic(void) |
| 5571 | { |
| 5572 | int i; |
| 5573 | |
| 5574 | /* Yield CPU */ |
| 5575 | if (!in_interrupt()) { |
| 5576 | /* |
| 5577 | * Wait about 200ms before retrying again. |
| 5578 | * This controls the number of retries for single |
| 5579 | * lock operation. |
| 5580 | */ |
| 5581 | msleep(100); |
| 5582 | schedule(); |
| 5583 | } else { |
| 5584 | for (i = 0; i < 20; i++) |
| 5585 | cpu_relax(); /* This a nop instr on i386 */ |
| 5586 | } |
| 5587 | } |
| 5588 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5589 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5590 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 5591 | { |
| 5592 | int rval; |
| 5593 | uint32_t data; |
| 5594 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 5595 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 5596 | struct qla_hw_data *ha = base_vha->hw; |
Bart Van Assche | bd432bb | 2019-04-11 14:53:17 -0700 | [diff] [blame] | 5597 | |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5598 | ql_dbg(ql_dbg_p3p, base_vha, 0xb086, |
| 5599 | "Trying force recovery of the IDC lock.\n"); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5600 | |
| 5601 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 5602 | if (rval) |
| 5603 | return rval; |
| 5604 | |
| 5605 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 5606 | return QLA_SUCCESS; |
| 5607 | } else { |
| 5608 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 5609 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 5610 | data); |
| 5611 | if (rval) |
| 5612 | return rval; |
| 5613 | |
| 5614 | msleep(200); |
| 5615 | |
| 5616 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 5617 | &data); |
| 5618 | if (rval) |
| 5619 | return rval; |
| 5620 | |
| 5621 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 5622 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 5623 | ~(idc_lck_rcvry_stage_mask)); |
| 5624 | rval = qla83xx_wr_reg(base_vha, |
| 5625 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 5626 | if (rval) |
| 5627 | return rval; |
| 5628 | |
| 5629 | /* Forcefully perform IDC UnLock */ |
| 5630 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 5631 | &data); |
| 5632 | if (rval) |
| 5633 | return rval; |
| 5634 | /* Clear lock-id by setting 0xff */ |
| 5635 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5636 | 0xff); |
| 5637 | if (rval) |
| 5638 | return rval; |
| 5639 | /* Clear lock-recovery by setting 0x0 */ |
| 5640 | rval = qla83xx_wr_reg(base_vha, |
| 5641 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 5642 | if (rval) |
| 5643 | return rval; |
| 5644 | } else |
| 5645 | return QLA_SUCCESS; |
| 5646 | } |
| 5647 | |
| 5648 | return rval; |
| 5649 | } |
| 5650 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5651 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5652 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 5653 | { |
| 5654 | int rval = QLA_SUCCESS; |
| 5655 | uint32_t o_drv_lockid, n_drv_lockid; |
| 5656 | unsigned long lock_recovery_timeout; |
| 5657 | |
| 5658 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 5659 | retry_lockid: |
| 5660 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 5661 | if (rval) |
| 5662 | goto exit; |
| 5663 | |
| 5664 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 5665 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 5666 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 5667 | return QLA_SUCCESS; |
| 5668 | else |
| 5669 | return QLA_FUNCTION_FAILED; |
| 5670 | } |
| 5671 | |
| 5672 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 5673 | if (rval) |
| 5674 | goto exit; |
| 5675 | |
| 5676 | if (o_drv_lockid == n_drv_lockid) { |
| 5677 | qla83xx_wait_logic(); |
| 5678 | goto retry_lockid; |
| 5679 | } else |
| 5680 | return QLA_SUCCESS; |
| 5681 | |
| 5682 | exit: |
| 5683 | return rval; |
| 5684 | } |
| 5685 | |
| 5686 | void |
| 5687 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 5688 | { |
| 5689 | uint16_t options = (requester_id << 15) | BIT_6; |
| 5690 | uint32_t data; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5691 | uint32_t lock_owner; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5692 | struct qla_hw_data *ha = base_vha->hw; |
| 5693 | |
| 5694 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 5695 | retry_lock: |
| 5696 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 5697 | == QLA_SUCCESS) { |
| 5698 | if (data) { |
| 5699 | /* Setting lock-id to our function-number */ |
| 5700 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5701 | ha->portnum); |
| 5702 | } else { |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5703 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5704 | &lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5705 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5706 | "Failed to acquire IDC lock, acquired by %d, " |
| 5707 | "retrying...\n", lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5708 | |
| 5709 | /* Retry/Perform IDC-Lock recovery */ |
| 5710 | if (qla83xx_idc_lock_recovery(base_vha) |
| 5711 | == QLA_SUCCESS) { |
| 5712 | qla83xx_wait_logic(); |
| 5713 | goto retry_lock; |
| 5714 | } else |
| 5715 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 5716 | "IDC Lock recovery FAILED.\n"); |
| 5717 | } |
| 5718 | |
| 5719 | } |
| 5720 | |
| 5721 | return; |
| 5722 | |
| 5723 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 5724 | retry_lock2: |
| 5725 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 5726 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 5727 | "Failed to acquire IDC lock. retrying...\n"); |
| 5728 | /* Retry/Perform IDC-Lock recovery */ |
| 5729 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 5730 | qla83xx_wait_logic(); |
| 5731 | goto retry_lock2; |
| 5732 | } else |
| 5733 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 5734 | "IDC Lock recovery FAILED.\n"); |
| 5735 | } |
| 5736 | |
| 5737 | return; |
| 5738 | } |
| 5739 | |
| 5740 | void |
| 5741 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 5742 | { |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5743 | #if 0 |
| 5744 | uint16_t options = (requester_id << 15) | BIT_7; |
| 5745 | #endif |
| 5746 | uint16_t retry; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5747 | uint32_t data; |
| 5748 | struct qla_hw_data *ha = base_vha->hw; |
| 5749 | |
| 5750 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 5751 | * remote registers |
| 5752 | */ |
| 5753 | retry = 0; |
| 5754 | retry_unlock: |
| 5755 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 5756 | == QLA_SUCCESS) { |
| 5757 | if (data == ha->portnum) { |
| 5758 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 5759 | /* Clearing lock-id by setting 0xff */ |
| 5760 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 5761 | } else if (retry < 10) { |
| 5762 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 5763 | |
| 5764 | /* Retry for IDC-unlock */ |
| 5765 | qla83xx_wait_logic(); |
| 5766 | retry++; |
| 5767 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5768 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5769 | goto retry_unlock; |
| 5770 | } |
| 5771 | } else if (retry < 10) { |
| 5772 | /* Retry for IDC-unlock */ |
| 5773 | qla83xx_wait_logic(); |
| 5774 | retry++; |
| 5775 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5776 | "Failed to read drv-lockid, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5777 | goto retry_unlock; |
| 5778 | } |
| 5779 | |
| 5780 | return; |
| 5781 | |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5782 | #if 0 |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5783 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 5784 | retry = 0; |
| 5785 | retry_unlock2: |
| 5786 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 5787 | if (retry < 10) { |
| 5788 | /* Retry for IDC-unlock */ |
| 5789 | qla83xx_wait_logic(); |
| 5790 | retry++; |
| 5791 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5792 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5793 | goto retry_unlock2; |
| 5794 | } |
| 5795 | } |
| 5796 | |
| 5797 | return; |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5798 | #endif |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5799 | } |
| 5800 | |
| 5801 | int |
| 5802 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 5803 | { |
| 5804 | int rval = QLA_SUCCESS; |
| 5805 | struct qla_hw_data *ha = vha->hw; |
| 5806 | uint32_t drv_presence; |
| 5807 | |
| 5808 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 5809 | if (rval == QLA_SUCCESS) { |
| 5810 | drv_presence |= (1 << ha->portnum); |
| 5811 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5812 | drv_presence); |
| 5813 | } |
| 5814 | |
| 5815 | return rval; |
| 5816 | } |
| 5817 | |
| 5818 | int |
| 5819 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 5820 | { |
| 5821 | int rval = QLA_SUCCESS; |
| 5822 | |
| 5823 | qla83xx_idc_lock(vha, 0); |
| 5824 | rval = __qla83xx_set_drv_presence(vha); |
| 5825 | qla83xx_idc_unlock(vha, 0); |
| 5826 | |
| 5827 | return rval; |
| 5828 | } |
| 5829 | |
| 5830 | int |
| 5831 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 5832 | { |
| 5833 | int rval = QLA_SUCCESS; |
| 5834 | struct qla_hw_data *ha = vha->hw; |
| 5835 | uint32_t drv_presence; |
| 5836 | |
| 5837 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 5838 | if (rval == QLA_SUCCESS) { |
| 5839 | drv_presence &= ~(1 << ha->portnum); |
| 5840 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5841 | drv_presence); |
| 5842 | } |
| 5843 | |
| 5844 | return rval; |
| 5845 | } |
| 5846 | |
| 5847 | int |
| 5848 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 5849 | { |
| 5850 | int rval = QLA_SUCCESS; |
| 5851 | |
| 5852 | qla83xx_idc_lock(vha, 0); |
| 5853 | rval = __qla83xx_clear_drv_presence(vha); |
| 5854 | qla83xx_idc_unlock(vha, 0); |
| 5855 | |
| 5856 | return rval; |
| 5857 | } |
| 5858 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5859 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5860 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 5861 | { |
| 5862 | struct qla_hw_data *ha = vha->hw; |
| 5863 | uint32_t drv_ack, drv_presence; |
| 5864 | unsigned long ack_timeout; |
| 5865 | |
| 5866 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 5867 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 5868 | while (1) { |
| 5869 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 5870 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 5871 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5872 | break; |
| 5873 | |
| 5874 | if (time_after_eq(jiffies, ack_timeout)) { |
| 5875 | ql_log(ql_log_warn, vha, 0xb067, |
| 5876 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 5877 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 5878 | /* |
| 5879 | * The function(s) which did not ack in time are forced |
| 5880 | * to withdraw any further participation in the IDC |
| 5881 | * reset. |
| 5882 | */ |
| 5883 | if (drv_ack != drv_presence) |
| 5884 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5885 | drv_ack); |
| 5886 | break; |
| 5887 | } |
| 5888 | |
| 5889 | qla83xx_idc_unlock(vha, 0); |
| 5890 | msleep(1000); |
| 5891 | qla83xx_idc_lock(vha, 0); |
| 5892 | } |
| 5893 | |
| 5894 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 5895 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 5896 | } |
| 5897 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5898 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5899 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 5900 | { |
| 5901 | int rval = QLA_SUCCESS; |
| 5902 | uint32_t idc_control; |
| 5903 | |
| 5904 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 5905 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 5906 | |
| 5907 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 5908 | __qla83xx_get_idc_control(vha, &idc_control); |
| 5909 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 5910 | __qla83xx_set_idc_control(vha, 0); |
| 5911 | |
| 5912 | qla83xx_idc_unlock(vha, 0); |
| 5913 | rval = qla83xx_restart_nic_firmware(vha); |
| 5914 | qla83xx_idc_lock(vha, 0); |
| 5915 | |
| 5916 | if (rval != QLA_SUCCESS) { |
| 5917 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 5918 | "Failed to restart NIC f/w.\n"); |
| 5919 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 5920 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 5921 | } else { |
| 5922 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 5923 | "Success in restarting nic f/w.\n"); |
| 5924 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 5925 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 5926 | } |
| 5927 | |
| 5928 | return rval; |
| 5929 | } |
| 5930 | |
| 5931 | /* Assumes idc_lock always held on entry */ |
| 5932 | int |
| 5933 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 5934 | { |
| 5935 | struct qla_hw_data *ha = base_vha->hw; |
| 5936 | int rval = QLA_SUCCESS; |
| 5937 | unsigned long dev_init_timeout; |
| 5938 | uint32_t dev_state; |
| 5939 | |
| 5940 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 5941 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 5942 | |
| 5943 | while (1) { |
| 5944 | |
| 5945 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 5946 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 5947 | "Initialization TIMEOUT!\n"); |
| 5948 | /* Init timeout. Disable further NIC Core |
| 5949 | * communication. |
| 5950 | */ |
| 5951 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5952 | QLA8XXX_DEV_FAILED); |
| 5953 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 5954 | "HW State: FAILED.\n"); |
| 5955 | } |
| 5956 | |
| 5957 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5958 | switch (dev_state) { |
| 5959 | case QLA8XXX_DEV_READY: |
| 5960 | if (ha->flags.nic_core_reset_owner) |
| 5961 | qla83xx_idc_audit(base_vha, |
| 5962 | IDC_AUDIT_COMPLETION); |
| 5963 | ha->flags.nic_core_reset_owner = 0; |
| 5964 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 5965 | "Reset_owner reset by 0x%x.\n", |
| 5966 | ha->portnum); |
| 5967 | goto exit; |
| 5968 | case QLA8XXX_DEV_COLD: |
| 5969 | if (ha->flags.nic_core_reset_owner) |
| 5970 | rval = qla83xx_device_bootstrap(base_vha); |
| 5971 | else { |
| 5972 | /* Wait for AEN to change device-state */ |
| 5973 | qla83xx_idc_unlock(base_vha, 0); |
| 5974 | msleep(1000); |
| 5975 | qla83xx_idc_lock(base_vha, 0); |
| 5976 | } |
| 5977 | break; |
| 5978 | case QLA8XXX_DEV_INITIALIZING: |
| 5979 | /* Wait for AEN to change device-state */ |
| 5980 | qla83xx_idc_unlock(base_vha, 0); |
| 5981 | msleep(1000); |
| 5982 | qla83xx_idc_lock(base_vha, 0); |
| 5983 | break; |
| 5984 | case QLA8XXX_DEV_NEED_RESET: |
| 5985 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 5986 | qla83xx_need_reset_handler(base_vha); |
| 5987 | else { |
| 5988 | /* Wait for AEN to change device-state */ |
| 5989 | qla83xx_idc_unlock(base_vha, 0); |
| 5990 | msleep(1000); |
| 5991 | qla83xx_idc_lock(base_vha, 0); |
| 5992 | } |
| 5993 | /* reset timeout value after need reset handler */ |
| 5994 | dev_init_timeout = jiffies + |
| 5995 | (ha->fcoe_dev_init_timeout * HZ); |
| 5996 | break; |
| 5997 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 5998 | /* XXX: DEBUG for now */ |
| 5999 | qla83xx_idc_unlock(base_vha, 0); |
| 6000 | msleep(1000); |
| 6001 | qla83xx_idc_lock(base_vha, 0); |
| 6002 | break; |
| 6003 | case QLA8XXX_DEV_QUIESCENT: |
| 6004 | /* XXX: DEBUG for now */ |
| 6005 | if (ha->flags.quiesce_owner) |
| 6006 | goto exit; |
| 6007 | |
| 6008 | qla83xx_idc_unlock(base_vha, 0); |
| 6009 | msleep(1000); |
| 6010 | qla83xx_idc_lock(base_vha, 0); |
| 6011 | dev_init_timeout = jiffies + |
| 6012 | (ha->fcoe_dev_init_timeout * HZ); |
| 6013 | break; |
| 6014 | case QLA8XXX_DEV_FAILED: |
| 6015 | if (ha->flags.nic_core_reset_owner) |
| 6016 | qla83xx_idc_audit(base_vha, |
| 6017 | IDC_AUDIT_COMPLETION); |
| 6018 | ha->flags.nic_core_reset_owner = 0; |
| 6019 | __qla83xx_clear_drv_presence(base_vha); |
| 6020 | qla83xx_idc_unlock(base_vha, 0); |
| 6021 | qla8xxx_dev_failed_handler(base_vha); |
| 6022 | rval = QLA_FUNCTION_FAILED; |
| 6023 | qla83xx_idc_lock(base_vha, 0); |
| 6024 | goto exit; |
| 6025 | case QLA8XXX_BAD_VALUE: |
| 6026 | qla83xx_idc_unlock(base_vha, 0); |
| 6027 | msleep(1000); |
| 6028 | qla83xx_idc_lock(base_vha, 0); |
| 6029 | break; |
| 6030 | default: |
| 6031 | ql_log(ql_log_warn, base_vha, 0xb071, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 6032 | "Unknown Device State: %x.\n", dev_state); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6033 | qla83xx_idc_unlock(base_vha, 0); |
| 6034 | qla8xxx_dev_failed_handler(base_vha); |
| 6035 | rval = QLA_FUNCTION_FAILED; |
| 6036 | qla83xx_idc_lock(base_vha, 0); |
| 6037 | goto exit; |
| 6038 | } |
| 6039 | } |
| 6040 | |
| 6041 | exit: |
| 6042 | return rval; |
| 6043 | } |
| 6044 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6045 | void |
| 6046 | qla2x00_disable_board_on_pci_error(struct work_struct *work) |
| 6047 | { |
| 6048 | struct qla_hw_data *ha = container_of(work, struct qla_hw_data, |
| 6049 | board_disable); |
| 6050 | struct pci_dev *pdev = ha->pdev; |
| 6051 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 6052 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 6053 | /* |
| 6054 | * if UNLOAD flag is already set, then continue unload, |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 6055 | * where it was set first. |
| 6056 | */ |
| 6057 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 6058 | return; |
| 6059 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6060 | ql_log(ql_log_warn, base_vha, 0x015b, |
| 6061 | "Disabling adapter.\n"); |
| 6062 | |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 6063 | if (!atomic_read(&pdev->enable_cnt)) { |
| 6064 | ql_log(ql_log_info, base_vha, 0xfffc, |
| 6065 | "PCI device disabled, no action req for PCI error=%lx\n", |
| 6066 | base_vha->pci_flags); |
| 6067 | return; |
| 6068 | } |
| 6069 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 6070 | qla2x00_wait_for_sess_deletion(base_vha); |
| 6071 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6072 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 6073 | |
| 6074 | qla2x00_delete_all_vps(ha, base_vha); |
| 6075 | |
| 6076 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 6077 | |
| 6078 | qla2x00_dfs_remove(base_vha); |
| 6079 | |
| 6080 | qla84xx_put_chip(base_vha); |
| 6081 | |
| 6082 | if (base_vha->timer_active) |
| 6083 | qla2x00_stop_timer(base_vha); |
| 6084 | |
| 6085 | base_vha->flags.online = 0; |
| 6086 | |
| 6087 | qla2x00_destroy_deferred_work(ha); |
| 6088 | |
| 6089 | /* |
| 6090 | * Do not try to stop beacon blink as it will issue a mailbox |
| 6091 | * command. |
| 6092 | */ |
| 6093 | qla2x00_free_sysfs_attr(base_vha, false); |
| 6094 | |
| 6095 | fc_remove_host(base_vha->host); |
| 6096 | |
| 6097 | scsi_remove_host(base_vha->host); |
| 6098 | |
| 6099 | base_vha->flags.init_done = 0; |
| 6100 | qla25xx_delete_queues(base_vha); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6101 | qla2x00_free_fcports(base_vha); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 6102 | qla2x00_free_irqs(base_vha); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6103 | qla2x00_mem_free(ha); |
| 6104 | qla82xx_md_free(base_vha); |
| 6105 | qla2x00_free_queues(ha); |
| 6106 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6107 | qla2x00_unmap_iobases(ha); |
| 6108 | |
| 6109 | pci_release_selected_regions(ha->pdev, ha->bars); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6110 | pci_disable_pcie_error_reporting(pdev); |
| 6111 | pci_disable_device(pdev); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6112 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 6113 | /* |
| 6114 | * Let qla2x00_remove_one cleanup qla_hw_data on device removal. |
| 6115 | */ |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6116 | } |
| 6117 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6118 | /************************************************************************** |
| 6119 | * qla2x00_do_dpc |
| 6120 | * This kernel thread is a task that is schedule by the interrupt handler |
| 6121 | * to perform the background processing for interrupts. |
| 6122 | * |
| 6123 | * Notes: |
| 6124 | * This task always run in the context of a kernel thread. It |
| 6125 | * is kick-off by the driver's detect code and starts up |
| 6126 | * up one per adapter. It immediately goes to sleep and waits for |
| 6127 | * some fibre event. When either the interrupt handler or |
| 6128 | * the timer routine detects a event it will one of the task |
| 6129 | * bits then wake us up. |
| 6130 | **************************************************************************/ |
| 6131 | static int |
| 6132 | qla2x00_do_dpc(void *data) |
| 6133 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6134 | scsi_qla_host_t *base_vha; |
| 6135 | struct qla_hw_data *ha; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6136 | uint32_t online; |
| 6137 | struct qla_qpair *qpair; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 6138 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6139 | ha = (struct qla_hw_data *)data; |
| 6140 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6141 | |
Dongsheng Yang | 8698a74 | 2014-03-11 18:09:12 +0800 | [diff] [blame] | 6142 | set_user_nice(current, MIN_NICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6143 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 6144 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 6145 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6146 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 6147 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6148 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 6149 | schedule(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6150 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 6151 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 6152 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6153 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6154 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6155 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 6156 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 6157 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6158 | } |
| 6159 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6160 | ha->dpc_active = 1; |
| 6161 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 6162 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 6163 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 6164 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6165 | |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 6166 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 6167 | break; |
| 6168 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6169 | if (IS_P3P_TYPE(ha)) { |
| 6170 | if (IS_QLA8044(ha)) { |
| 6171 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 6172 | &base_vha->dpc_flags)) { |
| 6173 | qla8044_idc_lock(ha); |
| 6174 | qla8044_wr_direct(base_vha, |
| 6175 | QLA8044_CRB_DEV_STATE_INDEX, |
| 6176 | QLA8XXX_DEV_FAILED); |
| 6177 | qla8044_idc_unlock(ha); |
| 6178 | ql_log(ql_log_info, base_vha, 0x4004, |
| 6179 | "HW State: FAILED.\n"); |
| 6180 | qla8044_device_state_handler(base_vha); |
| 6181 | continue; |
| 6182 | } |
| 6183 | |
| 6184 | } else { |
| 6185 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 6186 | &base_vha->dpc_flags)) { |
| 6187 | qla82xx_idc_lock(ha); |
| 6188 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
| 6189 | QLA8XXX_DEV_FAILED); |
| 6190 | qla82xx_idc_unlock(ha); |
| 6191 | ql_log(ql_log_info, base_vha, 0x0151, |
| 6192 | "HW State: FAILED.\n"); |
| 6193 | qla82xx_device_state_handler(base_vha); |
| 6194 | continue; |
| 6195 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6196 | } |
| 6197 | |
| 6198 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 6199 | &base_vha->dpc_flags)) { |
| 6200 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6201 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 6202 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6203 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 6204 | &base_vha->dpc_flags))) { |
| 6205 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 6206 | /* FCoE-ctx reset failed. |
| 6207 | * Escalate to chip-reset |
| 6208 | */ |
| 6209 | set_bit(ISP_ABORT_NEEDED, |
| 6210 | &base_vha->dpc_flags); |
| 6211 | } |
| 6212 | clear_bit(ABORT_ISP_ACTIVE, |
| 6213 | &base_vha->dpc_flags); |
| 6214 | } |
| 6215 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6216 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 6217 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6218 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6219 | } else if (IS_QLAFX00(ha)) { |
| 6220 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 6221 | &base_vha->dpc_flags)) { |
| 6222 | ql_dbg(ql_dbg_dpc, base_vha, 0x4020, |
| 6223 | "Firmware Reset Recovery\n"); |
| 6224 | if (qlafx00_reset_initialize(base_vha)) { |
| 6225 | /* Failed. Abort isp later. */ |
| 6226 | if (!test_bit(UNLOADING, |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 6227 | &base_vha->dpc_flags)) { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6228 | set_bit(ISP_UNRECOVERABLE, |
| 6229 | &base_vha->dpc_flags); |
| 6230 | ql_dbg(ql_dbg_dpc, base_vha, |
| 6231 | 0x4021, |
| 6232 | "Reset Recovery Failed\n"); |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 6233 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6234 | } |
| 6235 | } |
| 6236 | |
| 6237 | if (test_and_clear_bit(FX00_TARGET_SCAN, |
| 6238 | &base_vha->dpc_flags)) { |
| 6239 | ql_dbg(ql_dbg_dpc, base_vha, 0x4022, |
| 6240 | "ISPFx00 Target Scan scheduled\n"); |
| 6241 | if (qlafx00_rescan_isp(base_vha)) { |
| 6242 | if (!test_bit(UNLOADING, |
| 6243 | &base_vha->dpc_flags)) |
| 6244 | set_bit(ISP_UNRECOVERABLE, |
| 6245 | &base_vha->dpc_flags); |
| 6246 | ql_dbg(ql_dbg_dpc, base_vha, 0x401e, |
| 6247 | "ISPFx00 Target Scan Failed\n"); |
| 6248 | } |
| 6249 | ql_dbg(ql_dbg_dpc, base_vha, 0x401f, |
| 6250 | "ISPFx00 Target Scan End\n"); |
| 6251 | } |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 6252 | if (test_and_clear_bit(FX00_HOST_INFO_RESEND, |
| 6253 | &base_vha->dpc_flags)) { |
| 6254 | ql_dbg(ql_dbg_dpc, base_vha, 0x4023, |
| 6255 | "ISPFx00 Host Info resend scheduled\n"); |
| 6256 | qlafx00_fx_disc(base_vha, |
| 6257 | &base_vha->hw->mr.fcport, |
| 6258 | FXDISC_REG_HOST_INFO); |
| 6259 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6260 | } |
| 6261 | |
Quinn Tran | e4e3a2c | 2017-08-23 15:05:07 -0700 | [diff] [blame] | 6262 | if (test_and_clear_bit(DETECT_SFP_CHANGE, |
| 6263 | &base_vha->dpc_flags) && |
| 6264 | !test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) { |
| 6265 | qla24xx_detect_sfp(base_vha); |
| 6266 | |
| 6267 | if (ha->flags.detected_lr_sfp != |
| 6268 | ha->flags.using_lr_setting) |
| 6269 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 6270 | } |
| 6271 | |
Quinn Tran | b08abbd | 2018-07-18 14:29:54 -0700 | [diff] [blame] | 6272 | if (test_and_clear_bit |
| 6273 | (ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 6274 | !test_bit(UNLOADING, &base_vha->dpc_flags)) { |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame] | 6275 | bool do_reset = true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6276 | |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 6277 | switch (base_vha->qlini_mode) { |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame] | 6278 | case QLA2XXX_INI_MODE_ENABLED: |
| 6279 | break; |
| 6280 | case QLA2XXX_INI_MODE_DISABLED: |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 6281 | if (!qla_tgt_mode_enabled(base_vha) && |
| 6282 | !ha->flags.fw_started) |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame] | 6283 | do_reset = false; |
| 6284 | break; |
| 6285 | case QLA2XXX_INI_MODE_DUAL: |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 6286 | if (!qla_dual_mode_enabled(base_vha) && |
| 6287 | !ha->flags.fw_started) |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame] | 6288 | do_reset = false; |
| 6289 | break; |
| 6290 | default: |
| 6291 | break; |
| 6292 | } |
| 6293 | |
| 6294 | if (do_reset && !(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6295 | &base_vha->dpc_flags))) { |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame] | 6296 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 6297 | "ISP abort scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6298 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6299 | /* failed. retry later */ |
| 6300 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6301 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6302 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6303 | clear_bit(ABORT_ISP_ACTIVE, |
| 6304 | &base_vha->dpc_flags); |
Quinn Tran | 93eca61 | 2018-08-31 11:24:37 -0700 | [diff] [blame] | 6305 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 6306 | "ISP abort end.\n"); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 6307 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6308 | } |
| 6309 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 6310 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 6311 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6312 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 6313 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 6314 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6315 | if (IS_QLAFX00(ha)) |
| 6316 | goto loop_resync_check; |
| 6317 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6318 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6319 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 6320 | "Quiescence mode scheduled.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6321 | if (IS_P3P_TYPE(ha)) { |
| 6322 | if (IS_QLA82XX(ha)) |
| 6323 | qla82xx_device_state_handler(base_vha); |
| 6324 | if (IS_QLA8044(ha)) |
| 6325 | qla8044_device_state_handler(base_vha); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 6326 | clear_bit(ISP_QUIESCE_NEEDED, |
| 6327 | &base_vha->dpc_flags); |
| 6328 | if (!ha->flags.quiesce_owner) { |
| 6329 | qla2x00_perform_loop_resync(base_vha); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6330 | if (IS_QLA82XX(ha)) { |
| 6331 | qla82xx_idc_lock(ha); |
| 6332 | qla82xx_clear_qsnt_ready( |
| 6333 | base_vha); |
| 6334 | qla82xx_idc_unlock(ha); |
| 6335 | } else if (IS_QLA8044(ha)) { |
| 6336 | qla8044_idc_lock(ha); |
| 6337 | qla8044_clear_qsnt_ready( |
| 6338 | base_vha); |
| 6339 | qla8044_idc_unlock(ha); |
| 6340 | } |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 6341 | } |
| 6342 | } else { |
| 6343 | clear_bit(ISP_QUIESCE_NEEDED, |
| 6344 | &base_vha->dpc_flags); |
| 6345 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6346 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6347 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 6348 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6349 | } |
| 6350 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6351 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6352 | &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6353 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6354 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6355 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 6356 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6357 | qla2x00_rst_aen(base_vha); |
| 6358 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6359 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 6360 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6361 | } |
| 6362 | |
| 6363 | /* Retry each device up to login retry count */ |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 6364 | if (test_bit(RELOGIN_NEEDED, &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6365 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 6366 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6367 | |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 6368 | if (!base_vha->relogin_jif || |
| 6369 | time_after_eq(jiffies, base_vha->relogin_jif)) { |
| 6370 | base_vha->relogin_jif = jiffies + HZ; |
| 6371 | clear_bit(RELOGIN_NEEDED, &base_vha->dpc_flags); |
| 6372 | |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 6373 | ql_dbg(ql_dbg_disc, base_vha, 0x400d, |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 6374 | "Relogin scheduled.\n"); |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 6375 | qla24xx_post_relogin_work(base_vha); |
Quinn Tran | 4005a99 | 2017-12-04 14:45:06 -0800 | [diff] [blame] | 6376 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6377 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6378 | loop_resync_check: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6379 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6380 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6381 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6382 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 6383 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6384 | |
| 6385 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6386 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6387 | |
Bart Van Assche | 52c8282 | 2015-07-09 07:23:26 -0700 | [diff] [blame] | 6388 | qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6389 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6390 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 6391 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6392 | } |
| 6393 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6394 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 6395 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6396 | } |
| 6397 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6398 | if (IS_QLAFX00(ha)) |
| 6399 | goto intr_on_check; |
| 6400 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6401 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 6402 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 6403 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 6404 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 6405 | } |
| 6406 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6407 | intr_on_check: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6408 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 6409 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6410 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6411 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
Himanshu Madani | 90b604f | 2014-04-11 16:54:40 -0400 | [diff] [blame] | 6412 | &base_vha->dpc_flags)) { |
| 6413 | if (ha->beacon_blink_led == 1) |
| 6414 | ha->isp_ops->beacon_blink(base_vha); |
| 6415 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 6416 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6417 | /* qpair online check */ |
| 6418 | if (test_and_clear_bit(QPAIR_ONLINE_CHECK_NEEDED, |
| 6419 | &base_vha->dpc_flags)) { |
| 6420 | if (ha->flags.eeh_busy || |
| 6421 | ha->flags.pci_channel_io_perm_failure) |
| 6422 | online = 0; |
| 6423 | else |
| 6424 | online = 1; |
| 6425 | |
| 6426 | mutex_lock(&ha->mq_lock); |
| 6427 | list_for_each_entry(qpair, &base_vha->qp_list, |
| 6428 | qp_list_elem) |
| 6429 | qpair->online = online; |
| 6430 | mutex_unlock(&ha->mq_lock); |
| 6431 | } |
| 6432 | |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6433 | if (test_and_clear_bit(SET_NVME_ZIO_THRESHOLD_NEEDED, |
| 6434 | &base_vha->dpc_flags)) { |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6435 | ql_log(ql_log_info, base_vha, 0xffffff, |
| 6436 | "nvme: SET ZIO Activity exchange threshold to %d.\n", |
| 6437 | ha->nvme_last_rptd_aen); |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6438 | if (qla27xx_set_zio_threshold(base_vha, |
| 6439 | ha->nvme_last_rptd_aen)) { |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6440 | ql_log(ql_log_info, base_vha, 0xffffff, |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6441 | "nvme: Unable to SET ZIO Activity exchange threshold to %d.\n", |
| 6442 | ha->nvme_last_rptd_aen); |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6443 | } |
| 6444 | } |
| 6445 | |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6446 | if (test_and_clear_bit(SET_ZIO_THRESHOLD_NEEDED, |
| 6447 | &base_vha->dpc_flags)) { |
| 6448 | ql_log(ql_log_info, base_vha, 0xffffff, |
| 6449 | "SET ZIO Activity exchange threshold to %d.\n", |
| 6450 | ha->last_zio_threshold); |
| 6451 | qla27xx_set_zio_threshold(base_vha, |
| 6452 | ha->last_zio_threshold); |
| 6453 | } |
| 6454 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6455 | if (!IS_QLAFX00(ha)) |
| 6456 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6457 | |
Quinn Tran | 48acad0 | 2018-08-02 13:16:44 -0700 | [diff] [blame] | 6458 | if (test_and_clear_bit(N2N_LINK_RESET, |
| 6459 | &base_vha->dpc_flags)) { |
| 6460 | qla2x00_lip_reset(base_vha); |
| 6461 | } |
| 6462 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6463 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 6464 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 6465 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6466 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 6467 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6468 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6469 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 6470 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6471 | |
| 6472 | /* |
| 6473 | * Make sure that nobody tries to wake us up again. |
| 6474 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6475 | ha->dpc_active = 0; |
| 6476 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 6477 | /* Cleanup any residual CTX SRBs. */ |
| 6478 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 6479 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 6480 | return 0; |
| 6481 | } |
| 6482 | |
| 6483 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6484 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 6485 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6486 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 6487 | struct task_struct *t = ha->dpc_thread; |
| 6488 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6489 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 6490 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6491 | } |
| 6492 | |
| 6493 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6494 | * qla2x00_rst_aen |
| 6495 | * Processes asynchronous reset. |
| 6496 | * |
| 6497 | * Input: |
| 6498 | * ha = adapter block pointer. |
| 6499 | */ |
| 6500 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6501 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6502 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6503 | if (vha->flags.online && !vha->flags.reset_active && |
| 6504 | !atomic_read(&vha->loop_down_timer) && |
| 6505 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6506 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6507 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6508 | |
| 6509 | /* |
| 6510 | * Issue marker command only when we are going to start |
| 6511 | * the I/O. |
| 6512 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6513 | vha->marker_needed = 1; |
| 6514 | } while (!atomic_read(&vha->loop_down_timer) && |
| 6515 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6516 | } |
| 6517 | } |
| 6518 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6519 | /************************************************************************** |
| 6520 | * qla2x00_timer |
| 6521 | * |
| 6522 | * Description: |
| 6523 | * One second timer |
| 6524 | * |
| 6525 | * Context: Interrupt |
| 6526 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6527 | void |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 6528 | qla2x00_timer(struct timer_list *t) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6529 | { |
Kees Cook | 8e5f4ba | 2017-09-03 13:23:32 -0700 | [diff] [blame] | 6530 | scsi_qla_host_t *vha = from_timer(vha, t, timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6531 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6532 | int start_dpc = 0; |
| 6533 | int index; |
| 6534 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6535 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6536 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 6537 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6538 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6539 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6540 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 6541 | "EEH = %d, restarting timer.\n", |
| 6542 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6543 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 6544 | return; |
| 6545 | } |
| 6546 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6547 | /* |
| 6548 | * Hardware read to raise pending EEH errors during mailbox waits. If |
| 6549 | * the read returns -1 then disable the board. |
| 6550 | */ |
| 6551 | if (!pci_channel_offline(ha->pdev)) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6552 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Joe Lawrence | c821e0d | 2014-08-26 17:11:41 -0400 | [diff] [blame] | 6553 | qla2x00_check_reg16_for_disconnect(vha, w); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 6554 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6555 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 6556 | /* Make sure qla82xx_watchdog is run only for physical port */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6557 | if (!vha->vp_idx && IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6558 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 6559 | start_dpc++; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6560 | if (IS_QLA82XX(ha)) |
| 6561 | qla82xx_watchdog(vha); |
| 6562 | else if (IS_QLA8044(ha)) |
| 6563 | qla8044_watchdog(vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 6564 | } |
| 6565 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6566 | if (!vha->vp_idx && IS_QLAFX00(ha)) |
| 6567 | qlafx00_timer_routine(vha); |
| 6568 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6569 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6570 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 6571 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 6572 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6573 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6574 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6575 | if (atomic_read(&vha->loop_down_timer) == |
| 6576 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6577 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6578 | ql_log(ql_log_info, vha, 0x6008, |
| 6579 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6580 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6581 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 6582 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6583 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 6584 | /* |
| 6585 | * Schedule an ISP abort to return any FCP2-device |
| 6586 | * commands. |
| 6587 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6588 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6589 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6590 | spin_lock_irqsave(&ha->hardware_lock, |
| 6591 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 6592 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6593 | for (index = 1; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 6594 | index < req->num_outstanding_cmds; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6595 | index++) { |
| 6596 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 6597 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6598 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6599 | if (!sp) |
| 6600 | continue; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 6601 | if (sp->cmd_type != TYPE_SRB) |
| 6602 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 6603 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 6604 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6605 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 6606 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6607 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6608 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 6609 | if (IS_QLA82XX(ha)) |
| 6610 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 6611 | &vha->dpc_flags); |
| 6612 | else |
| 6613 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6614 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6615 | break; |
| 6616 | } |
| 6617 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6618 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6619 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6620 | start_dpc++; |
| 6621 | } |
| 6622 | |
| 6623 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6624 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 6625 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6626 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6627 | "Loop down - aborting ISP.\n"); |
| 6628 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 6629 | if (IS_QLA82XX(ha)) |
| 6630 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 6631 | &vha->dpc_flags); |
| 6632 | else |
| 6633 | set_bit(ISP_ABORT_NEEDED, |
| 6634 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6635 | } |
| 6636 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6637 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 6638 | "Loop down - seconds remaining %d.\n", |
| 6639 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6640 | } |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 6641 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 6642 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 6643 | /* There is no beacon_blink function for ISP82xx */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6644 | if (!IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 6645 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 6646 | start_dpc++; |
| 6647 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 6648 | } |
| 6649 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 6650 | /* Process any deferred work. */ |
Quinn Tran | 9b3e0f4 | 2017-12-28 12:33:16 -0800 | [diff] [blame] | 6651 | if (!list_empty(&vha->work_list)) { |
| 6652 | unsigned long flags; |
| 6653 | bool q = false; |
| 6654 | |
| 6655 | spin_lock_irqsave(&vha->work_lock, flags); |
| 6656 | if (!test_and_set_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags)) |
| 6657 | q = true; |
| 6658 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 6659 | if (q) |
| 6660 | queue_work(vha->hw->wq, &vha->iocb_work); |
| 6661 | } |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 6662 | |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 6663 | /* |
| 6664 | * FC-NVME |
| 6665 | * see if the active AEN count has changed from what was last reported. |
| 6666 | */ |
Giridhar Malavali | b2d1453a | 2019-04-02 14:24:32 -0700 | [diff] [blame] | 6667 | if (!vha->vp_idx && |
| 6668 | (atomic_read(&ha->nvme_active_aen_cnt) != ha->nvme_last_rptd_aen) && |
| 6669 | ha->zio_mode == QLA_ZIO_MODE_6 && |
| 6670 | !ha->flags.host_shutting_down) { |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 6671 | ql_log(ql_log_info, vha, 0x3002, |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6672 | "nvme: Sched: Set ZIO exchange threshold to %d.\n", |
| 6673 | ha->nvme_last_rptd_aen); |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6674 | ha->nvme_last_rptd_aen = atomic_read(&ha->nvme_active_aen_cnt); |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6675 | set_bit(SET_NVME_ZIO_THRESHOLD_NEEDED, &vha->dpc_flags); |
| 6676 | start_dpc++; |
| 6677 | } |
| 6678 | |
| 6679 | if (!vha->vp_idx && |
| 6680 | (atomic_read(&ha->zio_threshold) != ha->last_zio_threshold) && |
| 6681 | (ha->zio_mode == QLA_ZIO_MODE_6) && |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 6682 | (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))) { |
Quinn Tran | 8b4673b | 2018-09-04 14:19:14 -0700 | [diff] [blame] | 6683 | ql_log(ql_log_info, vha, 0x3002, |
| 6684 | "Sched: Set ZIO exchange threshold to %d.\n", |
| 6685 | ha->last_zio_threshold); |
| 6686 | ha->last_zio_threshold = atomic_read(&ha->zio_threshold); |
Duane Grigsby | deeae7a | 2017-07-21 09:32:25 -0700 | [diff] [blame] | 6687 | set_bit(SET_ZIO_THRESHOLD_NEEDED, &vha->dpc_flags); |
| 6688 | start_dpc++; |
Duane Grigsby | 7401bc1 | 2017-06-21 13:48:42 -0700 | [diff] [blame] | 6689 | } |
| 6690 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6691 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6692 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 6693 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 6694 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6695 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6696 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 6697 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6698 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 6699 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6700 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 6701 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6702 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 6703 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 6704 | "fcport_update_needed=%d start_dpc=%d " |
| 6705 | "reset_marker_needed=%d", |
| 6706 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 6707 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 6708 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 6709 | start_dpc, |
| 6710 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 6711 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 6712 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 6713 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 6714 | "relogin_needed=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6715 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 6716 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 6717 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 6718 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 6719 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6720 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6721 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6722 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6723 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6724 | } |
| 6725 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6726 | /* Firmware interface routines. */ |
| 6727 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6728 | #define FW_ISP21XX 0 |
| 6729 | #define FW_ISP22XX 1 |
| 6730 | #define FW_ISP2300 2 |
| 6731 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6732 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6733 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6734 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6735 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6736 | #define FW_ISP2031 8 |
| 6737 | #define FW_ISP8031 9 |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6738 | #define FW_ISP27XX 10 |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 6739 | #define FW_ISP28XX 11 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6740 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6741 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 6742 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 6743 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 6744 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 6745 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6746 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6747 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6748 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6749 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 6750 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6751 | #define FW_FILE_ISP27XX "ql2700_fw.bin" |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 6752 | #define FW_FILE_ISP28XX "ql2800_fw.bin" |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6753 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6754 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6755 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6756 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 6757 | static struct fw_blob qla_fw_blobs[] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6758 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 6759 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 6760 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 6761 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 6762 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6763 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6764 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6765 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6766 | { .name = FW_FILE_ISP2031, }, |
| 6767 | { .name = FW_FILE_ISP8031, }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6768 | { .name = FW_FILE_ISP27XX, }, |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 6769 | { .name = FW_FILE_ISP28XX, }, |
| 6770 | { .name = NULL, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6771 | }; |
| 6772 | |
| 6773 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6774 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6775 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6776 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6777 | struct fw_blob *blob; |
| 6778 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6779 | if (IS_QLA2100(ha)) { |
| 6780 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 6781 | } else if (IS_QLA2200(ha)) { |
| 6782 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6783 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6784 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6785 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6786 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 6787 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6788 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6789 | } else if (IS_QLA25XX(ha)) { |
| 6790 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6791 | } else if (IS_QLA81XX(ha)) { |
| 6792 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6793 | } else if (IS_QLA82XX(ha)) { |
| 6794 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6795 | } else if (IS_QLA2031(ha)) { |
| 6796 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 6797 | } else if (IS_QLA8031(ha)) { |
| 6798 | blob = &qla_fw_blobs[FW_ISP8031]; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6799 | } else if (IS_QLA27XX(ha)) { |
| 6800 | blob = &qla_fw_blobs[FW_ISP27XX]; |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 6801 | } else if (IS_QLA28XX(ha)) { |
| 6802 | blob = &qla_fw_blobs[FW_ISP28XX]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 6803 | } else { |
| 6804 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6805 | } |
| 6806 | |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 6807 | if (!blob->name) |
| 6808 | return NULL; |
| 6809 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6810 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6811 | if (blob->fw) |
| 6812 | goto out; |
| 6813 | |
| 6814 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6815 | ql_log(ql_log_warn, vha, 0x0063, |
| 6816 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6817 | blob->fw = NULL; |
| 6818 | blob = NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6819 | } |
| 6820 | |
| 6821 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6822 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6823 | return blob; |
| 6824 | } |
| 6825 | |
| 6826 | static void |
| 6827 | qla2x00_release_firmware(void) |
| 6828 | { |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 6829 | struct fw_blob *blob; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6830 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6831 | mutex_lock(&qla_fw_lock); |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 6832 | for (blob = qla_fw_blobs; blob->name; blob++) |
| 6833 | release_firmware(blob->fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6834 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6835 | } |
| 6836 | |
Quinn Tran | 5386a4e | 2019-05-06 13:52:19 -0700 | [diff] [blame] | 6837 | static void qla_pci_error_cleanup(scsi_qla_host_t *vha) |
| 6838 | { |
| 6839 | struct qla_hw_data *ha = vha->hw; |
| 6840 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 6841 | struct qla_qpair *qpair = NULL; |
| 6842 | struct scsi_qla_host *vp; |
| 6843 | fc_port_t *fcport; |
| 6844 | int i; |
| 6845 | unsigned long flags; |
| 6846 | |
| 6847 | ha->chip_reset++; |
| 6848 | |
| 6849 | ha->base_qpair->chip_reset = ha->chip_reset; |
| 6850 | for (i = 0; i < ha->max_qpairs; i++) { |
| 6851 | if (ha->queue_pair_map[i]) |
| 6852 | ha->queue_pair_map[i]->chip_reset = |
| 6853 | ha->base_qpair->chip_reset; |
| 6854 | } |
| 6855 | |
| 6856 | /* purge MBox commands */ |
| 6857 | if (atomic_read(&ha->num_pend_mbx_stage3)) { |
| 6858 | clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); |
| 6859 | complete(&ha->mbx_intr_comp); |
| 6860 | } |
| 6861 | |
| 6862 | i = 0; |
| 6863 | |
| 6864 | while (atomic_read(&ha->num_pend_mbx_stage3) || |
| 6865 | atomic_read(&ha->num_pend_mbx_stage2) || |
| 6866 | atomic_read(&ha->num_pend_mbx_stage1)) { |
| 6867 | msleep(20); |
| 6868 | i++; |
| 6869 | if (i > 50) |
| 6870 | break; |
| 6871 | } |
| 6872 | |
| 6873 | ha->flags.purge_mbox = 0; |
| 6874 | |
| 6875 | mutex_lock(&ha->mq_lock); |
| 6876 | list_for_each_entry(qpair, &base_vha->qp_list, qp_list_elem) |
| 6877 | qpair->online = 0; |
| 6878 | mutex_unlock(&ha->mq_lock); |
| 6879 | |
| 6880 | qla2x00_mark_all_devices_lost(vha, 0); |
| 6881 | |
| 6882 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 6883 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 6884 | atomic_inc(&vp->vref_count); |
| 6885 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 6886 | qla2x00_mark_all_devices_lost(vp, 0); |
| 6887 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 6888 | atomic_dec(&vp->vref_count); |
| 6889 | } |
| 6890 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 6891 | |
| 6892 | /* Clear all async request states across all VPs. */ |
| 6893 | list_for_each_entry(fcport, &vha->vp_fcports, list) |
| 6894 | fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); |
| 6895 | |
| 6896 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 6897 | list_for_each_entry(vp, &ha->vp_list, list) { |
| 6898 | atomic_inc(&vp->vref_count); |
| 6899 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 6900 | list_for_each_entry(fcport, &vp->vp_fcports, list) |
| 6901 | fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT); |
| 6902 | spin_lock_irqsave(&ha->vport_slock, flags); |
| 6903 | atomic_dec(&vp->vref_count); |
| 6904 | } |
| 6905 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 6906 | } |
| 6907 | |
| 6908 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6909 | static pci_ers_result_t |
| 6910 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 6911 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6912 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 6913 | struct qla_hw_data *ha = vha->hw; |
| 6914 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6915 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 6916 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 6917 | |
Sawan Chandak | efdb576 | 2017-08-23 15:05:00 -0700 | [diff] [blame] | 6918 | if (!atomic_read(&pdev->enable_cnt)) { |
| 6919 | ql_log(ql_log_info, vha, 0xffff, |
| 6920 | "PCI device is disabled,state %x\n", state); |
| 6921 | return PCI_ERS_RESULT_NEED_RESET; |
| 6922 | } |
| 6923 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6924 | switch (state) { |
| 6925 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6926 | ha->flags.eeh_busy = 0; |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 6927 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6928 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6929 | qla2xxx_wake_dpc(vha); |
| 6930 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6931 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 6932 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6933 | ha->flags.eeh_busy = 1; |
Quinn Tran | 5386a4e | 2019-05-06 13:52:19 -0700 | [diff] [blame] | 6934 | qla_pci_error_cleanup(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6935 | return PCI_ERS_RESULT_NEED_RESET; |
| 6936 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6937 | ha->flags.pci_channel_io_perm_failure = 1; |
| 6938 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Himanshu Madhani | c38d1ba | 2017-10-13 15:43:22 -0700 | [diff] [blame] | 6939 | if (ql2xmqsupport || ql2xnvmeenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6940 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6941 | qla2xxx_wake_dpc(vha); |
| 6942 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6943 | return PCI_ERS_RESULT_DISCONNECT; |
| 6944 | } |
| 6945 | return PCI_ERS_RESULT_NEED_RESET; |
| 6946 | } |
| 6947 | |
| 6948 | static pci_ers_result_t |
| 6949 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 6950 | { |
| 6951 | int risc_paused = 0; |
| 6952 | uint32_t stat; |
| 6953 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6954 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6955 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6956 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 6957 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 6958 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 6959 | if (IS_QLA82XX(ha)) |
| 6960 | return PCI_ERS_RESULT_RECOVERED; |
| 6961 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6962 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 6963 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 6964 | stat = RD_REG_DWORD(®->hccr); |
| 6965 | if (stat & HCCR_RISC_PAUSE) |
| 6966 | risc_paused = 1; |
| 6967 | } else if (IS_QLA23XX(ha)) { |
| 6968 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 6969 | if (stat & HSR_RISC_PAUSED) |
| 6970 | risc_paused = 1; |
| 6971 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 6972 | stat = RD_REG_DWORD(®24->host_status); |
| 6973 | if (stat & HSRX_RISC_PAUSED) |
| 6974 | risc_paused = 1; |
| 6975 | } |
| 6976 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 6977 | |
| 6978 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6979 | ql_log(ql_log_info, base_vha, 0x9003, |
| 6980 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6981 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6982 | |
| 6983 | return PCI_ERS_RESULT_NEED_RESET; |
| 6984 | } else |
| 6985 | return PCI_ERS_RESULT_RECOVERED; |
| 6986 | } |
| 6987 | |
| 6988 | static pci_ers_result_t |
| 6989 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 6990 | { |
| 6991 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6992 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6993 | struct qla_hw_data *ha = base_vha->hw; |
Quinn Tran | 5386a4e | 2019-05-06 13:52:19 -0700 | [diff] [blame] | 6994 | int rc; |
| 6995 | struct qla_qpair *qpair = NULL; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6996 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6997 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 6998 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6999 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 7000 | /* Workaround: qla2xxx driver which access hardware earlier |
| 7001 | * needs error state to be pci_channel_io_online. |
| 7002 | * Otherwise mailbox command timesout. |
| 7003 | */ |
| 7004 | pdev->error_state = pci_channel_io_normal; |
| 7005 | |
| 7006 | pci_restore_state(pdev); |
| 7007 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 7008 | /* pci_restore_state() clears the saved_state flag of the device |
| 7009 | * save restored state which resets saved_state flag |
| 7010 | */ |
| 7011 | pci_save_state(pdev); |
| 7012 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 7013 | if (ha->mem_only) |
| 7014 | rc = pci_enable_device_mem(pdev); |
| 7015 | else |
| 7016 | rc = pci_enable_device(pdev); |
| 7017 | |
| 7018 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7019 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7020 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 7021 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7022 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7023 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 7024 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 7025 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 7026 | goto exit_slot_reset; |
| 7027 | |
Quinn Tran | 5386a4e | 2019-05-06 13:52:19 -0700 | [diff] [blame] | 7028 | mutex_lock(&ha->mq_lock); |
| 7029 | list_for_each_entry(qpair, &base_vha->qp_list, qp_list_elem) |
| 7030 | qpair->online = 1; |
| 7031 | mutex_unlock(&ha->mq_lock); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7032 | |
Quinn Tran | 5386a4e | 2019-05-06 13:52:19 -0700 | [diff] [blame] | 7033 | base_vha->flags.online = 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 7034 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 7035 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7036 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 7037 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7038 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 7039 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 7040 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7041 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 7042 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 7043 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7044 | return ret; |
| 7045 | } |
| 7046 | |
| 7047 | static void |
| 7048 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 7049 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 7050 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 7051 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7052 | int ret; |
| 7053 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7054 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 7055 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 7056 | |
Quinn Tran | 5386a4e | 2019-05-06 13:52:19 -0700 | [diff] [blame] | 7057 | ha->flags.eeh_busy = 0; |
| 7058 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 7059 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7060 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7061 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 7062 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7063 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7064 | } |
| 7065 | |
Quinn Tran | 590f806 | 2019-01-24 23:23:40 -0800 | [diff] [blame] | 7066 | static void |
| 7067 | qla_pci_reset_prepare(struct pci_dev *pdev) |
| 7068 | { |
| 7069 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 7070 | struct qla_hw_data *ha = base_vha->hw; |
| 7071 | struct qla_qpair *qpair; |
| 7072 | |
| 7073 | ql_log(ql_log_warn, base_vha, 0xffff, |
| 7074 | "%s.\n", __func__); |
| 7075 | |
| 7076 | /* |
| 7077 | * PCI FLR/function reset is about to reset the |
| 7078 | * slot. Stop the chip to stop all DMA access. |
| 7079 | * It is assumed that pci_reset_done will be called |
| 7080 | * after FLR to resume Chip operation. |
| 7081 | */ |
| 7082 | ha->flags.eeh_busy = 1; |
| 7083 | mutex_lock(&ha->mq_lock); |
| 7084 | list_for_each_entry(qpair, &base_vha->qp_list, qp_list_elem) |
| 7085 | qpair->online = 0; |
| 7086 | mutex_unlock(&ha->mq_lock); |
| 7087 | |
| 7088 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 7089 | qla2x00_abort_isp_cleanup(base_vha); |
| 7090 | qla2x00_abort_all_cmds(base_vha, DID_RESET << 16); |
| 7091 | } |
| 7092 | |
| 7093 | static void |
| 7094 | qla_pci_reset_done(struct pci_dev *pdev) |
| 7095 | { |
| 7096 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 7097 | struct qla_hw_data *ha = base_vha->hw; |
| 7098 | struct qla_qpair *qpair; |
| 7099 | |
| 7100 | ql_log(ql_log_warn, base_vha, 0xffff, |
| 7101 | "%s.\n", __func__); |
| 7102 | |
| 7103 | /* |
| 7104 | * FLR just completed by PCI layer. Resume adapter |
| 7105 | */ |
| 7106 | ha->flags.eeh_busy = 0; |
| 7107 | mutex_lock(&ha->mq_lock); |
| 7108 | list_for_each_entry(qpair, &base_vha->qp_list, qp_list_elem) |
| 7109 | qpair->online = 1; |
| 7110 | mutex_unlock(&ha->mq_lock); |
| 7111 | |
| 7112 | base_vha->flags.online = 1; |
| 7113 | ha->isp_ops->abort_isp(base_vha); |
| 7114 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 7115 | } |
| 7116 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 7117 | static int qla2xxx_map_queues(struct Scsi_Host *shost) |
| 7118 | { |
Quinn Tran | d68b850 | 2017-12-04 14:44:59 -0800 | [diff] [blame] | 7119 | int rc; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 7120 | scsi_qla_host_t *vha = (scsi_qla_host_t *)shost->hostdata; |
Dongli Zhang | 485b0ec | 2019-03-12 09:00:30 +0800 | [diff] [blame] | 7121 | struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 7122 | |
Giridhar Malavali | f3e0269 | 2019-02-15 16:42:55 -0800 | [diff] [blame] | 7123 | if (USER_CTRL_IRQ(vha->hw) || !vha->hw->mqiobase) |
Jens Axboe | ed76e32 | 2018-10-29 13:06:14 -0600 | [diff] [blame] | 7124 | rc = blk_mq_map_queues(qmap); |
Quinn Tran | d68b850 | 2017-12-04 14:44:59 -0800 | [diff] [blame] | 7125 | else |
Ming Lei | f0783d4 | 2019-01-11 09:40:47 -0800 | [diff] [blame] | 7126 | rc = blk_mq_pci_map_queues(qmap, vha->hw->pdev, vha->irq_offset); |
Quinn Tran | d68b850 | 2017-12-04 14:44:59 -0800 | [diff] [blame] | 7127 | return rc; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 7128 | } |
| 7129 | |
Bart Van Assche | 6515ad7 | 2019-04-04 12:44:43 -0700 | [diff] [blame] | 7130 | struct scsi_host_template qla2xxx_driver_template = { |
| 7131 | .module = THIS_MODULE, |
| 7132 | .name = QLA2XXX_DRIVER_NAME, |
| 7133 | .queuecommand = qla2xxx_queuecommand, |
| 7134 | |
| 7135 | .eh_timed_out = fc_eh_timed_out, |
| 7136 | .eh_abort_handler = qla2xxx_eh_abort, |
| 7137 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
| 7138 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
| 7139 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 7140 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 7141 | |
| 7142 | .slave_configure = qla2xxx_slave_configure, |
| 7143 | |
| 7144 | .slave_alloc = qla2xxx_slave_alloc, |
| 7145 | .slave_destroy = qla2xxx_slave_destroy, |
| 7146 | .scan_finished = qla2xxx_scan_finished, |
| 7147 | .scan_start = qla2xxx_scan_start, |
| 7148 | .change_queue_depth = scsi_change_queue_depth, |
| 7149 | .map_queues = qla2xxx_map_queues, |
| 7150 | .this_id = -1, |
| 7151 | .cmd_per_lun = 3, |
| 7152 | .sg_tablesize = SG_ALL, |
| 7153 | |
| 7154 | .max_sectors = 0xFFFF, |
| 7155 | .shost_attrs = qla2x00_host_attrs, |
| 7156 | |
| 7157 | .supported_mode = MODE_INITIATOR, |
| 7158 | .track_queue_depth = 1, |
| 7159 | }; |
| 7160 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 7161 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7162 | .error_detected = qla2xxx_pci_error_detected, |
| 7163 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 7164 | .slot_reset = qla2xxx_pci_slot_reset, |
| 7165 | .resume = qla2xxx_pci_resume, |
Quinn Tran | 590f806 | 2019-01-24 23:23:40 -0800 | [diff] [blame] | 7166 | .reset_prepare = qla_pci_reset_prepare, |
| 7167 | .reset_done = qla_pci_reset_done, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7168 | }; |
| 7169 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 7170 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 7171 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 7172 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 7173 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 7174 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 7175 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 7176 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 7177 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 7178 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 7179 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 7180 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 7181 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 7182 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 7183 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 7184 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 7185 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 7186 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 7187 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 7188 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISPF001) }, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 7189 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8044) }, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 7190 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2071) }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 7191 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2271) }, |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 7192 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2261) }, |
Joe Carnuccio | ecc89f2 | 2019-03-12 11:08:13 -0700 | [diff] [blame] | 7193 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2061) }, |
| 7194 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2081) }, |
| 7195 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2281) }, |
| 7196 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2089) }, |
| 7197 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2289) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 7198 | { 0 }, |
| 7199 | }; |
| 7200 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 7201 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 7202 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 7203 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 7204 | .driver = { |
| 7205 | .owner = THIS_MODULE, |
| 7206 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 7207 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 7208 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 7209 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 7210 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 7211 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 7212 | }; |
| 7213 | |
Al Viro | 75ef9de | 2013-04-04 19:09:41 -0400 | [diff] [blame] | 7214 | static const struct file_operations apidev_fops = { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 7215 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 7216 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 7217 | }; |
| 7218 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7219 | /** |
| 7220 | * qla2x00_module_init - Module initialization. |
| 7221 | **/ |
| 7222 | static int __init |
| 7223 | qla2x00_module_init(void) |
| 7224 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 7225 | int ret = 0; |
| 7226 | |
Bart Van Assche | bc04459 | 2019-04-17 14:44:37 -0700 | [diff] [blame] | 7227 | BUILD_BUG_ON(sizeof(cmd_entry_t) != 64); |
| 7228 | BUILD_BUG_ON(sizeof(cont_a64_entry_t) != 64); |
| 7229 | BUILD_BUG_ON(sizeof(cont_entry_t) != 64); |
| 7230 | BUILD_BUG_ON(sizeof(init_cb_t) != 96); |
| 7231 | BUILD_BUG_ON(sizeof(ms_iocb_entry_t) != 64); |
| 7232 | BUILD_BUG_ON(sizeof(request_t) != 64); |
| 7233 | BUILD_BUG_ON(sizeof(struct access_chip_84xx) != 64); |
| 7234 | BUILD_BUG_ON(sizeof(struct cmd_bidir) != 64); |
| 7235 | BUILD_BUG_ON(sizeof(struct cmd_nvme) != 64); |
| 7236 | BUILD_BUG_ON(sizeof(struct cmd_type_6) != 64); |
| 7237 | BUILD_BUG_ON(sizeof(struct cmd_type_7) != 64); |
| 7238 | BUILD_BUG_ON(sizeof(struct cmd_type_7_fx00) != 64); |
| 7239 | BUILD_BUG_ON(sizeof(struct cmd_type_crc_2) != 64); |
| 7240 | BUILD_BUG_ON(sizeof(struct ct_entry_24xx) != 64); |
| 7241 | BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64); |
| 7242 | BUILD_BUG_ON(sizeof(struct els_entry_24xx) != 64); |
| 7243 | BUILD_BUG_ON(sizeof(struct fxdisc_entry_fx00) != 64); |
| 7244 | BUILD_BUG_ON(sizeof(struct init_cb_24xx) != 128); |
| 7245 | BUILD_BUG_ON(sizeof(struct init_cb_81xx) != 128); |
| 7246 | BUILD_BUG_ON(sizeof(struct pt_ls4_request) != 64); |
| 7247 | BUILD_BUG_ON(sizeof(struct sns_cmd_pkt) != 2064); |
| 7248 | BUILD_BUG_ON(sizeof(struct verify_chip_entry_84xx) != 64); |
| 7249 | BUILD_BUG_ON(sizeof(struct vf_evfp_entry_24xx) != 56); |
| 7250 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7251 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 7252 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 7253 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7254 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7255 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 7256 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7257 | return -ENOMEM; |
| 7258 | } |
| 7259 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 7260 | /* Initialize target kmem_cache and mem_pools */ |
| 7261 | ret = qlt_init(); |
| 7262 | if (ret < 0) { |
Bart Van Assche | c794d24 | 2019-04-04 12:44:46 -0700 | [diff] [blame] | 7263 | goto destroy_cache; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 7264 | } else if (ret > 0) { |
| 7265 | /* |
| 7266 | * If initiator mode is explictly disabled by qlt_init(), |
| 7267 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 7268 | * performing scsi_scan_target() during LOOP UP event. |
| 7269 | */ |
| 7270 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 7271 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 7272 | } |
| 7273 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7274 | /* Derive version string. */ |
| 7275 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 7276 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 7277 | strcat(qla2x00_version_str, "-debug"); |
Joe Carnuccio | fed0f68 | 2017-08-23 15:05:10 -0700 | [diff] [blame] | 7278 | if (ql2xextended_error_logging == 1) |
| 7279 | ql2xextended_error_logging = QL_DBG_DEFAULT1_MASK; |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 7280 | |
Quinn Tran | 0645cb8 | 2018-09-11 10:18:18 -0700 | [diff] [blame] | 7281 | if (ql2x_ini_mode == QLA2XXX_INI_MODE_DUAL) |
| 7282 | qla_insert_tgt_attrs(); |
| 7283 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 7284 | qla2xxx_transport_template = |
| 7285 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7286 | if (!qla2xxx_transport_template) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7287 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 7288 | "fc_attach_transport failed...Failing load!.\n"); |
Bart Van Assche | c794d24 | 2019-04-04 12:44:46 -0700 | [diff] [blame] | 7289 | ret = -ENODEV; |
| 7290 | goto qlt_exit; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7291 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 7292 | |
| 7293 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 7294 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7295 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 7296 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 7297 | } |
| 7298 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7299 | qla2xxx_transport_vport_template = |
| 7300 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 7301 | if (!qla2xxx_transport_vport_template) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7302 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 7303 | "fc_attach_transport vport failed...Failing load!.\n"); |
Bart Van Assche | c794d24 | 2019-04-04 12:44:46 -0700 | [diff] [blame] | 7304 | ret = -ENODEV; |
| 7305 | goto unreg_chrdev; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7306 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7307 | ql_log(ql_log_info, NULL, 0x0005, |
| 7308 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 7309 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 7310 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 7311 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 7312 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 7313 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 7314 | ret); |
Bart Van Assche | c794d24 | 2019-04-04 12:44:46 -0700 | [diff] [blame] | 7315 | goto release_vport_transport; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 7316 | } |
| 7317 | return ret; |
Bart Van Assche | c794d24 | 2019-04-04 12:44:46 -0700 | [diff] [blame] | 7318 | |
| 7319 | release_vport_transport: |
| 7320 | fc_release_transport(qla2xxx_transport_vport_template); |
| 7321 | |
| 7322 | unreg_chrdev: |
| 7323 | if (apidev_major >= 0) |
| 7324 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
| 7325 | fc_release_transport(qla2xxx_transport_template); |
| 7326 | |
| 7327 | qlt_exit: |
| 7328 | qlt_exit(); |
| 7329 | |
| 7330 | destroy_cache: |
| 7331 | kmem_cache_destroy(srb_cachep); |
| 7332 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7333 | } |
| 7334 | |
| 7335 | /** |
| 7336 | * qla2x00_module_exit - Module cleanup. |
| 7337 | **/ |
| 7338 | static void __exit |
| 7339 | qla2x00_module_exit(void) |
| 7340 | { |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 7341 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 7342 | qla2x00_release_firmware(); |
Thomas Meyer | 75c1d48 | 2018-12-02 21:52:11 +0100 | [diff] [blame] | 7343 | kmem_cache_destroy(ctx_cachep); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 7344 | fc_release_transport(qla2xxx_transport_vport_template); |
Bart Van Assche | 59c209a | 2019-04-04 12:44:47 -0700 | [diff] [blame] | 7345 | if (apidev_major >= 0) |
| 7346 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
| 7347 | fc_release_transport(qla2xxx_transport_template); |
| 7348 | qlt_exit(); |
| 7349 | kmem_cache_destroy(srb_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7350 | } |
| 7351 | |
| 7352 | module_init(qla2x00_module_init); |
| 7353 | module_exit(qla2x00_module_exit); |
| 7354 | |
| 7355 | MODULE_AUTHOR("QLogic Corporation"); |
| 7356 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 7357 | MODULE_LICENSE("GPL"); |
| 7358 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 7359 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 7360 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 7361 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 7362 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 7363 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 7364 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |