Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 2 | * QLogic Fibre Channel HBA Driver |
Armen Baloyan | bd21eaf | 2014-04-11 16:54:24 -0400 | [diff] [blame] | 3 | * Copyright (c) 2003-2014 QLogic Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | #include "qla_def.h" |
| 8 | |
| 9 | #include <linux/moduleparam.h> |
| 10 | #include <linux/vmalloc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/delay.h> |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 12 | #include <linux/kthread.h> |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 13 | #include <linux/mutex.h> |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 14 | #include <linux/kobject.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 15 | #include <linux/slab.h> |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 16 | #include <linux/blk-mq-pci.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <scsi/scsi_tcq.h> |
| 18 | #include <scsi/scsicam.h> |
| 19 | #include <scsi/scsi_transport.h> |
| 20 | #include <scsi/scsi_transport_fc.h> |
| 21 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 22 | #include "qla_target.h" |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | /* |
| 25 | * Driver version |
| 26 | */ |
| 27 | char qla2x00_version_str[40]; |
| 28 | |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 29 | static int apidev_major; |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | /* |
| 32 | * SRB allocation cache |
| 33 | */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 34 | struct kmem_cache *srb_cachep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 36 | /* |
| 37 | * CT6 CTX allocation cache |
| 38 | */ |
| 39 | static struct kmem_cache *ctx_cachep; |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 40 | /* |
| 41 | * error level for logging |
| 42 | */ |
| 43 | int ql_errlev = ql_log_all; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 44 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 45 | static int ql2xenableclass2; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 46 | module_param(ql2xenableclass2, int, S_IRUGO|S_IRUSR); |
| 47 | MODULE_PARM_DESC(ql2xenableclass2, |
| 48 | "Specify if Class 2 operations are supported from the very " |
| 49 | "beginning. Default is 0 - class 2 not supported."); |
| 50 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | int ql2xlogintimeout = 20; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 53 | module_param(ql2xlogintimeout, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | MODULE_PARM_DESC(ql2xlogintimeout, |
| 55 | "Login timeout value in seconds."); |
| 56 | |
Andrew Vasquez | a7b6184 | 2007-05-07 07:42:59 -0700 | [diff] [blame] | 57 | int qlport_down_retry; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 58 | module_param(qlport_down_retry, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | MODULE_PARM_DESC(qlport_down_retry, |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 60 | "Maximum number of command retries to a port that returns " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | "a PORT-DOWN status."); |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | int ql2xplogiabsentdevice; |
| 64 | module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); |
| 65 | MODULE_PARM_DESC(ql2xplogiabsentdevice, |
| 66 | "Option to enable PLOGI to devices that are not present after " |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 67 | "a Fabric scan. This is needed for several broken switches. " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | "Default is 0 - no PLOGI. 1 - perfom PLOGI."); |
| 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | int ql2xloginretrycount = 0; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 71 | module_param(ql2xloginretrycount, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | MODULE_PARM_DESC(ql2xloginretrycount, |
| 73 | "Specify an alternate value for the NVRAM login retry count."); |
| 74 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 75 | int ql2xallocfwdump = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 76 | module_param(ql2xallocfwdump, int, S_IRUGO); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 77 | MODULE_PARM_DESC(ql2xallocfwdump, |
| 78 | "Option to enable allocation of memory for a firmware dump " |
| 79 | "during HBA initialization. Memory allocation requirements " |
| 80 | "vary by ISP type. Default is 1 - allocate memory."); |
| 81 | |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 82 | int ql2xextended_error_logging; |
Andrew Vasquez | 27d9403 | 2007-03-12 10:41:30 -0700 | [diff] [blame] | 83 | module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 84 | module_param_named(logging, ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 85 | MODULE_PARM_DESC(ql2xextended_error_logging, |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 86 | "Option to enable extended error logging,\n" |
| 87 | "\t\tDefault is 0 - no logging. 0x40000000 - Module Init & Probe.\n" |
| 88 | "\t\t0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.\n" |
| 89 | "\t\t0x08000000 - IO tracing. 0x04000000 - DPC Thread.\n" |
| 90 | "\t\t0x02000000 - Async events. 0x01000000 - Timer routines.\n" |
| 91 | "\t\t0x00800000 - User space. 0x00400000 - Task Management.\n" |
| 92 | "\t\t0x00200000 - AER/EEH. 0x00100000 - Multi Q.\n" |
| 93 | "\t\t0x00080000 - P3P Specific. 0x00040000 - Virtual Port.\n" |
| 94 | "\t\t0x00020000 - Buffer Dump. 0x00010000 - Misc.\n" |
Chad Dupuis | 29f9f90 | 2012-11-21 02:40:41 -0500 | [diff] [blame] | 95 | "\t\t0x00008000 - Verbose. 0x00004000 - Target.\n" |
| 96 | "\t\t0x00002000 - Target Mgmt. 0x00001000 - Target TMF.\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 97 | "\t\t0x7fffffff - For enabling all logs, can be too many logs.\n" |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 98 | "\t\t0x1e400000 - Preferred value for capturing essential " |
| 99 | "debug information (equivalent to old " |
| 100 | "ql2xextended_error_logging=1).\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 101 | "\t\tDo LOGICAL OR of the value to enable more than one level"); |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 102 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 103 | int ql2xshiftctondsd = 6; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 104 | module_param(ql2xshiftctondsd, int, S_IRUGO); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 105 | MODULE_PARM_DESC(ql2xshiftctondsd, |
| 106 | "Set to control shifting of command type processing " |
| 107 | "based on total number of SG elements."); |
| 108 | |
Andrew Vasquez | 7e47e5c | 2008-04-24 15:21:26 -0700 | [diff] [blame] | 109 | int ql2xfdmienable=1; |
Himanshu Madhani | de187df | 2014-09-25 05:16:50 -0400 | [diff] [blame] | 110 | module_param(ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 111 | module_param_named(fdmi, ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 112 | MODULE_PARM_DESC(ql2xfdmienable, |
Ferenc Wagner | 7794a5a | 2010-03-23 18:14:59 +0100 | [diff] [blame] | 113 | "Enables FDMI registrations. " |
| 114 | "0 - no FDMI. Default is 1 - perform FDMI."); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 115 | |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 116 | #define MAX_Q_DEPTH 32 |
| 117 | static int ql2xmaxqdepth = MAX_Q_DEPTH; |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 118 | module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR); |
| 119 | MODULE_PARM_DESC(ql2xmaxqdepth, |
Chad Dupuis | e92e4a8 | 2012-08-22 14:21:23 -0400 | [diff] [blame] | 120 | "Maximum queue depth to set for each LUN. " |
| 121 | "Default is 32."); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 122 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 123 | int ql2xenabledif = 2; |
| 124 | module_param(ql2xenabledif, int, S_IRUGO); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 125 | MODULE_PARM_DESC(ql2xenabledif, |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 126 | " Enable T10-CRC-DIF:\n" |
| 127 | " Default is 2.\n" |
| 128 | " 0 -- No DIF Support\n" |
| 129 | " 1 -- Enable DIF for all types\n" |
| 130 | " 2 -- Enable DIF for all types, except Type 0.\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 131 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 132 | int ql2xenablehba_err_chk = 2; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 133 | module_param(ql2xenablehba_err_chk, int, S_IRUGO|S_IWUSR); |
| 134 | MODULE_PARM_DESC(ql2xenablehba_err_chk, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 135 | " Enable T10-CRC-DIF Error isolation by HBA:\n" |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 136 | " Default is 2.\n" |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 137 | " 0 -- Error isolation disabled\n" |
| 138 | " 1 -- Error isolation enabled only for DIX Type 0\n" |
| 139 | " 2 -- Error isolation enabled for all Types\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 140 | |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 141 | int ql2xiidmaenable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 142 | module_param(ql2xiidmaenable, int, S_IRUGO); |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 143 | MODULE_PARM_DESC(ql2xiidmaenable, |
| 144 | "Enables iIDMA settings " |
| 145 | "Default is 1 - perform iIDMA. 0 - no iIDMA."); |
| 146 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 147 | int ql2xmqsupport = 1; |
| 148 | module_param(ql2xmqsupport, int, S_IRUGO); |
| 149 | MODULE_PARM_DESC(ql2xmqsupport, |
| 150 | "Enable on demand multiple queue pairs support " |
| 151 | "Default is 1 for supported. " |
| 152 | "Set it to 0 to turn off mq qpair support."); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 153 | |
| 154 | int ql2xfwloadbin; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 155 | module_param(ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 156 | module_param_named(fwload, ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 157 | MODULE_PARM_DESC(ql2xfwloadbin, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 158 | "Option to specify location from which to load ISP firmware:.\n" |
| 159 | " 2 -- load firmware via the request_firmware() (hotplug).\n" |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 160 | " interface.\n" |
| 161 | " 1 -- load firmware from flash.\n" |
| 162 | " 0 -- use default semantics.\n"); |
| 163 | |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 164 | int ql2xetsenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 165 | module_param(ql2xetsenable, int, S_IRUGO); |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 166 | MODULE_PARM_DESC(ql2xetsenable, |
| 167 | "Enables firmware ETS burst." |
| 168 | "Default is 0 - skip ETS enablement."); |
| 169 | |
Giridhar Malavali | 6907869 | 2010-05-28 15:08:28 -0700 | [diff] [blame] | 170 | int ql2xdbwr = 1; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 171 | module_param(ql2xdbwr, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 172 | MODULE_PARM_DESC(ql2xdbwr, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 173 | "Option to specify scheme for request queue posting.\n" |
| 174 | " 0 -- Regular doorbell.\n" |
| 175 | " 1 -- CAMRAM doorbell (faster).\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 176 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 177 | int ql2xtargetreset = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 178 | module_param(ql2xtargetreset, int, S_IRUGO); |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 179 | MODULE_PARM_DESC(ql2xtargetreset, |
| 180 | "Enable target reset." |
| 181 | "Default is 1 - use hw defaults."); |
| 182 | |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 183 | int ql2xgffidenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 184 | module_param(ql2xgffidenable, int, S_IRUGO); |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 185 | MODULE_PARM_DESC(ql2xgffidenable, |
| 186 | "Enables GFF_ID checks of port type. " |
| 187 | "Default is 0 - Do not use GFF_ID information."); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 188 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 189 | int ql2xasynctmfenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 190 | module_param(ql2xasynctmfenable, int, S_IRUGO); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 191 | MODULE_PARM_DESC(ql2xasynctmfenable, |
| 192 | "Enables issue of TM IOCBs asynchronously via IOCB mechanism" |
| 193 | "Default is 0 - Issue TM IOCBs via mailbox mechanism."); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 194 | |
| 195 | int ql2xdontresethba; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 196 | module_param(ql2xdontresethba, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 197 | MODULE_PARM_DESC(ql2xdontresethba, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 198 | "Option to specify reset behaviour.\n" |
| 199 | " 0 (Default) -- Reset on failure.\n" |
| 200 | " 1 -- Do not reset on failure.\n"); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 201 | |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 202 | uint64_t ql2xmaxlun = MAX_LUNS; |
| 203 | module_param(ql2xmaxlun, ullong, S_IRUGO); |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 204 | MODULE_PARM_DESC(ql2xmaxlun, |
| 205 | "Defines the maximum LU number to register with the SCSI " |
| 206 | "midlayer. Default is 65535."); |
| 207 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 208 | int ql2xmdcapmask = 0x1F; |
| 209 | module_param(ql2xmdcapmask, int, S_IRUGO); |
| 210 | MODULE_PARM_DESC(ql2xmdcapmask, |
| 211 | "Set the Minidump driver capture mask level. " |
Giridhar Malavali | 6e96fa7 | 2011-11-18 09:03:14 -0800 | [diff] [blame] | 212 | "Default is 0x1F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 213 | |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 214 | int ql2xmdenable = 1; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 215 | module_param(ql2xmdenable, int, S_IRUGO); |
| 216 | MODULE_PARM_DESC(ql2xmdenable, |
| 217 | "Enable/disable MiniDump. " |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 218 | "0 - MiniDump disabled. " |
| 219 | "1 (Default) - MiniDump enabled."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 220 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 221 | int ql2xexlogins = 0; |
| 222 | module_param(ql2xexlogins, uint, S_IRUGO|S_IWUSR); |
| 223 | MODULE_PARM_DESC(ql2xexlogins, |
| 224 | "Number of extended Logins. " |
| 225 | "0 (Default)- Disabled."); |
| 226 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 227 | int ql2xexchoffld = 1024; |
| 228 | module_param(ql2xexchoffld, uint, 0644); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 229 | MODULE_PARM_DESC(ql2xexchoffld, |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 230 | "Number of target exchanges."); |
| 231 | |
| 232 | int ql2xiniexchg = 1024; |
| 233 | module_param(ql2xiniexchg, uint, 0644); |
| 234 | MODULE_PARM_DESC(ql2xiniexchg, |
| 235 | "Number of initiator exchanges."); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 236 | |
Himanshu Madhani | f198caf | 2016-01-27 12:03:30 -0500 | [diff] [blame] | 237 | int ql2xfwholdabts = 0; |
| 238 | module_param(ql2xfwholdabts, int, S_IRUGO); |
| 239 | MODULE_PARM_DESC(ql2xfwholdabts, |
| 240 | "Allow FW to hold status IOCB until ABTS rsp received. " |
| 241 | "0 (Default) Do not set fw option. " |
| 242 | "1 - Set fw option to hold ABTS."); |
| 243 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 244 | int ql2xmvasynctoatio = 1; |
| 245 | module_param(ql2xmvasynctoatio, int, S_IRUGO|S_IWUSR); |
| 246 | MODULE_PARM_DESC(ql2xmvasynctoatio, |
| 247 | "Move PUREX, ABTS RX and RIDA IOCBs to ATIOQ" |
| 248 | "0 (Default). Do not move IOCBs" |
| 249 | "1 - Move IOCBs."); |
| 250 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 252 | * SCSI host template entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | */ |
| 254 | static int qla2xxx_slave_configure(struct scsi_device * device); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 255 | static int qla2xxx_slave_alloc(struct scsi_device *); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 256 | static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); |
| 257 | static void qla2xxx_scan_start(struct Scsi_Host *); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 258 | static void qla2xxx_slave_destroy(struct scsi_device *); |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 259 | static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | static int qla2xxx_eh_abort(struct scsi_cmnd *); |
| 261 | static int qla2xxx_eh_device_reset(struct scsi_cmnd *); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 262 | static int qla2xxx_eh_target_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); |
| 264 | static int qla2xxx_eh_host_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 266 | static void qla2x00_clear_drv_active(struct qla_hw_data *); |
Saurav Kashyap | 3491255 | 2013-06-25 11:27:18 -0400 | [diff] [blame] | 267 | static void qla2x00_free_device(scsi_qla_host_t *); |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 268 | static void qla83xx_disable_laser(scsi_qla_host_t *vha); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 269 | static int qla2xxx_map_queues(struct Scsi_Host *shost); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 270 | |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 271 | struct scsi_host_template qla2xxx_driver_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | .module = THIS_MODULE, |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 273 | .name = QLA2XXX_DRIVER_NAME, |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 274 | .queuecommand = qla2xxx_queuecommand, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 275 | |
Christoph Hellwig | b6a05c8 | 2017-01-30 13:18:58 +0100 | [diff] [blame] | 276 | .eh_timed_out = fc_eh_timed_out, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 277 | .eh_abort_handler = qla2xxx_eh_abort, |
| 278 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 279 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 280 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 281 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 282 | |
| 283 | .slave_configure = qla2xxx_slave_configure, |
| 284 | |
| 285 | .slave_alloc = qla2xxx_slave_alloc, |
| 286 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 287 | .scan_finished = qla2xxx_scan_finished, |
| 288 | .scan_start = qla2xxx_scan_start, |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 289 | .change_queue_depth = scsi_change_queue_depth, |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 290 | .map_queues = qla2xxx_map_queues, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 291 | .this_id = -1, |
| 292 | .cmd_per_lun = 3, |
| 293 | .use_clustering = ENABLE_CLUSTERING, |
| 294 | .sg_tablesize = SG_ALL, |
| 295 | |
| 296 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 297 | .shost_attrs = qla2x00_host_attrs, |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 298 | |
| 299 | .supported_mode = MODE_INITIATOR, |
Christoph Hellwig | c40ecc1 | 2014-11-13 14:25:11 +0100 | [diff] [blame] | 300 | .track_queue_depth = 1, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 301 | }; |
| 302 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 304 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | /* TODO Convert to inlines |
| 307 | * |
| 308 | * Timer routines |
| 309 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 311 | __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 312 | qla2x00_start_timer(scsi_qla_host_t *vha, void *func, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 314 | init_timer(&vha->timer); |
| 315 | vha->timer.expires = jiffies + interval * HZ; |
| 316 | vha->timer.data = (unsigned long)vha; |
| 317 | vha->timer.function = (void (*)(unsigned long))func; |
| 318 | add_timer(&vha->timer); |
| 319 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 323 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 325 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 326 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 327 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 328 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 329 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 330 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 331 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 332 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | } |
| 334 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 335 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 336 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 338 | del_timer_sync(&vha->timer); |
| 339 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | } |
| 341 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | static int qla2x00_do_dpc(void *data); |
| 343 | |
| 344 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 345 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 346 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 347 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 348 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 349 | static void qla2x00_mem_free(struct qla_hw_data *); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 350 | int qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 351 | struct qla_qpair *qpair); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | /* -------------------------------------------------------------------------- */ |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 354 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 355 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 356 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 357 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 358 | ha->req_q_map = kzalloc(sizeof(struct req_que *) * ha->max_req_queues, |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 359 | GFP_KERNEL); |
| 360 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 361 | ql_log(ql_log_fatal, vha, 0x003b, |
| 362 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 363 | goto fail_req_map; |
| 364 | } |
| 365 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 366 | ha->rsp_q_map = kzalloc(sizeof(struct rsp_que *) * ha->max_rsp_queues, |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 367 | GFP_KERNEL); |
| 368 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 369 | ql_log(ql_log_fatal, vha, 0x003c, |
| 370 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 371 | goto fail_rsp_map; |
| 372 | } |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 373 | |
| 374 | if (ql2xmqsupport && ha->max_qpairs) { |
| 375 | ha->queue_pair_map = kcalloc(ha->max_qpairs, sizeof(struct qla_qpair *), |
| 376 | GFP_KERNEL); |
| 377 | if (!ha->queue_pair_map) { |
| 378 | ql_log(ql_log_fatal, vha, 0x0180, |
| 379 | "Unable to allocate memory for queue pair ptrs.\n"); |
| 380 | goto fail_qpair_map; |
| 381 | } |
| 382 | ha->base_qpair = kzalloc(sizeof(struct qla_qpair), GFP_KERNEL); |
| 383 | if (ha->base_qpair == NULL) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 384 | ql_log(ql_log_warn, vha, 0x00e0, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 385 | "Failed to allocate base queue pair memory.\n"); |
| 386 | goto fail_base_qpair; |
| 387 | } |
| 388 | ha->base_qpair->req = req; |
| 389 | ha->base_qpair->rsp = rsp; |
| 390 | } |
| 391 | |
Quinn Tran | 82de802 | 2017-06-13 20:47:17 -0700 | [diff] [blame^] | 392 | rsp->qpair = ha->base_qpair; |
| 393 | rsp->req = req; |
| 394 | ha->base_qpair->vha = vha; |
| 395 | ha->base_qpair->qp_lock_ptr = &ha->hardware_lock; |
| 396 | ha->queue_pair_map[0] = ha->base_qpair; |
| 397 | set_bit(0, ha->qpair_qid_map); |
| 398 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 399 | /* |
| 400 | * Make sure we record at least the request and response queue zero in |
| 401 | * case we need to free them if part of the probe fails. |
| 402 | */ |
| 403 | ha->rsp_q_map[0] = rsp; |
| 404 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 405 | set_bit(0, ha->rsp_qid_map); |
| 406 | set_bit(0, ha->req_qid_map); |
| 407 | return 1; |
| 408 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 409 | fail_qpair_map: |
Quinn Tran | 82de802 | 2017-06-13 20:47:17 -0700 | [diff] [blame^] | 410 | kfree(ha->base_qpair); |
| 411 | ha->base_qpair = NULL; |
| 412 | fail_base_qpair: |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 413 | kfree(ha->rsp_q_map); |
| 414 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 415 | fail_rsp_map: |
| 416 | kfree(ha->req_q_map); |
| 417 | ha->req_q_map = NULL; |
| 418 | fail_req_map: |
| 419 | return -ENOMEM; |
| 420 | } |
| 421 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 422 | 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] | 423 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 424 | if (IS_QLAFX00(ha)) { |
| 425 | if (req && req->ring_fx00) |
| 426 | dma_free_coherent(&ha->pdev->dev, |
| 427 | (req->length_fx00 + 1) * sizeof(request_t), |
| 428 | req->ring_fx00, req->dma_fx00); |
| 429 | } else if (req && req->ring) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 430 | dma_free_coherent(&ha->pdev->dev, |
| 431 | (req->length + 1) * sizeof(request_t), |
| 432 | req->ring, req->dma); |
| 433 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 434 | if (req) |
| 435 | kfree(req->outstanding_cmds); |
| 436 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 437 | kfree(req); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 438 | } |
| 439 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 440 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 441 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 442 | if (IS_QLAFX00(ha)) { |
| 443 | if (rsp && rsp->ring) |
| 444 | dma_free_coherent(&ha->pdev->dev, |
| 445 | (rsp->length_fx00 + 1) * sizeof(request_t), |
| 446 | rsp->ring_fx00, rsp->dma_fx00); |
| 447 | } else if (rsp && rsp->ring) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 448 | dma_free_coherent(&ha->pdev->dev, |
| 449 | (rsp->length + 1) * sizeof(response_t), |
| 450 | rsp->ring, rsp->dma); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 451 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 452 | kfree(rsp); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 453 | } |
| 454 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 455 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 456 | { |
| 457 | struct req_que *req; |
| 458 | struct rsp_que *rsp; |
| 459 | int cnt; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 460 | unsigned long flags; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 461 | |
Quinn Tran | 82de802 | 2017-06-13 20:47:17 -0700 | [diff] [blame^] | 462 | if (ha->queue_pair_map) { |
| 463 | kfree(ha->queue_pair_map); |
| 464 | ha->queue_pair_map = NULL; |
| 465 | } |
| 466 | if (ha->base_qpair) { |
| 467 | kfree(ha->base_qpair); |
| 468 | ha->base_qpair = NULL; |
| 469 | } |
| 470 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 471 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 472 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 473 | if (!test_bit(cnt, ha->req_qid_map)) |
| 474 | continue; |
| 475 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 476 | req = ha->req_q_map[cnt]; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 477 | clear_bit(cnt, ha->req_qid_map); |
| 478 | ha->req_q_map[cnt] = NULL; |
| 479 | |
| 480 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 481 | qla2x00_free_req_que(ha, req); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 482 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 483 | } |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 484 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 485 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 486 | kfree(ha->req_q_map); |
| 487 | ha->req_q_map = NULL; |
| 488 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 489 | |
| 490 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 491 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 492 | if (!test_bit(cnt, ha->rsp_qid_map)) |
| 493 | continue; |
| 494 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 495 | rsp = ha->rsp_q_map[cnt]; |
Dave Jones | c3c4239 | 2016-12-27 13:13:21 -0500 | [diff] [blame] | 496 | clear_bit(cnt, ha->rsp_qid_map); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 497 | ha->rsp_q_map[cnt] = NULL; |
| 498 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 499 | qla2x00_free_rsp_que(ha, rsp); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 500 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 501 | } |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 502 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 503 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 504 | kfree(ha->rsp_q_map); |
| 505 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 506 | } |
| 507 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 509 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 511 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | static char *pci_bus_modes[] = { |
| 513 | "33", "66", "100", "133", |
| 514 | }; |
| 515 | uint16_t pci_bus; |
| 516 | |
| 517 | strcpy(str, "PCI"); |
| 518 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 519 | if (pci_bus) { |
| 520 | strcat(str, "-X ("); |
| 521 | strcat(str, pci_bus_modes[pci_bus]); |
| 522 | } else { |
| 523 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 524 | strcat(str, " ("); |
| 525 | strcat(str, pci_bus_modes[pci_bus]); |
| 526 | } |
| 527 | strcat(str, " MHz)"); |
| 528 | |
| 529 | return (str); |
| 530 | } |
| 531 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 532 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 533 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 534 | { |
| 535 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 536 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 537 | uint32_t pci_bus; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 538 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 539 | if (pci_is_pcie(ha->pdev)) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 540 | char lwstr[6]; |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 541 | uint32_t lstat, lspeed, lwidth; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 542 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 543 | pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); |
| 544 | lspeed = lstat & PCI_EXP_LNKCAP_SLS; |
| 545 | lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 546 | |
| 547 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 548 | switch (lspeed) { |
| 549 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 550 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 551 | break; |
| 552 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 553 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 554 | break; |
| 555 | case 3: |
| 556 | strcat(str, "8.0GT/s "); |
| 557 | break; |
| 558 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 559 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 560 | break; |
| 561 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 562 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 563 | strcat(str, lwstr); |
| 564 | |
| 565 | return str; |
| 566 | } |
| 567 | |
| 568 | strcpy(str, "PCI"); |
| 569 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 570 | if (pci_bus == 0 || pci_bus == 8) { |
| 571 | strcat(str, " ("); |
| 572 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 573 | } else { |
| 574 | strcat(str, "-X "); |
| 575 | if (pci_bus & BIT_2) |
| 576 | strcat(str, "Mode 2"); |
| 577 | else |
| 578 | strcat(str, "Mode 1"); |
| 579 | strcat(str, " ("); |
| 580 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 581 | } |
| 582 | strcat(str, " MHz)"); |
| 583 | |
| 584 | return str; |
| 585 | } |
| 586 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 587 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 588 | 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] | 589 | { |
| 590 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 591 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 592 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 593 | snprintf(str, size, "%d.%02d.%02d ", ha->fw_major_version, |
| 594 | ha->fw_minor_version, ha->fw_subminor_version); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | |
| 596 | if (ha->fw_attributes & BIT_9) { |
| 597 | strcat(str, "FLX"); |
| 598 | return (str); |
| 599 | } |
| 600 | |
| 601 | switch (ha->fw_attributes & 0xFF) { |
| 602 | case 0x7: |
| 603 | strcat(str, "EF"); |
| 604 | break; |
| 605 | case 0x17: |
| 606 | strcat(str, "TP"); |
| 607 | break; |
| 608 | case 0x37: |
| 609 | strcat(str, "IP"); |
| 610 | break; |
| 611 | case 0x77: |
| 612 | strcat(str, "VI"); |
| 613 | break; |
| 614 | default: |
| 615 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 616 | strcat(str, un_str); |
| 617 | break; |
| 618 | } |
| 619 | if (ha->fw_attributes & 0x100) |
| 620 | strcat(str, "X"); |
| 621 | |
| 622 | return (str); |
| 623 | } |
| 624 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 625 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 626 | 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] | 627 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 628 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 629 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 630 | snprintf(str, size, "%d.%02d.%02d (%x)", ha->fw_major_version, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 631 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 632 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 633 | } |
| 634 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 635 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 636 | qla2x00_sp_free_dma(void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 637 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 638 | srb_t *sp = ptr; |
| 639 | struct qla_hw_data *ha = sp->vha->hw; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 640 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 641 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 642 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 643 | if (sp->flags & SRB_DMA_VALID) { |
| 644 | scsi_dma_unmap(cmd); |
| 645 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 646 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 647 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 648 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 649 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 650 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 651 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 652 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 653 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 654 | if (!ctx) |
| 655 | goto end; |
| 656 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 657 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 658 | /* List assured to be having elements */ |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 659 | qla2x00_clean_dsd_pool(ha, ctx); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 660 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 661 | } |
| 662 | |
| 663 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 664 | struct crc_context *ctx0 = ctx; |
| 665 | |
| 666 | dma_pool_free(ha->dl_dma_pool, ctx0, ctx0->crc_ctx_dma); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 667 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 668 | } |
| 669 | |
| 670 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 671 | struct ct6_dsd *ctx1 = ctx; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 672 | |
| 673 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 674 | ctx1->fcp_cmnd_dma); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 675 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 676 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 677 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 678 | mempool_free(ctx1, ha->ctx_mempool); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 679 | } |
| 680 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 681 | end: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 682 | CMD_SP(cmd) = NULL; |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 683 | qla2x00_rel_sp(sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 684 | } |
| 685 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 686 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 687 | qla2x00_sp_compl(void *ptr, int res) |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 688 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 689 | srb_t *sp = ptr; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 690 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 691 | |
| 692 | cmd->result = res; |
| 693 | |
| 694 | if (atomic_read(&sp->ref_count) == 0) { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 695 | ql_dbg(ql_dbg_io, sp->vha, 0x3015, |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 696 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 697 | sp, GET_CMD_SP(sp)); |
| 698 | if (ql2xextended_error_logging & ql_dbg_io) |
Hiral Patel | 8fbdac8 | 2015-08-04 13:37:56 -0400 | [diff] [blame] | 699 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 700 | return; |
| 701 | } |
| 702 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 703 | return; |
| 704 | |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 705 | qla2x00_sp_free_dma(sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 706 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 707 | } |
| 708 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 709 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 710 | qla2xxx_qpair_sp_free_dma(void *ptr) |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 711 | { |
| 712 | srb_t *sp = (srb_t *)ptr; |
| 713 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 714 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 715 | void *ctx = GET_CMD_CTX_SP(sp); |
| 716 | |
| 717 | if (sp->flags & SRB_DMA_VALID) { |
| 718 | scsi_dma_unmap(cmd); |
| 719 | sp->flags &= ~SRB_DMA_VALID; |
| 720 | } |
| 721 | |
| 722 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 723 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 724 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 725 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 726 | } |
| 727 | |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 728 | if (!ctx) |
| 729 | goto end; |
| 730 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 731 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 732 | /* List assured to be having elements */ |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 733 | qla2x00_clean_dsd_pool(ha, ctx); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 734 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 735 | } |
| 736 | |
| 737 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 738 | struct crc_context *ctx0 = ctx; |
| 739 | |
| 740 | dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 741 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 742 | } |
| 743 | |
| 744 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 745 | struct ct6_dsd *ctx1 = ctx; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 746 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 747 | ctx1->fcp_cmnd_dma); |
| 748 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 749 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 750 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 751 | mempool_free(ctx1, ha->ctx_mempool); |
| 752 | } |
Joe Carnuccio | d5ff0ee | 2017-05-24 18:06:24 -0700 | [diff] [blame] | 753 | end: |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 754 | CMD_SP(cmd) = NULL; |
| 755 | qla2xxx_rel_qpair_sp(sp->qpair, sp); |
| 756 | } |
| 757 | |
| 758 | void |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 759 | qla2xxx_qpair_sp_compl(void *ptr, int res) |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 760 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 761 | srb_t *sp = ptr; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 762 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 763 | |
| 764 | cmd->result = res; |
| 765 | |
| 766 | if (atomic_read(&sp->ref_count) == 0) { |
| 767 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079, |
| 768 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 769 | sp, GET_CMD_SP(sp)); |
| 770 | if (ql2xextended_error_logging & ql_dbg_io) |
| 771 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
| 772 | return; |
| 773 | } |
| 774 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 775 | return; |
| 776 | |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 777 | qla2xxx_qpair_sp_free_dma(sp); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 778 | cmd->scsi_done(cmd); |
| 779 | } |
| 780 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 781 | /* If we are SP1 here, we need to still take and release the host_lock as SP1 |
| 782 | * does not have the changes necessary to avoid taking host->host_lock. |
| 783 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 785 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 786 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 787 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 788 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 789 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 790 | struct qla_hw_data *ha = vha->hw; |
| 791 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 792 | srb_t *sp; |
| 793 | int rval; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 794 | struct qla_qpair *qpair = NULL; |
| 795 | uint32_t tag; |
| 796 | uint16_t hwq; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 797 | |
Mauricio Faria de Oliveira | 04dfaa5 | 2016-11-07 17:53:30 -0200 | [diff] [blame] | 798 | if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { |
| 799 | cmd->result = DID_NO_CONNECT << 16; |
| 800 | goto qc24_fail_command; |
| 801 | } |
| 802 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 803 | if (ha->mqenable) { |
| 804 | if (shost_use_blk_mq(vha->host)) { |
| 805 | tag = blk_mq_unique_tag(cmd->request); |
| 806 | hwq = blk_mq_unique_tag_to_hwq(tag); |
| 807 | qpair = ha->queue_pair_map[hwq]; |
| 808 | } else if (vha->vp_idx && vha->qpair) { |
| 809 | qpair = vha->qpair; |
| 810 | } |
| 811 | |
| 812 | if (qpair) |
| 813 | return qla2xxx_mqueuecommand(host, cmd, qpair); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 814 | } |
| 815 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 816 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 817 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 818 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 819 | "PCI Channel IO permanent failure, exiting " |
| 820 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 821 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 822 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 823 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 824 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 825 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 826 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 827 | goto qc24_fail_command; |
| 828 | } |
| 829 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 830 | rval = fc_remote_port_chkready(rport); |
| 831 | if (rval) { |
| 832 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 833 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 834 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 835 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 836 | goto qc24_fail_command; |
| 837 | } |
| 838 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 839 | if (!vha->flags.difdix_supported && |
| 840 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 841 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 842 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 843 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 844 | cmd->result = DID_NO_CONNECT << 16; |
| 845 | goto qc24_fail_command; |
| 846 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 847 | |
| 848 | if (!fcport) { |
| 849 | cmd->result = DID_NO_CONNECT << 16; |
| 850 | goto qc24_fail_command; |
| 851 | } |
| 852 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 853 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 854 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 855 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 856 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 857 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 858 | atomic_read(&fcport->state), |
| 859 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 860 | cmd->result = DID_NO_CONNECT << 16; |
| 861 | goto qc24_fail_command; |
| 862 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 863 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 864 | } |
| 865 | |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 866 | /* |
| 867 | * Return target busy if we've received a non-zero retry_delay_timer |
| 868 | * in a FCP_RSP. |
| 869 | */ |
Bruno Prémont | 975f7d4 | 2014-12-19 10:29:16 +0100 | [diff] [blame] | 870 | if (fcport->retry_delay_timestamp == 0) { |
| 871 | /* retry delay not set */ |
| 872 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 873 | fcport->retry_delay_timestamp = 0; |
| 874 | else |
| 875 | goto qc24_target_busy; |
| 876 | |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 877 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 878 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 879 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 880 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 881 | sp->u.scmd.cmd = cmd; |
| 882 | sp->type = SRB_SCSI_CMD; |
| 883 | atomic_set(&sp->ref_count, 1); |
| 884 | CMD_SP(cmd) = (void *)sp; |
| 885 | sp->free = qla2x00_sp_free_dma; |
| 886 | sp->done = qla2x00_sp_compl; |
| 887 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 888 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 889 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 890 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 891 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 892 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 893 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 894 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 895 | return 0; |
| 896 | |
| 897 | qc24_host_busy_free_sp: |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 898 | qla2x00_sp_free_dma(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 899 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 900 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 901 | return SCSI_MLQUEUE_HOST_BUSY; |
| 902 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 903 | qc24_target_busy: |
| 904 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 905 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 906 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 907 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 908 | |
| 909 | return 0; |
| 910 | } |
| 911 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 912 | /* For MQ supported I/O */ |
| 913 | int |
| 914 | qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 915 | struct qla_qpair *qpair) |
| 916 | { |
| 917 | scsi_qla_host_t *vha = shost_priv(host); |
| 918 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 919 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
| 920 | struct qla_hw_data *ha = vha->hw; |
| 921 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
| 922 | srb_t *sp; |
| 923 | int rval; |
| 924 | |
| 925 | rval = fc_remote_port_chkready(rport); |
| 926 | if (rval) { |
| 927 | cmd->result = rval; |
| 928 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3076, |
| 929 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 930 | cmd, rval); |
| 931 | goto qc24_fail_command; |
| 932 | } |
| 933 | |
| 934 | if (!fcport) { |
| 935 | cmd->result = DID_NO_CONNECT << 16; |
| 936 | goto qc24_fail_command; |
| 937 | } |
| 938 | |
| 939 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 940 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
| 941 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
| 942 | ql_dbg(ql_dbg_io, vha, 0x3077, |
| 943 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 944 | atomic_read(&fcport->state), |
| 945 | atomic_read(&base_vha->loop_state)); |
| 946 | cmd->result = DID_NO_CONNECT << 16; |
| 947 | goto qc24_fail_command; |
| 948 | } |
| 949 | goto qc24_target_busy; |
| 950 | } |
| 951 | |
| 952 | /* |
| 953 | * Return target busy if we've received a non-zero retry_delay_timer |
| 954 | * in a FCP_RSP. |
| 955 | */ |
| 956 | if (fcport->retry_delay_timestamp == 0) { |
| 957 | /* retry delay not set */ |
| 958 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
| 959 | fcport->retry_delay_timestamp = 0; |
| 960 | else |
| 961 | goto qc24_target_busy; |
| 962 | |
| 963 | sp = qla2xxx_get_qpair_sp(qpair, fcport, GFP_ATOMIC); |
| 964 | if (!sp) |
| 965 | goto qc24_host_busy; |
| 966 | |
| 967 | sp->u.scmd.cmd = cmd; |
| 968 | sp->type = SRB_SCSI_CMD; |
| 969 | atomic_set(&sp->ref_count, 1); |
| 970 | CMD_SP(cmd) = (void *)sp; |
| 971 | sp->free = qla2xxx_qpair_sp_free_dma; |
| 972 | sp->done = qla2xxx_qpair_sp_compl; |
| 973 | sp->qpair = qpair; |
| 974 | |
| 975 | rval = ha->isp_ops->start_scsi_mq(sp); |
| 976 | if (rval != QLA_SUCCESS) { |
| 977 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3078, |
| 978 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
| 979 | if (rval == QLA_INTERFACE_ERROR) |
| 980 | goto qc24_fail_command; |
| 981 | goto qc24_host_busy_free_sp; |
| 982 | } |
| 983 | |
| 984 | return 0; |
| 985 | |
| 986 | qc24_host_busy_free_sp: |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 987 | qla2xxx_qpair_sp_free_dma(sp); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 988 | |
| 989 | qc24_host_busy: |
| 990 | return SCSI_MLQUEUE_HOST_BUSY; |
| 991 | |
| 992 | qc24_target_busy: |
| 993 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 994 | |
| 995 | qc24_fail_command: |
| 996 | cmd->scsi_done(cmd); |
| 997 | |
| 998 | return 0; |
| 999 | } |
| 1000 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1001 | /* |
| 1002 | * qla2x00_eh_wait_on_command |
| 1003 | * Waits for the command to be returned by the Firmware for some |
| 1004 | * max time. |
| 1005 | * |
| 1006 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | * |
| 1009 | * Return: |
| 1010 | * Not Found : 0 |
| 1011 | * Found : 1 |
| 1012 | */ |
| 1013 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1014 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 1016 | #define ABORT_POLLING_PERIOD 1000 |
Chad Dupuis | 478c3b0 | 2014-04-11 16:54:35 -0400 | [diff] [blame] | 1017 | #define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1018 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1019 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1020 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1021 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1023 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1024 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 1025 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 1026 | return ret; |
| 1027 | } |
| 1028 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 1029 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 1030 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1031 | } |
| 1032 | if (CMD_SP(cmd)) |
| 1033 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1034 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1035 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | /* |
| 1039 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1040 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 1042 | * finally HBA is disabled ie marked offline |
| 1043 | * |
| 1044 | * Input: |
| 1045 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1046 | * |
| 1047 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | * Does context switching-Release SPIN_LOCK |
| 1049 | * (if any) before calling this routine. |
| 1050 | * |
| 1051 | * Return: |
| 1052 | * Success (Adapter is online) : 0 |
| 1053 | * Failed (Adapter is offline/disabled) : 1 |
| 1054 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 1055 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1056 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1057 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 1058 | int return_status; |
| 1059 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1060 | struct qla_hw_data *ha = vha->hw; |
| 1061 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1063 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1064 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1065 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1066 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1067 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | |
| 1069 | msleep(1000); |
| 1070 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1071 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1072 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | else |
| 1074 | return_status = QLA_FUNCTION_FAILED; |
| 1075 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1076 | return (return_status); |
| 1077 | } |
| 1078 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1079 | static inline int test_fcport_count(scsi_qla_host_t *vha) |
| 1080 | { |
| 1081 | struct qla_hw_data *ha = vha->hw; |
| 1082 | unsigned long flags; |
| 1083 | int res; |
| 1084 | |
| 1085 | spin_lock_irqsave(&ha->tgt.sess_lock, flags); |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 1086 | ql_dbg(ql_dbg_init, vha, 0x00ec, |
| 1087 | "tgt %p, fcport_count=%d\n", |
| 1088 | vha, vha->fcport_count); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1089 | res = (vha->fcport_count == 0); |
| 1090 | spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); |
| 1091 | |
| 1092 | return res; |
| 1093 | } |
| 1094 | |
| 1095 | /* |
| 1096 | * qla2x00_wait_for_sess_deletion can only be called from remove_one. |
| 1097 | * it has dependency on UNLOADING flag to stop device discovery |
| 1098 | */ |
| 1099 | static void |
| 1100 | qla2x00_wait_for_sess_deletion(scsi_qla_host_t *vha) |
| 1101 | { |
| 1102 | qla2x00_mark_all_devices_lost(vha, 0); |
| 1103 | |
| 1104 | wait_event(vha->fcport_waitQ, test_fcport_count(vha)); |
| 1105 | } |
| 1106 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1107 | /* |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1108 | * qla2x00_wait_for_hba_ready |
| 1109 | * Wait till the HBA is ready before doing driver unload |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1110 | * |
| 1111 | * Input: |
| 1112 | * ha - pointer to host adapter structure |
| 1113 | * |
| 1114 | * Note: |
| 1115 | * Does context switching-Release SPIN_LOCK |
| 1116 | * (if any) before calling this routine. |
| 1117 | * |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1118 | */ |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1119 | static void |
| 1120 | qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1121 | { |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1122 | struct qla_hw_data *ha = vha->hw; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1123 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1124 | |
Dan Carpenter | 1d48390 | 2016-08-03 21:42:32 +0300 | [diff] [blame] | 1125 | while ((qla2x00_reset_active(vha) || ha->dpc_active || |
| 1126 | ha->flags.mbox_busy) || |
| 1127 | test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags) || |
| 1128 | test_bit(FX00_TARGET_SCAN, &vha->dpc_flags)) { |
| 1129 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 1130 | break; |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1131 | msleep(1000); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1132 | } |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1133 | } |
| 1134 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 1135 | int |
| 1136 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 1137 | { |
| 1138 | int return_status; |
| 1139 | unsigned long wait_reset; |
| 1140 | struct qla_hw_data *ha = vha->hw; |
| 1141 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 1142 | |
| 1143 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 1144 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1145 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1146 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1147 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 1148 | |
| 1149 | msleep(1000); |
| 1150 | |
| 1151 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 1152 | ha->flags.chip_reset_done) |
| 1153 | break; |
| 1154 | } |
| 1155 | if (ha->flags.chip_reset_done) |
| 1156 | return_status = QLA_SUCCESS; |
| 1157 | else |
| 1158 | return_status = QLA_FUNCTION_FAILED; |
| 1159 | |
| 1160 | return return_status; |
| 1161 | } |
| 1162 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 1163 | static void |
| 1164 | sp_get(struct srb *sp) |
| 1165 | { |
| 1166 | atomic_inc(&sp->ref_count); |
| 1167 | } |
| 1168 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1169 | #define ISP_REG_DISCONNECT 0xffffffffU |
| 1170 | /************************************************************************** |
| 1171 | * qla2x00_isp_reg_stat |
| 1172 | * |
| 1173 | * Description: |
| 1174 | * Read the host status register of ISP before aborting the command. |
| 1175 | * |
| 1176 | * Input: |
| 1177 | * ha = pointer to host adapter structure. |
| 1178 | * |
| 1179 | * |
| 1180 | * Returns: |
| 1181 | * Either true or false. |
| 1182 | * |
| 1183 | * Note: Return true if there is register disconnect. |
| 1184 | **************************************************************************/ |
| 1185 | static inline |
| 1186 | uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) |
| 1187 | { |
| 1188 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
Sawan Chandak | bf6061b1 | 2017-03-31 14:37:03 -0700 | [diff] [blame] | 1189 | struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1190 | |
Sawan Chandak | bf6061b1 | 2017-03-31 14:37:03 -0700 | [diff] [blame] | 1191 | if (IS_P3P_TYPE(ha)) |
| 1192 | return ((RD_REG_DWORD(®82->host_int)) == ISP_REG_DISCONNECT); |
| 1193 | else |
| 1194 | return ((RD_REG_DWORD(®->host_status)) == |
| 1195 | ISP_REG_DISCONNECT); |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1196 | } |
| 1197 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | /************************************************************************** |
| 1199 | * qla2xxx_eh_abort |
| 1200 | * |
| 1201 | * Description: |
| 1202 | * The abort function will abort the specified command. |
| 1203 | * |
| 1204 | * Input: |
| 1205 | * cmd = Linux SCSI command packet to be aborted. |
| 1206 | * |
| 1207 | * Returns: |
| 1208 | * Either SUCCESS or FAILED. |
| 1209 | * |
| 1210 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1211 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1212 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1213 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1214 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 1215 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1216 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1217 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1218 | int ret; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1219 | unsigned int id; |
| 1220 | uint64_t lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1221 | unsigned long flags; |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1222 | int rval, wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1223 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1224 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1225 | if (qla2x00_isp_reg_stat(ha)) { |
| 1226 | ql_log(ql_log_info, vha, 0x8042, |
| 1227 | "PCI/Register disconnect, exiting.\n"); |
| 1228 | return FAILED; |
| 1229 | } |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1230 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1231 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1233 | ret = fc_block_scsi_eh(cmd); |
| 1234 | if (ret != 0) |
| 1235 | return ret; |
| 1236 | ret = SUCCESS; |
| 1237 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1238 | id = cmd->device->id; |
| 1239 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1240 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1241 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1242 | sp = (srb_t *) CMD_SP(cmd); |
| 1243 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1244 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1245 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1246 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1247 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1248 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | c7bc4ca | 2015-08-04 13:37:57 -0400 | [diff] [blame] | 1249 | "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n", |
| 1250 | vha->host_no, id, lun, sp, cmd, sp->handle); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1251 | |
| 1252 | /* Get a reference to the sp and drop the lock.*/ |
| 1253 | sp_get(sp); |
| 1254 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1255 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1256 | rval = ha->isp_ops->abort_command(sp); |
| 1257 | if (rval) { |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1258 | if (rval == QLA_FUNCTION_PARAMETER_ERROR) |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1259 | ret = SUCCESS; |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1260 | else |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1261 | ret = FAILED; |
| 1262 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1263 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1264 | "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1265 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1266 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1267 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1268 | wait = 1; |
| 1269 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1270 | |
| 1271 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 1272 | sp->done(sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1273 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1274 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 1275 | /* Did the command return during mailbox execution? */ |
| 1276 | if (ret == FAILED && !CMD_SP(cmd)) |
| 1277 | ret = SUCCESS; |
| 1278 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1279 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1280 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1281 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1282 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1283 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1284 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1285 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1286 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1287 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1288 | ql_log(ql_log_info, vha, 0x801c, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1289 | "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1290 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1291 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1292 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1293 | } |
| 1294 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1295 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1296 | 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] | 1297 | uint64_t l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1298 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1299 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1300 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1301 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1302 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1303 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1304 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1305 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1306 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1307 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1308 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1309 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1310 | for (cnt = 1; status == QLA_SUCCESS && |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1311 | cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1312 | sp = req->outstanding_cmds[cnt]; |
| 1313 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1314 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1315 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1316 | continue; |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 1317 | if (vha->vp_idx != sp->vha->vp_idx) |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1318 | continue; |
| 1319 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1320 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1321 | switch (type) { |
| 1322 | case WAIT_HOST: |
| 1323 | match = 1; |
| 1324 | break; |
| 1325 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1326 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1327 | break; |
| 1328 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1329 | match = (cmd->device->id == t && |
| 1330 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1331 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1332 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1333 | if (!match) |
| 1334 | continue; |
| 1335 | |
| 1336 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1337 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1338 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1340 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1341 | |
| 1342 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1343 | } |
| 1344 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1345 | static char *reset_errors[] = { |
| 1346 | "HBA not online", |
| 1347 | "HBA not ready", |
| 1348 | "Task management failed", |
| 1349 | "Waiting for command completions", |
| 1350 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1351 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1352 | static int |
| 1353 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1354 | 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] | 1355 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1356 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1357 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1358 | int err; |
| 1359 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1360 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1361 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1362 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1363 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1364 | err = fc_block_scsi_eh(cmd); |
| 1365 | if (err != 0) |
| 1366 | return err; |
| 1367 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1368 | ql_log(ql_log_info, vha, 0x8009, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1369 | "%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] | 1370 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1371 | |
| 1372 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1373 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1374 | ql_log(ql_log_warn, vha, 0x800a, |
| 1375 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1376 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1377 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1378 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1379 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1380 | != QLA_SUCCESS) { |
| 1381 | ql_log(ql_log_warn, vha, 0x800c, |
| 1382 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1383 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1384 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1385 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1386 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1387 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1388 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1389 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1390 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1391 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1392 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1393 | ql_log(ql_log_info, vha, 0x800e, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1394 | "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1395 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1396 | |
| 1397 | return SUCCESS; |
| 1398 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1399 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1400 | ql_log(ql_log_info, vha, 0x800f, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1401 | "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1402 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1403 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1404 | return FAILED; |
| 1405 | } |
| 1406 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1407 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1408 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1409 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1410 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1411 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1412 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1413 | if (qla2x00_isp_reg_stat(ha)) { |
| 1414 | ql_log(ql_log_info, vha, 0x803e, |
| 1415 | "PCI/Register disconnect, exiting.\n"); |
| 1416 | return FAILED; |
| 1417 | } |
| 1418 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1419 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1420 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1421 | } |
| 1422 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1424 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1425 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1426 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1427 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1429 | if (qla2x00_isp_reg_stat(ha)) { |
| 1430 | ql_log(ql_log_info, vha, 0x803f, |
| 1431 | "PCI/Register disconnect, exiting.\n"); |
| 1432 | return FAILED; |
| 1433 | } |
| 1434 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1435 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1436 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1437 | } |
| 1438 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | /************************************************************************** |
| 1440 | * qla2xxx_eh_bus_reset |
| 1441 | * |
| 1442 | * Description: |
| 1443 | * The bus reset function will reset the bus and abort any executing |
| 1444 | * commands. |
| 1445 | * |
| 1446 | * Input: |
| 1447 | * cmd = Linux SCSI command packet of the command that cause the |
| 1448 | * bus reset. |
| 1449 | * |
| 1450 | * Returns: |
| 1451 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1452 | * |
| 1453 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1454 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1455 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1456 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1457 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1458 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1459 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1460 | unsigned int id; |
| 1461 | uint64_t lun; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1462 | struct qla_hw_data *ha = vha->hw; |
| 1463 | |
| 1464 | if (qla2x00_isp_reg_stat(ha)) { |
| 1465 | ql_log(ql_log_info, vha, 0x8040, |
| 1466 | "PCI/Register disconnect, exiting.\n"); |
| 1467 | return FAILED; |
| 1468 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1469 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1470 | id = cmd->device->id; |
| 1471 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1472 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1473 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1474 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1475 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1477 | ret = fc_block_scsi_eh(cmd); |
| 1478 | if (ret != 0) |
| 1479 | return ret; |
| 1480 | ret = FAILED; |
| 1481 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1482 | ql_log(ql_log_info, vha, 0x8012, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1483 | "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] | 1484 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1485 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1486 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1487 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1488 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | } |
| 1490 | |
Saurav Kashyap | ad537689 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1491 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1492 | ret = SUCCESS; |
| 1493 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1494 | if (ret == FAILED) |
| 1495 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1496 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1497 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1498 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1499 | QLA_SUCCESS) { |
| 1500 | ql_log(ql_log_warn, vha, 0x8014, |
| 1501 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1502 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1503 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1504 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1505 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1506 | ql_log(ql_log_warn, vha, 0x802b, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1507 | "BUS RESET %s nexus=%ld:%d:%llu.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1508 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1509 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1510 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1511 | } |
| 1512 | |
| 1513 | /************************************************************************** |
| 1514 | * qla2xxx_eh_host_reset |
| 1515 | * |
| 1516 | * Description: |
| 1517 | * The reset function will reset the Adapter. |
| 1518 | * |
| 1519 | * Input: |
| 1520 | * cmd = Linux SCSI command packet of the command that cause the |
| 1521 | * adapter reset. |
| 1522 | * |
| 1523 | * Returns: |
| 1524 | * Either SUCCESS or FAILED. |
| 1525 | * |
| 1526 | * Note: |
| 1527 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1528 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1529 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1530 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1531 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1532 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1533 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1534 | unsigned int id; |
| 1535 | uint64_t lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1536 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1538 | if (qla2x00_isp_reg_stat(ha)) { |
| 1539 | ql_log(ql_log_info, vha, 0x8041, |
| 1540 | "PCI/Register disconnect, exiting.\n"); |
| 1541 | schedule_work(&ha->board_disable); |
| 1542 | return SUCCESS; |
| 1543 | } |
| 1544 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1545 | id = cmd->device->id; |
| 1546 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1547 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1548 | ql_log(ql_log_info, vha, 0x8018, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1549 | "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] | 1550 | |
Chad Dupuis | 63ee707 | 2014-04-11 16:54:46 -0400 | [diff] [blame] | 1551 | /* |
| 1552 | * No point in issuing another reset if one is active. Also do not |
| 1553 | * attempt a reset if we are updating flash. |
| 1554 | */ |
| 1555 | if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1556 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1557 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1558 | if (vha != base_vha) { |
| 1559 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1560 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1561 | } else { |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1562 | if (IS_P3P_TYPE(vha->hw)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1563 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1564 | /* Ctx reset success */ |
| 1565 | ret = SUCCESS; |
| 1566 | goto eh_host_reset_lock; |
| 1567 | } |
| 1568 | /* fall thru if ctx reset failed */ |
| 1569 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1570 | if (ha->wq) |
| 1571 | flush_workqueue(ha->wq); |
| 1572 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1573 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1574 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1575 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1576 | /* failed. schedule dpc to try */ |
| 1577 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1578 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1579 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1580 | ql_log(ql_log_warn, vha, 0x802a, |
| 1581 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1582 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1583 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1584 | } |
| 1585 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1586 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1587 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1588 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1589 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1590 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1591 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1592 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1593 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1594 | ql_log(ql_log_info, vha, 0x8017, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1595 | "ADAPTER RESET %s nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1596 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1597 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1598 | return ret; |
| 1599 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1600 | |
| 1601 | /* |
| 1602 | * qla2x00_loop_reset |
| 1603 | * Issue loop reset. |
| 1604 | * |
| 1605 | * Input: |
| 1606 | * ha = adapter block pointer. |
| 1607 | * |
| 1608 | * Returns: |
| 1609 | * 0 = success |
| 1610 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1611 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1612 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1613 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1614 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1615 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1616 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1617 | |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1618 | if (IS_QLAFX00(ha)) { |
| 1619 | return qlafx00_loop_reset(vha); |
| 1620 | } |
| 1621 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1622 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1623 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1624 | if (fcport->port_type != FCT_TARGET) |
| 1625 | continue; |
| 1626 | |
| 1627 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1628 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1629 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1630 | "Bus Reset failed: Reset=%d " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1631 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1632 | } |
| 1633 | } |
| 1634 | } |
| 1635 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1636 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1637 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Andrew Vasquez | 0b7e7c5 | 2013-02-08 01:57:42 -0500 | [diff] [blame] | 1638 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1639 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1640 | qla2x00_mark_all_devices_lost(vha, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1641 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1642 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1643 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1644 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1645 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | } |
| 1647 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1648 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1649 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad537689 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1650 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1651 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1652 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1653 | } |
| 1654 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1655 | /* 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] | 1656 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1657 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1658 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1659 | } |
| 1660 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1661 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1662 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1663 | { |
Bill Kuzeja | 4cd3b6e | 2017-05-25 15:26:31 -0400 | [diff] [blame] | 1664 | int que, cnt, status; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1665 | unsigned long flags; |
| 1666 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1667 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1668 | struct req_que *req; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 1669 | struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; |
| 1670 | struct qla_tgt_cmd *cmd; |
| 1671 | uint8_t trace = 0; |
Arun Easi | c0cb449 | 2014-09-25 06:14:51 -0400 | [diff] [blame] | 1672 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1673 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1674 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1675 | req = ha->req_q_map[que]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1676 | if (!req) |
| 1677 | continue; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1678 | if (!req->outstanding_cmds) |
| 1679 | continue; |
| 1680 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1681 | sp = req->outstanding_cmds[cnt]; |
Andrew Vasquez | e612d46 | 2009-03-24 09:08:04 -0700 | [diff] [blame] | 1682 | if (sp) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1683 | req->outstanding_cmds[cnt] = NULL; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 1684 | if (sp->cmd_type == TYPE_SRB) { |
| 1685 | /* |
| 1686 | * Don't abort commands in adapter |
| 1687 | * during EEH recovery as it's not |
| 1688 | * accessible/responding. |
| 1689 | */ |
| 1690 | if (GET_CMD_SP(sp) && |
| 1691 | !ha->flags.eeh_busy && |
| 1692 | (sp->type == SRB_SCSI_CMD)) { |
| 1693 | /* |
| 1694 | * Get a reference to the sp |
| 1695 | * and drop the lock. The |
| 1696 | * reference ensures this |
| 1697 | * sp->done() call and not the |
| 1698 | * call in qla2xxx_eh_abort() |
| 1699 | * ends the SCSI command (with |
| 1700 | * result 'res'). |
| 1701 | */ |
| 1702 | sp_get(sp); |
| 1703 | spin_unlock_irqrestore( |
| 1704 | &ha->hardware_lock, flags); |
| 1705 | status = qla2xxx_eh_abort( |
| 1706 | GET_CMD_SP(sp)); |
| 1707 | spin_lock_irqsave( |
| 1708 | &ha->hardware_lock, flags); |
| 1709 | /* |
| 1710 | * Get rid of extra reference |
| 1711 | * if immediate exit from |
| 1712 | * ql2xxx_eh_abort |
| 1713 | */ |
| 1714 | if (status == FAILED && |
| 1715 | (qla2x00_isp_reg_stat(ha))) |
| 1716 | atomic_dec( |
| 1717 | &sp->ref_count); |
| 1718 | } |
| 1719 | sp->done(sp, res); |
| 1720 | } else { |
| 1721 | if (!vha->hw->tgt.tgt_ops || !tgt || |
| 1722 | qla_ini_mode_enabled(vha)) { |
| 1723 | if (!trace) |
| 1724 | ql_dbg(ql_dbg_tgt_mgt, |
| 1725 | vha, 0xf003, |
| 1726 | "HOST-ABORT-HNDLR: dpc_flags=%lx. Target mode disabled\n", |
| 1727 | vha->dpc_flags); |
| 1728 | continue; |
| 1729 | } |
| 1730 | cmd = (struct qla_tgt_cmd *)sp; |
| 1731 | qlt_abort_cmd_on_host_reset(cmd->vha, |
| 1732 | cmd); |
| 1733 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1734 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1735 | } |
| 1736 | } |
| 1737 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1738 | } |
| 1739 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1740 | static int |
| 1741 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1742 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1743 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1744 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1745 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1746 | return -ENXIO; |
| 1747 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1748 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1749 | |
| 1750 | return 0; |
| 1751 | } |
| 1752 | |
| 1753 | static int |
| 1754 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1755 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1756 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1757 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1758 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1759 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1760 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1761 | |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 1762 | scsi_change_queue_depth(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1763 | return 0; |
| 1764 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1765 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1766 | static void |
| 1767 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1768 | { |
| 1769 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1770 | } |
| 1771 | |
| 1772 | /** |
| 1773 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1774 | * @ha: HA context |
| 1775 | * |
| 1776 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1777 | * supported addressing method. |
| 1778 | */ |
| 1779 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1780 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1781 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1782 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1783 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1784 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1785 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1786 | /* Any upper-dword bits set? */ |
| 1787 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1788 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1789 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1790 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1791 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1792 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1793 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1794 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1795 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1796 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1797 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1798 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1799 | } |
| 1800 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1801 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1802 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1803 | { |
| 1804 | unsigned long flags = 0; |
| 1805 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1806 | |
| 1807 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1808 | ha->interrupts_on = 1; |
| 1809 | /* enable risc and host interrupts */ |
| 1810 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1811 | RD_REG_WORD(®->ictrl); |
| 1812 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1813 | |
| 1814 | } |
| 1815 | |
| 1816 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1817 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1818 | { |
| 1819 | unsigned long flags = 0; |
| 1820 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1821 | |
| 1822 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1823 | ha->interrupts_on = 0; |
| 1824 | /* disable risc and host interrupts */ |
| 1825 | WRT_REG_WORD(®->ictrl, 0); |
| 1826 | RD_REG_WORD(®->ictrl); |
| 1827 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1828 | } |
| 1829 | |
| 1830 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1831 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1832 | { |
| 1833 | unsigned long flags = 0; |
| 1834 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1835 | |
| 1836 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1837 | ha->interrupts_on = 1; |
| 1838 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1839 | RD_REG_DWORD(®->ictrl); |
| 1840 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1841 | } |
| 1842 | |
| 1843 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1844 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1845 | { |
| 1846 | unsigned long flags = 0; |
| 1847 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1848 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1849 | if (IS_NOPOLLING_TYPE(ha)) |
| 1850 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1851 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1852 | ha->interrupts_on = 0; |
| 1853 | WRT_REG_DWORD(®->ictrl, 0); |
| 1854 | RD_REG_DWORD(®->ictrl); |
| 1855 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1856 | } |
| 1857 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1858 | static int |
| 1859 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1860 | { |
| 1861 | resource_size_t pio; |
| 1862 | uint16_t msix; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1863 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1864 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1865 | QLA2XXX_DRIVER_NAME)) { |
| 1866 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1867 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1868 | pci_name(ha->pdev)); |
| 1869 | goto iospace_error_exit; |
| 1870 | } |
| 1871 | if (!(ha->bars & 1)) |
| 1872 | goto skip_pio; |
| 1873 | |
| 1874 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1875 | pio = pci_resource_start(ha->pdev, 0); |
| 1876 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1877 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1878 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1879 | "Invalid pci I/O region size (%s).\n", |
| 1880 | pci_name(ha->pdev)); |
| 1881 | pio = 0; |
| 1882 | } |
| 1883 | } else { |
| 1884 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1885 | "Region #0 no a PIO resource (%s).\n", |
| 1886 | pci_name(ha->pdev)); |
| 1887 | pio = 0; |
| 1888 | } |
| 1889 | ha->pio_address = pio; |
| 1890 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1891 | "PIO address=%llu.\n", |
| 1892 | (unsigned long long)ha->pio_address); |
| 1893 | |
| 1894 | skip_pio: |
| 1895 | /* Use MMIO operations for all accesses. */ |
| 1896 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1897 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1898 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1899 | pci_name(ha->pdev)); |
| 1900 | goto iospace_error_exit; |
| 1901 | } |
| 1902 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1903 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1904 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1905 | pci_name(ha->pdev)); |
| 1906 | goto iospace_error_exit; |
| 1907 | } |
| 1908 | |
| 1909 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1910 | if (!ha->iobase) { |
| 1911 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1912 | "Cannot remap MMIO (%s), aborting.\n", |
| 1913 | pci_name(ha->pdev)); |
| 1914 | goto iospace_error_exit; |
| 1915 | } |
| 1916 | |
| 1917 | /* Determine queue resources */ |
| 1918 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 1919 | ha->msix_count = QLA_BASE_VECTORS; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1920 | if (!ql2xmqsupport || (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1921 | goto mqiobase_exit; |
| 1922 | |
| 1923 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1924 | pci_resource_len(ha->pdev, 3)); |
| 1925 | if (ha->mqiobase) { |
| 1926 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 1927 | "MQIO Base=%p.\n", ha->mqiobase); |
| 1928 | /* Read MSIX vector size of the board */ |
| 1929 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1930 | ha->msix_count = msix + 1; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1931 | /* Max queues are bounded by available msix vectors */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1932 | /* MB interrupt uses 1 vector */ |
| 1933 | ha->max_req_queues = ha->msix_count - 1; |
| 1934 | ha->max_rsp_queues = ha->max_req_queues; |
| 1935 | /* Queue pairs is the max value minus the base queue pair */ |
| 1936 | ha->max_qpairs = ha->max_rsp_queues - 1; |
| 1937 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0188, |
| 1938 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
| 1939 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1940 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1941 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1942 | } else |
| 1943 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 1944 | "BAR 3 not enabled.\n"); |
| 1945 | |
| 1946 | mqiobase_exit: |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1947 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 1948 | "MSIX Count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1949 | return (0); |
| 1950 | |
| 1951 | iospace_error_exit: |
| 1952 | return (-ENOMEM); |
| 1953 | } |
| 1954 | |
| 1955 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1956 | static int |
| 1957 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 1958 | { |
| 1959 | uint16_t msix; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1960 | |
| 1961 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1962 | QLA2XXX_DRIVER_NAME)) { |
| 1963 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 1964 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1965 | pci_name(ha->pdev)); |
| 1966 | |
| 1967 | goto iospace_error_exit; |
| 1968 | } |
| 1969 | |
| 1970 | /* Use MMIO operations for all accesses. */ |
| 1971 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 1972 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 1973 | "Invalid pci I/O region size (%s).\n", |
| 1974 | pci_name(ha->pdev)); |
| 1975 | goto iospace_error_exit; |
| 1976 | } |
| 1977 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1978 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 1979 | "Invalid PCI mem region size (%s), aborting\n", |
| 1980 | pci_name(ha->pdev)); |
| 1981 | goto iospace_error_exit; |
| 1982 | } |
| 1983 | |
| 1984 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 1985 | if (!ha->iobase) { |
| 1986 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 1987 | "Cannot remap MMIO (%s), aborting.\n", |
| 1988 | pci_name(ha->pdev)); |
| 1989 | goto iospace_error_exit; |
| 1990 | } |
| 1991 | |
| 1992 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 1993 | /* 83XX 26XX always use MQ type access for queues |
| 1994 | * - mbar 2, a.k.a region 4 */ |
| 1995 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 1996 | ha->msix_count = QLA_BASE_VECTORS; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1997 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 1998 | pci_resource_len(ha->pdev, 4)); |
| 1999 | |
| 2000 | if (!ha->mqiobase) { |
| 2001 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 2002 | "BAR2/region4 not enabled\n"); |
| 2003 | goto mqiobase_exit; |
| 2004 | } |
| 2005 | |
| 2006 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 2007 | pci_resource_len(ha->pdev, 2)); |
| 2008 | if (ha->msixbase) { |
| 2009 | /* Read MSIX vector size of the board */ |
| 2010 | pci_read_config_word(ha->pdev, |
| 2011 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2012 | ha->msix_count = msix + 1; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 2013 | /* |
| 2014 | * By default, driver uses at least two msix vectors |
| 2015 | * (default & rspq) |
| 2016 | */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2017 | if (ql2xmqsupport) { |
| 2018 | /* MB interrupt uses 1 vector */ |
| 2019 | ha->max_req_queues = ha->msix_count - 1; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 2020 | |
| 2021 | /* ATIOQ needs 1 vector. That's 1 less QPair */ |
| 2022 | if (QLA_TGT_MODE_ENABLED()) |
| 2023 | ha->max_req_queues--; |
| 2024 | |
Michael Hernandez | d0d2c68 | 2017-02-15 15:37:20 -0800 | [diff] [blame] | 2025 | ha->max_rsp_queues = ha->max_req_queues; |
| 2026 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2027 | /* Queue pairs is the max value minus |
| 2028 | * the base queue pair */ |
| 2029 | ha->max_qpairs = ha->max_req_queues - 1; |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2030 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x00e3, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2031 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2032 | } |
| 2033 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2034 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2035 | } else |
| 2036 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 2037 | "BAR 1 not enabled.\n"); |
| 2038 | |
| 2039 | mqiobase_exit: |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2040 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame] | 2041 | "MSIX Count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2042 | return 0; |
| 2043 | |
| 2044 | iospace_error_exit: |
| 2045 | return -ENOMEM; |
| 2046 | } |
| 2047 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2048 | static struct isp_operations qla2100_isp_ops = { |
| 2049 | .pci_config = qla2100_pci_config, |
| 2050 | .reset_chip = qla2x00_reset_chip, |
| 2051 | .chip_diag = qla2x00_chip_diag, |
| 2052 | .config_rings = qla2x00_config_rings, |
| 2053 | .reset_adapter = qla2x00_reset_adapter, |
| 2054 | .nvram_config = qla2x00_nvram_config, |
| 2055 | .update_fw_options = qla2x00_update_fw_options, |
| 2056 | .load_risc = qla2x00_load_risc, |
| 2057 | .pci_info_str = qla2x00_pci_info_str, |
| 2058 | .fw_version_str = qla2x00_fw_version_str, |
| 2059 | .intr_handler = qla2100_intr_handler, |
| 2060 | .enable_intrs = qla2x00_enable_intrs, |
| 2061 | .disable_intrs = qla2x00_disable_intrs, |
| 2062 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2063 | .target_reset = qla2x00_abort_target, |
| 2064 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2065 | .fabric_login = qla2x00_login_fabric, |
| 2066 | .fabric_logout = qla2x00_fabric_logout, |
| 2067 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 2068 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 2069 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 2070 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 2071 | .read_nvram = qla2x00_read_nvram_data, |
| 2072 | .write_nvram = qla2x00_write_nvram_data, |
| 2073 | .fw_dump = qla2100_fw_dump, |
| 2074 | .beacon_on = NULL, |
| 2075 | .beacon_off = NULL, |
| 2076 | .beacon_blink = NULL, |
| 2077 | .read_optrom = qla2x00_read_optrom_data, |
| 2078 | .write_optrom = qla2x00_write_optrom_data, |
| 2079 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2080 | .start_scsi = qla2x00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2081 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2082 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2083 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2084 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2085 | }; |
| 2086 | |
| 2087 | static struct isp_operations qla2300_isp_ops = { |
| 2088 | .pci_config = qla2300_pci_config, |
| 2089 | .reset_chip = qla2x00_reset_chip, |
| 2090 | .chip_diag = qla2x00_chip_diag, |
| 2091 | .config_rings = qla2x00_config_rings, |
| 2092 | .reset_adapter = qla2x00_reset_adapter, |
| 2093 | .nvram_config = qla2x00_nvram_config, |
| 2094 | .update_fw_options = qla2x00_update_fw_options, |
| 2095 | .load_risc = qla2x00_load_risc, |
| 2096 | .pci_info_str = qla2x00_pci_info_str, |
| 2097 | .fw_version_str = qla2x00_fw_version_str, |
| 2098 | .intr_handler = qla2300_intr_handler, |
| 2099 | .enable_intrs = qla2x00_enable_intrs, |
| 2100 | .disable_intrs = qla2x00_disable_intrs, |
| 2101 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2102 | .target_reset = qla2x00_abort_target, |
| 2103 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2104 | .fabric_login = qla2x00_login_fabric, |
| 2105 | .fabric_logout = qla2x00_fabric_logout, |
| 2106 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 2107 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 2108 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 2109 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 2110 | .read_nvram = qla2x00_read_nvram_data, |
| 2111 | .write_nvram = qla2x00_write_nvram_data, |
| 2112 | .fw_dump = qla2300_fw_dump, |
| 2113 | .beacon_on = qla2x00_beacon_on, |
| 2114 | .beacon_off = qla2x00_beacon_off, |
| 2115 | .beacon_blink = qla2x00_beacon_blink, |
| 2116 | .read_optrom = qla2x00_read_optrom_data, |
| 2117 | .write_optrom = qla2x00_write_optrom_data, |
| 2118 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2119 | .start_scsi = qla2x00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2120 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2121 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2122 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2123 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2124 | }; |
| 2125 | |
| 2126 | static struct isp_operations qla24xx_isp_ops = { |
| 2127 | .pci_config = qla24xx_pci_config, |
| 2128 | .reset_chip = qla24xx_reset_chip, |
| 2129 | .chip_diag = qla24xx_chip_diag, |
| 2130 | .config_rings = qla24xx_config_rings, |
| 2131 | .reset_adapter = qla24xx_reset_adapter, |
| 2132 | .nvram_config = qla24xx_nvram_config, |
| 2133 | .update_fw_options = qla24xx_update_fw_options, |
| 2134 | .load_risc = qla24xx_load_risc, |
| 2135 | .pci_info_str = qla24xx_pci_info_str, |
| 2136 | .fw_version_str = qla24xx_fw_version_str, |
| 2137 | .intr_handler = qla24xx_intr_handler, |
| 2138 | .enable_intrs = qla24xx_enable_intrs, |
| 2139 | .disable_intrs = qla24xx_disable_intrs, |
| 2140 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2141 | .target_reset = qla24xx_abort_target, |
| 2142 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2143 | .fabric_login = qla24xx_login_fabric, |
| 2144 | .fabric_logout = qla24xx_fabric_logout, |
| 2145 | .calc_req_entries = NULL, |
| 2146 | .build_iocbs = NULL, |
| 2147 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2148 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2149 | .read_nvram = qla24xx_read_nvram_data, |
| 2150 | .write_nvram = qla24xx_write_nvram_data, |
| 2151 | .fw_dump = qla24xx_fw_dump, |
| 2152 | .beacon_on = qla24xx_beacon_on, |
| 2153 | .beacon_off = qla24xx_beacon_off, |
| 2154 | .beacon_blink = qla24xx_beacon_blink, |
| 2155 | .read_optrom = qla24xx_read_optrom_data, |
| 2156 | .write_optrom = qla24xx_write_optrom_data, |
| 2157 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2158 | .start_scsi = qla24xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2159 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2160 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2161 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2162 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2163 | }; |
| 2164 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2165 | static struct isp_operations qla25xx_isp_ops = { |
| 2166 | .pci_config = qla25xx_pci_config, |
| 2167 | .reset_chip = qla24xx_reset_chip, |
| 2168 | .chip_diag = qla24xx_chip_diag, |
| 2169 | .config_rings = qla24xx_config_rings, |
| 2170 | .reset_adapter = qla24xx_reset_adapter, |
| 2171 | .nvram_config = qla24xx_nvram_config, |
| 2172 | .update_fw_options = qla24xx_update_fw_options, |
| 2173 | .load_risc = qla24xx_load_risc, |
| 2174 | .pci_info_str = qla24xx_pci_info_str, |
| 2175 | .fw_version_str = qla24xx_fw_version_str, |
| 2176 | .intr_handler = qla24xx_intr_handler, |
| 2177 | .enable_intrs = qla24xx_enable_intrs, |
| 2178 | .disable_intrs = qla24xx_disable_intrs, |
| 2179 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2180 | .target_reset = qla24xx_abort_target, |
| 2181 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2182 | .fabric_login = qla24xx_login_fabric, |
| 2183 | .fabric_logout = qla24xx_fabric_logout, |
| 2184 | .calc_req_entries = NULL, |
| 2185 | .build_iocbs = NULL, |
| 2186 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2187 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2188 | .read_nvram = qla25xx_read_nvram_data, |
| 2189 | .write_nvram = qla25xx_write_nvram_data, |
| 2190 | .fw_dump = qla25xx_fw_dump, |
| 2191 | .beacon_on = qla24xx_beacon_on, |
| 2192 | .beacon_off = qla24xx_beacon_off, |
| 2193 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 2194 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2195 | .write_optrom = qla24xx_write_optrom_data, |
| 2196 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2197 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2198 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2199 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2200 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2201 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2202 | }; |
| 2203 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2204 | static struct isp_operations qla81xx_isp_ops = { |
| 2205 | .pci_config = qla25xx_pci_config, |
| 2206 | .reset_chip = qla24xx_reset_chip, |
| 2207 | .chip_diag = qla24xx_chip_diag, |
| 2208 | .config_rings = qla24xx_config_rings, |
| 2209 | .reset_adapter = qla24xx_reset_adapter, |
| 2210 | .nvram_config = qla81xx_nvram_config, |
| 2211 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 2212 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2213 | .pci_info_str = qla24xx_pci_info_str, |
| 2214 | .fw_version_str = qla24xx_fw_version_str, |
| 2215 | .intr_handler = qla24xx_intr_handler, |
| 2216 | .enable_intrs = qla24xx_enable_intrs, |
| 2217 | .disable_intrs = qla24xx_disable_intrs, |
| 2218 | .abort_command = qla24xx_abort_command, |
| 2219 | .target_reset = qla24xx_abort_target, |
| 2220 | .lun_reset = qla24xx_lun_reset, |
| 2221 | .fabric_login = qla24xx_login_fabric, |
| 2222 | .fabric_logout = qla24xx_fabric_logout, |
| 2223 | .calc_req_entries = NULL, |
| 2224 | .build_iocbs = NULL, |
| 2225 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2226 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 2227 | .read_nvram = NULL, |
| 2228 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2229 | .fw_dump = qla81xx_fw_dump, |
| 2230 | .beacon_on = qla24xx_beacon_on, |
| 2231 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2232 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2233 | .read_optrom = qla25xx_read_optrom_data, |
| 2234 | .write_optrom = qla24xx_write_optrom_data, |
| 2235 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 2236 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2237 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2238 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2239 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2240 | .initialize_adapter = qla2x00_initialize_adapter, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2241 | }; |
| 2242 | |
| 2243 | static struct isp_operations qla82xx_isp_ops = { |
| 2244 | .pci_config = qla82xx_pci_config, |
| 2245 | .reset_chip = qla82xx_reset_chip, |
| 2246 | .chip_diag = qla24xx_chip_diag, |
| 2247 | .config_rings = qla82xx_config_rings, |
| 2248 | .reset_adapter = qla24xx_reset_adapter, |
| 2249 | .nvram_config = qla81xx_nvram_config, |
| 2250 | .update_fw_options = qla24xx_update_fw_options, |
| 2251 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 2252 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2253 | .fw_version_str = qla24xx_fw_version_str, |
| 2254 | .intr_handler = qla82xx_intr_handler, |
| 2255 | .enable_intrs = qla82xx_enable_intrs, |
| 2256 | .disable_intrs = qla82xx_disable_intrs, |
| 2257 | .abort_command = qla24xx_abort_command, |
| 2258 | .target_reset = qla24xx_abort_target, |
| 2259 | .lun_reset = qla24xx_lun_reset, |
| 2260 | .fabric_login = qla24xx_login_fabric, |
| 2261 | .fabric_logout = qla24xx_fabric_logout, |
| 2262 | .calc_req_entries = NULL, |
| 2263 | .build_iocbs = NULL, |
| 2264 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2265 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2266 | .read_nvram = qla24xx_read_nvram_data, |
| 2267 | .write_nvram = qla24xx_write_nvram_data, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2268 | .fw_dump = qla82xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 2269 | .beacon_on = qla82xx_beacon_on, |
| 2270 | .beacon_off = qla82xx_beacon_off, |
| 2271 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2272 | .read_optrom = qla82xx_read_optrom_data, |
| 2273 | .write_optrom = qla82xx_write_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2274 | .get_flash_version = qla82xx_get_flash_version, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2275 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2276 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2277 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2278 | .iospace_config = qla82xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2279 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2280 | }; |
| 2281 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2282 | static struct isp_operations qla8044_isp_ops = { |
| 2283 | .pci_config = qla82xx_pci_config, |
| 2284 | .reset_chip = qla82xx_reset_chip, |
| 2285 | .chip_diag = qla24xx_chip_diag, |
| 2286 | .config_rings = qla82xx_config_rings, |
| 2287 | .reset_adapter = qla24xx_reset_adapter, |
| 2288 | .nvram_config = qla81xx_nvram_config, |
| 2289 | .update_fw_options = qla24xx_update_fw_options, |
| 2290 | .load_risc = qla82xx_load_risc, |
| 2291 | .pci_info_str = qla24xx_pci_info_str, |
| 2292 | .fw_version_str = qla24xx_fw_version_str, |
| 2293 | .intr_handler = qla8044_intr_handler, |
| 2294 | .enable_intrs = qla82xx_enable_intrs, |
| 2295 | .disable_intrs = qla82xx_disable_intrs, |
| 2296 | .abort_command = qla24xx_abort_command, |
| 2297 | .target_reset = qla24xx_abort_target, |
| 2298 | .lun_reset = qla24xx_lun_reset, |
| 2299 | .fabric_login = qla24xx_login_fabric, |
| 2300 | .fabric_logout = qla24xx_fabric_logout, |
| 2301 | .calc_req_entries = NULL, |
| 2302 | .build_iocbs = NULL, |
| 2303 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2304 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2305 | .read_nvram = NULL, |
| 2306 | .write_nvram = NULL, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2307 | .fw_dump = qla8044_fw_dump, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2308 | .beacon_on = qla82xx_beacon_on, |
| 2309 | .beacon_off = qla82xx_beacon_off, |
| 2310 | .beacon_blink = NULL, |
Saurav Kashyap | 888e639 | 2014-02-26 04:15:13 -0500 | [diff] [blame] | 2311 | .read_optrom = qla8044_read_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2312 | .write_optrom = qla8044_write_optrom_data, |
| 2313 | .get_flash_version = qla82xx_get_flash_version, |
| 2314 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2315 | .start_scsi_mq = NULL, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2316 | .abort_isp = qla8044_abort_isp, |
| 2317 | .iospace_config = qla82xx_iospace_config, |
| 2318 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2319 | }; |
| 2320 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2321 | static struct isp_operations qla83xx_isp_ops = { |
| 2322 | .pci_config = qla25xx_pci_config, |
| 2323 | .reset_chip = qla24xx_reset_chip, |
| 2324 | .chip_diag = qla24xx_chip_diag, |
| 2325 | .config_rings = qla24xx_config_rings, |
| 2326 | .reset_adapter = qla24xx_reset_adapter, |
| 2327 | .nvram_config = qla81xx_nvram_config, |
| 2328 | .update_fw_options = qla81xx_update_fw_options, |
| 2329 | .load_risc = qla81xx_load_risc, |
| 2330 | .pci_info_str = qla24xx_pci_info_str, |
| 2331 | .fw_version_str = qla24xx_fw_version_str, |
| 2332 | .intr_handler = qla24xx_intr_handler, |
| 2333 | .enable_intrs = qla24xx_enable_intrs, |
| 2334 | .disable_intrs = qla24xx_disable_intrs, |
| 2335 | .abort_command = qla24xx_abort_command, |
| 2336 | .target_reset = qla24xx_abort_target, |
| 2337 | .lun_reset = qla24xx_lun_reset, |
| 2338 | .fabric_login = qla24xx_login_fabric, |
| 2339 | .fabric_logout = qla24xx_fabric_logout, |
| 2340 | .calc_req_entries = NULL, |
| 2341 | .build_iocbs = NULL, |
| 2342 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2343 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2344 | .read_nvram = NULL, |
| 2345 | .write_nvram = NULL, |
| 2346 | .fw_dump = qla83xx_fw_dump, |
| 2347 | .beacon_on = qla24xx_beacon_on, |
| 2348 | .beacon_off = qla24xx_beacon_off, |
| 2349 | .beacon_blink = qla83xx_beacon_blink, |
| 2350 | .read_optrom = qla25xx_read_optrom_data, |
| 2351 | .write_optrom = qla24xx_write_optrom_data, |
| 2352 | .get_flash_version = qla24xx_get_flash_version, |
| 2353 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2354 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2355 | .abort_isp = qla2x00_abort_isp, |
| 2356 | .iospace_config = qla83xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2357 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2358 | }; |
| 2359 | |
| 2360 | static struct isp_operations qlafx00_isp_ops = { |
| 2361 | .pci_config = qlafx00_pci_config, |
| 2362 | .reset_chip = qlafx00_soft_reset, |
| 2363 | .chip_diag = qlafx00_chip_diag, |
| 2364 | .config_rings = qlafx00_config_rings, |
| 2365 | .reset_adapter = qlafx00_soft_reset, |
| 2366 | .nvram_config = NULL, |
| 2367 | .update_fw_options = NULL, |
| 2368 | .load_risc = NULL, |
| 2369 | .pci_info_str = qlafx00_pci_info_str, |
| 2370 | .fw_version_str = qlafx00_fw_version_str, |
| 2371 | .intr_handler = qlafx00_intr_handler, |
| 2372 | .enable_intrs = qlafx00_enable_intrs, |
| 2373 | .disable_intrs = qlafx00_disable_intrs, |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2374 | .abort_command = qla24xx_async_abort_command, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2375 | .target_reset = qlafx00_abort_target, |
| 2376 | .lun_reset = qlafx00_lun_reset, |
| 2377 | .fabric_login = NULL, |
| 2378 | .fabric_logout = NULL, |
| 2379 | .calc_req_entries = NULL, |
| 2380 | .build_iocbs = NULL, |
| 2381 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2382 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2383 | .read_nvram = qla24xx_read_nvram_data, |
| 2384 | .write_nvram = qla24xx_write_nvram_data, |
| 2385 | .fw_dump = NULL, |
| 2386 | .beacon_on = qla24xx_beacon_on, |
| 2387 | .beacon_off = qla24xx_beacon_off, |
| 2388 | .beacon_blink = NULL, |
| 2389 | .read_optrom = qla24xx_read_optrom_data, |
| 2390 | .write_optrom = qla24xx_write_optrom_data, |
| 2391 | .get_flash_version = qla24xx_get_flash_version, |
| 2392 | .start_scsi = qlafx00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2393 | .start_scsi_mq = NULL, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2394 | .abort_isp = qlafx00_abort_isp, |
| 2395 | .iospace_config = qlafx00_iospace_config, |
| 2396 | .initialize_adapter = qlafx00_initialize_adapter, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2397 | }; |
| 2398 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2399 | static struct isp_operations qla27xx_isp_ops = { |
| 2400 | .pci_config = qla25xx_pci_config, |
| 2401 | .reset_chip = qla24xx_reset_chip, |
| 2402 | .chip_diag = qla24xx_chip_diag, |
| 2403 | .config_rings = qla24xx_config_rings, |
| 2404 | .reset_adapter = qla24xx_reset_adapter, |
| 2405 | .nvram_config = qla81xx_nvram_config, |
| 2406 | .update_fw_options = qla81xx_update_fw_options, |
| 2407 | .load_risc = qla81xx_load_risc, |
| 2408 | .pci_info_str = qla24xx_pci_info_str, |
| 2409 | .fw_version_str = qla24xx_fw_version_str, |
| 2410 | .intr_handler = qla24xx_intr_handler, |
| 2411 | .enable_intrs = qla24xx_enable_intrs, |
| 2412 | .disable_intrs = qla24xx_disable_intrs, |
| 2413 | .abort_command = qla24xx_abort_command, |
| 2414 | .target_reset = qla24xx_abort_target, |
| 2415 | .lun_reset = qla24xx_lun_reset, |
| 2416 | .fabric_login = qla24xx_login_fabric, |
| 2417 | .fabric_logout = qla24xx_fabric_logout, |
| 2418 | .calc_req_entries = NULL, |
| 2419 | .build_iocbs = NULL, |
| 2420 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2421 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2422 | .read_nvram = NULL, |
| 2423 | .write_nvram = NULL, |
| 2424 | .fw_dump = qla27xx_fwdump, |
| 2425 | .beacon_on = qla24xx_beacon_on, |
| 2426 | .beacon_off = qla24xx_beacon_off, |
| 2427 | .beacon_blink = qla83xx_beacon_blink, |
| 2428 | .read_optrom = qla25xx_read_optrom_data, |
| 2429 | .write_optrom = qla24xx_write_optrom_data, |
| 2430 | .get_flash_version = qla24xx_get_flash_version, |
| 2431 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2432 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2433 | .abort_isp = qla2x00_abort_isp, |
| 2434 | .iospace_config = qla83xx_iospace_config, |
| 2435 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2436 | }; |
| 2437 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2438 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2439 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2440 | { |
| 2441 | ha->device_type = DT_EXTENDED_IDS; |
| 2442 | switch (ha->pdev->device) { |
| 2443 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2444 | ha->isp_type |= DT_ISP2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2445 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2446 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2447 | break; |
| 2448 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2449 | ha->isp_type |= DT_ISP2200; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2450 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2451 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2452 | break; |
| 2453 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2454 | ha->isp_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2455 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2456 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2457 | break; |
| 2458 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2459 | ha->isp_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2460 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2461 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2462 | break; |
| 2463 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2464 | ha->isp_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2465 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2466 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2467 | ha->pdev->subsystem_device == 0x0170) |
| 2468 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2469 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2470 | break; |
| 2471 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2472 | ha->isp_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2473 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2474 | break; |
| 2475 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2476 | ha->isp_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2477 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2478 | break; |
| 2479 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2480 | ha->isp_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2481 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2482 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2483 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2484 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2485 | break; |
| 2486 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2487 | ha->isp_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2488 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2489 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2490 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2491 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2492 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2493 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2494 | ha->isp_type |= DT_ISP8432; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2495 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2496 | ha->device_type |= DT_FWI2; |
| 2497 | ha->device_type |= DT_IIDMA; |
| 2498 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2499 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2500 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2501 | ha->isp_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2502 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2503 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2504 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2505 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2506 | ha->isp_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2507 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2508 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2509 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2510 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2511 | ha->isp_type |= DT_ISP2532; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2512 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2513 | ha->device_type |= DT_FWI2; |
| 2514 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2515 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2516 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2517 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2518 | ha->isp_type |= DT_ISP8001; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2519 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2520 | ha->device_type |= DT_FWI2; |
| 2521 | ha->device_type |= DT_IIDMA; |
| 2522 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2523 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2524 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2525 | ha->isp_type |= DT_ISP8021; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2526 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2527 | ha->device_type |= DT_FWI2; |
| 2528 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2529 | /* Initialize 82XX ISP flags */ |
| 2530 | qla82xx_init_flags(ha); |
| 2531 | break; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2532 | case PCI_DEVICE_ID_QLOGIC_ISP8044: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2533 | ha->isp_type |= DT_ISP8044; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2534 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2535 | ha->device_type |= DT_FWI2; |
| 2536 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2537 | /* Initialize 82XX ISP flags */ |
| 2538 | qla82xx_init_flags(ha); |
| 2539 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2540 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2541 | ha->isp_type |= DT_ISP2031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2542 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2543 | ha->device_type |= DT_FWI2; |
| 2544 | ha->device_type |= DT_IIDMA; |
| 2545 | ha->device_type |= DT_T10_PI; |
| 2546 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2547 | break; |
| 2548 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2549 | ha->isp_type |= DT_ISP8031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2550 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2551 | ha->device_type |= DT_FWI2; |
| 2552 | ha->device_type |= DT_IIDMA; |
| 2553 | ha->device_type |= DT_T10_PI; |
| 2554 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2555 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2556 | case PCI_DEVICE_ID_QLOGIC_ISPF001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2557 | ha->isp_type |= DT_ISPFX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2558 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2559 | case PCI_DEVICE_ID_QLOGIC_ISP2071: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2560 | ha->isp_type |= DT_ISP2071; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2561 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2562 | ha->device_type |= DT_FWI2; |
| 2563 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2564 | ha->device_type |= DT_T10_PI; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2565 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2566 | break; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2567 | case PCI_DEVICE_ID_QLOGIC_ISP2271: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2568 | ha->isp_type |= DT_ISP2271; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2569 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2570 | ha->device_type |= DT_FWI2; |
| 2571 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2572 | ha->device_type |= DT_T10_PI; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2573 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2574 | break; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2575 | case PCI_DEVICE_ID_QLOGIC_ISP2261: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2576 | ha->isp_type |= DT_ISP2261; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2577 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2578 | ha->device_type |= DT_FWI2; |
| 2579 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2580 | ha->device_type |= DT_T10_PI; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2581 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2582 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2583 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2584 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2585 | if (IS_QLA82XX(ha)) |
Saurav Kashyap | 43a9c38 | 2014-02-26 04:15:16 -0500 | [diff] [blame] | 2586 | ha->port_no = ha->portnum & 1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2587 | else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2588 | /* Get adapter physical port no from interrupt pin register. */ |
| 2589 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2590 | if (IS_QLA27XX(ha)) |
| 2591 | ha->port_no--; |
| 2592 | else |
| 2593 | ha->port_no = !(ha->port_no & 1); |
| 2594 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2595 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2596 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2597 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2598 | ha->device_type, ha->port_no, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2599 | } |
| 2600 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2601 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2602 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2603 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2604 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2605 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2606 | if (vha->hw->flags.running_gold_fw) |
| 2607 | return; |
| 2608 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2609 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2610 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2611 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2612 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2613 | } |
| 2614 | |
| 2615 | static int |
| 2616 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2617 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2618 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2619 | |
Bill Kuzeja | a5dd506e | 2016-10-21 16:45:27 -0400 | [diff] [blame] | 2620 | if (test_bit(UNLOADING, &vha->dpc_flags)) |
| 2621 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2622 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2623 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2624 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2625 | return 1; |
| 2626 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2627 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2628 | } |
| 2629 | |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 2630 | static void qla2x00_iocb_work_fn(struct work_struct *work) |
| 2631 | { |
| 2632 | struct scsi_qla_host *vha = container_of(work, |
| 2633 | struct scsi_qla_host, iocb_work); |
| 2634 | int cnt = 0; |
| 2635 | |
| 2636 | while (!list_empty(&vha->work_list)) { |
| 2637 | qla2x00_do_work(vha); |
| 2638 | cnt++; |
| 2639 | if (cnt > 10) |
| 2640 | break; |
| 2641 | } |
| 2642 | } |
| 2643 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2644 | /* |
| 2645 | * PCI driver interface |
| 2646 | */ |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 2647 | static int |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2648 | 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] | 2649 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2650 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2651 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2652 | scsi_qla_host_t *base_vha = NULL; |
| 2653 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2654 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2655 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2656 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2657 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2658 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2659 | struct req_que *req = NULL; |
| 2660 | struct rsp_que *rsp = NULL; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 2661 | int i; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2662 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2663 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2664 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2665 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2666 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2667 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2668 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2669 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2670 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2671 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2672 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2673 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2674 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031 || |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2675 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISPF001 || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2676 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8044 || |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2677 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2071 || |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2678 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271 || |
| 2679 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2261) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2680 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2681 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2682 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2683 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2684 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2685 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2686 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2687 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2688 | if (mem_only) { |
| 2689 | if (pci_enable_device_mem(pdev)) |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2690 | return ret; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2691 | } else { |
| 2692 | if (pci_enable_device(pdev)) |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2693 | return ret; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2694 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2695 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2696 | /* This may fail but that's ok */ |
| 2697 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2698 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2699 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2700 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2701 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2702 | "Unable to allocate memory for ha.\n"); |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 2703 | goto disable_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2704 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2705 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2706 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2707 | ha->pdev = pdev; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2708 | ha->tgt.enable_class_2 = ql2xenableclass2; |
Quinn Tran | 33e7997 | 2014-09-25 06:14:55 -0400 | [diff] [blame] | 2709 | INIT_LIST_HEAD(&ha->tgt.q_full_list); |
| 2710 | spin_lock_init(&ha->tgt.q_full_lock); |
Quinn Tran | 7560151 | 2015-12-17 14:57:04 -0500 | [diff] [blame] | 2711 | spin_lock_init(&ha->tgt.sess_lock); |
Quinn Tran | 2f424b9 | 2015-12-17 14:57:07 -0500 | [diff] [blame] | 2712 | spin_lock_init(&ha->tgt.atio_lock); |
| 2713 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2714 | |
| 2715 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2716 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2717 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2718 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2719 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2720 | mutex_init(&ha->selflogin_lock); |
Chad Dupuis | 7a8ab9c | 2014-02-26 04:14:56 -0500 | [diff] [blame] | 2721 | mutex_init(&ha->optrom_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2722 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2723 | /* Set ISP-type information. */ |
| 2724 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2725 | |
| 2726 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2727 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2728 | IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2729 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2730 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2731 | ha->prev_topology = 0; |
| 2732 | ha->init_cb_size = sizeof(init_cb_t); |
| 2733 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2734 | ha->optrom_size = OPTROM_SIZE_2300; |
| 2735 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2736 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2737 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2738 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2739 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2740 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2741 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2742 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2743 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2744 | ha->flash_conf_off = ~0; |
| 2745 | ha->flash_data_off = ~0; |
| 2746 | ha->nvram_conf_off = ~0; |
| 2747 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2748 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2749 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2750 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2751 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2752 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2753 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2754 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2755 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2756 | ha->flash_conf_off = ~0; |
| 2757 | ha->flash_data_off = ~0; |
| 2758 | ha->nvram_conf_off = ~0; |
| 2759 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2760 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2761 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2762 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2763 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2764 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2765 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2766 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2767 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2768 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2769 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2770 | ha->flash_conf_off = ~0; |
| 2771 | ha->flash_data_off = ~0; |
| 2772 | ha->nvram_conf_off = ~0; |
| 2773 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2774 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2775 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2776 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2777 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2778 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2779 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2780 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2781 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2782 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2783 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2784 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2785 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2786 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2787 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2788 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2789 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2790 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2791 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2792 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2793 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2794 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2795 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2796 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2797 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2798 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2799 | ha->gid_list_info_size = 8; |
| 2800 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2801 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2802 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2803 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2804 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2805 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2806 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2807 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2808 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2809 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2810 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2811 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 2812 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2813 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2814 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2815 | ha->gid_list_info_size = 8; |
| 2816 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2817 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2818 | ha->isp_ops = &qla81xx_isp_ops; |
| 2819 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2820 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2821 | ha->nvram_conf_off = ~0; |
| 2822 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2823 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2824 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2825 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2826 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2827 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2828 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2829 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2830 | ha->gid_list_info_size = 8; |
| 2831 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2832 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2833 | ha->isp_ops = &qla82xx_isp_ops; |
| 2834 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2835 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2836 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2837 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2838 | } else if (IS_QLA8044(ha)) { |
| 2839 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2840 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2841 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2842 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2843 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2844 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2845 | ha->gid_list_info_size = 8; |
| 2846 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2847 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2848 | ha->isp_ops = &qla8044_isp_ops; |
| 2849 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2850 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2851 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2852 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2853 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2854 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2855 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2856 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Saurav Kashyap | f2ea653 | 2014-09-25 06:14:54 -0400 | [diff] [blame] | 2857 | req_length = REQUEST_ENTRY_CNT_83XX; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2858 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Arun Easi | b8aa4bd | 2013-01-30 03:34:40 -0500 | [diff] [blame] | 2859 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2860 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2861 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2862 | ha->gid_list_info_size = 8; |
| 2863 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2864 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2865 | ha->isp_ops = &qla83xx_isp_ops; |
| 2866 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2867 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2868 | ha->nvram_conf_off = ~0; |
| 2869 | ha->nvram_data_off = ~0; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2870 | } else if (IS_QLAFX00(ha)) { |
| 2871 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_FX00; |
| 2872 | ha->mbx_count = MAILBOX_REGISTER_COUNT_FX00; |
| 2873 | ha->aen_mbx_count = AEN_MAILBOX_REGISTER_COUNT_FX00; |
| 2874 | req_length = REQUEST_ENTRY_CNT_FX00; |
| 2875 | rsp_length = RESPONSE_ENTRY_CNT_FX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2876 | ha->isp_ops = &qlafx00_isp_ops; |
| 2877 | ha->port_down_retry_count = 30; /* default value */ |
| 2878 | ha->mr.fw_hbt_cnt = QLAFX00_HEARTBEAT_INTERVAL; |
| 2879 | ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; |
Armen Baloyan | 71e5600 | 2013-08-27 01:37:38 -0400 | [diff] [blame] | 2880 | ha->mr.fw_critemp_timer_tick = QLAFX00_CRITEMP_INTERVAL; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2881 | ha->mr.fw_hbt_en = 1; |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 2882 | ha->mr.host_info_resend = false; |
| 2883 | ha->mr.hinfo_resend_timer_tick = QLAFX00_HINFO_RESEND_INTERVAL; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2884 | } else if (IS_QLA27XX(ha)) { |
| 2885 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
| 2886 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2887 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2888 | req_length = REQUEST_ENTRY_CNT_83XX; |
| 2889 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 2890 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2891 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2892 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2893 | ha->gid_list_info_size = 8; |
| 2894 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2895 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2896 | ha->isp_ops = &qla27xx_isp_ops; |
| 2897 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2898 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2899 | ha->nvram_conf_off = ~0; |
| 2900 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2901 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2902 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2903 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 2904 | "mbx_count=%d, req_length=%d, " |
| 2905 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2906 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 2907 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2908 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 2909 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2910 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2911 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 2912 | "isp_ops=%p, flash_conf_off=%d, " |
| 2913 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 2914 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 2915 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2916 | |
| 2917 | /* Configure PCI I/O space */ |
| 2918 | ret = ha->isp_ops->iospace_config(ha); |
| 2919 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2920 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2921 | |
| 2922 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 2923 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 2924 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 2925 | mutex_init(&ha->vport_lock); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2926 | mutex_init(&ha->mq_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2927 | init_completion(&ha->mbx_cmd_comp); |
| 2928 | complete(&ha->mbx_cmd_comp); |
| 2929 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 2930 | init_completion(&ha->dcbx_comp); |
Chad Dupuis | f356bef | 2013-02-08 01:58:04 -0500 | [diff] [blame] | 2931 | init_completion(&ha->lb_portup_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2932 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2933 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2934 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 2935 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2936 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 2937 | "64 Bit addressing is %s.\n", |
| 2938 | ha->flags.enable_64bit_addressing ? "enable" : |
| 2939 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2940 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 2941 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2942 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 2943 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2944 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2945 | goto probe_hw_failed; |
| 2946 | } |
| 2947 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2948 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2949 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2950 | req->max_q_depth = ql2xmaxqdepth; |
| 2951 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2952 | |
| 2953 | base_vha = qla2x00_create_host(sht, ha); |
| 2954 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2955 | ret = -ENOMEM; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2956 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2957 | qla2x00_free_req_que(ha, req); |
| 2958 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2959 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2960 | } |
| 2961 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2962 | pci_set_drvdata(pdev, base_vha); |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 2963 | set_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2964 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2965 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2966 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2967 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2968 | base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2969 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2970 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 2971 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2972 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2973 | /* Setup fcport template structure. */ |
| 2974 | ha->mr.fcport.vha = base_vha; |
| 2975 | ha->mr.fcport.port_type = FCT_UNKNOWN; |
| 2976 | ha->mr.fcport.loop_id = FC_NO_LOOP_ID; |
| 2977 | qla2x00_set_fcport_state(&ha->mr.fcport, FCS_UNCONFIGURED); |
| 2978 | ha->mr.fcport.supported_classes = FC_COS_UNSPECIFIED; |
| 2979 | ha->mr.fcport.scan_state = 1; |
| 2980 | |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2981 | /* Set the SG table size based on ISP type */ |
| 2982 | if (!IS_FWI2_CAPABLE(ha)) { |
| 2983 | if (IS_QLA2100(ha)) |
| 2984 | host->sg_tablesize = 32; |
| 2985 | } else { |
| 2986 | if (!IS_QLA82XX(ha)) |
| 2987 | host->sg_tablesize = QLA_SG_ALL; |
| 2988 | } |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2989 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2990 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 2991 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2992 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2993 | host->max_cmd_len = 32; |
| 2994 | else |
| 2995 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 2996 | host->max_channel = MAX_BUSES - 1; |
Hannes Reinecke | 755f516 | 2014-06-03 10:58:54 +0200 | [diff] [blame] | 2997 | /* Older HBAs support only 16-bit LUNs */ |
| 2998 | if (!IS_QLAFX00(ha) && !IS_FWI2_CAPABLE(ha) && |
| 2999 | ql2xmaxlun > 0xffff) |
| 3000 | host->max_lun = 0xffff; |
| 3001 | else |
| 3002 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3003 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 3004 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3005 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3006 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 3007 | "max_id=%d this_id=%d " |
| 3008 | "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] | 3009 | "max_lun=%llu transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3010 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 3011 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 3012 | host->transportt, sht->vendor_id); |
| 3013 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3014 | /* Set up the irqs */ |
| 3015 | ret = qla2x00_request_irqs(ha, rsp); |
| 3016 | if (ret) |
| 3017 | goto probe_init_failed; |
| 3018 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3019 | /* Alloc arrays of request and response ring ptrs */ |
| 3020 | if (!qla2x00_alloc_queues(ha, req, rsp)) { |
| 3021 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 3022 | "Failed to allocate memory for queue pointers..." |
| 3023 | "aborting.\n"); |
| 3024 | goto probe_init_failed; |
| 3025 | } |
| 3026 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3027 | if (ha->mqenable && shost_use_blk_mq(host)) { |
| 3028 | /* number of hardware queues supported by blk/scsi-mq*/ |
| 3029 | host->nr_hw_queues = ha->max_qpairs; |
| 3030 | |
| 3031 | ql_dbg(ql_dbg_init, base_vha, 0x0192, |
| 3032 | "blk/scsi-mq enabled, HW queues = %d.\n", host->nr_hw_queues); |
| 3033 | } else |
| 3034 | ql_dbg(ql_dbg_init, base_vha, 0x0193, |
| 3035 | "blk/scsi-mq disabled.\n"); |
| 3036 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3037 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3038 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3039 | pci_save_state(pdev); |
| 3040 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3041 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3042 | rsp->req = req; |
| 3043 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3044 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3045 | if (IS_QLAFX00(ha)) { |
| 3046 | ha->rsp_q_map[0] = rsp; |
| 3047 | ha->req_q_map[0] = req; |
| 3048 | set_bit(0, ha->req_qid_map); |
| 3049 | set_bit(0, ha->rsp_qid_map); |
| 3050 | } |
| 3051 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 3052 | /* FWI2-capable only. */ |
| 3053 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 3054 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 3055 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 3056 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3057 | if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 3058 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 3059 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 3060 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 3061 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 3062 | } |
| 3063 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3064 | if (IS_QLAFX00(ha)) { |
| 3065 | req->req_q_in = &ha->iobase->ispfx00.req_q_in; |
| 3066 | req->req_q_out = &ha->iobase->ispfx00.req_q_out; |
| 3067 | rsp->rsp_q_in = &ha->iobase->ispfx00.rsp_q_in; |
| 3068 | rsp->rsp_q_out = &ha->iobase->ispfx00.rsp_q_out; |
| 3069 | } |
| 3070 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3071 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3072 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 3073 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 3074 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 3075 | } |
| 3076 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3077 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 3078 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 3079 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 3080 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 3081 | "req->req_q_in=%p req->req_q_out=%p " |
| 3082 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 3083 | req->req_q_in, req->req_q_out, |
| 3084 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 3085 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 3086 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 3087 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 3088 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 3089 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 3090 | 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] | 3091 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3092 | if (ha->isp_ops->initialize_adapter(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3093 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 3094 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 3095 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3096 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3097 | if (IS_QLA82XX(ha)) { |
| 3098 | qla82xx_idc_lock(ha); |
| 3099 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3100 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3101 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3102 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 3103 | "HW State: FAILED.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3104 | } else if (IS_QLA8044(ha)) { |
| 3105 | qla8044_idc_lock(ha); |
| 3106 | qla8044_wr_direct(base_vha, |
| 3107 | QLA8044_CRB_DEV_STATE_INDEX, |
| 3108 | QLA8XXX_DEV_FAILED); |
| 3109 | qla8044_idc_unlock(ha); |
| 3110 | ql_log(ql_log_fatal, base_vha, 0x0150, |
| 3111 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3112 | } |
| 3113 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3114 | ret = -ENODEV; |
| 3115 | goto probe_failed; |
| 3116 | } |
| 3117 | |
Chad Dupuis | 3b1bef6 | 2014-02-26 04:15:04 -0500 | [diff] [blame] | 3118 | if (IS_QLAFX00(ha)) |
| 3119 | host->can_queue = QLAFX00_MAX_CANQUEUE; |
| 3120 | else |
| 3121 | host->can_queue = req->num_outstanding_cmds - 10; |
| 3122 | |
| 3123 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 3124 | "can_queue=%d, req=%p, mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 3125 | host->can_queue, base_vha->req, |
| 3126 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
| 3127 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3128 | if (ha->mqenable && qla_ini_mode_enabled(base_vha)) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3129 | ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3130 | /* Create start of day qpairs for Block MQ */ |
| 3131 | if (shost_use_blk_mq(host)) { |
| 3132 | for (i = 0; i < ha->max_qpairs; i++) |
Quinn Tran | 82de802 | 2017-06-13 20:47:17 -0700 | [diff] [blame^] | 3133 | qla2xxx_create_qpair(base_vha, 5, 0, true); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3134 | } |
| 3135 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3136 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3137 | if (ha->flags.running_gold_fw) |
| 3138 | goto skip_dpc; |
| 3139 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3140 | /* |
| 3141 | * Startup the kernel thread for this host adapter |
| 3142 | */ |
| 3143 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3144 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3145 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3146 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 3147 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3148 | ret = PTR_ERR(ha->dpc_thread); |
| 3149 | goto probe_failed; |
| 3150 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3151 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 3152 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3153 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3154 | /* |
| 3155 | * If we're not coming up in initiator mode, we might sit for |
| 3156 | * a while without waking up the dpc thread, which leads to a |
| 3157 | * stuck process warning. So just kick the dpc once here and |
| 3158 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 3159 | */ |
| 3160 | qla2xxx_wake_dpc(base_vha); |
| 3161 | |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 3162 | INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 3163 | INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); |
| 3164 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3165 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 3166 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 3167 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 3168 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 3169 | |
| 3170 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 3171 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 3172 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 3173 | INIT_WORK(&ha->idc_state_handler, |
| 3174 | qla83xx_idc_state_handler_work); |
| 3175 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 3176 | qla83xx_nic_core_unrecoverable_work); |
| 3177 | } |
| 3178 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3179 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3180 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 3181 | base_vha->host->irq = ha->pdev->irq; |
| 3182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3183 | /* Initialized the timer */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3184 | qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3185 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 3186 | "Started qla2x00_timer with " |
| 3187 | "interval=%d.\n", WATCH_INTERVAL); |
| 3188 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 3189 | "Detected hba at address=%p.\n", |
| 3190 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3191 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 3192 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3193 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3194 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3195 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3196 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 3197 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3198 | if (ql2xenabledif == 1) |
| 3199 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3200 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3201 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3202 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3203 | | SHOST_DIF_TYPE3_PROTECTION |
| 3204 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3205 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3206 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3207 | |
| 3208 | guard = SHOST_DIX_GUARD_CRC; |
| 3209 | |
| 3210 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 3211 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 3212 | guard |= SHOST_DIX_GUARD_IP; |
| 3213 | |
| 3214 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3215 | } else |
| 3216 | base_vha->flags.difdix_supported = 0; |
| 3217 | } |
| 3218 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3219 | ha->isp_ops->enable_intrs(ha); |
| 3220 | |
Armen Baloyan | 1fe19ee | 2013-08-27 01:37:41 -0400 | [diff] [blame] | 3221 | if (IS_QLAFX00(ha)) { |
| 3222 | ret = qlafx00_fx_disc(base_vha, |
| 3223 | &base_vha->hw->mr.fcport, FXDISC_GET_CONFIG_INFO); |
| 3224 | host->sg_tablesize = (ha->mr.extended_io_enabled) ? |
| 3225 | QLA_SG_ALL : 128; |
| 3226 | } |
| 3227 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3228 | ret = scsi_add_host(host, &pdev->dev); |
| 3229 | if (ret) |
| 3230 | goto probe_failed; |
| 3231 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3232 | base_vha->flags.init_done = 1; |
| 3233 | base_vha->flags.online = 1; |
Saurav Kashyap | edaa5c7 | 2014-04-11 16:54:14 -0400 | [diff] [blame] | 3234 | ha->prev_minidump_failed = 0; |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3235 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3236 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 3237 | "Init done and hba is online.\n"); |
| 3238 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3239 | if (qla_ini_mode_enabled(base_vha) || |
| 3240 | qla_dual_mode_enabled(base_vha)) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3241 | scsi_scan_host(host); |
| 3242 | else |
| 3243 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 3244 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 3245 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3246 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3247 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3248 | if (IS_QLAFX00(ha)) { |
| 3249 | ret = qlafx00_fx_disc(base_vha, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3250 | &base_vha->hw->mr.fcport, FXDISC_GET_PORT_INFO); |
| 3251 | |
| 3252 | /* Register system information */ |
| 3253 | ret = qlafx00_fx_disc(base_vha, |
| 3254 | &base_vha->hw->mr.fcport, FXDISC_REG_HOST_INFO); |
| 3255 | } |
| 3256 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3257 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3258 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3259 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3260 | |
Armen Baloyan | 03eb912 | 2013-10-30 03:38:22 -0400 | [diff] [blame] | 3261 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 3262 | "QLogic %s - %s.\n", ha->model_number, ha->model_desc); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3263 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 3264 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 3265 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 3266 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 3267 | base_vha->host_no, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 3268 | 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] | 3269 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3270 | qlt_add_target(ha, base_vha); |
| 3271 | |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 3272 | clear_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 3273 | |
| 3274 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3275 | return -ENODEV; |
| 3276 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3277 | return 0; |
| 3278 | |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 3279 | probe_init_failed: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3280 | qla2x00_free_req_que(ha, req); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3281 | ha->req_q_map[0] = NULL; |
| 3282 | clear_bit(0, ha->req_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3283 | qla2x00_free_rsp_que(ha, rsp); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3284 | ha->rsp_q_map[0] = NULL; |
| 3285 | clear_bit(0, ha->rsp_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3286 | ha->max_req_queues = ha->max_rsp_queues = 0; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 3287 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3288 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3289 | if (base_vha->timer_active) |
| 3290 | qla2x00_stop_timer(base_vha); |
| 3291 | base_vha->flags.online = 0; |
| 3292 | if (ha->dpc_thread) { |
| 3293 | struct task_struct *t = ha->dpc_thread; |
| 3294 | |
| 3295 | ha->dpc_thread = NULL; |
| 3296 | kthread_stop(t); |
| 3297 | } |
| 3298 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3299 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3300 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3301 | scsi_host_put(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3302 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3303 | probe_hw_failed: |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 3304 | qla2x00_clear_drv_active(ha); |
| 3305 | |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3306 | iospace_config_failed: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3307 | if (IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3308 | if (!ha->nx_pcibase) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3309 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3310 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3311 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3312 | } else { |
| 3313 | if (ha->iobase) |
| 3314 | iounmap(ha->iobase); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3315 | if (ha->cregbase) |
| 3316 | iounmap(ha->cregbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3317 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3318 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3319 | kfree(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3320 | |
Johannes Thumshirn | ddff7ed | 2017-05-23 16:50:47 +0200 | [diff] [blame] | 3321 | disable_device: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3322 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3323 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3324 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3325 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 3326 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3327 | qla2x00_shutdown(struct pci_dev *pdev) |
| 3328 | { |
| 3329 | scsi_qla_host_t *vha; |
| 3330 | struct qla_hw_data *ha; |
| 3331 | |
Masanari Iida | 552f3f9 | 2013-02-08 01:57:44 -0500 | [diff] [blame] | 3332 | if (!atomic_read(&pdev->enable_cnt)) |
| 3333 | return; |
| 3334 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3335 | vha = pci_get_drvdata(pdev); |
| 3336 | ha = vha->hw; |
| 3337 | |
Armen Baloyan | 4247934 | 2013-08-27 01:37:37 -0400 | [diff] [blame] | 3338 | /* Notify ISPFX00 firmware */ |
| 3339 | if (IS_QLAFX00(ha)) |
| 3340 | qlafx00_driver_shutdown(vha, 20); |
| 3341 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3342 | /* Turn-off FCE trace */ |
| 3343 | if (ha->flags.fce_enabled) { |
| 3344 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 3345 | ha->flags.fce_enabled = 0; |
| 3346 | } |
| 3347 | |
| 3348 | /* Turn-off EFT trace */ |
| 3349 | if (ha->eft) |
| 3350 | qla2x00_disable_eft_trace(vha); |
| 3351 | |
| 3352 | /* Stop currently executing firmware. */ |
| 3353 | qla2x00_try_to_stop_firmware(vha); |
| 3354 | |
| 3355 | /* Turn adapter off line */ |
| 3356 | vha->flags.online = 0; |
| 3357 | |
| 3358 | /* turn-off interrupts on the card */ |
| 3359 | if (ha->interrupts_on) { |
| 3360 | vha->flags.init_done = 0; |
| 3361 | ha->isp_ops->disable_intrs(ha); |
| 3362 | } |
| 3363 | |
| 3364 | qla2x00_free_irqs(vha); |
| 3365 | |
| 3366 | qla2x00_free_fw_dump(ha); |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3367 | |
| 3368 | pci_disable_pcie_error_reporting(pdev); |
| 3369 | pci_disable_device(pdev); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3370 | } |
| 3371 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3372 | /* Deletes all the virtual ports for a given ha */ |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3373 | static void |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3374 | 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] | 3375 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3376 | scsi_qla_host_t *vha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3377 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3378 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3379 | mutex_lock(&ha->vport_lock); |
| 3380 | while (ha->cur_vport_count) { |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3381 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3382 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3383 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 3384 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 3385 | 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] | 3386 | scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3387 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3388 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3389 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3390 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3391 | fc_vport_terminate(vha->fc_vport); |
| 3392 | scsi_host_put(vha->host); |
| 3393 | |
| 3394 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3395 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3396 | mutex_unlock(&ha->vport_lock); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3397 | } |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3398 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3399 | /* Stops all deferred work threads */ |
| 3400 | static void |
| 3401 | qla2x00_destroy_deferred_work(struct qla_hw_data *ha) |
| 3402 | { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3403 | /* Cancel all work and destroy DPC workqueues */ |
| 3404 | if (ha->dpc_lp_wq) { |
| 3405 | cancel_work_sync(&ha->idc_aen); |
| 3406 | destroy_workqueue(ha->dpc_lp_wq); |
| 3407 | ha->dpc_lp_wq = NULL; |
| 3408 | } |
| 3409 | |
| 3410 | if (ha->dpc_hp_wq) { |
| 3411 | cancel_work_sync(&ha->nic_core_reset); |
| 3412 | cancel_work_sync(&ha->idc_state_handler); |
| 3413 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 3414 | destroy_workqueue(ha->dpc_hp_wq); |
| 3415 | ha->dpc_hp_wq = NULL; |
| 3416 | } |
| 3417 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3418 | /* Kill the kernel thread for this host */ |
| 3419 | if (ha->dpc_thread) { |
| 3420 | struct task_struct *t = ha->dpc_thread; |
| 3421 | |
| 3422 | /* |
| 3423 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 3424 | * so we need to zero it out. |
| 3425 | */ |
| 3426 | ha->dpc_thread = NULL; |
| 3427 | kthread_stop(t); |
| 3428 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3429 | } |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3430 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3431 | static void |
| 3432 | qla2x00_unmap_iobases(struct qla_hw_data *ha) |
| 3433 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3434 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 3435 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3436 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3437 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3438 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3439 | } else { |
| 3440 | if (ha->iobase) |
| 3441 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3442 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3443 | if (ha->cregbase) |
| 3444 | iounmap(ha->cregbase); |
| 3445 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3446 | if (ha->mqiobase) |
| 3447 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3448 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3449 | if ((IS_QLA83XX(ha) || IS_QLA27XX(ha)) && ha->msixbase) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3450 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3451 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3452 | } |
| 3453 | |
| 3454 | static void |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3455 | qla2x00_clear_drv_active(struct qla_hw_data *ha) |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3456 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3457 | if (IS_QLA8044(ha)) { |
| 3458 | qla8044_idc_lock(ha); |
Saurav Kashyap | c41afc9 | 2013-11-07 02:54:56 -0500 | [diff] [blame] | 3459 | qla8044_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3460 | qla8044_idc_unlock(ha); |
| 3461 | } else if (IS_QLA82XX(ha)) { |
| 3462 | qla82xx_idc_lock(ha); |
| 3463 | qla82xx_clear_drv_active(ha); |
| 3464 | qla82xx_idc_unlock(ha); |
| 3465 | } |
| 3466 | } |
| 3467 | |
| 3468 | static void |
| 3469 | qla2x00_remove_one(struct pci_dev *pdev) |
| 3470 | { |
| 3471 | scsi_qla_host_t *base_vha; |
| 3472 | struct qla_hw_data *ha; |
| 3473 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3474 | base_vha = pci_get_drvdata(pdev); |
| 3475 | ha = base_vha->hw; |
| 3476 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3477 | /* Indicate device removal to prevent future board_disable and wait |
| 3478 | * until any pending board_disable has completed. */ |
| 3479 | set_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags); |
| 3480 | cancel_work_sync(&ha->board_disable); |
| 3481 | |
| 3482 | /* |
| 3483 | * If the PCI device is disabled then there was a PCI-disconnect and |
| 3484 | * qla2x00_disable_board_on_pci_error has taken care of most of the |
| 3485 | * resources. |
| 3486 | */ |
| 3487 | if (!atomic_read(&pdev->enable_cnt)) { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3488 | dma_free_coherent(&ha->pdev->dev, base_vha->gnl.size, |
| 3489 | base_vha->gnl.l, base_vha->gnl.ldma); |
| 3490 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3491 | scsi_host_put(base_vha->host); |
| 3492 | kfree(ha); |
| 3493 | pci_set_drvdata(pdev, NULL); |
| 3494 | return; |
| 3495 | } |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 3496 | qla2x00_wait_for_hba_ready(base_vha); |
| 3497 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3498 | /* |
| 3499 | * if UNLOAD flag is already set, then continue unload, |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 3500 | * where it was set first. |
| 3501 | */ |
| 3502 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3503 | return; |
| 3504 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3505 | set_bit(UNLOADING, &base_vha->dpc_flags); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3506 | dma_free_coherent(&ha->pdev->dev, |
| 3507 | base_vha->gnl.size, base_vha->gnl.l, base_vha->gnl.ldma); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3508 | |
| 3509 | if (IS_QLAFX00(ha)) |
| 3510 | qlafx00_driver_shutdown(base_vha, 20); |
| 3511 | |
| 3512 | qla2x00_delete_all_vps(ha, base_vha); |
| 3513 | |
| 3514 | if (IS_QLA8031(ha)) { |
| 3515 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 3516 | "Clearing fcoe driver presence.\n"); |
| 3517 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 3518 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 3519 | "Error while clearing DRV-Presence.\n"); |
| 3520 | } |
| 3521 | |
| 3522 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 3523 | |
| 3524 | qla2x00_dfs_remove(base_vha); |
| 3525 | |
| 3526 | qla84xx_put_chip(base_vha); |
| 3527 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 3528 | /* Laser should be disabled only for ISP2031 */ |
| 3529 | if (IS_QLA2031(ha)) |
| 3530 | qla83xx_disable_laser(base_vha); |
| 3531 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3532 | /* Disable timer */ |
| 3533 | if (base_vha->timer_active) |
| 3534 | qla2x00_stop_timer(base_vha); |
| 3535 | |
| 3536 | base_vha->flags.online = 0; |
| 3537 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3538 | /* free DMA memory */ |
| 3539 | if (ha->exlogin_buf) |
| 3540 | qla2x00_free_exlogin_buffer(ha); |
| 3541 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3542 | /* free DMA memory */ |
| 3543 | if (ha->exchoffld_buf) |
| 3544 | qla2x00_free_exchoffld_buffer(ha); |
| 3545 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3546 | qla2x00_destroy_deferred_work(ha); |
| 3547 | |
| 3548 | qlt_remove_target(ha, base_vha); |
| 3549 | |
| 3550 | qla2x00_free_sysfs_attr(base_vha, true); |
| 3551 | |
| 3552 | fc_remove_host(base_vha->host); |
Quinn Tran | 482c9dc | 2017-03-15 09:48:54 -0700 | [diff] [blame] | 3553 | qlt_remove_target_resources(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3554 | |
| 3555 | scsi_remove_host(base_vha->host); |
| 3556 | |
| 3557 | qla2x00_free_device(base_vha); |
| 3558 | |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3559 | qla2x00_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3560 | |
Arun Easi | d2749ff | 2014-09-25 05:16:51 -0400 | [diff] [blame] | 3561 | scsi_host_put(base_vha->host); |
| 3562 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3563 | qla2x00_unmap_iobases(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3564 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3565 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3566 | kfree(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3567 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3568 | pci_disable_pcie_error_reporting(pdev); |
| 3569 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 3570 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3571 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3572 | |
| 3573 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3574 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3575 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3576 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3577 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3578 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 3579 | |
| 3580 | /* Disable timer */ |
| 3581 | if (vha->timer_active) |
| 3582 | qla2x00_stop_timer(vha); |
| 3583 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3584 | qla25xx_delete_queues(vha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3585 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3586 | if (ha->flags.fce_enabled) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3587 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3588 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3589 | if (ha->eft) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3590 | qla2x00_disable_eft_trace(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3591 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3592 | /* Stop currently executing firmware. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3593 | qla2x00_try_to_stop_firmware(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3594 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3595 | vha->flags.online = 0; |
| 3596 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3597 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3598 | if (ha->interrupts_on) { |
| 3599 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 3600 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3601 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3602 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3603 | qla2x00_free_fcports(vha); |
| 3604 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3605 | qla2x00_free_irqs(vha); |
| 3606 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3607 | /* Flush the work queue and remove it */ |
| 3608 | if (ha->wq) { |
| 3609 | flush_workqueue(ha->wq); |
| 3610 | destroy_workqueue(ha->wq); |
| 3611 | ha->wq = NULL; |
| 3612 | } |
| 3613 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3614 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3615 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3616 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 3617 | qla82xx_md_free(vha); |
| 3618 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3619 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3620 | } |
| 3621 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3622 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 3623 | { |
| 3624 | fc_port_t *fcport, *tfcport; |
| 3625 | |
| 3626 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 3627 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3628 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3629 | kfree(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3630 | } |
| 3631 | } |
| 3632 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3633 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3634 | 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] | 3635 | int defer) |
| 3636 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3637 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3638 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3639 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3640 | |
| 3641 | if (!fcport->rport) |
| 3642 | return; |
| 3643 | |
| 3644 | rport = fcport->rport; |
| 3645 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3646 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3647 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3648 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3649 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3650 | qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3651 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 3652 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3653 | } else { |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3654 | int now; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3655 | if (rport) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3656 | ql_dbg(ql_dbg_disc, fcport->vha, 0x2109, |
| 3657 | "%s %8phN. rport %p roles %x\n", |
| 3658 | __func__, fcport->port_name, rport, |
| 3659 | rport->roles); |
Alexei Potashnik | d20ed91 | 2015-07-14 16:00:47 -0400 | [diff] [blame] | 3660 | fc_remote_port_delete(rport); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3661 | } |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3662 | qlt_do_generation_tick(vha, &now); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3663 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3664 | } |
| 3665 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3666 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3667 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 3668 | * |
| 3669 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 3670 | * |
| 3671 | * Return: None. |
| 3672 | * |
| 3673 | * Context: |
| 3674 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3675 | 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] | 3676 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3677 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3678 | if (IS_QLAFX00(vha->hw)) { |
| 3679 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
| 3680 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3681 | return; |
| 3682 | } |
| 3683 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3684 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3685 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3686 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3687 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3688 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3689 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3690 | * We may need to retry the login, so don't change the state of the |
| 3691 | * port but do the retries. |
| 3692 | */ |
| 3693 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3694 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3695 | |
| 3696 | if (!do_login) |
| 3697 | return; |
| 3698 | |
Arun Easi | a1d0285 | 2015-08-04 13:38:02 -0400 | [diff] [blame] | 3699 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 3700 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3701 | if (fcport->login_retry == 0) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3702 | fcport->login_retry = vha->hw->login_retry_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3703 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3704 | ql_dbg(ql_dbg_disc, vha, 0x20a3, |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3705 | "Port login retry %8phN, lid 0x%04x retry cnt=%d.\n", |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 3706 | fcport->port_name, fcport->loop_id, fcport->login_retry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3707 | } |
| 3708 | } |
| 3709 | |
| 3710 | /* |
| 3711 | * qla2x00_mark_all_devices_lost |
| 3712 | * Updates fcport state when device goes offline. |
| 3713 | * |
| 3714 | * Input: |
| 3715 | * ha = adapter block pointer. |
| 3716 | * fcport = port structure pointer. |
| 3717 | * |
| 3718 | * Return: |
| 3719 | * None. |
| 3720 | * |
| 3721 | * Context: |
| 3722 | */ |
| 3723 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3724 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3725 | { |
| 3726 | fc_port_t *fcport; |
| 3727 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3728 | ql_dbg(ql_dbg_disc, vha, 0x20f1, |
| 3729 | "Mark all dev lost\n"); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3730 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3731 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3732 | fcport->scan_state = 0; |
| 3733 | qlt_schedule_sess_for_deletion_lock(fcport); |
| 3734 | |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3735 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3736 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3737 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3738 | /* |
| 3739 | * No point in marking the device as lost, if the device is |
| 3740 | * already DEAD. |
| 3741 | */ |
| 3742 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3743 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3744 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3745 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3746 | if (defer) |
| 3747 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3748 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3749 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3750 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3751 | } |
| 3752 | } |
| 3753 | |
| 3754 | /* |
| 3755 | * qla2x00_mem_alloc |
| 3756 | * Allocates adapter memory. |
| 3757 | * |
| 3758 | * Returns: |
| 3759 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3760 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3761 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3762 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3763 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3764 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3765 | { |
| 3766 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3767 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3768 | 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] | 3769 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3770 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3771 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3772 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3773 | if (qlt_mem_alloc(ha) < 0) |
| 3774 | goto fail_free_init_cb; |
| 3775 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3776 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3777 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3778 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3779 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3780 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3781 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3782 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3783 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3784 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3785 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3786 | /* Allocate cache for CT6 Ctx. */ |
| 3787 | if (!ctx_cachep) { |
| 3788 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3789 | sizeof(struct ct6_dsd), 0, |
| 3790 | SLAB_HWCACHE_ALIGN, NULL); |
| 3791 | if (!ctx_cachep) |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3792 | goto fail_free_srb_mempool; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3793 | } |
| 3794 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3795 | ctx_cachep); |
| 3796 | if (!ha->ctx_mempool) |
| 3797 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3798 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3799 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3800 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3801 | } |
| 3802 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3803 | /* Get memory for cached NVRAM */ |
| 3804 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3805 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3806 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3807 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3808 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3809 | ha->pdev->device); |
| 3810 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3811 | DMA_POOL_SIZE, 8, 0); |
| 3812 | if (!ha->s_dma_pool) |
| 3813 | goto fail_free_nvram; |
| 3814 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3815 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3816 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3817 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3818 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3819 | if (IS_P3P_TYPE(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3820 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3821 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3822 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3823 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3824 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3825 | goto fail_s_dma_pool; |
| 3826 | } |
| 3827 | |
| 3828 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3829 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3830 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3831 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3832 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3833 | goto fail_dl_dma_pool; |
| 3834 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3835 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3836 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3837 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3838 | } |
| 3839 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3840 | /* Allocate memory for SNS commands */ |
| 3841 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3842 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3843 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3844 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3845 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3846 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3847 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 3848 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3849 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3850 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3851 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3852 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3853 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3854 | goto fail_dma_pool; |
| 3855 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3856 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3857 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3858 | if (!ha->ct_sns) |
| 3859 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3860 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 3861 | "ms_iocb=%p ct_sns=%p.\n", |
| 3862 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3863 | } |
| 3864 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3865 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3866 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 3867 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3868 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 3869 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3870 | goto fail_req; |
| 3871 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3872 | (*req)->length = req_len; |
| 3873 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3874 | ((*req)->length + 1) * sizeof(request_t), |
| 3875 | &(*req)->dma, GFP_KERNEL); |
| 3876 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3877 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 3878 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3879 | goto fail_req_ring; |
| 3880 | } |
| 3881 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3882 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 3883 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3884 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 3885 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3886 | goto fail_rsp; |
| 3887 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3888 | (*rsp)->hw = ha; |
| 3889 | (*rsp)->length = rsp_len; |
| 3890 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3891 | ((*rsp)->length + 1) * sizeof(response_t), |
| 3892 | &(*rsp)->dma, GFP_KERNEL); |
| 3893 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3894 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 3895 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3896 | goto fail_rsp_ring; |
| 3897 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3898 | (*req)->rsp = *rsp; |
| 3899 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3900 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 3901 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 3902 | "rsp->length=%d rsp->ring=%p.\n", |
| 3903 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 3904 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3905 | /* Allocate memory for NVRAM data for vports */ |
| 3906 | if (ha->nvram_npiv_size) { |
| 3907 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3908 | ha->nvram_npiv_size, GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3909 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3910 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 3911 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3912 | goto fail_npiv_info; |
| 3913 | } |
| 3914 | } else |
| 3915 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3916 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3917 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3918 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3919 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3920 | &ha->ex_init_cb_dma); |
| 3921 | if (!ha->ex_init_cb) |
| 3922 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3923 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 3924 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3925 | } |
| 3926 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3927 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 3928 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3929 | /* Get consistent memory allocated for Async Port-Database. */ |
| 3930 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3931 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3932 | &ha->async_pd_dma); |
| 3933 | if (!ha->async_pd) |
| 3934 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3935 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 3936 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3937 | } |
| 3938 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3939 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3940 | |
| 3941 | /* Allocate memory for our loop_id bitmap */ |
| 3942 | ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), |
| 3943 | GFP_KERNEL); |
| 3944 | if (!ha->loop_id_map) |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3945 | goto fail_loop_id_map; |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3946 | else { |
| 3947 | qla2x00_set_reserved_loop_ids(ha); |
| 3948 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3949 | "loop_id_map=%p.\n", ha->loop_id_map); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3950 | } |
| 3951 | |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3952 | return 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3953 | |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3954 | fail_loop_id_map: |
| 3955 | 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] | 3956 | fail_async_pd: |
| 3957 | 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] | 3958 | fail_ex_init_cb: |
| 3959 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3960 | fail_npiv_info: |
| 3961 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 3962 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 3963 | (*rsp)->ring = NULL; |
| 3964 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3965 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3966 | kfree(*rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3967 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3968 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 3969 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 3970 | (*req)->ring = NULL; |
| 3971 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3972 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3973 | kfree(*req); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3974 | fail_req: |
| 3975 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 3976 | ha->ct_sns, ha->ct_sns_dma); |
| 3977 | ha->ct_sns = NULL; |
| 3978 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3979 | fail_free_ms_iocb: |
| 3980 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3981 | ha->ms_iocb = NULL; |
| 3982 | ha->ms_iocb_dma = 0; |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3983 | |
| 3984 | if (ha->sns_cmd) |
| 3985 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
| 3986 | ha->sns_cmd, ha->sns_cmd_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3987 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3988 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3989 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3990 | ha->fcp_cmnd_dma_pool = NULL; |
| 3991 | } |
| 3992 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3993 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3994 | dma_pool_destroy(ha->dl_dma_pool); |
| 3995 | ha->dl_dma_pool = NULL; |
| 3996 | } |
| 3997 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3998 | dma_pool_destroy(ha->s_dma_pool); |
| 3999 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4000 | fail_free_nvram: |
| 4001 | kfree(ha->nvram); |
| 4002 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4003 | fail_free_ctx_mempool: |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4004 | if (ha->ctx_mempool) |
| 4005 | mempool_destroy(ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4006 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4007 | fail_free_srb_mempool: |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 4008 | if (ha->srb_mempool) |
| 4009 | mempool_destroy(ha->srb_mempool); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4010 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4011 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 4012 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 4013 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4014 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4015 | ha->gid_list = NULL; |
| 4016 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4017 | fail_free_tgt_mem: |
| 4018 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4019 | fail_free_init_cb: |
| 4020 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 4021 | ha->init_cb_dma); |
| 4022 | ha->init_cb = NULL; |
| 4023 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4024 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4025 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 4026 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4027 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4028 | } |
| 4029 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4030 | int |
| 4031 | qla2x00_set_exlogins_buffer(scsi_qla_host_t *vha) |
| 4032 | { |
| 4033 | int rval; |
| 4034 | uint16_t size, max_cnt, temp; |
| 4035 | struct qla_hw_data *ha = vha->hw; |
| 4036 | |
| 4037 | /* Return if we don't need to alloacate any extended logins */ |
| 4038 | if (!ql2xexlogins) |
| 4039 | return QLA_SUCCESS; |
| 4040 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4041 | if (!IS_EXLOGIN_OFFLD_CAPABLE(ha)) |
| 4042 | return QLA_SUCCESS; |
| 4043 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4044 | ql_log(ql_log_info, vha, 0xd021, "EXLOGIN count: %d.\n", ql2xexlogins); |
| 4045 | max_cnt = 0; |
| 4046 | rval = qla_get_exlogin_status(vha, &size, &max_cnt); |
| 4047 | if (rval != QLA_SUCCESS) { |
| 4048 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd029, |
| 4049 | "Failed to get exlogin status.\n"); |
| 4050 | return rval; |
| 4051 | } |
| 4052 | |
| 4053 | temp = (ql2xexlogins > max_cnt) ? max_cnt : ql2xexlogins; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4054 | temp *= size; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4055 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4056 | if (temp != ha->exlogin_size) { |
| 4057 | qla2x00_free_exlogin_buffer(ha); |
| 4058 | ha->exlogin_size = temp; |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4059 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4060 | ql_log(ql_log_info, vha, 0xd024, |
| 4061 | "EXLOGIN: max_logins=%d, portdb=0x%x, total=%d.\n", |
| 4062 | max_cnt, size, temp); |
| 4063 | |
| 4064 | ql_log(ql_log_info, vha, 0xd025, |
| 4065 | "EXLOGIN: requested size=0x%x\n", ha->exlogin_size); |
| 4066 | |
| 4067 | /* Get consistent memory for extended logins */ |
| 4068 | ha->exlogin_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 4069 | ha->exlogin_size, &ha->exlogin_buf_dma, GFP_KERNEL); |
| 4070 | if (!ha->exlogin_buf) { |
| 4071 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd02a, |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4072 | "Failed to allocate memory for exlogin_buf_dma.\n"); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4073 | return -ENOMEM; |
| 4074 | } |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4075 | } |
| 4076 | |
| 4077 | /* Now configure the dma buffer */ |
| 4078 | rval = qla_set_exlogin_mem_cfg(vha, ha->exlogin_buf_dma); |
| 4079 | if (rval) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4080 | ql_log(ql_log_fatal, vha, 0xd033, |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 4081 | "Setup extended login buffer ****FAILED****.\n"); |
| 4082 | qla2x00_free_exlogin_buffer(ha); |
| 4083 | } |
| 4084 | |
| 4085 | return rval; |
| 4086 | } |
| 4087 | |
| 4088 | /* |
| 4089 | * qla2x00_free_exlogin_buffer |
| 4090 | * |
| 4091 | * Input: |
| 4092 | * ha = adapter block pointer |
| 4093 | */ |
| 4094 | void |
| 4095 | qla2x00_free_exlogin_buffer(struct qla_hw_data *ha) |
| 4096 | { |
| 4097 | if (ha->exlogin_buf) { |
| 4098 | dma_free_coherent(&ha->pdev->dev, ha->exlogin_size, |
| 4099 | ha->exlogin_buf, ha->exlogin_buf_dma); |
| 4100 | ha->exlogin_buf = NULL; |
| 4101 | ha->exlogin_size = 0; |
| 4102 | } |
| 4103 | } |
| 4104 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4105 | static void |
| 4106 | qla2x00_number_of_exch(scsi_qla_host_t *vha, u32 *ret_cnt, u16 max_cnt) |
| 4107 | { |
| 4108 | u32 temp; |
| 4109 | *ret_cnt = FW_DEF_EXCHANGES_CNT; |
| 4110 | |
| 4111 | if (qla_ini_mode_enabled(vha)) { |
| 4112 | if (ql2xiniexchg > max_cnt) |
| 4113 | ql2xiniexchg = max_cnt; |
| 4114 | |
| 4115 | if (ql2xiniexchg > FW_DEF_EXCHANGES_CNT) |
| 4116 | *ret_cnt = ql2xiniexchg; |
| 4117 | } else if (qla_tgt_mode_enabled(vha)) { |
| 4118 | if (ql2xexchoffld > max_cnt) |
| 4119 | ql2xexchoffld = max_cnt; |
| 4120 | |
| 4121 | if (ql2xexchoffld > FW_DEF_EXCHANGES_CNT) |
| 4122 | *ret_cnt = ql2xexchoffld; |
| 4123 | } else if (qla_dual_mode_enabled(vha)) { |
| 4124 | temp = ql2xiniexchg + ql2xexchoffld; |
| 4125 | if (temp > max_cnt) { |
| 4126 | ql2xiniexchg -= (temp - max_cnt)/2; |
| 4127 | ql2xexchoffld -= (((temp - max_cnt)/2) + 1); |
| 4128 | temp = max_cnt; |
| 4129 | } |
| 4130 | |
| 4131 | if (temp > FW_DEF_EXCHANGES_CNT) |
| 4132 | *ret_cnt = temp; |
| 4133 | } |
| 4134 | } |
| 4135 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4136 | int |
| 4137 | qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) |
| 4138 | { |
| 4139 | int rval; |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4140 | u16 size, max_cnt; |
| 4141 | u32 temp; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4142 | struct qla_hw_data *ha = vha->hw; |
| 4143 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4144 | if (!ha->flags.exchoffld_enabled) |
| 4145 | return QLA_SUCCESS; |
| 4146 | |
| 4147 | if (!IS_EXCHG_OFFLD_CAPABLE(ha)) |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4148 | return QLA_SUCCESS; |
| 4149 | |
| 4150 | ql_log(ql_log_info, vha, 0xd014, |
| 4151 | "Exchange offload count: %d.\n", ql2xexlogins); |
| 4152 | |
| 4153 | max_cnt = 0; |
| 4154 | rval = qla_get_exchoffld_status(vha, &size, &max_cnt); |
| 4155 | if (rval != QLA_SUCCESS) { |
| 4156 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd012, |
| 4157 | "Failed to get exlogin status.\n"); |
| 4158 | return rval; |
| 4159 | } |
| 4160 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4161 | qla2x00_number_of_exch(vha, &temp, max_cnt); |
| 4162 | temp *= size; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4163 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4164 | if (temp != ha->exchoffld_size) { |
| 4165 | qla2x00_free_exchoffld_buffer(ha); |
| 4166 | ha->exchoffld_size = temp; |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4167 | |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4168 | ql_log(ql_log_info, vha, 0xd016, |
| 4169 | "Exchange offload: max_count=%d, buffers=0x%x, total=%d.\n", |
| 4170 | max_cnt, size, temp); |
| 4171 | |
| 4172 | ql_log(ql_log_info, vha, 0xd017, |
| 4173 | "Exchange Buffers requested size = 0x%x\n", |
| 4174 | ha->exchoffld_size); |
| 4175 | |
| 4176 | /* Get consistent memory for extended logins */ |
| 4177 | ha->exchoffld_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 4178 | ha->exchoffld_size, &ha->exchoffld_buf_dma, GFP_KERNEL); |
| 4179 | if (!ha->exchoffld_buf) { |
| 4180 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
| 4181 | "Failed to allocate memory for exchoffld_buf_dma.\n"); |
| 4182 | return -ENOMEM; |
| 4183 | } |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4184 | } |
| 4185 | |
| 4186 | /* Now configure the dma buffer */ |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4187 | rval = qla_set_exchoffld_mem_cfg(vha); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4188 | if (rval) { |
| 4189 | ql_log(ql_log_fatal, vha, 0xd02e, |
| 4190 | "Setup exchange offload buffer ****FAILED****.\n"); |
| 4191 | qla2x00_free_exchoffld_buffer(ha); |
Quinn Tran | 99e1b68 | 2017-06-02 09:12:03 -0700 | [diff] [blame] | 4192 | } else { |
| 4193 | /* re-adjust number of target exchange */ |
| 4194 | struct init_cb_81xx *icb = (struct init_cb_81xx *)ha->init_cb; |
| 4195 | |
| 4196 | if (qla_ini_mode_enabled(vha)) |
| 4197 | icb->exchange_count = 0; |
| 4198 | else |
| 4199 | icb->exchange_count = cpu_to_le16(ql2xexchoffld); |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 4200 | } |
| 4201 | |
| 4202 | return rval; |
| 4203 | } |
| 4204 | |
| 4205 | /* |
| 4206 | * qla2x00_free_exchoffld_buffer |
| 4207 | * |
| 4208 | * Input: |
| 4209 | * ha = adapter block pointer |
| 4210 | */ |
| 4211 | void |
| 4212 | qla2x00_free_exchoffld_buffer(struct qla_hw_data *ha) |
| 4213 | { |
| 4214 | if (ha->exchoffld_buf) { |
| 4215 | dma_free_coherent(&ha->pdev->dev, ha->exchoffld_size, |
| 4216 | ha->exchoffld_buf, ha->exchoffld_buf_dma); |
| 4217 | ha->exchoffld_buf = NULL; |
| 4218 | ha->exchoffld_size = 0; |
| 4219 | } |
| 4220 | } |
| 4221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4222 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4223 | * qla2x00_free_fw_dump |
| 4224 | * Frees fw dump stuff. |
| 4225 | * |
| 4226 | * Input: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 4227 | * ha = adapter block pointer |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4228 | */ |
| 4229 | static void |
| 4230 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 4231 | { |
| 4232 | if (ha->fce) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4233 | dma_free_coherent(&ha->pdev->dev, |
| 4234 | FCE_SIZE, ha->fce, ha->fce_dma); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4235 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4236 | if (ha->eft) |
| 4237 | dma_free_coherent(&ha->pdev->dev, |
| 4238 | EFT_SIZE, ha->eft, ha->eft_dma); |
| 4239 | |
| 4240 | if (ha->fw_dump) |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4241 | vfree(ha->fw_dump); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4242 | if (ha->fw_dump_template) |
| 4243 | vfree(ha->fw_dump_template); |
| 4244 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4245 | ha->fce = NULL; |
| 4246 | ha->fce_dma = 0; |
| 4247 | ha->eft = NULL; |
| 4248 | ha->eft_dma = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4249 | ha->fw_dumped = 0; |
Hiral Patel | 61f098d | 2014-04-11 16:54:21 -0400 | [diff] [blame] | 4250 | ha->fw_dump_cap_flags = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4251 | ha->fw_dump_reading = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4252 | ha->fw_dump = NULL; |
| 4253 | ha->fw_dump_len = 0; |
| 4254 | ha->fw_dump_template = NULL; |
| 4255 | ha->fw_dump_template_len = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4256 | } |
| 4257 | |
| 4258 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4259 | * qla2x00_mem_free |
| 4260 | * Frees all adapter allocated memory. |
| 4261 | * |
| 4262 | * Input: |
| 4263 | * ha = adapter block pointer. |
| 4264 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 4265 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4266 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4267 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4268 | qla2x00_free_fw_dump(ha); |
| 4269 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4270 | if (ha->mctp_dump) |
| 4271 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 4272 | ha->mctp_dump_dma); |
| 4273 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4274 | if (ha->srb_mempool) |
| 4275 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4276 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4277 | if (ha->dcbx_tlv) |
| 4278 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 4279 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 4280 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4281 | if (ha->xgmac_data) |
| 4282 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 4283 | ha->xgmac_data, ha->xgmac_data_dma); |
| 4284 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4285 | if (ha->sns_cmd) |
| 4286 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4287 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4288 | |
| 4289 | if (ha->ct_sns) |
| 4290 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4291 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4292 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 4293 | if (ha->sfp_data) |
| 4294 | dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); |
| 4295 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4296 | if (ha->ms_iocb) |
| 4297 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 4298 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4299 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4300 | dma_pool_free(ha->s_dma_pool, |
| 4301 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4302 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4303 | if (ha->async_pd) |
| 4304 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 4305 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4306 | if (ha->s_dma_pool) |
| 4307 | dma_pool_destroy(ha->s_dma_pool); |
| 4308 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4309 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 4310 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 4311 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4312 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4313 | if (IS_QLA82XX(ha)) { |
| 4314 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 4315 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 4316 | |
| 4317 | /* clean up allocated prev pool */ |
| 4318 | list_for_each_entry_safe(dsd_ptr, |
| 4319 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 4320 | dma_pool_free(ha->dl_dma_pool, |
| 4321 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 4322 | list_del(&dsd_ptr->list); |
| 4323 | kfree(dsd_ptr); |
| 4324 | } |
| 4325 | } |
| 4326 | } |
| 4327 | |
| 4328 | if (ha->dl_dma_pool) |
| 4329 | dma_pool_destroy(ha->dl_dma_pool); |
| 4330 | |
| 4331 | if (ha->fcp_cmnd_dma_pool) |
| 4332 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 4333 | |
| 4334 | if (ha->ctx_mempool) |
| 4335 | mempool_destroy(ha->ctx_mempool); |
| 4336 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4337 | qlt_mem_free(ha); |
| 4338 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4339 | if (ha->init_cb) |
| 4340 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4341 | ha->init_cb, ha->init_cb_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4342 | vfree(ha->optrom_buffer); |
| 4343 | kfree(ha->nvram); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4344 | kfree(ha->npiv_info); |
Andrew Vasquez | 7a67735 | 2012-02-09 11:15:56 -0800 | [diff] [blame] | 4345 | kfree(ha->swl); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4346 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4347 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4348 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4349 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4350 | ha->sns_cmd = NULL; |
| 4351 | ha->sns_cmd_dma = 0; |
| 4352 | ha->ct_sns = NULL; |
| 4353 | ha->ct_sns_dma = 0; |
| 4354 | ha->ms_iocb = NULL; |
| 4355 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4356 | ha->init_cb = NULL; |
| 4357 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4358 | ha->ex_init_cb = NULL; |
| 4359 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4360 | ha->async_pd = NULL; |
| 4361 | ha->async_pd_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4362 | |
| 4363 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4364 | ha->dl_dma_pool = NULL; |
| 4365 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4366 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4367 | ha->gid_list = NULL; |
| 4368 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4369 | |
| 4370 | ha->tgt.atio_ring = NULL; |
| 4371 | ha->tgt.atio_dma = 0; |
| 4372 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4373 | } |
| 4374 | |
| 4375 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 4376 | struct qla_hw_data *ha) |
| 4377 | { |
| 4378 | struct Scsi_Host *host; |
| 4379 | struct scsi_qla_host *vha = NULL; |
| 4380 | |
| 4381 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4382 | if (!host) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4383 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 4384 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4385 | return NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4386 | } |
| 4387 | |
| 4388 | /* Clear our data area */ |
| 4389 | vha = shost_priv(host); |
| 4390 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 4391 | |
| 4392 | vha->host = host; |
| 4393 | vha->host_no = host->host_no; |
| 4394 | vha->hw = ha; |
| 4395 | |
| 4396 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 4397 | INIT_LIST_HEAD(&vha->work_list); |
| 4398 | INIT_LIST_HEAD(&vha->list); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4399 | INIT_LIST_HEAD(&vha->qla_cmd_list); |
| 4400 | INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list); |
Alexei Potashnik | 71cdc07 | 2015-12-17 14:57:01 -0500 | [diff] [blame] | 4401 | INIT_LIST_HEAD(&vha->logo_list); |
Alexei Potashnik | b7bd104 | 2015-12-17 14:57:02 -0500 | [diff] [blame] | 4402 | INIT_LIST_HEAD(&vha->plogi_ack_list); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 4403 | INIT_LIST_HEAD(&vha->qp_list); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4404 | INIT_LIST_HEAD(&vha->gnl.fcports); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4405 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4406 | spin_lock_init(&vha->work_lock); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4407 | spin_lock_init(&vha->cmd_list_lock); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4408 | init_waitqueue_head(&vha->fcport_waitQ); |
Joe Carnuccio | c4a9b53 | 2017-03-15 09:48:43 -0700 | [diff] [blame] | 4409 | init_waitqueue_head(&vha->vref_waitq); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4410 | |
Bart Van Assche | 2fdbc65 | 2017-01-20 13:31:13 -0800 | [diff] [blame] | 4411 | vha->gnl.size = sizeof(struct get_name_list_extended) * |
| 4412 | (ha->max_loop_id + 1); |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4413 | vha->gnl.l = dma_alloc_coherent(&ha->pdev->dev, |
| 4414 | vha->gnl.size, &vha->gnl.ldma, GFP_KERNEL); |
| 4415 | if (!vha->gnl.l) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4416 | ql_log(ql_log_fatal, vha, 0xd04a, |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 4417 | "Alloc failed for name list.\n"); |
| 4418 | scsi_remove_host(vha->host); |
| 4419 | return NULL; |
| 4420 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4421 | |
| 4422 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4423 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 4424 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 4425 | vha->host, vha->hw, vha, |
| 4426 | dev_name(&(ha->pdev->dev))); |
| 4427 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4428 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4429 | } |
| 4430 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4431 | struct qla_work_evt * |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4432 | 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] | 4433 | { |
| 4434 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4435 | uint8_t bail; |
| 4436 | |
| 4437 | QLA_VHA_MARK_BUSY(vha, bail); |
| 4438 | if (bail) |
| 4439 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4440 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4441 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4442 | if (!e) { |
| 4443 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4444 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4445 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4446 | |
| 4447 | INIT_LIST_HEAD(&e->list); |
| 4448 | e->type = type; |
| 4449 | e->flags = QLA_EVT_FLAG_FREE; |
| 4450 | return e; |
| 4451 | } |
| 4452 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4453 | int |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4454 | 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] | 4455 | { |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4456 | unsigned long flags; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4457 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4458 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4459 | list_add_tail(&e->list, &vha->work_list); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4460 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Quinn Tran | ec7193e | 2017-03-15 09:48:55 -0700 | [diff] [blame] | 4461 | |
| 4462 | if (QLA_EARLY_LINKUP(vha->hw)) |
| 4463 | schedule_work(&vha->iocb_work); |
| 4464 | else |
| 4465 | qla2xxx_wake_dpc(vha); |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4466 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4467 | return QLA_SUCCESS; |
| 4468 | } |
| 4469 | |
| 4470 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4471 | 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] | 4472 | u32 data) |
| 4473 | { |
| 4474 | struct qla_work_evt *e; |
| 4475 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4476 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4477 | if (!e) |
| 4478 | return QLA_FUNCTION_FAILED; |
| 4479 | |
| 4480 | e->u.aen.code = code; |
| 4481 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4482 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4483 | } |
| 4484 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4485 | int |
| 4486 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 4487 | { |
| 4488 | struct qla_work_evt *e; |
| 4489 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4490 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4491 | if (!e) |
| 4492 | return QLA_FUNCTION_FAILED; |
| 4493 | |
| 4494 | 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] | 4495 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4496 | } |
| 4497 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4498 | #define qla2x00_post_async_work(name, type) \ |
| 4499 | int qla2x00_post_async_##name##_work( \ |
| 4500 | struct scsi_qla_host *vha, \ |
| 4501 | fc_port_t *fcport, uint16_t *data) \ |
| 4502 | { \ |
| 4503 | struct qla_work_evt *e; \ |
| 4504 | \ |
| 4505 | e = qla2x00_alloc_work(vha, type); \ |
| 4506 | if (!e) \ |
| 4507 | return QLA_FUNCTION_FAILED; \ |
| 4508 | \ |
| 4509 | e->u.logio.fcport = fcport; \ |
| 4510 | if (data) { \ |
| 4511 | e->u.logio.data[0] = data[0]; \ |
| 4512 | e->u.logio.data[1] = data[1]; \ |
| 4513 | } \ |
| 4514 | return qla2x00_post_work(vha, e); \ |
| 4515 | } |
| 4516 | |
| 4517 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4518 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 4519 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4520 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 4521 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4522 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4523 | int |
| 4524 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 4525 | { |
| 4526 | struct qla_work_evt *e; |
| 4527 | |
| 4528 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 4529 | if (!e) |
| 4530 | return QLA_FUNCTION_FAILED; |
| 4531 | |
| 4532 | e->u.uevent.code = code; |
| 4533 | return qla2x00_post_work(vha, e); |
| 4534 | } |
| 4535 | |
| 4536 | static void |
| 4537 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 4538 | { |
| 4539 | char event_string[40]; |
| 4540 | char *envp[] = { event_string, NULL }; |
| 4541 | |
| 4542 | switch (code) { |
| 4543 | case QLA_UEVENT_CODE_FW_DUMP: |
| 4544 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 4545 | vha->host_no); |
| 4546 | break; |
| 4547 | default: |
| 4548 | /* do nothing */ |
| 4549 | break; |
| 4550 | } |
| 4551 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 4552 | } |
| 4553 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4554 | int |
| 4555 | qlafx00_post_aenfx_work(struct scsi_qla_host *vha, uint32_t evtcode, |
| 4556 | uint32_t *data, int cnt) |
| 4557 | { |
| 4558 | struct qla_work_evt *e; |
| 4559 | |
| 4560 | e = qla2x00_alloc_work(vha, QLA_EVT_AENFX); |
| 4561 | if (!e) |
| 4562 | return QLA_FUNCTION_FAILED; |
| 4563 | |
| 4564 | e->u.aenfx.evtcode = evtcode; |
| 4565 | e->u.aenfx.count = cnt; |
| 4566 | memcpy(e->u.aenfx.mbx, data, sizeof(*data) * cnt); |
| 4567 | return qla2x00_post_work(vha, e); |
| 4568 | } |
| 4569 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4570 | int qla24xx_post_upd_fcport_work(struct scsi_qla_host *vha, fc_port_t *fcport) |
| 4571 | { |
| 4572 | struct qla_work_evt *e; |
| 4573 | |
| 4574 | e = qla2x00_alloc_work(vha, QLA_EVT_UPD_FCPORT); |
| 4575 | if (!e) |
| 4576 | return QLA_FUNCTION_FAILED; |
| 4577 | |
| 4578 | e->u.fcport.fcport = fcport; |
| 4579 | return qla2x00_post_work(vha, e); |
| 4580 | } |
| 4581 | |
| 4582 | static |
| 4583 | void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) |
| 4584 | { |
| 4585 | unsigned long flags; |
| 4586 | fc_port_t *fcport = NULL; |
| 4587 | struct qlt_plogi_ack_t *pla = |
| 4588 | (struct qlt_plogi_ack_t *)e->u.new_sess.pla; |
| 4589 | |
| 4590 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 4591 | fcport = qla2x00_find_fcport_by_wwpn(vha, e->u.new_sess.port_name, 1); |
| 4592 | if (fcport) { |
| 4593 | fcport->d_id = e->u.new_sess.id; |
| 4594 | if (pla) { |
| 4595 | fcport->fw_login_state = DSC_LS_PLOGI_PEND; |
| 4596 | qlt_plogi_ack_link(vha, pla, fcport, QLT_PLOGI_LINK_SAME_WWN); |
| 4597 | /* we took an extra ref_count to prevent PLOGI ACK when |
| 4598 | * fcport/sess has not been created. |
| 4599 | */ |
| 4600 | pla->ref_count--; |
| 4601 | } |
| 4602 | } else { |
| 4603 | fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
| 4604 | if (fcport) { |
| 4605 | fcport->d_id = e->u.new_sess.id; |
| 4606 | fcport->scan_state = QLA_FCPORT_FOUND; |
| 4607 | fcport->flags |= FCF_FABRIC_DEVICE; |
| 4608 | fcport->fw_login_state = DSC_LS_PLOGI_PEND; |
| 4609 | |
| 4610 | memcpy(fcport->port_name, e->u.new_sess.port_name, |
| 4611 | WWN_SIZE); |
| 4612 | list_add_tail(&fcport->list, &vha->vp_fcports); |
| 4613 | |
| 4614 | if (pla) { |
| 4615 | qlt_plogi_ack_link(vha, pla, fcport, |
| 4616 | QLT_PLOGI_LINK_SAME_WWN); |
| 4617 | pla->ref_count--; |
| 4618 | } |
| 4619 | } |
| 4620 | } |
| 4621 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 4622 | |
| 4623 | if (fcport) { |
| 4624 | if (pla) |
| 4625 | qlt_plogi_ack_unref(vha, pla); |
| 4626 | else |
| 4627 | qla24xx_async_gnl(vha, fcport); |
| 4628 | } |
| 4629 | } |
| 4630 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4631 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4632 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4633 | { |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4634 | struct qla_work_evt *e, *tmp; |
| 4635 | unsigned long flags; |
| 4636 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4637 | |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4638 | spin_lock_irqsave(&vha->work_lock, flags); |
| 4639 | list_splice_init(&vha->work_list, &work); |
| 4640 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 4641 | |
| 4642 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4643 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4644 | |
| 4645 | switch (e->type) { |
| 4646 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4647 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4648 | e->u.aen.code, e->u.aen.data); |
| 4649 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4650 | case QLA_EVT_IDC_ACK: |
| 4651 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 4652 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4653 | case QLA_EVT_ASYNC_LOGIN: |
| 4654 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 4655 | e->u.logio.data); |
| 4656 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4657 | case QLA_EVT_ASYNC_LOGOUT: |
| 4658 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 4659 | break; |
| 4660 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 4661 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 4662 | e->u.logio.data); |
| 4663 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4664 | case QLA_EVT_ASYNC_ADISC: |
| 4665 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 4666 | e->u.logio.data); |
| 4667 | break; |
| 4668 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 4669 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 4670 | e->u.logio.data); |
| 4671 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4672 | case QLA_EVT_UEVENT: |
| 4673 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 4674 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4675 | case QLA_EVT_AENFX: |
| 4676 | qlafx00_process_aen(vha, e); |
| 4677 | break; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4678 | case QLA_EVT_GIDPN: |
| 4679 | qla24xx_async_gidpn(vha, e->u.fcport.fcport); |
| 4680 | break; |
| 4681 | case QLA_EVT_GPNID: |
| 4682 | qla24xx_async_gpnid(vha, &e->u.gpnid.id); |
| 4683 | break; |
| 4684 | case QLA_EVT_GPNID_DONE: |
| 4685 | qla24xx_async_gpnid_done(vha, e->u.iosb.sp); |
| 4686 | break; |
| 4687 | case QLA_EVT_NEW_SESS: |
| 4688 | qla24xx_create_new_sess(vha, e); |
| 4689 | break; |
| 4690 | case QLA_EVT_GPDB: |
| 4691 | qla24xx_async_gpdb(vha, e->u.fcport.fcport, |
| 4692 | e->u.fcport.opt); |
| 4693 | break; |
| 4694 | case QLA_EVT_GPSC: |
| 4695 | qla24xx_async_gpsc(vha, e->u.fcport.fcport); |
| 4696 | break; |
| 4697 | case QLA_EVT_UPD_FCPORT: |
| 4698 | qla2x00_update_fcport(vha, e->u.fcport.fcport); |
| 4699 | break; |
| 4700 | case QLA_EVT_GNL: |
| 4701 | qla24xx_async_gnl(vha, e->u.fcport.fcport); |
| 4702 | break; |
| 4703 | case QLA_EVT_NACK: |
| 4704 | qla24xx_do_nack_work(vha, e); |
| 4705 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4706 | } |
| 4707 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 4708 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4709 | |
| 4710 | /* For each work completed decrement vha ref count */ |
| 4711 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4712 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4713 | } |
Andrew Vasquez | f999f4c1 | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4714 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4715 | /* Relogins all the fcports of a vport |
| 4716 | * Context: dpc thread |
| 4717 | */ |
| 4718 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 4719 | { |
| 4720 | fc_port_t *fcport; |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 4721 | int status; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4722 | struct event_arg ea; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4723 | |
| 4724 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 4725 | /* |
| 4726 | * If the port is not ONLINE then try to login |
| 4727 | * to it if we haven't run out of retries. |
| 4728 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4729 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
| 4730 | fcport->login_retry && !(fcport->flags & FCF_ASYNC_SENT)) { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4731 | fcport->login_retry--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4732 | if (fcport->flags & FCF_FABRIC_DEVICE) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 4733 | ql_dbg(ql_dbg_disc, fcport->vha, 0x2108, |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4734 | "%s %8phC DS %d LS %d\n", __func__, |
| 4735 | fcport->port_name, fcport->disc_state, |
| 4736 | fcport->fw_login_state); |
| 4737 | memset(&ea, 0, sizeof(ea)); |
| 4738 | ea.event = FCME_RELOGIN; |
| 4739 | ea.fcport = fcport; |
| 4740 | qla2x00_fcport_event_handler(vha, &ea); |
| 4741 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4742 | status = qla2x00_local_device_login(vha, |
| 4743 | fcport); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4744 | if (status == QLA_SUCCESS) { |
| 4745 | fcport->old_loop_id = fcport->loop_id; |
| 4746 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 4747 | "Port login OK: logged in ID 0x%x.\n", |
| 4748 | fcport->loop_id); |
| 4749 | qla2x00_update_fcport(vha, fcport); |
| 4750 | } else if (status == 1) { |
| 4751 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 4752 | /* retry the login again */ |
| 4753 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 4754 | "Retrying %d login again loop_id 0x%x.\n", |
| 4755 | fcport->login_retry, |
| 4756 | fcport->loop_id); |
| 4757 | } else { |
| 4758 | fcport->login_retry = 0; |
| 4759 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4760 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 4761 | if (fcport->login_retry == 0 && |
| 4762 | status != QLA_SUCCESS) |
| 4763 | qla2x00_clear_loop_id(fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4764 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4765 | } |
| 4766 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 4767 | break; |
| 4768 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4769 | } |
| 4770 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4771 | /* Schedule work on any of the dpc-workqueues */ |
| 4772 | void |
| 4773 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 4774 | { |
| 4775 | struct qla_hw_data *ha = base_vha->hw; |
| 4776 | |
| 4777 | switch (work_code) { |
| 4778 | case MBA_IDC_AEN: /* 0x8200 */ |
| 4779 | if (ha->dpc_lp_wq) |
| 4780 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 4781 | break; |
| 4782 | |
| 4783 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 4784 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4785 | if (ha->dpc_hp_wq) |
| 4786 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 4787 | } else |
| 4788 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 4789 | "NIC Core reset is already active. Skip " |
| 4790 | "scheduling it again.\n"); |
| 4791 | break; |
| 4792 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 4793 | if (ha->dpc_hp_wq) |
| 4794 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 4795 | break; |
| 4796 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 4797 | if (ha->dpc_hp_wq) |
| 4798 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 4799 | break; |
| 4800 | default: |
| 4801 | ql_log(ql_log_warn, base_vha, 0xb05f, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 4802 | "Unknown work-code=0x%x.\n", work_code); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4803 | } |
| 4804 | |
| 4805 | return; |
| 4806 | } |
| 4807 | |
| 4808 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 4809 | void |
| 4810 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 4811 | { |
| 4812 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4813 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4814 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4815 | uint32_t dev_state = 0; |
| 4816 | |
| 4817 | qla83xx_idc_lock(base_vha, 0); |
| 4818 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4819 | qla83xx_reset_ownership(base_vha); |
| 4820 | if (ha->flags.nic_core_reset_owner) { |
| 4821 | ha->flags.nic_core_reset_owner = 0; |
| 4822 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4823 | QLA8XXX_DEV_FAILED); |
| 4824 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 4825 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4826 | } |
| 4827 | qla83xx_idc_unlock(base_vha, 0); |
| 4828 | } |
| 4829 | |
| 4830 | /* Work: Execute IDC state handler */ |
| 4831 | void |
| 4832 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 4833 | { |
| 4834 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4835 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4836 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4837 | uint32_t dev_state = 0; |
| 4838 | |
| 4839 | qla83xx_idc_lock(base_vha, 0); |
| 4840 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4841 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 4842 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 4843 | qla83xx_idc_state_handler(base_vha); |
| 4844 | qla83xx_idc_unlock(base_vha, 0); |
| 4845 | } |
| 4846 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4847 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4848 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 4849 | { |
| 4850 | int rval = QLA_SUCCESS; |
| 4851 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 4852 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 4853 | |
| 4854 | do { |
| 4855 | if (time_after(jiffies, heart_beat_wait)) { |
| 4856 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 4857 | "Nic Core f/w is not alive.\n"); |
| 4858 | rval = QLA_FUNCTION_FAILED; |
| 4859 | break; |
| 4860 | } |
| 4861 | |
| 4862 | qla83xx_idc_lock(base_vha, 0); |
| 4863 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4864 | &heart_beat_counter1); |
| 4865 | qla83xx_idc_unlock(base_vha, 0); |
| 4866 | msleep(100); |
| 4867 | qla83xx_idc_lock(base_vha, 0); |
| 4868 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4869 | &heart_beat_counter2); |
| 4870 | qla83xx_idc_unlock(base_vha, 0); |
| 4871 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 4872 | |
| 4873 | return rval; |
| 4874 | } |
| 4875 | |
| 4876 | /* Work: Perform NIC Core Reset handling */ |
| 4877 | void |
| 4878 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 4879 | { |
| 4880 | struct qla_hw_data *ha = |
| 4881 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 4882 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4883 | uint32_t dev_state = 0; |
| 4884 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4885 | if (IS_QLA2031(ha)) { |
| 4886 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 4887 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 4888 | "Failed to dump mctp\n"); |
| 4889 | return; |
| 4890 | } |
| 4891 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4892 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4893 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 4894 | qla83xx_idc_lock(base_vha, 0); |
| 4895 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4896 | &dev_state); |
| 4897 | qla83xx_idc_unlock(base_vha, 0); |
| 4898 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 4899 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 4900 | "Nic Core f/w is alive.\n"); |
| 4901 | return; |
| 4902 | } |
| 4903 | } |
| 4904 | |
| 4905 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 4906 | if (qla83xx_nic_core_reset(base_vha)) { |
| 4907 | /* NIC Core reset failed. */ |
| 4908 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 4909 | "NIC Core reset failed.\n"); |
| 4910 | } |
| 4911 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 4912 | } |
| 4913 | } |
| 4914 | |
| 4915 | /* Work: Handle 8200 IDC aens */ |
| 4916 | void |
| 4917 | qla83xx_service_idc_aen(struct work_struct *work) |
| 4918 | { |
| 4919 | struct qla_hw_data *ha = |
| 4920 | container_of(work, struct qla_hw_data, idc_aen); |
| 4921 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4922 | uint32_t dev_state, idc_control; |
| 4923 | |
| 4924 | qla83xx_idc_lock(base_vha, 0); |
| 4925 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4926 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 4927 | qla83xx_idc_unlock(base_vha, 0); |
| 4928 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 4929 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 4930 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 4931 | "Application requested NIC Core Reset.\n"); |
| 4932 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4933 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 4934 | QLA_SUCCESS) { |
| 4935 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 4936 | "Other protocol driver requested NIC Core Reset.\n"); |
| 4937 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4938 | } |
| 4939 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 4940 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 4941 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4942 | } |
| 4943 | } |
| 4944 | |
| 4945 | static void |
| 4946 | qla83xx_wait_logic(void) |
| 4947 | { |
| 4948 | int i; |
| 4949 | |
| 4950 | /* Yield CPU */ |
| 4951 | if (!in_interrupt()) { |
| 4952 | /* |
| 4953 | * Wait about 200ms before retrying again. |
| 4954 | * This controls the number of retries for single |
| 4955 | * lock operation. |
| 4956 | */ |
| 4957 | msleep(100); |
| 4958 | schedule(); |
| 4959 | } else { |
| 4960 | for (i = 0; i < 20; i++) |
| 4961 | cpu_relax(); /* This a nop instr on i386 */ |
| 4962 | } |
| 4963 | } |
| 4964 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4965 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4966 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 4967 | { |
| 4968 | int rval; |
| 4969 | uint32_t data; |
| 4970 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 4971 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 4972 | struct qla_hw_data *ha = base_vha->hw; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4973 | ql_dbg(ql_dbg_p3p, base_vha, 0xb086, |
| 4974 | "Trying force recovery of the IDC lock.\n"); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4975 | |
| 4976 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 4977 | if (rval) |
| 4978 | return rval; |
| 4979 | |
| 4980 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 4981 | return QLA_SUCCESS; |
| 4982 | } else { |
| 4983 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 4984 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4985 | data); |
| 4986 | if (rval) |
| 4987 | return rval; |
| 4988 | |
| 4989 | msleep(200); |
| 4990 | |
| 4991 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4992 | &data); |
| 4993 | if (rval) |
| 4994 | return rval; |
| 4995 | |
| 4996 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 4997 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 4998 | ~(idc_lck_rcvry_stage_mask)); |
| 4999 | rval = qla83xx_wr_reg(base_vha, |
| 5000 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 5001 | if (rval) |
| 5002 | return rval; |
| 5003 | |
| 5004 | /* Forcefully perform IDC UnLock */ |
| 5005 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 5006 | &data); |
| 5007 | if (rval) |
| 5008 | return rval; |
| 5009 | /* Clear lock-id by setting 0xff */ |
| 5010 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5011 | 0xff); |
| 5012 | if (rval) |
| 5013 | return rval; |
| 5014 | /* Clear lock-recovery by setting 0x0 */ |
| 5015 | rval = qla83xx_wr_reg(base_vha, |
| 5016 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 5017 | if (rval) |
| 5018 | return rval; |
| 5019 | } else |
| 5020 | return QLA_SUCCESS; |
| 5021 | } |
| 5022 | |
| 5023 | return rval; |
| 5024 | } |
| 5025 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5026 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5027 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 5028 | { |
| 5029 | int rval = QLA_SUCCESS; |
| 5030 | uint32_t o_drv_lockid, n_drv_lockid; |
| 5031 | unsigned long lock_recovery_timeout; |
| 5032 | |
| 5033 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 5034 | retry_lockid: |
| 5035 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 5036 | if (rval) |
| 5037 | goto exit; |
| 5038 | |
| 5039 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 5040 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 5041 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 5042 | return QLA_SUCCESS; |
| 5043 | else |
| 5044 | return QLA_FUNCTION_FAILED; |
| 5045 | } |
| 5046 | |
| 5047 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 5048 | if (rval) |
| 5049 | goto exit; |
| 5050 | |
| 5051 | if (o_drv_lockid == n_drv_lockid) { |
| 5052 | qla83xx_wait_logic(); |
| 5053 | goto retry_lockid; |
| 5054 | } else |
| 5055 | return QLA_SUCCESS; |
| 5056 | |
| 5057 | exit: |
| 5058 | return rval; |
| 5059 | } |
| 5060 | |
| 5061 | void |
| 5062 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 5063 | { |
| 5064 | uint16_t options = (requester_id << 15) | BIT_6; |
| 5065 | uint32_t data; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5066 | uint32_t lock_owner; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5067 | struct qla_hw_data *ha = base_vha->hw; |
| 5068 | |
| 5069 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 5070 | retry_lock: |
| 5071 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 5072 | == QLA_SUCCESS) { |
| 5073 | if (data) { |
| 5074 | /* Setting lock-id to our function-number */ |
| 5075 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5076 | ha->portnum); |
| 5077 | } else { |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5078 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 5079 | &lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5080 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 5081 | "Failed to acquire IDC lock, acquired by %d, " |
| 5082 | "retrying...\n", lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5083 | |
| 5084 | /* Retry/Perform IDC-Lock recovery */ |
| 5085 | if (qla83xx_idc_lock_recovery(base_vha) |
| 5086 | == QLA_SUCCESS) { |
| 5087 | qla83xx_wait_logic(); |
| 5088 | goto retry_lock; |
| 5089 | } else |
| 5090 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 5091 | "IDC Lock recovery FAILED.\n"); |
| 5092 | } |
| 5093 | |
| 5094 | } |
| 5095 | |
| 5096 | return; |
| 5097 | |
| 5098 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 5099 | retry_lock2: |
| 5100 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 5101 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 5102 | "Failed to acquire IDC lock. retrying...\n"); |
| 5103 | /* Retry/Perform IDC-Lock recovery */ |
| 5104 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 5105 | qla83xx_wait_logic(); |
| 5106 | goto retry_lock2; |
| 5107 | } else |
| 5108 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 5109 | "IDC Lock recovery FAILED.\n"); |
| 5110 | } |
| 5111 | |
| 5112 | return; |
| 5113 | } |
| 5114 | |
| 5115 | void |
| 5116 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 5117 | { |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5118 | #if 0 |
| 5119 | uint16_t options = (requester_id << 15) | BIT_7; |
| 5120 | #endif |
| 5121 | uint16_t retry; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5122 | uint32_t data; |
| 5123 | struct qla_hw_data *ha = base_vha->hw; |
| 5124 | |
| 5125 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 5126 | * remote registers |
| 5127 | */ |
| 5128 | retry = 0; |
| 5129 | retry_unlock: |
| 5130 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 5131 | == QLA_SUCCESS) { |
| 5132 | if (data == ha->portnum) { |
| 5133 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 5134 | /* Clearing lock-id by setting 0xff */ |
| 5135 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 5136 | } else if (retry < 10) { |
| 5137 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 5138 | |
| 5139 | /* Retry for IDC-unlock */ |
| 5140 | qla83xx_wait_logic(); |
| 5141 | retry++; |
| 5142 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5143 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5144 | goto retry_unlock; |
| 5145 | } |
| 5146 | } else if (retry < 10) { |
| 5147 | /* Retry for IDC-unlock */ |
| 5148 | qla83xx_wait_logic(); |
| 5149 | retry++; |
| 5150 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5151 | "Failed to read drv-lockid, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5152 | goto retry_unlock; |
| 5153 | } |
| 5154 | |
| 5155 | return; |
| 5156 | |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5157 | #if 0 |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5158 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 5159 | retry = 0; |
| 5160 | retry_unlock2: |
| 5161 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 5162 | if (retry < 10) { |
| 5163 | /* Retry for IDC-unlock */ |
| 5164 | qla83xx_wait_logic(); |
| 5165 | retry++; |
| 5166 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 5167 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5168 | goto retry_unlock2; |
| 5169 | } |
| 5170 | } |
| 5171 | |
| 5172 | return; |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 5173 | #endif |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5174 | } |
| 5175 | |
| 5176 | int |
| 5177 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 5178 | { |
| 5179 | int rval = QLA_SUCCESS; |
| 5180 | struct qla_hw_data *ha = vha->hw; |
| 5181 | uint32_t drv_presence; |
| 5182 | |
| 5183 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 5184 | if (rval == QLA_SUCCESS) { |
| 5185 | drv_presence |= (1 << ha->portnum); |
| 5186 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5187 | drv_presence); |
| 5188 | } |
| 5189 | |
| 5190 | return rval; |
| 5191 | } |
| 5192 | |
| 5193 | int |
| 5194 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 5195 | { |
| 5196 | int rval = QLA_SUCCESS; |
| 5197 | |
| 5198 | qla83xx_idc_lock(vha, 0); |
| 5199 | rval = __qla83xx_set_drv_presence(vha); |
| 5200 | qla83xx_idc_unlock(vha, 0); |
| 5201 | |
| 5202 | return rval; |
| 5203 | } |
| 5204 | |
| 5205 | int |
| 5206 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 5207 | { |
| 5208 | int rval = QLA_SUCCESS; |
| 5209 | struct qla_hw_data *ha = vha->hw; |
| 5210 | uint32_t drv_presence; |
| 5211 | |
| 5212 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 5213 | if (rval == QLA_SUCCESS) { |
| 5214 | drv_presence &= ~(1 << ha->portnum); |
| 5215 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5216 | drv_presence); |
| 5217 | } |
| 5218 | |
| 5219 | return rval; |
| 5220 | } |
| 5221 | |
| 5222 | int |
| 5223 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 5224 | { |
| 5225 | int rval = QLA_SUCCESS; |
| 5226 | |
| 5227 | qla83xx_idc_lock(vha, 0); |
| 5228 | rval = __qla83xx_clear_drv_presence(vha); |
| 5229 | qla83xx_idc_unlock(vha, 0); |
| 5230 | |
| 5231 | return rval; |
| 5232 | } |
| 5233 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5234 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5235 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 5236 | { |
| 5237 | struct qla_hw_data *ha = vha->hw; |
| 5238 | uint32_t drv_ack, drv_presence; |
| 5239 | unsigned long ack_timeout; |
| 5240 | |
| 5241 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 5242 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 5243 | while (1) { |
| 5244 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 5245 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 5246 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5247 | break; |
| 5248 | |
| 5249 | if (time_after_eq(jiffies, ack_timeout)) { |
| 5250 | ql_log(ql_log_warn, vha, 0xb067, |
| 5251 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 5252 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 5253 | /* |
| 5254 | * The function(s) which did not ack in time are forced |
| 5255 | * to withdraw any further participation in the IDC |
| 5256 | * reset. |
| 5257 | */ |
| 5258 | if (drv_ack != drv_presence) |
| 5259 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5260 | drv_ack); |
| 5261 | break; |
| 5262 | } |
| 5263 | |
| 5264 | qla83xx_idc_unlock(vha, 0); |
| 5265 | msleep(1000); |
| 5266 | qla83xx_idc_lock(vha, 0); |
| 5267 | } |
| 5268 | |
| 5269 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 5270 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 5271 | } |
| 5272 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5273 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5274 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 5275 | { |
| 5276 | int rval = QLA_SUCCESS; |
| 5277 | uint32_t idc_control; |
| 5278 | |
| 5279 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 5280 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 5281 | |
| 5282 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 5283 | __qla83xx_get_idc_control(vha, &idc_control); |
| 5284 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 5285 | __qla83xx_set_idc_control(vha, 0); |
| 5286 | |
| 5287 | qla83xx_idc_unlock(vha, 0); |
| 5288 | rval = qla83xx_restart_nic_firmware(vha); |
| 5289 | qla83xx_idc_lock(vha, 0); |
| 5290 | |
| 5291 | if (rval != QLA_SUCCESS) { |
| 5292 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 5293 | "Failed to restart NIC f/w.\n"); |
| 5294 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 5295 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 5296 | } else { |
| 5297 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 5298 | "Success in restarting nic f/w.\n"); |
| 5299 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 5300 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 5301 | } |
| 5302 | |
| 5303 | return rval; |
| 5304 | } |
| 5305 | |
| 5306 | /* Assumes idc_lock always held on entry */ |
| 5307 | int |
| 5308 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 5309 | { |
| 5310 | struct qla_hw_data *ha = base_vha->hw; |
| 5311 | int rval = QLA_SUCCESS; |
| 5312 | unsigned long dev_init_timeout; |
| 5313 | uint32_t dev_state; |
| 5314 | |
| 5315 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 5316 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 5317 | |
| 5318 | while (1) { |
| 5319 | |
| 5320 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 5321 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 5322 | "Initialization TIMEOUT!\n"); |
| 5323 | /* Init timeout. Disable further NIC Core |
| 5324 | * communication. |
| 5325 | */ |
| 5326 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5327 | QLA8XXX_DEV_FAILED); |
| 5328 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 5329 | "HW State: FAILED.\n"); |
| 5330 | } |
| 5331 | |
| 5332 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5333 | switch (dev_state) { |
| 5334 | case QLA8XXX_DEV_READY: |
| 5335 | if (ha->flags.nic_core_reset_owner) |
| 5336 | qla83xx_idc_audit(base_vha, |
| 5337 | IDC_AUDIT_COMPLETION); |
| 5338 | ha->flags.nic_core_reset_owner = 0; |
| 5339 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 5340 | "Reset_owner reset by 0x%x.\n", |
| 5341 | ha->portnum); |
| 5342 | goto exit; |
| 5343 | case QLA8XXX_DEV_COLD: |
| 5344 | if (ha->flags.nic_core_reset_owner) |
| 5345 | rval = qla83xx_device_bootstrap(base_vha); |
| 5346 | else { |
| 5347 | /* Wait for AEN to change device-state */ |
| 5348 | qla83xx_idc_unlock(base_vha, 0); |
| 5349 | msleep(1000); |
| 5350 | qla83xx_idc_lock(base_vha, 0); |
| 5351 | } |
| 5352 | break; |
| 5353 | case QLA8XXX_DEV_INITIALIZING: |
| 5354 | /* Wait for AEN to change device-state */ |
| 5355 | qla83xx_idc_unlock(base_vha, 0); |
| 5356 | msleep(1000); |
| 5357 | qla83xx_idc_lock(base_vha, 0); |
| 5358 | break; |
| 5359 | case QLA8XXX_DEV_NEED_RESET: |
| 5360 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 5361 | qla83xx_need_reset_handler(base_vha); |
| 5362 | else { |
| 5363 | /* Wait for AEN to change device-state */ |
| 5364 | qla83xx_idc_unlock(base_vha, 0); |
| 5365 | msleep(1000); |
| 5366 | qla83xx_idc_lock(base_vha, 0); |
| 5367 | } |
| 5368 | /* reset timeout value after need reset handler */ |
| 5369 | dev_init_timeout = jiffies + |
| 5370 | (ha->fcoe_dev_init_timeout * HZ); |
| 5371 | break; |
| 5372 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 5373 | /* XXX: DEBUG for now */ |
| 5374 | qla83xx_idc_unlock(base_vha, 0); |
| 5375 | msleep(1000); |
| 5376 | qla83xx_idc_lock(base_vha, 0); |
| 5377 | break; |
| 5378 | case QLA8XXX_DEV_QUIESCENT: |
| 5379 | /* XXX: DEBUG for now */ |
| 5380 | if (ha->flags.quiesce_owner) |
| 5381 | goto exit; |
| 5382 | |
| 5383 | qla83xx_idc_unlock(base_vha, 0); |
| 5384 | msleep(1000); |
| 5385 | qla83xx_idc_lock(base_vha, 0); |
| 5386 | dev_init_timeout = jiffies + |
| 5387 | (ha->fcoe_dev_init_timeout * HZ); |
| 5388 | break; |
| 5389 | case QLA8XXX_DEV_FAILED: |
| 5390 | if (ha->flags.nic_core_reset_owner) |
| 5391 | qla83xx_idc_audit(base_vha, |
| 5392 | IDC_AUDIT_COMPLETION); |
| 5393 | ha->flags.nic_core_reset_owner = 0; |
| 5394 | __qla83xx_clear_drv_presence(base_vha); |
| 5395 | qla83xx_idc_unlock(base_vha, 0); |
| 5396 | qla8xxx_dev_failed_handler(base_vha); |
| 5397 | rval = QLA_FUNCTION_FAILED; |
| 5398 | qla83xx_idc_lock(base_vha, 0); |
| 5399 | goto exit; |
| 5400 | case QLA8XXX_BAD_VALUE: |
| 5401 | qla83xx_idc_unlock(base_vha, 0); |
| 5402 | msleep(1000); |
| 5403 | qla83xx_idc_lock(base_vha, 0); |
| 5404 | break; |
| 5405 | default: |
| 5406 | ql_log(ql_log_warn, base_vha, 0xb071, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 5407 | "Unknown Device State: %x.\n", dev_state); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5408 | qla83xx_idc_unlock(base_vha, 0); |
| 5409 | qla8xxx_dev_failed_handler(base_vha); |
| 5410 | rval = QLA_FUNCTION_FAILED; |
| 5411 | qla83xx_idc_lock(base_vha, 0); |
| 5412 | goto exit; |
| 5413 | } |
| 5414 | } |
| 5415 | |
| 5416 | exit: |
| 5417 | return rval; |
| 5418 | } |
| 5419 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5420 | void |
| 5421 | qla2x00_disable_board_on_pci_error(struct work_struct *work) |
| 5422 | { |
| 5423 | struct qla_hw_data *ha = container_of(work, struct qla_hw_data, |
| 5424 | board_disable); |
| 5425 | struct pci_dev *pdev = ha->pdev; |
| 5426 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5427 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5428 | /* |
| 5429 | * if UNLOAD flag is already set, then continue unload, |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 5430 | * where it was set first. |
| 5431 | */ |
| 5432 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5433 | return; |
| 5434 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5435 | ql_log(ql_log_warn, base_vha, 0x015b, |
| 5436 | "Disabling adapter.\n"); |
| 5437 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 5438 | qla2x00_wait_for_sess_deletion(base_vha); |
| 5439 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5440 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 5441 | |
| 5442 | qla2x00_delete_all_vps(ha, base_vha); |
| 5443 | |
| 5444 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5445 | |
| 5446 | qla2x00_dfs_remove(base_vha); |
| 5447 | |
| 5448 | qla84xx_put_chip(base_vha); |
| 5449 | |
| 5450 | if (base_vha->timer_active) |
| 5451 | qla2x00_stop_timer(base_vha); |
| 5452 | |
| 5453 | base_vha->flags.online = 0; |
| 5454 | |
| 5455 | qla2x00_destroy_deferred_work(ha); |
| 5456 | |
| 5457 | /* |
| 5458 | * Do not try to stop beacon blink as it will issue a mailbox |
| 5459 | * command. |
| 5460 | */ |
| 5461 | qla2x00_free_sysfs_attr(base_vha, false); |
| 5462 | |
| 5463 | fc_remove_host(base_vha->host); |
| 5464 | |
| 5465 | scsi_remove_host(base_vha->host); |
| 5466 | |
| 5467 | base_vha->flags.init_done = 0; |
| 5468 | qla25xx_delete_queues(base_vha); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5469 | qla2x00_free_fcports(base_vha); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 5470 | qla2x00_free_irqs(base_vha); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5471 | qla2x00_mem_free(ha); |
| 5472 | qla82xx_md_free(base_vha); |
| 5473 | qla2x00_free_queues(ha); |
| 5474 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5475 | qla2x00_unmap_iobases(ha); |
| 5476 | |
| 5477 | pci_release_selected_regions(ha->pdev, ha->bars); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5478 | pci_disable_pcie_error_reporting(pdev); |
| 5479 | pci_disable_device(pdev); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5480 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 5481 | /* |
| 5482 | * Let qla2x00_remove_one cleanup qla_hw_data on device removal. |
| 5483 | */ |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5484 | } |
| 5485 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5486 | /************************************************************************** |
| 5487 | * qla2x00_do_dpc |
| 5488 | * This kernel thread is a task that is schedule by the interrupt handler |
| 5489 | * to perform the background processing for interrupts. |
| 5490 | * |
| 5491 | * Notes: |
| 5492 | * This task always run in the context of a kernel thread. It |
| 5493 | * is kick-off by the driver's detect code and starts up |
| 5494 | * up one per adapter. It immediately goes to sleep and waits for |
| 5495 | * some fibre event. When either the interrupt handler or |
| 5496 | * the timer routine detects a event it will one of the task |
| 5497 | * bits then wake us up. |
| 5498 | **************************************************************************/ |
| 5499 | static int |
| 5500 | qla2x00_do_dpc(void *data) |
| 5501 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5502 | scsi_qla_host_t *base_vha; |
| 5503 | struct qla_hw_data *ha; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5504 | uint32_t online; |
| 5505 | struct qla_qpair *qpair; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5506 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5507 | ha = (struct qla_hw_data *)data; |
| 5508 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5509 | |
Dongsheng Yang | 8698a74 | 2014-03-11 18:09:12 +0800 | [diff] [blame] | 5510 | set_user_nice(current, MIN_NICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5511 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5512 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5513 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5514 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 5515 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5516 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5517 | schedule(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5518 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5519 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 5520 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5521 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5522 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5523 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 5524 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5525 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5526 | } |
| 5527 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5528 | ha->dpc_active = 1; |
| 5529 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5530 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 5531 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 5532 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5533 | |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 5534 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5535 | break; |
| 5536 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5537 | qla2x00_do_work(base_vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5538 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5539 | if (IS_P3P_TYPE(ha)) { |
| 5540 | if (IS_QLA8044(ha)) { |
| 5541 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5542 | &base_vha->dpc_flags)) { |
| 5543 | qla8044_idc_lock(ha); |
| 5544 | qla8044_wr_direct(base_vha, |
| 5545 | QLA8044_CRB_DEV_STATE_INDEX, |
| 5546 | QLA8XXX_DEV_FAILED); |
| 5547 | qla8044_idc_unlock(ha); |
| 5548 | ql_log(ql_log_info, base_vha, 0x4004, |
| 5549 | "HW State: FAILED.\n"); |
| 5550 | qla8044_device_state_handler(base_vha); |
| 5551 | continue; |
| 5552 | } |
| 5553 | |
| 5554 | } else { |
| 5555 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5556 | &base_vha->dpc_flags)) { |
| 5557 | qla82xx_idc_lock(ha); |
| 5558 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
| 5559 | QLA8XXX_DEV_FAILED); |
| 5560 | qla82xx_idc_unlock(ha); |
| 5561 | ql_log(ql_log_info, base_vha, 0x0151, |
| 5562 | "HW State: FAILED.\n"); |
| 5563 | qla82xx_device_state_handler(base_vha); |
| 5564 | continue; |
| 5565 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5566 | } |
| 5567 | |
| 5568 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 5569 | &base_vha->dpc_flags)) { |
| 5570 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5571 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 5572 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5573 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 5574 | &base_vha->dpc_flags))) { |
| 5575 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 5576 | /* FCoE-ctx reset failed. |
| 5577 | * Escalate to chip-reset |
| 5578 | */ |
| 5579 | set_bit(ISP_ABORT_NEEDED, |
| 5580 | &base_vha->dpc_flags); |
| 5581 | } |
| 5582 | clear_bit(ABORT_ISP_ACTIVE, |
| 5583 | &base_vha->dpc_flags); |
| 5584 | } |
| 5585 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5586 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 5587 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5588 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5589 | } else if (IS_QLAFX00(ha)) { |
| 5590 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5591 | &base_vha->dpc_flags)) { |
| 5592 | ql_dbg(ql_dbg_dpc, base_vha, 0x4020, |
| 5593 | "Firmware Reset Recovery\n"); |
| 5594 | if (qlafx00_reset_initialize(base_vha)) { |
| 5595 | /* Failed. Abort isp later. */ |
| 5596 | if (!test_bit(UNLOADING, |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5597 | &base_vha->dpc_flags)) { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5598 | set_bit(ISP_UNRECOVERABLE, |
| 5599 | &base_vha->dpc_flags); |
| 5600 | ql_dbg(ql_dbg_dpc, base_vha, |
| 5601 | 0x4021, |
| 5602 | "Reset Recovery Failed\n"); |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5603 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5604 | } |
| 5605 | } |
| 5606 | |
| 5607 | if (test_and_clear_bit(FX00_TARGET_SCAN, |
| 5608 | &base_vha->dpc_flags)) { |
| 5609 | ql_dbg(ql_dbg_dpc, base_vha, 0x4022, |
| 5610 | "ISPFx00 Target Scan scheduled\n"); |
| 5611 | if (qlafx00_rescan_isp(base_vha)) { |
| 5612 | if (!test_bit(UNLOADING, |
| 5613 | &base_vha->dpc_flags)) |
| 5614 | set_bit(ISP_UNRECOVERABLE, |
| 5615 | &base_vha->dpc_flags); |
| 5616 | ql_dbg(ql_dbg_dpc, base_vha, 0x401e, |
| 5617 | "ISPFx00 Target Scan Failed\n"); |
| 5618 | } |
| 5619 | ql_dbg(ql_dbg_dpc, base_vha, 0x401f, |
| 5620 | "ISPFx00 Target Scan End\n"); |
| 5621 | } |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 5622 | if (test_and_clear_bit(FX00_HOST_INFO_RESEND, |
| 5623 | &base_vha->dpc_flags)) { |
| 5624 | ql_dbg(ql_dbg_dpc, base_vha, 0x4023, |
| 5625 | "ISPFx00 Host Info resend scheduled\n"); |
| 5626 | qlafx00_fx_disc(base_vha, |
| 5627 | &base_vha->hw->mr.fcport, |
| 5628 | FXDISC_REG_HOST_INFO); |
| 5629 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5630 | } |
| 5631 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5632 | if (test_and_clear_bit(ISP_ABORT_NEEDED, |
| 5633 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5634 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5635 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 5636 | "ISP abort scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5637 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5638 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5639 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5640 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5641 | /* failed. retry later */ |
| 5642 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5643 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5644 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5645 | clear_bit(ABORT_ISP_ACTIVE, |
| 5646 | &base_vha->dpc_flags); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5647 | } |
| 5648 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5649 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 5650 | "ISP abort end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5651 | } |
| 5652 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 5653 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 5654 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5655 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 5656 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 5657 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5658 | if (IS_QLAFX00(ha)) |
| 5659 | goto loop_resync_check; |
| 5660 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5661 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5662 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 5663 | "Quiescence mode scheduled.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5664 | if (IS_P3P_TYPE(ha)) { |
| 5665 | if (IS_QLA82XX(ha)) |
| 5666 | qla82xx_device_state_handler(base_vha); |
| 5667 | if (IS_QLA8044(ha)) |
| 5668 | qla8044_device_state_handler(base_vha); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5669 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5670 | &base_vha->dpc_flags); |
| 5671 | if (!ha->flags.quiesce_owner) { |
| 5672 | qla2x00_perform_loop_resync(base_vha); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5673 | if (IS_QLA82XX(ha)) { |
| 5674 | qla82xx_idc_lock(ha); |
| 5675 | qla82xx_clear_qsnt_ready( |
| 5676 | base_vha); |
| 5677 | qla82xx_idc_unlock(ha); |
| 5678 | } else if (IS_QLA8044(ha)) { |
| 5679 | qla8044_idc_lock(ha); |
| 5680 | qla8044_clear_qsnt_ready( |
| 5681 | base_vha); |
| 5682 | qla8044_idc_unlock(ha); |
| 5683 | } |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5684 | } |
| 5685 | } else { |
| 5686 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5687 | &base_vha->dpc_flags); |
| 5688 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5689 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5690 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 5691 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5692 | } |
| 5693 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5694 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5695 | &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5696 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5697 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5698 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 5699 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5700 | qla2x00_rst_aen(base_vha); |
| 5701 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5702 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 5703 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5704 | } |
| 5705 | |
| 5706 | /* Retry each device up to login retry count */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5707 | if ((test_and_clear_bit(RELOGIN_NEEDED, |
| 5708 | &base_vha->dpc_flags)) && |
| 5709 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 5710 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5711 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5712 | ql_dbg(ql_dbg_dpc, base_vha, 0x400d, |
| 5713 | "Relogin scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5714 | qla2x00_relogin(base_vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5715 | ql_dbg(ql_dbg_dpc, base_vha, 0x400e, |
| 5716 | "Relogin end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5717 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5718 | loop_resync_check: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5719 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5720 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5721 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5722 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 5723 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5724 | |
| 5725 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5726 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5727 | |
Bart Van Assche | 52c8282 | 2015-07-09 07:23:26 -0700 | [diff] [blame] | 5728 | qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5729 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5730 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 5731 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5732 | } |
| 5733 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5734 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 5735 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5736 | } |
| 5737 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5738 | if (IS_QLAFX00(ha)) |
| 5739 | goto intr_on_check; |
| 5740 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5741 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 5742 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 5743 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 5744 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 5745 | } |
| 5746 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5747 | intr_on_check: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5748 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 5749 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5750 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5751 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
Himanshu Madani | 90b604f | 2014-04-11 16:54:40 -0400 | [diff] [blame] | 5752 | &base_vha->dpc_flags)) { |
| 5753 | if (ha->beacon_blink_led == 1) |
| 5754 | ha->isp_ops->beacon_blink(base_vha); |
| 5755 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5756 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5757 | /* qpair online check */ |
| 5758 | if (test_and_clear_bit(QPAIR_ONLINE_CHECK_NEEDED, |
| 5759 | &base_vha->dpc_flags)) { |
| 5760 | if (ha->flags.eeh_busy || |
| 5761 | ha->flags.pci_channel_io_perm_failure) |
| 5762 | online = 0; |
| 5763 | else |
| 5764 | online = 1; |
| 5765 | |
| 5766 | mutex_lock(&ha->mq_lock); |
| 5767 | list_for_each_entry(qpair, &base_vha->qp_list, |
| 5768 | qp_list_elem) |
| 5769 | qpair->online = online; |
| 5770 | mutex_unlock(&ha->mq_lock); |
| 5771 | } |
| 5772 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5773 | if (!IS_QLAFX00(ha)) |
| 5774 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5775 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5776 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5777 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5778 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5779 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5780 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5781 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5782 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 5783 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5784 | |
| 5785 | /* |
| 5786 | * Make sure that nobody tries to wake us up again. |
| 5787 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5788 | ha->dpc_active = 0; |
| 5789 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5790 | /* Cleanup any residual CTX SRBs. */ |
| 5791 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5792 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5793 | return 0; |
| 5794 | } |
| 5795 | |
| 5796 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5797 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5798 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5799 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5800 | struct task_struct *t = ha->dpc_thread; |
| 5801 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5802 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5803 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5804 | } |
| 5805 | |
| 5806 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5807 | * qla2x00_rst_aen |
| 5808 | * Processes asynchronous reset. |
| 5809 | * |
| 5810 | * Input: |
| 5811 | * ha = adapter block pointer. |
| 5812 | */ |
| 5813 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5814 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5815 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5816 | if (vha->flags.online && !vha->flags.reset_active && |
| 5817 | !atomic_read(&vha->loop_down_timer) && |
| 5818 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5819 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5820 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5821 | |
| 5822 | /* |
| 5823 | * Issue marker command only when we are going to start |
| 5824 | * the I/O. |
| 5825 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5826 | vha->marker_needed = 1; |
| 5827 | } while (!atomic_read(&vha->loop_down_timer) && |
| 5828 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5829 | } |
| 5830 | } |
| 5831 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5832 | /************************************************************************** |
| 5833 | * qla2x00_timer |
| 5834 | * |
| 5835 | * Description: |
| 5836 | * One second timer |
| 5837 | * |
| 5838 | * Context: Interrupt |
| 5839 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5840 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5841 | qla2x00_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5842 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5843 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5844 | int start_dpc = 0; |
| 5845 | int index; |
| 5846 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5847 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5848 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5849 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5850 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5851 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5852 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 5853 | "EEH = %d, restarting timer.\n", |
| 5854 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5855 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 5856 | return; |
| 5857 | } |
| 5858 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5859 | /* |
| 5860 | * Hardware read to raise pending EEH errors during mailbox waits. If |
| 5861 | * the read returns -1 then disable the board. |
| 5862 | */ |
| 5863 | if (!pci_channel_offline(ha->pdev)) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5864 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Joe Lawrence | c821e0d | 2014-08-26 17:11:41 -0400 | [diff] [blame] | 5865 | qla2x00_check_reg16_for_disconnect(vha, w); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5866 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5867 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5868 | /* Make sure qla82xx_watchdog is run only for physical port */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5869 | if (!vha->vp_idx && IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5870 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 5871 | start_dpc++; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5872 | if (IS_QLA82XX(ha)) |
| 5873 | qla82xx_watchdog(vha); |
| 5874 | else if (IS_QLA8044(ha)) |
| 5875 | qla8044_watchdog(vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5876 | } |
| 5877 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5878 | if (!vha->vp_idx && IS_QLAFX00(ha)) |
| 5879 | qlafx00_timer_routine(vha); |
| 5880 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5881 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5882 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5883 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 5884 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5885 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5886 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5887 | if (atomic_read(&vha->loop_down_timer) == |
| 5888 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5889 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5890 | ql_log(ql_log_info, vha, 0x6008, |
| 5891 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5892 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5893 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 5894 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5895 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5896 | /* |
| 5897 | * Schedule an ISP abort to return any FCP2-device |
| 5898 | * commands. |
| 5899 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5900 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5901 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5902 | spin_lock_irqsave(&ha->hardware_lock, |
| 5903 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5904 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5905 | for (index = 1; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 5906 | index < req->num_outstanding_cmds; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5907 | index++) { |
| 5908 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 5909 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5910 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5911 | if (!sp) |
| 5912 | continue; |
Quinn Tran | c5419e2 | 2017-06-13 20:47:16 -0700 | [diff] [blame] | 5913 | if (sp->cmd_type != TYPE_SRB) |
| 5914 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 5915 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 5916 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5917 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5918 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5919 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5920 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5921 | if (IS_QLA82XX(ha)) |
| 5922 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5923 | &vha->dpc_flags); |
| 5924 | else |
| 5925 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5926 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5927 | break; |
| 5928 | } |
| 5929 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5930 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5931 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5932 | start_dpc++; |
| 5933 | } |
| 5934 | |
| 5935 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5936 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 5937 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5938 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5939 | "Loop down - aborting ISP.\n"); |
| 5940 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5941 | if (IS_QLA82XX(ha)) |
| 5942 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5943 | &vha->dpc_flags); |
| 5944 | else |
| 5945 | set_bit(ISP_ABORT_NEEDED, |
| 5946 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5947 | } |
| 5948 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5949 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 5950 | "Loop down - seconds remaining %d.\n", |
| 5951 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5952 | } |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5953 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 5954 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5955 | /* There is no beacon_blink function for ISP82xx */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5956 | if (!IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5957 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 5958 | start_dpc++; |
| 5959 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5960 | } |
| 5961 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5962 | /* Process any deferred work. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5963 | if (!list_empty(&vha->work_list)) |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5964 | start_dpc++; |
| 5965 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5966 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5967 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 5968 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 5969 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5970 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5971 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 5972 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5973 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 5974 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5975 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5976 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5977 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 5978 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 5979 | "fcport_update_needed=%d start_dpc=%d " |
| 5980 | "reset_marker_needed=%d", |
| 5981 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 5982 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 5983 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 5984 | start_dpc, |
| 5985 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 5986 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 5987 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 5988 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5989 | "relogin_needed=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5990 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 5991 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 5992 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 5993 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5994 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5995 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5996 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5997 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5998 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5999 | } |
| 6000 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6001 | /* Firmware interface routines. */ |
| 6002 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6003 | #define FW_BLOBS 11 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6004 | #define FW_ISP21XX 0 |
| 6005 | #define FW_ISP22XX 1 |
| 6006 | #define FW_ISP2300 2 |
| 6007 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6008 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6009 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6010 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6011 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6012 | #define FW_ISP2031 8 |
| 6013 | #define FW_ISP8031 9 |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6014 | #define FW_ISP27XX 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6015 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6016 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 6017 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 6018 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 6019 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 6020 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6021 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6022 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6023 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6024 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 6025 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6026 | #define FW_FILE_ISP27XX "ql2700_fw.bin" |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6027 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6028 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6029 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6030 | |
| 6031 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6032 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 6033 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 6034 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 6035 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 6036 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6037 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6038 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6039 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6040 | { .name = FW_FILE_ISP2031, }, |
| 6041 | { .name = FW_FILE_ISP8031, }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6042 | { .name = FW_FILE_ISP27XX, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6043 | }; |
| 6044 | |
| 6045 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6046 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6047 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6048 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6049 | struct fw_blob *blob; |
| 6050 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6051 | if (IS_QLA2100(ha)) { |
| 6052 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 6053 | } else if (IS_QLA2200(ha)) { |
| 6054 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6055 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6056 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 6057 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6058 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 6059 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6060 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6061 | } else if (IS_QLA25XX(ha)) { |
| 6062 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6063 | } else if (IS_QLA81XX(ha)) { |
| 6064 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6065 | } else if (IS_QLA82XX(ha)) { |
| 6066 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6067 | } else if (IS_QLA2031(ha)) { |
| 6068 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 6069 | } else if (IS_QLA8031(ha)) { |
| 6070 | blob = &qla_fw_blobs[FW_ISP8031]; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6071 | } else if (IS_QLA27XX(ha)) { |
| 6072 | blob = &qla_fw_blobs[FW_ISP27XX]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 6073 | } else { |
| 6074 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6075 | } |
| 6076 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6077 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6078 | if (blob->fw) |
| 6079 | goto out; |
| 6080 | |
| 6081 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6082 | ql_log(ql_log_warn, vha, 0x0063, |
| 6083 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6084 | blob->fw = NULL; |
| 6085 | blob = NULL; |
| 6086 | goto out; |
| 6087 | } |
| 6088 | |
| 6089 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6090 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6091 | return blob; |
| 6092 | } |
| 6093 | |
| 6094 | static void |
| 6095 | qla2x00_release_firmware(void) |
| 6096 | { |
| 6097 | int idx; |
| 6098 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6099 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6100 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 6101 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 6102 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6103 | } |
| 6104 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6105 | static pci_ers_result_t |
| 6106 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 6107 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6108 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 6109 | struct qla_hw_data *ha = vha->hw; |
| 6110 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6111 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 6112 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 6113 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6114 | switch (state) { |
| 6115 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6116 | ha->flags.eeh_busy = 0; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6117 | if (ql2xmqsupport) { |
| 6118 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6119 | qla2xxx_wake_dpc(vha); |
| 6120 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6121 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 6122 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6123 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6124 | /* For ISP82XX complete any pending mailbox cmd */ |
| 6125 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6126 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 6127 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 6128 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6129 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6130 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6131 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 6132 | /* Return back all IOs */ |
| 6133 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6134 | if (ql2xmqsupport) { |
| 6135 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6136 | qla2xxx_wake_dpc(vha); |
| 6137 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6138 | return PCI_ERS_RESULT_NEED_RESET; |
| 6139 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6140 | ha->flags.pci_channel_io_perm_failure = 1; |
| 6141 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 6142 | if (ql2xmqsupport) { |
| 6143 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 6144 | qla2xxx_wake_dpc(vha); |
| 6145 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6146 | return PCI_ERS_RESULT_DISCONNECT; |
| 6147 | } |
| 6148 | return PCI_ERS_RESULT_NEED_RESET; |
| 6149 | } |
| 6150 | |
| 6151 | static pci_ers_result_t |
| 6152 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 6153 | { |
| 6154 | int risc_paused = 0; |
| 6155 | uint32_t stat; |
| 6156 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6157 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6158 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6159 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 6160 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 6161 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 6162 | if (IS_QLA82XX(ha)) |
| 6163 | return PCI_ERS_RESULT_RECOVERED; |
| 6164 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6165 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 6166 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 6167 | stat = RD_REG_DWORD(®->hccr); |
| 6168 | if (stat & HCCR_RISC_PAUSE) |
| 6169 | risc_paused = 1; |
| 6170 | } else if (IS_QLA23XX(ha)) { |
| 6171 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 6172 | if (stat & HSR_RISC_PAUSED) |
| 6173 | risc_paused = 1; |
| 6174 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 6175 | stat = RD_REG_DWORD(®24->host_status); |
| 6176 | if (stat & HSRX_RISC_PAUSED) |
| 6177 | risc_paused = 1; |
| 6178 | } |
| 6179 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 6180 | |
| 6181 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6182 | ql_log(ql_log_info, base_vha, 0x9003, |
| 6183 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6184 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6185 | |
| 6186 | return PCI_ERS_RESULT_NEED_RESET; |
| 6187 | } else |
| 6188 | return PCI_ERS_RESULT_RECOVERED; |
| 6189 | } |
| 6190 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 6191 | static uint32_t |
| 6192 | qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6193 | { |
| 6194 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 6195 | uint32_t drv_active = 0; |
| 6196 | struct qla_hw_data *ha = base_vha->hw; |
| 6197 | int fn; |
| 6198 | struct pci_dev *other_pdev = NULL; |
| 6199 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6200 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 6201 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6202 | |
| 6203 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 6204 | |
| 6205 | if (base_vha->flags.online) { |
| 6206 | /* Abort all outstanding commands, |
| 6207 | * so as to be requeued later */ |
| 6208 | qla2x00_abort_isp_cleanup(base_vha); |
| 6209 | } |
| 6210 | |
| 6211 | |
| 6212 | fn = PCI_FUNC(ha->pdev->devfn); |
| 6213 | while (fn > 0) { |
| 6214 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6215 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 6216 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6217 | other_pdev = |
| 6218 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 6219 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 6220 | fn)); |
| 6221 | |
| 6222 | if (!other_pdev) |
| 6223 | continue; |
| 6224 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6225 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 6226 | "Found PCI func available and enable at 0x%x.\n", |
| 6227 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6228 | pci_dev_put(other_pdev); |
| 6229 | break; |
| 6230 | } |
| 6231 | pci_dev_put(other_pdev); |
| 6232 | } |
| 6233 | |
| 6234 | if (!fn) { |
| 6235 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6236 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 6237 | "This devfn is reset owner = 0x%x.\n", |
| 6238 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6239 | qla82xx_idc_lock(ha); |
| 6240 | |
| 6241 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6242 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6243 | |
| 6244 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 6245 | QLA82XX_IDC_VERSION); |
| 6246 | |
| 6247 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6248 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 6249 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6250 | |
| 6251 | qla82xx_idc_unlock(ha); |
| 6252 | /* Reset if device is not already reset |
| 6253 | * drv_active would be 0 if a reset has already been done |
| 6254 | */ |
| 6255 | if (drv_active) |
| 6256 | rval = qla82xx_start_firmware(base_vha); |
| 6257 | else |
| 6258 | rval = QLA_SUCCESS; |
| 6259 | qla82xx_idc_lock(ha); |
| 6260 | |
| 6261 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6262 | ql_log(ql_log_info, base_vha, 0x900b, |
| 6263 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6264 | qla82xx_clear_drv_active(ha); |
| 6265 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6266 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6267 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6268 | ql_log(ql_log_info, base_vha, 0x900c, |
| 6269 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6270 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6271 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6272 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6273 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6274 | rval = qla82xx_restart_isp(base_vha); |
| 6275 | qla82xx_idc_lock(ha); |
| 6276 | /* Clear driver state register */ |
| 6277 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 6278 | qla82xx_set_drv_active(base_vha); |
| 6279 | } |
| 6280 | qla82xx_idc_unlock(ha); |
| 6281 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6282 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 6283 | "This devfn is not reset owner = 0x%x.\n", |
| 6284 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6285 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6286 | QLA8XXX_DEV_READY)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6287 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6288 | rval = qla82xx_restart_isp(base_vha); |
| 6289 | qla82xx_idc_lock(ha); |
| 6290 | qla82xx_set_drv_active(base_vha); |
| 6291 | qla82xx_idc_unlock(ha); |
| 6292 | } |
| 6293 | } |
| 6294 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 6295 | |
| 6296 | return rval; |
| 6297 | } |
| 6298 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6299 | static pci_ers_result_t |
| 6300 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 6301 | { |
| 6302 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6303 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6304 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6305 | struct rsp_que *rsp; |
| 6306 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6307 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6308 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 6309 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6310 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6311 | /* Workaround: qla2xxx driver which access hardware earlier |
| 6312 | * needs error state to be pci_channel_io_online. |
| 6313 | * Otherwise mailbox command timesout. |
| 6314 | */ |
| 6315 | pdev->error_state = pci_channel_io_normal; |
| 6316 | |
| 6317 | pci_restore_state(pdev); |
| 6318 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 6319 | /* pci_restore_state() clears the saved_state flag of the device |
| 6320 | * save restored state which resets saved_state flag |
| 6321 | */ |
| 6322 | pci_save_state(pdev); |
| 6323 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 6324 | if (ha->mem_only) |
| 6325 | rc = pci_enable_device_mem(pdev); |
| 6326 | else |
| 6327 | rc = pci_enable_device(pdev); |
| 6328 | |
| 6329 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6330 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6331 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6332 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6333 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6334 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6335 | rsp = ha->rsp_q_map[0]; |
| 6336 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6337 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6338 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6339 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6340 | goto exit_slot_reset; |
| 6341 | |
| 6342 | if (IS_QLA82XX(ha)) { |
| 6343 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 6344 | ret = PCI_ERS_RESULT_RECOVERED; |
| 6345 | goto exit_slot_reset; |
| 6346 | } else |
| 6347 | goto exit_slot_reset; |
| 6348 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6349 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6350 | while (ha->flags.mbox_busy && retries--) |
| 6351 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6352 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6353 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6354 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6355 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6356 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6357 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6358 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6359 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6360 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 6361 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6362 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6363 | return ret; |
| 6364 | } |
| 6365 | |
| 6366 | static void |
| 6367 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 6368 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6369 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6370 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6371 | int ret; |
| 6372 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6373 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 6374 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6375 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6376 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6377 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6378 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 6379 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6380 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6381 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 6382 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 6383 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6384 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6385 | } |
| 6386 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 6387 | static void |
| 6388 | qla83xx_disable_laser(scsi_qla_host_t *vha) |
| 6389 | { |
| 6390 | uint32_t reg, data, fn; |
| 6391 | struct qla_hw_data *ha = vha->hw; |
| 6392 | struct device_reg_24xx __iomem *isp_reg = &ha->iobase->isp24; |
| 6393 | |
| 6394 | /* pci func #/port # */ |
| 6395 | ql_dbg(ql_dbg_init, vha, 0x004b, |
| 6396 | "Disabling Laser for hba: %p\n", vha); |
| 6397 | |
| 6398 | fn = (RD_REG_DWORD(&isp_reg->ctrl_status) & |
| 6399 | (BIT_15|BIT_14|BIT_13|BIT_12)); |
| 6400 | |
| 6401 | fn = (fn >> 12); |
| 6402 | |
| 6403 | if (fn & 1) |
| 6404 | reg = PORT_1_2031; |
| 6405 | else |
| 6406 | reg = PORT_0_2031; |
| 6407 | |
| 6408 | data = LASER_OFF_2031; |
| 6409 | |
| 6410 | qla83xx_wr_reg(vha, reg, data); |
| 6411 | } |
| 6412 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 6413 | static int qla2xxx_map_queues(struct Scsi_Host *shost) |
| 6414 | { |
| 6415 | scsi_qla_host_t *vha = (scsi_qla_host_t *)shost->hostdata; |
| 6416 | |
| 6417 | return blk_mq_pci_map_queues(&shost->tag_set, vha->hw->pdev); |
| 6418 | } |
| 6419 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 6420 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6421 | .error_detected = qla2xxx_pci_error_detected, |
| 6422 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 6423 | .slot_reset = qla2xxx_pci_slot_reset, |
| 6424 | .resume = qla2xxx_pci_resume, |
| 6425 | }; |
| 6426 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6427 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 6428 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 6429 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 6430 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 6431 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 6432 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 6433 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 6434 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 6435 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 6436 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 6437 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 6438 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 6439 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6440 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6441 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6442 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6443 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 6444 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6445 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISPF001) }, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6446 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8044) }, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6447 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2071) }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6448 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2271) }, |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 6449 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2261) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6450 | { 0 }, |
| 6451 | }; |
| 6452 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 6453 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6454 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 6455 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 6456 | .driver = { |
| 6457 | .owner = THIS_MODULE, |
| 6458 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6459 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6460 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 6461 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 6462 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6463 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6464 | }; |
| 6465 | |
Al Viro | 75ef9de | 2013-04-04 19:09:41 -0400 | [diff] [blame] | 6466 | static const struct file_operations apidev_fops = { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6467 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 6468 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6469 | }; |
| 6470 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6471 | /** |
| 6472 | * qla2x00_module_init - Module initialization. |
| 6473 | **/ |
| 6474 | static int __init |
| 6475 | qla2x00_module_init(void) |
| 6476 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6477 | int ret = 0; |
| 6478 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6479 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6480 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 6481 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6482 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6483 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 6484 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6485 | return -ENOMEM; |
| 6486 | } |
| 6487 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6488 | /* Initialize target kmem_cache and mem_pools */ |
| 6489 | ret = qlt_init(); |
| 6490 | if (ret < 0) { |
| 6491 | kmem_cache_destroy(srb_cachep); |
| 6492 | return ret; |
| 6493 | } else if (ret > 0) { |
| 6494 | /* |
| 6495 | * If initiator mode is explictly disabled by qlt_init(), |
| 6496 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 6497 | * performing scsi_scan_target() during LOOP UP event. |
| 6498 | */ |
| 6499 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 6500 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 6501 | } |
| 6502 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6503 | /* Derive version string. */ |
| 6504 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 6505 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 6506 | strcat(qla2x00_version_str, "-debug"); |
| 6507 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 6508 | qla2xxx_transport_template = |
| 6509 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6510 | if (!qla2xxx_transport_template) { |
| 6511 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6512 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 6513 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6514 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6515 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6516 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6517 | |
| 6518 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 6519 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6520 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 6521 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6522 | } |
| 6523 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6524 | qla2xxx_transport_vport_template = |
| 6525 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 6526 | if (!qla2xxx_transport_vport_template) { |
| 6527 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6528 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6529 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6530 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 6531 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6532 | return -ENODEV; |
| 6533 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6534 | ql_log(ql_log_info, NULL, 0x0005, |
| 6535 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 6536 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6537 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6538 | if (ret) { |
| 6539 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6540 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6541 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6542 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6543 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 6544 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 6545 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6546 | } |
| 6547 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6548 | } |
| 6549 | |
| 6550 | /** |
| 6551 | * qla2x00_module_exit - Module cleanup. |
| 6552 | **/ |
| 6553 | static void __exit |
| 6554 | qla2x00_module_exit(void) |
| 6555 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6556 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6557 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6558 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6559 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6560 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6561 | if (ctx_cachep) |
| 6562 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6563 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6564 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6565 | } |
| 6566 | |
| 6567 | module_init(qla2x00_module_init); |
| 6568 | module_exit(qla2x00_module_exit); |
| 6569 | |
| 6570 | MODULE_AUTHOR("QLogic Corporation"); |
| 6571 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 6572 | MODULE_LICENSE("GPL"); |
| 6573 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6574 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 6575 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 6576 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 6577 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 6578 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 6579 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |