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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <scsi/scsi_tcq.h> |
| 17 | #include <scsi/scsicam.h> |
| 18 | #include <scsi/scsi_transport.h> |
| 19 | #include <scsi/scsi_transport_fc.h> |
| 20 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 21 | #include "qla_target.h" |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | /* |
| 24 | * Driver version |
| 25 | */ |
| 26 | char qla2x00_version_str[40]; |
| 27 | |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 28 | static int apidev_major; |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | /* |
| 31 | * SRB allocation cache |
| 32 | */ |
Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 33 | static struct kmem_cache *srb_cachep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 35 | /* |
| 36 | * CT6 CTX allocation cache |
| 37 | */ |
| 38 | static struct kmem_cache *ctx_cachep; |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 39 | /* |
| 40 | * error level for logging |
| 41 | */ |
| 42 | int ql_errlev = ql_log_all; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 43 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 44 | static int ql2xenableclass2; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 45 | module_param(ql2xenableclass2, int, S_IRUGO|S_IRUSR); |
| 46 | MODULE_PARM_DESC(ql2xenableclass2, |
| 47 | "Specify if Class 2 operations are supported from the very " |
| 48 | "beginning. Default is 0 - class 2 not supported."); |
| 49 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | int ql2xlogintimeout = 20; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 52 | module_param(ql2xlogintimeout, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | MODULE_PARM_DESC(ql2xlogintimeout, |
| 54 | "Login timeout value in seconds."); |
| 55 | |
Andrew Vasquez | a7b6184 | 2007-05-07 07:42:59 -0700 | [diff] [blame] | 56 | int qlport_down_retry; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 57 | module_param(qlport_down_retry, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | MODULE_PARM_DESC(qlport_down_retry, |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 59 | "Maximum number of command retries to a port that returns " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | "a PORT-DOWN status."); |
| 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | int ql2xplogiabsentdevice; |
| 63 | module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); |
| 64 | MODULE_PARM_DESC(ql2xplogiabsentdevice, |
| 65 | "Option to enable PLOGI to devices that are not present after " |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 66 | "a Fabric scan. This is needed for several broken switches. " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | "Default is 0 - no PLOGI. 1 - perfom PLOGI."); |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | int ql2xloginretrycount = 0; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 70 | module_param(ql2xloginretrycount, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | MODULE_PARM_DESC(ql2xloginretrycount, |
| 72 | "Specify an alternate value for the NVRAM login retry count."); |
| 73 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 74 | int ql2xallocfwdump = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 75 | module_param(ql2xallocfwdump, int, S_IRUGO); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 76 | MODULE_PARM_DESC(ql2xallocfwdump, |
| 77 | "Option to enable allocation of memory for a firmware dump " |
| 78 | "during HBA initialization. Memory allocation requirements " |
| 79 | "vary by ISP type. Default is 1 - allocate memory."); |
| 80 | |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 81 | int ql2xextended_error_logging; |
Andrew Vasquez | 27d9403 | 2007-03-12 10:41:30 -0700 | [diff] [blame] | 82 | module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 83 | module_param_named(logging, ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 84 | MODULE_PARM_DESC(ql2xextended_error_logging, |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 85 | "Option to enable extended error logging,\n" |
| 86 | "\t\tDefault is 0 - no logging. 0x40000000 - Module Init & Probe.\n" |
| 87 | "\t\t0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.\n" |
| 88 | "\t\t0x08000000 - IO tracing. 0x04000000 - DPC Thread.\n" |
| 89 | "\t\t0x02000000 - Async events. 0x01000000 - Timer routines.\n" |
| 90 | "\t\t0x00800000 - User space. 0x00400000 - Task Management.\n" |
| 91 | "\t\t0x00200000 - AER/EEH. 0x00100000 - Multi Q.\n" |
| 92 | "\t\t0x00080000 - P3P Specific. 0x00040000 - Virtual Port.\n" |
| 93 | "\t\t0x00020000 - Buffer Dump. 0x00010000 - Misc.\n" |
Chad Dupuis | 29f9f90 | 2012-11-21 02:40:41 -0500 | [diff] [blame] | 94 | "\t\t0x00008000 - Verbose. 0x00004000 - Target.\n" |
| 95 | "\t\t0x00002000 - Target Mgmt. 0x00001000 - Target TMF.\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 96 | "\t\t0x7fffffff - For enabling all logs, can be too many logs.\n" |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 97 | "\t\t0x1e400000 - Preferred value for capturing essential " |
| 98 | "debug information (equivalent to old " |
| 99 | "ql2xextended_error_logging=1).\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 100 | "\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] | 101 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 102 | int ql2xshiftctondsd = 6; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 103 | module_param(ql2xshiftctondsd, int, S_IRUGO); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 104 | MODULE_PARM_DESC(ql2xshiftctondsd, |
| 105 | "Set to control shifting of command type processing " |
| 106 | "based on total number of SG elements."); |
| 107 | |
Andrew Vasquez | 7e47e5c | 2008-04-24 15:21:26 -0700 | [diff] [blame] | 108 | int ql2xfdmienable=1; |
Himanshu Madhani | de187df | 2014-09-25 05:16:50 -0400 | [diff] [blame] | 109 | module_param(ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 110 | module_param_named(fdmi, ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 111 | MODULE_PARM_DESC(ql2xfdmienable, |
Ferenc Wagner | 7794a5a | 2010-03-23 18:14:59 +0100 | [diff] [blame] | 112 | "Enables FDMI registrations. " |
| 113 | "0 - no FDMI. Default is 1 - perform FDMI."); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 114 | |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 115 | #define MAX_Q_DEPTH 32 |
| 116 | static int ql2xmaxqdepth = MAX_Q_DEPTH; |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 117 | module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR); |
| 118 | MODULE_PARM_DESC(ql2xmaxqdepth, |
Chad Dupuis | e92e4a8 | 2012-08-22 14:21:23 -0400 | [diff] [blame] | 119 | "Maximum queue depth to set for each LUN. " |
| 120 | "Default is 32."); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 121 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 122 | int ql2xenabledif = 2; |
| 123 | module_param(ql2xenabledif, int, S_IRUGO); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 124 | MODULE_PARM_DESC(ql2xenabledif, |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 125 | " Enable T10-CRC-DIF:\n" |
| 126 | " Default is 2.\n" |
| 127 | " 0 -- No DIF Support\n" |
| 128 | " 1 -- Enable DIF for all types\n" |
| 129 | " 2 -- Enable DIF for all types, except Type 0.\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 130 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 131 | int ql2xenablehba_err_chk = 2; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 132 | module_param(ql2xenablehba_err_chk, int, S_IRUGO|S_IWUSR); |
| 133 | MODULE_PARM_DESC(ql2xenablehba_err_chk, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 134 | " Enable T10-CRC-DIF Error isolation by HBA:\n" |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 135 | " Default is 2.\n" |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 136 | " 0 -- Error isolation disabled\n" |
| 137 | " 1 -- Error isolation enabled only for DIX Type 0\n" |
| 138 | " 2 -- Error isolation enabled for all Types\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 139 | |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 140 | int ql2xiidmaenable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 141 | module_param(ql2xiidmaenable, int, S_IRUGO); |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 142 | MODULE_PARM_DESC(ql2xiidmaenable, |
| 143 | "Enables iIDMA settings " |
| 144 | "Default is 1 - perform iIDMA. 0 - no iIDMA."); |
| 145 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 146 | int ql2xmaxqueues = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 147 | module_param(ql2xmaxqueues, int, S_IRUGO); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 148 | MODULE_PARM_DESC(ql2xmaxqueues, |
| 149 | "Enables MQ settings " |
Joe Perches | ae68230 | 2010-08-10 18:01:21 -0700 | [diff] [blame] | 150 | "Default is 1 for single queue. Set it to number " |
| 151 | "of queues in MQ mode."); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 152 | |
| 153 | int ql2xmultique_tag; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 154 | module_param(ql2xmultique_tag, int, S_IRUGO); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 155 | MODULE_PARM_DESC(ql2xmultique_tag, |
| 156 | "Enables CPU affinity settings for the driver " |
| 157 | "Default is 0 for no affinity of request and response IO. " |
| 158 | "Set it to 1 to turn on the cpu affinity."); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 159 | |
| 160 | int ql2xfwloadbin; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 161 | module_param(ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 162 | module_param_named(fwload, ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 163 | MODULE_PARM_DESC(ql2xfwloadbin, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 164 | "Option to specify location from which to load ISP firmware:.\n" |
| 165 | " 2 -- load firmware via the request_firmware() (hotplug).\n" |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 166 | " interface.\n" |
| 167 | " 1 -- load firmware from flash.\n" |
| 168 | " 0 -- use default semantics.\n"); |
| 169 | |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 170 | int ql2xetsenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 171 | module_param(ql2xetsenable, int, S_IRUGO); |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 172 | MODULE_PARM_DESC(ql2xetsenable, |
| 173 | "Enables firmware ETS burst." |
| 174 | "Default is 0 - skip ETS enablement."); |
| 175 | |
Giridhar Malavali | 6907869 | 2010-05-28 15:08:28 -0700 | [diff] [blame] | 176 | int ql2xdbwr = 1; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 177 | module_param(ql2xdbwr, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 178 | MODULE_PARM_DESC(ql2xdbwr, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 179 | "Option to specify scheme for request queue posting.\n" |
| 180 | " 0 -- Regular doorbell.\n" |
| 181 | " 1 -- CAMRAM doorbell (faster).\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 182 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 183 | int ql2xtargetreset = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 184 | module_param(ql2xtargetreset, int, S_IRUGO); |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 185 | MODULE_PARM_DESC(ql2xtargetreset, |
| 186 | "Enable target reset." |
| 187 | "Default is 1 - use hw defaults."); |
| 188 | |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 189 | int ql2xgffidenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 190 | module_param(ql2xgffidenable, int, S_IRUGO); |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 191 | MODULE_PARM_DESC(ql2xgffidenable, |
| 192 | "Enables GFF_ID checks of port type. " |
| 193 | "Default is 0 - Do not use GFF_ID information."); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 194 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 195 | int ql2xasynctmfenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 196 | module_param(ql2xasynctmfenable, int, S_IRUGO); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 197 | MODULE_PARM_DESC(ql2xasynctmfenable, |
| 198 | "Enables issue of TM IOCBs asynchronously via IOCB mechanism" |
| 199 | "Default is 0 - Issue TM IOCBs via mailbox mechanism."); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 200 | |
| 201 | int ql2xdontresethba; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 202 | module_param(ql2xdontresethba, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 203 | MODULE_PARM_DESC(ql2xdontresethba, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 204 | "Option to specify reset behaviour.\n" |
| 205 | " 0 (Default) -- Reset on failure.\n" |
| 206 | " 1 -- Do not reset on failure.\n"); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 207 | |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 208 | uint64_t ql2xmaxlun = MAX_LUNS; |
| 209 | module_param(ql2xmaxlun, ullong, S_IRUGO); |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 210 | MODULE_PARM_DESC(ql2xmaxlun, |
| 211 | "Defines the maximum LU number to register with the SCSI " |
| 212 | "midlayer. Default is 65535."); |
| 213 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 214 | int ql2xmdcapmask = 0x1F; |
| 215 | module_param(ql2xmdcapmask, int, S_IRUGO); |
| 216 | MODULE_PARM_DESC(ql2xmdcapmask, |
| 217 | "Set the Minidump driver capture mask level. " |
Giridhar Malavali | 6e96fa7 | 2011-11-18 09:03:14 -0800 | [diff] [blame] | 218 | "Default is 0x1F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 219 | |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 220 | int ql2xmdenable = 1; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 221 | module_param(ql2xmdenable, int, S_IRUGO); |
| 222 | MODULE_PARM_DESC(ql2xmdenable, |
| 223 | "Enable/disable MiniDump. " |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 224 | "0 - MiniDump disabled. " |
| 225 | "1 (Default) - MiniDump enabled."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 226 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 227 | int ql2xexlogins = 0; |
| 228 | module_param(ql2xexlogins, uint, S_IRUGO|S_IWUSR); |
| 229 | MODULE_PARM_DESC(ql2xexlogins, |
| 230 | "Number of extended Logins. " |
| 231 | "0 (Default)- Disabled."); |
| 232 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 233 | int ql2xexchoffld = 0; |
| 234 | module_param(ql2xexchoffld, uint, S_IRUGO|S_IWUSR); |
| 235 | MODULE_PARM_DESC(ql2xexchoffld, |
| 236 | "Number of exchanges to offload. " |
| 237 | "0 (Default)- Disabled."); |
| 238 | |
Himanshu Madhani | f198caf | 2016-01-27 12:03:30 -0500 | [diff] [blame] | 239 | int ql2xfwholdabts = 0; |
| 240 | module_param(ql2xfwholdabts, int, S_IRUGO); |
| 241 | MODULE_PARM_DESC(ql2xfwholdabts, |
| 242 | "Allow FW to hold status IOCB until ABTS rsp received. " |
| 243 | "0 (Default) Do not set fw option. " |
| 244 | "1 - Set fw option to hold ABTS."); |
| 245 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 247 | * SCSI host template entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | */ |
| 249 | static int qla2xxx_slave_configure(struct scsi_device * device); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 250 | static int qla2xxx_slave_alloc(struct scsi_device *); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 251 | static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); |
| 252 | static void qla2xxx_scan_start(struct Scsi_Host *); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 253 | static void qla2xxx_slave_destroy(struct scsi_device *); |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 254 | static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | static int qla2xxx_eh_abort(struct scsi_cmnd *); |
| 256 | static int qla2xxx_eh_device_reset(struct scsi_cmnd *); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 257 | static int qla2xxx_eh_target_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); |
| 259 | static int qla2xxx_eh_host_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 261 | static void qla2x00_clear_drv_active(struct qla_hw_data *); |
Saurav Kashyap | 3491255 | 2013-06-25 11:27:18 -0400 | [diff] [blame] | 262 | static void qla2x00_free_device(scsi_qla_host_t *); |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 263 | static void qla83xx_disable_laser(scsi_qla_host_t *vha); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 264 | |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 265 | struct scsi_host_template qla2xxx_driver_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | .module = THIS_MODULE, |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 267 | .name = QLA2XXX_DRIVER_NAME, |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 268 | .queuecommand = qla2xxx_queuecommand, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 269 | |
| 270 | .eh_abort_handler = qla2xxx_eh_abort, |
| 271 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 272 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 273 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 274 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 275 | |
| 276 | .slave_configure = qla2xxx_slave_configure, |
| 277 | |
| 278 | .slave_alloc = qla2xxx_slave_alloc, |
| 279 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 280 | .scan_finished = qla2xxx_scan_finished, |
| 281 | .scan_start = qla2xxx_scan_start, |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 282 | .change_queue_depth = scsi_change_queue_depth, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 283 | .this_id = -1, |
| 284 | .cmd_per_lun = 3, |
| 285 | .use_clustering = ENABLE_CLUSTERING, |
| 286 | .sg_tablesize = SG_ALL, |
| 287 | |
| 288 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 289 | .shost_attrs = qla2x00_host_attrs, |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 290 | |
| 291 | .supported_mode = MODE_INITIATOR, |
Christoph Hellwig | c40ecc1 | 2014-11-13 14:25:11 +0100 | [diff] [blame] | 292 | .track_queue_depth = 1, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 293 | }; |
| 294 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 296 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | /* TODO Convert to inlines |
| 299 | * |
| 300 | * Timer routines |
| 301 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 303 | __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 304 | 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] | 305 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 306 | init_timer(&vha->timer); |
| 307 | vha->timer.expires = jiffies + interval * HZ; |
| 308 | vha->timer.data = (unsigned long)vha; |
| 309 | vha->timer.function = (void (*)(unsigned long))func; |
| 310 | add_timer(&vha->timer); |
| 311 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 315 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 317 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 318 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 319 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 320 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 321 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 322 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 323 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 324 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | } |
| 326 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 327 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 328 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 330 | del_timer_sync(&vha->timer); |
| 331 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | static int qla2x00_do_dpc(void *data); |
| 335 | |
| 336 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 337 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 338 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 339 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 340 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 341 | static void qla2x00_mem_free(struct qla_hw_data *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | /* -------------------------------------------------------------------------- */ |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 344 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 345 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 346 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 347 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 348 | 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] | 349 | GFP_KERNEL); |
| 350 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 351 | ql_log(ql_log_fatal, vha, 0x003b, |
| 352 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 353 | goto fail_req_map; |
| 354 | } |
| 355 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 356 | 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] | 357 | GFP_KERNEL); |
| 358 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 359 | ql_log(ql_log_fatal, vha, 0x003c, |
| 360 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 361 | goto fail_rsp_map; |
| 362 | } |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 363 | /* |
| 364 | * Make sure we record at least the request and response queue zero in |
| 365 | * case we need to free them if part of the probe fails. |
| 366 | */ |
| 367 | ha->rsp_q_map[0] = rsp; |
| 368 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 369 | set_bit(0, ha->rsp_qid_map); |
| 370 | set_bit(0, ha->req_qid_map); |
| 371 | return 1; |
| 372 | |
| 373 | fail_rsp_map: |
| 374 | kfree(ha->req_q_map); |
| 375 | ha->req_q_map = NULL; |
| 376 | fail_req_map: |
| 377 | return -ENOMEM; |
| 378 | } |
| 379 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 380 | 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] | 381 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 382 | if (IS_QLAFX00(ha)) { |
| 383 | if (req && req->ring_fx00) |
| 384 | dma_free_coherent(&ha->pdev->dev, |
| 385 | (req->length_fx00 + 1) * sizeof(request_t), |
| 386 | req->ring_fx00, req->dma_fx00); |
| 387 | } else if (req && req->ring) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 388 | dma_free_coherent(&ha->pdev->dev, |
| 389 | (req->length + 1) * sizeof(request_t), |
| 390 | req->ring, req->dma); |
| 391 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 392 | if (req) |
| 393 | kfree(req->outstanding_cmds); |
| 394 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 395 | kfree(req); |
| 396 | req = NULL; |
| 397 | } |
| 398 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 399 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 400 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 401 | if (IS_QLAFX00(ha)) { |
| 402 | if (rsp && rsp->ring) |
| 403 | dma_free_coherent(&ha->pdev->dev, |
| 404 | (rsp->length_fx00 + 1) * sizeof(request_t), |
| 405 | rsp->ring_fx00, rsp->dma_fx00); |
| 406 | } else if (rsp && rsp->ring) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 407 | dma_free_coherent(&ha->pdev->dev, |
| 408 | (rsp->length + 1) * sizeof(response_t), |
| 409 | rsp->ring, rsp->dma); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 410 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 411 | kfree(rsp); |
| 412 | rsp = NULL; |
| 413 | } |
| 414 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 415 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 416 | { |
| 417 | struct req_que *req; |
| 418 | struct rsp_que *rsp; |
| 419 | int cnt; |
| 420 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 421 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 422 | if (!test_bit(cnt, ha->req_qid_map)) |
| 423 | continue; |
| 424 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 425 | req = ha->req_q_map[cnt]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 426 | qla2x00_free_req_que(ha, req); |
| 427 | } |
| 428 | kfree(ha->req_q_map); |
| 429 | ha->req_q_map = NULL; |
| 430 | |
| 431 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 432 | if (!test_bit(cnt, ha->rsp_qid_map)) |
| 433 | continue; |
| 434 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 435 | rsp = ha->rsp_q_map[cnt]; |
| 436 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 437 | } |
| 438 | kfree(ha->rsp_q_map); |
| 439 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 440 | } |
| 441 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 442 | static int qla25xx_setup_mode(struct scsi_qla_host *vha) |
| 443 | { |
| 444 | uint16_t options = 0; |
| 445 | int ques, req, ret; |
| 446 | struct qla_hw_data *ha = vha->hw; |
| 447 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 448 | if (!(ha->fw_attributes & BIT_6)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 449 | ql_log(ql_log_warn, vha, 0x00d8, |
| 450 | "Firmware is not multi-queue capable.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 451 | goto fail; |
| 452 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 453 | if (ql2xmultique_tag) { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 454 | /* create a request queue for IO */ |
| 455 | options |= BIT_7; |
| 456 | req = qla25xx_create_req_que(ha, options, 0, 0, -1, |
| 457 | QLA_DEFAULT_QUE_QOS); |
| 458 | if (!req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 459 | ql_log(ql_log_warn, vha, 0x00e0, |
| 460 | "Failed to create request queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 461 | goto fail; |
| 462 | } |
Tejun Heo | 278274d | 2011-02-01 11:42:42 +0100 | [diff] [blame] | 463 | ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 464 | vha->req = ha->req_q_map[req]; |
| 465 | options |= BIT_1; |
| 466 | for (ques = 1; ques < ha->max_rsp_queues; ques++) { |
| 467 | ret = qla25xx_create_rsp_que(ha, options, 0, 0, req); |
| 468 | if (!ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 469 | ql_log(ql_log_warn, vha, 0x00e8, |
| 470 | "Failed to create response queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 471 | goto fail2; |
| 472 | } |
| 473 | } |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 474 | ha->flags.cpu_affinity_enabled = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 475 | ql_dbg(ql_dbg_multiq, vha, 0xc007, |
Yannick Guerrini | 6ef68da | 2015-02-23 23:26:50 +0100 | [diff] [blame] | 476 | "CPU affinity mode enabled, " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 477 | "no. of response queues:%d no. of request queues:%d.\n", |
| 478 | ha->max_rsp_queues, ha->max_req_queues); |
| 479 | ql_dbg(ql_dbg_init, vha, 0x00e9, |
Yannick Guerrini | 6ef68da | 2015-02-23 23:26:50 +0100 | [diff] [blame] | 480 | "CPU affinity mode enabled, " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 481 | "no. of response queues:%d no. of request queues:%d.\n", |
| 482 | ha->max_rsp_queues, ha->max_req_queues); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 483 | } |
| 484 | return 0; |
| 485 | fail2: |
| 486 | qla25xx_delete_queues(vha); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 487 | destroy_workqueue(ha->wq); |
| 488 | ha->wq = NULL; |
Giridhar Malavali | 0cd33fc | 2011-11-18 09:02:12 -0800 | [diff] [blame] | 489 | vha->req = ha->req_q_map[0]; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 490 | fail: |
| 491 | ha->mqenable = 0; |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 492 | kfree(ha->req_q_map); |
| 493 | kfree(ha->rsp_q_map); |
| 494 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 495 | return 1; |
| 496 | } |
| 497 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 499 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 501 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | static char *pci_bus_modes[] = { |
| 503 | "33", "66", "100", "133", |
| 504 | }; |
| 505 | uint16_t pci_bus; |
| 506 | |
| 507 | strcpy(str, "PCI"); |
| 508 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 509 | if (pci_bus) { |
| 510 | strcat(str, "-X ("); |
| 511 | strcat(str, pci_bus_modes[pci_bus]); |
| 512 | } else { |
| 513 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 514 | strcat(str, " ("); |
| 515 | strcat(str, pci_bus_modes[pci_bus]); |
| 516 | } |
| 517 | strcat(str, " MHz)"); |
| 518 | |
| 519 | return (str); |
| 520 | } |
| 521 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 522 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 523 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 524 | { |
| 525 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 526 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 527 | uint32_t pci_bus; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 528 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 529 | if (pci_is_pcie(ha->pdev)) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 530 | char lwstr[6]; |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 531 | uint32_t lstat, lspeed, lwidth; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 532 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 533 | pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); |
| 534 | lspeed = lstat & PCI_EXP_LNKCAP_SLS; |
| 535 | lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 536 | |
| 537 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 538 | switch (lspeed) { |
| 539 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 540 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 541 | break; |
| 542 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 543 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 544 | break; |
| 545 | case 3: |
| 546 | strcat(str, "8.0GT/s "); |
| 547 | break; |
| 548 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 549 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 550 | break; |
| 551 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 552 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 553 | strcat(str, lwstr); |
| 554 | |
| 555 | return str; |
| 556 | } |
| 557 | |
| 558 | strcpy(str, "PCI"); |
| 559 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 560 | if (pci_bus == 0 || pci_bus == 8) { |
| 561 | strcat(str, " ("); |
| 562 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 563 | } else { |
| 564 | strcat(str, "-X "); |
| 565 | if (pci_bus & BIT_2) |
| 566 | strcat(str, "Mode 2"); |
| 567 | else |
| 568 | strcat(str, "Mode 1"); |
| 569 | strcat(str, " ("); |
| 570 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 571 | } |
| 572 | strcat(str, " MHz)"); |
| 573 | |
| 574 | return str; |
| 575 | } |
| 576 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 577 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 578 | 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] | 579 | { |
| 580 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 581 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 582 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 583 | snprintf(str, size, "%d.%02d.%02d ", ha->fw_major_version, |
| 584 | ha->fw_minor_version, ha->fw_subminor_version); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | |
| 586 | if (ha->fw_attributes & BIT_9) { |
| 587 | strcat(str, "FLX"); |
| 588 | return (str); |
| 589 | } |
| 590 | |
| 591 | switch (ha->fw_attributes & 0xFF) { |
| 592 | case 0x7: |
| 593 | strcat(str, "EF"); |
| 594 | break; |
| 595 | case 0x17: |
| 596 | strcat(str, "TP"); |
| 597 | break; |
| 598 | case 0x37: |
| 599 | strcat(str, "IP"); |
| 600 | break; |
| 601 | case 0x77: |
| 602 | strcat(str, "VI"); |
| 603 | break; |
| 604 | default: |
| 605 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 606 | strcat(str, un_str); |
| 607 | break; |
| 608 | } |
| 609 | if (ha->fw_attributes & 0x100) |
| 610 | strcat(str, "X"); |
| 611 | |
| 612 | return (str); |
| 613 | } |
| 614 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 615 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 616 | 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] | 617 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 618 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 619 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 620 | snprintf(str, size, "%d.%02d.%02d (%x)", ha->fw_major_version, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 621 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 622 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 623 | } |
| 624 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 625 | void |
| 626 | qla2x00_sp_free_dma(void *vha, void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 627 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 628 | srb_t *sp = (srb_t *)ptr; |
| 629 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 630 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 631 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 632 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 633 | if (sp->flags & SRB_DMA_VALID) { |
| 634 | scsi_dma_unmap(cmd); |
| 635 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 636 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 637 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 638 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 639 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 640 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 641 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 642 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 643 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 644 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 645 | /* List assured to be having elements */ |
Quinn Tran | f83adb6 | 2014-04-11 16:54:43 -0400 | [diff] [blame] | 646 | qla2x00_clean_dsd_pool(ha, sp, NULL); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 647 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 648 | } |
| 649 | |
| 650 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
| 651 | dma_pool_free(ha->dl_dma_pool, ctx, |
| 652 | ((struct crc_context *)ctx)->crc_ctx_dma); |
| 653 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 654 | } |
| 655 | |
| 656 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
| 657 | struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; |
| 658 | |
| 659 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 660 | ctx1->fcp_cmnd_dma); |
| 661 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 662 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 663 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 664 | mempool_free(ctx1, ha->ctx_mempool); |
| 665 | ctx1 = NULL; |
| 666 | } |
| 667 | |
| 668 | CMD_SP(cmd) = NULL; |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 669 | qla2x00_rel_sp(sp->fcport->vha, sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 670 | } |
| 671 | |
Fengguang Wu | 14b0680 | 2013-04-25 01:29:19 -0400 | [diff] [blame] | 672 | static void |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 673 | qla2x00_sp_compl(void *data, void *ptr, int res) |
| 674 | { |
| 675 | struct qla_hw_data *ha = (struct qla_hw_data *)data; |
| 676 | srb_t *sp = (srb_t *)ptr; |
| 677 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 678 | |
| 679 | cmd->result = res; |
| 680 | |
| 681 | if (atomic_read(&sp->ref_count) == 0) { |
| 682 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3015, |
| 683 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 684 | sp, GET_CMD_SP(sp)); |
| 685 | if (ql2xextended_error_logging & ql_dbg_io) |
Hiral Patel | 8fbdac8 | 2015-08-04 13:37:56 -0400 | [diff] [blame] | 686 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 687 | return; |
| 688 | } |
| 689 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 690 | return; |
| 691 | |
| 692 | qla2x00_sp_free_dma(ha, sp); |
| 693 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 694 | } |
| 695 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 696 | /* If we are SP1 here, we need to still take and release the host_lock as SP1 |
| 697 | * does not have the changes necessary to avoid taking host->host_lock. |
| 698 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 700 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 701 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 702 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 703 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 704 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 705 | struct qla_hw_data *ha = vha->hw; |
| 706 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 707 | srb_t *sp; |
| 708 | int rval; |
| 709 | |
Mauricio Faria de Oliveira | 04dfaa5 | 2016-11-07 17:53:30 -0200 | [diff] [blame] | 710 | if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { |
| 711 | cmd->result = DID_NO_CONNECT << 16; |
| 712 | goto qc24_fail_command; |
| 713 | } |
| 714 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 715 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 716 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 717 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 718 | "PCI Channel IO permanent failure, exiting " |
| 719 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 720 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 721 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 722 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 723 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 724 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 725 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 726 | goto qc24_fail_command; |
| 727 | } |
| 728 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 729 | rval = fc_remote_port_chkready(rport); |
| 730 | if (rval) { |
| 731 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 732 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 733 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 734 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 735 | goto qc24_fail_command; |
| 736 | } |
| 737 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 738 | if (!vha->flags.difdix_supported && |
| 739 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 740 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 741 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 742 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 743 | cmd->result = DID_NO_CONNECT << 16; |
| 744 | goto qc24_fail_command; |
| 745 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 746 | |
| 747 | if (!fcport) { |
| 748 | cmd->result = DID_NO_CONNECT << 16; |
| 749 | goto qc24_fail_command; |
| 750 | } |
| 751 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 752 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 753 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 754 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 755 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 756 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 757 | atomic_read(&fcport->state), |
| 758 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 759 | cmd->result = DID_NO_CONNECT << 16; |
| 760 | goto qc24_fail_command; |
| 761 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 762 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 763 | } |
| 764 | |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 765 | /* |
| 766 | * Return target busy if we've received a non-zero retry_delay_timer |
| 767 | * in a FCP_RSP. |
| 768 | */ |
Bruno Prémont | 975f7d4 | 2014-12-19 10:29:16 +0100 | [diff] [blame] | 769 | if (fcport->retry_delay_timestamp == 0) { |
| 770 | /* retry delay not set */ |
| 771 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 772 | fcport->retry_delay_timestamp = 0; |
| 773 | else |
| 774 | goto qc24_target_busy; |
| 775 | |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 776 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 777 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 778 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 779 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 780 | sp->u.scmd.cmd = cmd; |
| 781 | sp->type = SRB_SCSI_CMD; |
| 782 | atomic_set(&sp->ref_count, 1); |
| 783 | CMD_SP(cmd) = (void *)sp; |
| 784 | sp->free = qla2x00_sp_free_dma; |
| 785 | sp->done = qla2x00_sp_compl; |
| 786 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 787 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 788 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 789 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 790 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 791 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 792 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 793 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 794 | return 0; |
| 795 | |
| 796 | qc24_host_busy_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 797 | qla2x00_sp_free_dma(ha, sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 798 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 799 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 800 | return SCSI_MLQUEUE_HOST_BUSY; |
| 801 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 802 | qc24_target_busy: |
| 803 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 804 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 805 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 806 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 807 | |
| 808 | return 0; |
| 809 | } |
| 810 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | /* |
| 812 | * qla2x00_eh_wait_on_command |
| 813 | * Waits for the command to be returned by the Firmware for some |
| 814 | * max time. |
| 815 | * |
| 816 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | * |
| 819 | * Return: |
| 820 | * Not Found : 0 |
| 821 | * Found : 1 |
| 822 | */ |
| 823 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 824 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 826 | #define ABORT_POLLING_PERIOD 1000 |
Chad Dupuis | 478c3b0 | 2014-04-11 16:54:35 -0400 | [diff] [blame] | 827 | #define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 828 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 829 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 830 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 831 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 833 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 834 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 835 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 836 | return ret; |
| 837 | } |
| 838 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 839 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 840 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 841 | } |
| 842 | if (CMD_SP(cmd)) |
| 843 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 845 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | /* |
| 849 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 850 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 852 | * finally HBA is disabled ie marked offline |
| 853 | * |
| 854 | * Input: |
| 855 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 856 | * |
| 857 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | * Does context switching-Release SPIN_LOCK |
| 859 | * (if any) before calling this routine. |
| 860 | * |
| 861 | * Return: |
| 862 | * Success (Adapter is online) : 0 |
| 863 | * Failed (Adapter is offline/disabled) : 1 |
| 864 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 865 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 866 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 868 | int return_status; |
| 869 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 870 | struct qla_hw_data *ha = vha->hw; |
| 871 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 873 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 874 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 875 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 876 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 877 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | |
| 879 | msleep(1000); |
| 880 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 881 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 882 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | else |
| 884 | return_status = QLA_FUNCTION_FAILED; |
| 885 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | return (return_status); |
| 887 | } |
| 888 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 889 | /* |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 890 | * qla2x00_wait_for_hba_ready |
| 891 | * Wait till the HBA is ready before doing driver unload |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 892 | * |
| 893 | * Input: |
| 894 | * ha - pointer to host adapter structure |
| 895 | * |
| 896 | * Note: |
| 897 | * Does context switching-Release SPIN_LOCK |
| 898 | * (if any) before calling this routine. |
| 899 | * |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 900 | */ |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 901 | static void |
| 902 | qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 903 | { |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 904 | struct qla_hw_data *ha = vha->hw; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 905 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 906 | |
Dan Carpenter | 1d48390 | 2016-08-03 21:42:32 +0300 | [diff] [blame] | 907 | while ((qla2x00_reset_active(vha) || ha->dpc_active || |
| 908 | ha->flags.mbox_busy) || |
| 909 | test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags) || |
| 910 | test_bit(FX00_TARGET_SCAN, &vha->dpc_flags)) { |
| 911 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 912 | break; |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 913 | msleep(1000); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 914 | } |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 915 | } |
| 916 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 917 | int |
| 918 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 919 | { |
| 920 | int return_status; |
| 921 | unsigned long wait_reset; |
| 922 | struct qla_hw_data *ha = vha->hw; |
| 923 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 924 | |
| 925 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 926 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 927 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 928 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 929 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 930 | |
| 931 | msleep(1000); |
| 932 | |
| 933 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 934 | ha->flags.chip_reset_done) |
| 935 | break; |
| 936 | } |
| 937 | if (ha->flags.chip_reset_done) |
| 938 | return_status = QLA_SUCCESS; |
| 939 | else |
| 940 | return_status = QLA_FUNCTION_FAILED; |
| 941 | |
| 942 | return return_status; |
| 943 | } |
| 944 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 945 | static void |
| 946 | sp_get(struct srb *sp) |
| 947 | { |
| 948 | atomic_inc(&sp->ref_count); |
| 949 | } |
| 950 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 951 | #define ISP_REG_DISCONNECT 0xffffffffU |
| 952 | /************************************************************************** |
| 953 | * qla2x00_isp_reg_stat |
| 954 | * |
| 955 | * Description: |
| 956 | * Read the host status register of ISP before aborting the command. |
| 957 | * |
| 958 | * Input: |
| 959 | * ha = pointer to host adapter structure. |
| 960 | * |
| 961 | * |
| 962 | * Returns: |
| 963 | * Either true or false. |
| 964 | * |
| 965 | * Note: Return true if there is register disconnect. |
| 966 | **************************************************************************/ |
| 967 | static inline |
| 968 | uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) |
| 969 | { |
| 970 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 971 | |
| 972 | return ((RD_REG_DWORD(®->host_status)) == ISP_REG_DISCONNECT); |
| 973 | } |
| 974 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | /************************************************************************** |
| 976 | * qla2xxx_eh_abort |
| 977 | * |
| 978 | * Description: |
| 979 | * The abort function will abort the specified command. |
| 980 | * |
| 981 | * Input: |
| 982 | * cmd = Linux SCSI command packet to be aborted. |
| 983 | * |
| 984 | * Returns: |
| 985 | * Either SUCCESS or FAILED. |
| 986 | * |
| 987 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 988 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 990 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 991 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 992 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 993 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 994 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 995 | int ret; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 996 | unsigned int id; |
| 997 | uint64_t lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 998 | unsigned long flags; |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 999 | int rval, wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1000 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1001 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1002 | if (qla2x00_isp_reg_stat(ha)) { |
| 1003 | ql_log(ql_log_info, vha, 0x8042, |
| 1004 | "PCI/Register disconnect, exiting.\n"); |
| 1005 | return FAILED; |
| 1006 | } |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1007 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1008 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1010 | ret = fc_block_scsi_eh(cmd); |
| 1011 | if (ret != 0) |
| 1012 | return ret; |
| 1013 | ret = SUCCESS; |
| 1014 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1015 | id = cmd->device->id; |
| 1016 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1017 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1018 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1019 | sp = (srb_t *) CMD_SP(cmd); |
| 1020 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1021 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1022 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1023 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1024 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1025 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | c7bc4ca | 2015-08-04 13:37:57 -0400 | [diff] [blame] | 1026 | "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n", |
| 1027 | vha->host_no, id, lun, sp, cmd, sp->handle); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1028 | |
| 1029 | /* Get a reference to the sp and drop the lock.*/ |
| 1030 | sp_get(sp); |
| 1031 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1032 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1033 | rval = ha->isp_ops->abort_command(sp); |
| 1034 | if (rval) { |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1035 | if (rval == QLA_FUNCTION_PARAMETER_ERROR) |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1036 | ret = SUCCESS; |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1037 | else |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1038 | ret = FAILED; |
| 1039 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1040 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1041 | "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1042 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1043 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1044 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1045 | wait = 1; |
| 1046 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1047 | |
| 1048 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1049 | sp->done(ha, sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1050 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1051 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 1052 | /* Did the command return during mailbox execution? */ |
| 1053 | if (ret == FAILED && !CMD_SP(cmd)) |
| 1054 | ret = SUCCESS; |
| 1055 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1056 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1057 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1058 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1059 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1060 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1061 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1062 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1064 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1065 | ql_log(ql_log_info, vha, 0x801c, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1066 | "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1067 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1069 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | } |
| 1071 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1072 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1073 | 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] | 1074 | uint64_t l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1075 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1076 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1077 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1078 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1079 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1080 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1081 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1082 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1083 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1084 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1085 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1086 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1087 | for (cnt = 1; status == QLA_SUCCESS && |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1088 | cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1089 | sp = req->outstanding_cmds[cnt]; |
| 1090 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1091 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1092 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1093 | continue; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1094 | if (vha->vp_idx != sp->fcport->vha->vp_idx) |
| 1095 | continue; |
| 1096 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1097 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1098 | switch (type) { |
| 1099 | case WAIT_HOST: |
| 1100 | match = 1; |
| 1101 | break; |
| 1102 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1103 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1104 | break; |
| 1105 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1106 | match = (cmd->device->id == t && |
| 1107 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1108 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1110 | if (!match) |
| 1111 | continue; |
| 1112 | |
| 1113 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1114 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1115 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1117 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1118 | |
| 1119 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | } |
| 1121 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1122 | static char *reset_errors[] = { |
| 1123 | "HBA not online", |
| 1124 | "HBA not ready", |
| 1125 | "Task management failed", |
| 1126 | "Waiting for command completions", |
| 1127 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1128 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1129 | static int |
| 1130 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1131 | 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] | 1132 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1133 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1134 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1135 | int err; |
| 1136 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1137 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1138 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1139 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1140 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1141 | err = fc_block_scsi_eh(cmd); |
| 1142 | if (err != 0) |
| 1143 | return err; |
| 1144 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1145 | ql_log(ql_log_info, vha, 0x8009, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1146 | "%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] | 1147 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1148 | |
| 1149 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1150 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1151 | ql_log(ql_log_warn, vha, 0x800a, |
| 1152 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1153 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1154 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1155 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1156 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1157 | != QLA_SUCCESS) { |
| 1158 | ql_log(ql_log_warn, vha, 0x800c, |
| 1159 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1160 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1161 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1162 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1163 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1164 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1165 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1166 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1167 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1168 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1169 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1170 | ql_log(ql_log_info, vha, 0x800e, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1171 | "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1172 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1173 | |
| 1174 | return SUCCESS; |
| 1175 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1176 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1177 | ql_log(ql_log_info, vha, 0x800f, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1178 | "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1179 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1180 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1181 | return FAILED; |
| 1182 | } |
| 1183 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1184 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1185 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1186 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1187 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1188 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1189 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1190 | if (qla2x00_isp_reg_stat(ha)) { |
| 1191 | ql_log(ql_log_info, vha, 0x803e, |
| 1192 | "PCI/Register disconnect, exiting.\n"); |
| 1193 | return FAILED; |
| 1194 | } |
| 1195 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1196 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1197 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | } |
| 1199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1201 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1203 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1204 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1205 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1206 | if (qla2x00_isp_reg_stat(ha)) { |
| 1207 | ql_log(ql_log_info, vha, 0x803f, |
| 1208 | "PCI/Register disconnect, exiting.\n"); |
| 1209 | return FAILED; |
| 1210 | } |
| 1211 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1212 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1213 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1214 | } |
| 1215 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1216 | /************************************************************************** |
| 1217 | * qla2xxx_eh_bus_reset |
| 1218 | * |
| 1219 | * Description: |
| 1220 | * The bus reset function will reset the bus and abort any executing |
| 1221 | * commands. |
| 1222 | * |
| 1223 | * Input: |
| 1224 | * cmd = Linux SCSI command packet of the command that cause the |
| 1225 | * bus reset. |
| 1226 | * |
| 1227 | * Returns: |
| 1228 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1229 | * |
| 1230 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1231 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1233 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1234 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1235 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1236 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1237 | unsigned int id; |
| 1238 | uint64_t lun; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1239 | struct qla_hw_data *ha = vha->hw; |
| 1240 | |
| 1241 | if (qla2x00_isp_reg_stat(ha)) { |
| 1242 | ql_log(ql_log_info, vha, 0x8040, |
| 1243 | "PCI/Register disconnect, exiting.\n"); |
| 1244 | return FAILED; |
| 1245 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1246 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1247 | id = cmd->device->id; |
| 1248 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1249 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1250 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1251 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1252 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1253 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1254 | ret = fc_block_scsi_eh(cmd); |
| 1255 | if (ret != 0) |
| 1256 | return ret; |
| 1257 | ret = FAILED; |
| 1258 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1259 | ql_log(ql_log_info, vha, 0x8012, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1260 | "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] | 1261 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1262 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1263 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1264 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1265 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1266 | } |
| 1267 | |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1268 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1269 | ret = SUCCESS; |
| 1270 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1271 | if (ret == FAILED) |
| 1272 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1273 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1274 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1275 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1276 | QLA_SUCCESS) { |
| 1277 | ql_log(ql_log_warn, vha, 0x8014, |
| 1278 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1279 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1280 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1281 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1282 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1283 | ql_log(ql_log_warn, vha, 0x802b, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1284 | "BUS RESET %s nexus=%ld:%d:%llu.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1285 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1286 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1287 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | } |
| 1289 | |
| 1290 | /************************************************************************** |
| 1291 | * qla2xxx_eh_host_reset |
| 1292 | * |
| 1293 | * Description: |
| 1294 | * The reset function will reset the Adapter. |
| 1295 | * |
| 1296 | * Input: |
| 1297 | * cmd = Linux SCSI command packet of the command that cause the |
| 1298 | * adapter reset. |
| 1299 | * |
| 1300 | * Returns: |
| 1301 | * Either SUCCESS or FAILED. |
| 1302 | * |
| 1303 | * Note: |
| 1304 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1305 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1306 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1307 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1308 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1309 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1310 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1311 | unsigned int id; |
| 1312 | uint64_t lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1313 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1314 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1315 | if (qla2x00_isp_reg_stat(ha)) { |
| 1316 | ql_log(ql_log_info, vha, 0x8041, |
| 1317 | "PCI/Register disconnect, exiting.\n"); |
| 1318 | schedule_work(&ha->board_disable); |
| 1319 | return SUCCESS; |
| 1320 | } |
| 1321 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1322 | id = cmd->device->id; |
| 1323 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1324 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1325 | ql_log(ql_log_info, vha, 0x8018, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1326 | "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] | 1327 | |
Chad Dupuis | 63ee707 | 2014-04-11 16:54:46 -0400 | [diff] [blame] | 1328 | /* |
| 1329 | * No point in issuing another reset if one is active. Also do not |
| 1330 | * attempt a reset if we are updating flash. |
| 1331 | */ |
| 1332 | if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1333 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1335 | if (vha != base_vha) { |
| 1336 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1337 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1338 | } else { |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1339 | if (IS_P3P_TYPE(vha->hw)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1340 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1341 | /* Ctx reset success */ |
| 1342 | ret = SUCCESS; |
| 1343 | goto eh_host_reset_lock; |
| 1344 | } |
| 1345 | /* fall thru if ctx reset failed */ |
| 1346 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1347 | if (ha->wq) |
| 1348 | flush_workqueue(ha->wq); |
| 1349 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1350 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1351 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1352 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1353 | /* failed. schedule dpc to try */ |
| 1354 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1355 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1356 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1357 | ql_log(ql_log_warn, vha, 0x802a, |
| 1358 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1359 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1360 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1361 | } |
| 1362 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1363 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1364 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1365 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1366 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1367 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1368 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1369 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1370 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1371 | ql_log(ql_log_info, vha, 0x8017, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1372 | "ADAPTER RESET %s nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1373 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1374 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1375 | return ret; |
| 1376 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1377 | |
| 1378 | /* |
| 1379 | * qla2x00_loop_reset |
| 1380 | * Issue loop reset. |
| 1381 | * |
| 1382 | * Input: |
| 1383 | * ha = adapter block pointer. |
| 1384 | * |
| 1385 | * Returns: |
| 1386 | * 0 = success |
| 1387 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1388 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1389 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1390 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1391 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1392 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1393 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1394 | |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1395 | if (IS_QLAFX00(ha)) { |
| 1396 | return qlafx00_loop_reset(vha); |
| 1397 | } |
| 1398 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1399 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1400 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1401 | if (fcport->port_type != FCT_TARGET) |
| 1402 | continue; |
| 1403 | |
| 1404 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1405 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1406 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1407 | "Bus Reset failed: Reset=%d " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1408 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1409 | } |
| 1410 | } |
| 1411 | } |
| 1412 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1413 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1414 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Andrew Vasquez | 0b7e7c5 | 2013-02-08 01:57:42 -0500 | [diff] [blame] | 1415 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1416 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1417 | qla2x00_mark_all_devices_lost(vha, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1418 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1419 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1420 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1421 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1422 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | } |
| 1424 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1425 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1426 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1427 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1428 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1429 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1430 | } |
| 1431 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1432 | /* 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] | 1433 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1434 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1435 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1436 | } |
| 1437 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1438 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1439 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1440 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1441 | int que, cnt; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1442 | unsigned long flags; |
| 1443 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1444 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1445 | struct req_que *req; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1446 | |
Arun Easi | c0cb449 | 2014-09-25 06:14:51 -0400 | [diff] [blame] | 1447 | qlt_host_reset_handler(ha); |
| 1448 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1449 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1450 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1451 | req = ha->req_q_map[que]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1452 | if (!req) |
| 1453 | continue; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1454 | if (!req->outstanding_cmds) |
| 1455 | continue; |
| 1456 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1457 | sp = req->outstanding_cmds[cnt]; |
Andrew Vasquez | e612d46 | 2009-03-24 09:08:04 -0700 | [diff] [blame] | 1458 | if (sp) { |
Mauricio Faria de Oliveira | c733ab3 | 2016-11-14 19:26:22 -0200 | [diff] [blame] | 1459 | /* Don't abort commands in adapter during EEH |
| 1460 | * recovery as it's not accessible/responding. |
Mauricio Faria de Oliveira | 1535aa7 | 2016-11-07 17:53:31 -0200 | [diff] [blame] | 1461 | */ |
Mauricio Faria de Oliveira | 76a9ac0 | 2017-01-25 22:07:06 -0200 | [diff] [blame] | 1462 | if (GET_CMD_SP(sp) && !ha->flags.eeh_busy) { |
Mauricio Faria de Oliveira | c733ab3 | 2016-11-14 19:26:22 -0200 | [diff] [blame] | 1463 | /* Get a reference to the sp and drop the lock. |
| 1464 | * The reference ensures this sp->done() call |
| 1465 | * - and not the call in qla2xxx_eh_abort() - |
| 1466 | * ends the SCSI command (with result 'res'). |
| 1467 | */ |
| 1468 | sp_get(sp); |
| 1469 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1470 | qla2xxx_eh_abort(GET_CMD_SP(sp)); |
| 1471 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1472 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1473 | req->outstanding_cmds[cnt] = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1474 | sp->done(vha, sp, res); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1475 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1476 | } |
| 1477 | } |
| 1478 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1479 | } |
| 1480 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1481 | static int |
| 1482 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1483 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1484 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1485 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1486 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1487 | return -ENXIO; |
| 1488 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1489 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1490 | |
| 1491 | return 0; |
| 1492 | } |
| 1493 | |
| 1494 | static int |
| 1495 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1496 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1497 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1498 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1499 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1500 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1501 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1502 | |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 1503 | scsi_change_queue_depth(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1504 | return 0; |
| 1505 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1506 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1507 | static void |
| 1508 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1509 | { |
| 1510 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1511 | } |
| 1512 | |
| 1513 | /** |
| 1514 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1515 | * @ha: HA context |
| 1516 | * |
| 1517 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1518 | * supported addressing method. |
| 1519 | */ |
| 1520 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1521 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1522 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1523 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1524 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1525 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1526 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1527 | /* Any upper-dword bits set? */ |
| 1528 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1529 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1530 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1531 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1532 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1533 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1534 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1535 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1536 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1537 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1538 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1539 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1540 | } |
| 1541 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1542 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1543 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1544 | { |
| 1545 | unsigned long flags = 0; |
| 1546 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1547 | |
| 1548 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1549 | ha->interrupts_on = 1; |
| 1550 | /* enable risc and host interrupts */ |
| 1551 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1552 | RD_REG_WORD(®->ictrl); |
| 1553 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1554 | |
| 1555 | } |
| 1556 | |
| 1557 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1558 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1559 | { |
| 1560 | unsigned long flags = 0; |
| 1561 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1562 | |
| 1563 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1564 | ha->interrupts_on = 0; |
| 1565 | /* disable risc and host interrupts */ |
| 1566 | WRT_REG_WORD(®->ictrl, 0); |
| 1567 | RD_REG_WORD(®->ictrl); |
| 1568 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1569 | } |
| 1570 | |
| 1571 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1572 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1573 | { |
| 1574 | unsigned long flags = 0; |
| 1575 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1576 | |
| 1577 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1578 | ha->interrupts_on = 1; |
| 1579 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1580 | RD_REG_DWORD(®->ictrl); |
| 1581 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1582 | } |
| 1583 | |
| 1584 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1585 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1586 | { |
| 1587 | unsigned long flags = 0; |
| 1588 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1589 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1590 | if (IS_NOPOLLING_TYPE(ha)) |
| 1591 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1592 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1593 | ha->interrupts_on = 0; |
| 1594 | WRT_REG_DWORD(®->ictrl, 0); |
| 1595 | RD_REG_DWORD(®->ictrl); |
| 1596 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1597 | } |
| 1598 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1599 | static int |
| 1600 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1601 | { |
| 1602 | resource_size_t pio; |
| 1603 | uint16_t msix; |
| 1604 | int cpus; |
| 1605 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1606 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1607 | QLA2XXX_DRIVER_NAME)) { |
| 1608 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1609 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1610 | pci_name(ha->pdev)); |
| 1611 | goto iospace_error_exit; |
| 1612 | } |
| 1613 | if (!(ha->bars & 1)) |
| 1614 | goto skip_pio; |
| 1615 | |
| 1616 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1617 | pio = pci_resource_start(ha->pdev, 0); |
| 1618 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1619 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1620 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1621 | "Invalid pci I/O region size (%s).\n", |
| 1622 | pci_name(ha->pdev)); |
| 1623 | pio = 0; |
| 1624 | } |
| 1625 | } else { |
| 1626 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1627 | "Region #0 no a PIO resource (%s).\n", |
| 1628 | pci_name(ha->pdev)); |
| 1629 | pio = 0; |
| 1630 | } |
| 1631 | ha->pio_address = pio; |
| 1632 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1633 | "PIO address=%llu.\n", |
| 1634 | (unsigned long long)ha->pio_address); |
| 1635 | |
| 1636 | skip_pio: |
| 1637 | /* Use MMIO operations for all accesses. */ |
| 1638 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1639 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1640 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1641 | pci_name(ha->pdev)); |
| 1642 | goto iospace_error_exit; |
| 1643 | } |
| 1644 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1645 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1646 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1647 | pci_name(ha->pdev)); |
| 1648 | goto iospace_error_exit; |
| 1649 | } |
| 1650 | |
| 1651 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1652 | if (!ha->iobase) { |
| 1653 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1654 | "Cannot remap MMIO (%s), aborting.\n", |
| 1655 | pci_name(ha->pdev)); |
| 1656 | goto iospace_error_exit; |
| 1657 | } |
| 1658 | |
| 1659 | /* Determine queue resources */ |
| 1660 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1661 | if ((ql2xmaxqueues <= 1 && !ql2xmultique_tag) || |
| 1662 | (ql2xmaxqueues > 1 && ql2xmultique_tag) || |
| 1663 | (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
| 1664 | goto mqiobase_exit; |
| 1665 | |
| 1666 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1667 | pci_resource_len(ha->pdev, 3)); |
| 1668 | if (ha->mqiobase) { |
| 1669 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 1670 | "MQIO Base=%p.\n", ha->mqiobase); |
| 1671 | /* Read MSIX vector size of the board */ |
| 1672 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
| 1673 | ha->msix_count = msix; |
| 1674 | /* Max queues are bounded by available msix vectors */ |
| 1675 | /* queue 0 uses two msix vectors */ |
| 1676 | if (ql2xmultique_tag) { |
| 1677 | cpus = num_online_cpus(); |
| 1678 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1679 | (cpus + 1) : (ha->msix_count - 1); |
| 1680 | ha->max_req_queues = 2; |
| 1681 | } else if (ql2xmaxqueues > 1) { |
| 1682 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1683 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1684 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc008, |
| 1685 | "QoS mode set, max no of request queues:%d.\n", |
| 1686 | ha->max_req_queues); |
| 1687 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0019, |
| 1688 | "QoS mode set, max no of request queues:%d.\n", |
| 1689 | ha->max_req_queues); |
| 1690 | } |
| 1691 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
| 1692 | "MSI-X vector count: %d.\n", msix); |
| 1693 | } else |
| 1694 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 1695 | "BAR 3 not enabled.\n"); |
| 1696 | |
| 1697 | mqiobase_exit: |
| 1698 | ha->msix_count = ha->max_rsp_queues + 1; |
| 1699 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
| 1700 | "MSIX Count:%d.\n", ha->msix_count); |
| 1701 | return (0); |
| 1702 | |
| 1703 | iospace_error_exit: |
| 1704 | return (-ENOMEM); |
| 1705 | } |
| 1706 | |
| 1707 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1708 | static int |
| 1709 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 1710 | { |
| 1711 | uint16_t msix; |
| 1712 | int cpus; |
| 1713 | |
| 1714 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1715 | QLA2XXX_DRIVER_NAME)) { |
| 1716 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 1717 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1718 | pci_name(ha->pdev)); |
| 1719 | |
| 1720 | goto iospace_error_exit; |
| 1721 | } |
| 1722 | |
| 1723 | /* Use MMIO operations for all accesses. */ |
| 1724 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 1725 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 1726 | "Invalid pci I/O region size (%s).\n", |
| 1727 | pci_name(ha->pdev)); |
| 1728 | goto iospace_error_exit; |
| 1729 | } |
| 1730 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1731 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 1732 | "Invalid PCI mem region size (%s), aborting\n", |
| 1733 | pci_name(ha->pdev)); |
| 1734 | goto iospace_error_exit; |
| 1735 | } |
| 1736 | |
| 1737 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 1738 | if (!ha->iobase) { |
| 1739 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 1740 | "Cannot remap MMIO (%s), aborting.\n", |
| 1741 | pci_name(ha->pdev)); |
| 1742 | goto iospace_error_exit; |
| 1743 | } |
| 1744 | |
| 1745 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 1746 | /* 83XX 26XX always use MQ type access for queues |
| 1747 | * - mbar 2, a.k.a region 4 */ |
| 1748 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1749 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 1750 | pci_resource_len(ha->pdev, 4)); |
| 1751 | |
| 1752 | if (!ha->mqiobase) { |
| 1753 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 1754 | "BAR2/region4 not enabled\n"); |
| 1755 | goto mqiobase_exit; |
| 1756 | } |
| 1757 | |
| 1758 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 1759 | pci_resource_len(ha->pdev, 2)); |
| 1760 | if (ha->msixbase) { |
| 1761 | /* Read MSIX vector size of the board */ |
| 1762 | pci_read_config_word(ha->pdev, |
| 1763 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
| 1764 | ha->msix_count = msix; |
| 1765 | /* Max queues are bounded by available msix vectors */ |
| 1766 | /* queue 0 uses two msix vectors */ |
| 1767 | if (ql2xmultique_tag) { |
| 1768 | cpus = num_online_cpus(); |
| 1769 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1770 | (cpus + 1) : (ha->msix_count - 1); |
| 1771 | ha->max_req_queues = 2; |
| 1772 | } else if (ql2xmaxqueues > 1) { |
| 1773 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1774 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1775 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc00c, |
| 1776 | "QoS mode set, max no of request queues:%d.\n", |
| 1777 | ha->max_req_queues); |
| 1778 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b, |
| 1779 | "QoS mode set, max no of request queues:%d.\n", |
| 1780 | ha->max_req_queues); |
| 1781 | } |
| 1782 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
| 1783 | "MSI-X vector count: %d.\n", msix); |
| 1784 | } else |
| 1785 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 1786 | "BAR 1 not enabled.\n"); |
| 1787 | |
| 1788 | mqiobase_exit: |
| 1789 | ha->msix_count = ha->max_rsp_queues + 1; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 1790 | |
| 1791 | qlt_83xx_iospace_config(ha); |
| 1792 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1793 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
| 1794 | "MSIX Count:%d.\n", ha->msix_count); |
| 1795 | return 0; |
| 1796 | |
| 1797 | iospace_error_exit: |
| 1798 | return -ENOMEM; |
| 1799 | } |
| 1800 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1801 | static struct isp_operations qla2100_isp_ops = { |
| 1802 | .pci_config = qla2100_pci_config, |
| 1803 | .reset_chip = qla2x00_reset_chip, |
| 1804 | .chip_diag = qla2x00_chip_diag, |
| 1805 | .config_rings = qla2x00_config_rings, |
| 1806 | .reset_adapter = qla2x00_reset_adapter, |
| 1807 | .nvram_config = qla2x00_nvram_config, |
| 1808 | .update_fw_options = qla2x00_update_fw_options, |
| 1809 | .load_risc = qla2x00_load_risc, |
| 1810 | .pci_info_str = qla2x00_pci_info_str, |
| 1811 | .fw_version_str = qla2x00_fw_version_str, |
| 1812 | .intr_handler = qla2100_intr_handler, |
| 1813 | .enable_intrs = qla2x00_enable_intrs, |
| 1814 | .disable_intrs = qla2x00_disable_intrs, |
| 1815 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1816 | .target_reset = qla2x00_abort_target, |
| 1817 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1818 | .fabric_login = qla2x00_login_fabric, |
| 1819 | .fabric_logout = qla2x00_fabric_logout, |
| 1820 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1821 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1822 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1823 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1824 | .read_nvram = qla2x00_read_nvram_data, |
| 1825 | .write_nvram = qla2x00_write_nvram_data, |
| 1826 | .fw_dump = qla2100_fw_dump, |
| 1827 | .beacon_on = NULL, |
| 1828 | .beacon_off = NULL, |
| 1829 | .beacon_blink = NULL, |
| 1830 | .read_optrom = qla2x00_read_optrom_data, |
| 1831 | .write_optrom = qla2x00_write_optrom_data, |
| 1832 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1833 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1834 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1835 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1836 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1837 | }; |
| 1838 | |
| 1839 | static struct isp_operations qla2300_isp_ops = { |
| 1840 | .pci_config = qla2300_pci_config, |
| 1841 | .reset_chip = qla2x00_reset_chip, |
| 1842 | .chip_diag = qla2x00_chip_diag, |
| 1843 | .config_rings = qla2x00_config_rings, |
| 1844 | .reset_adapter = qla2x00_reset_adapter, |
| 1845 | .nvram_config = qla2x00_nvram_config, |
| 1846 | .update_fw_options = qla2x00_update_fw_options, |
| 1847 | .load_risc = qla2x00_load_risc, |
| 1848 | .pci_info_str = qla2x00_pci_info_str, |
| 1849 | .fw_version_str = qla2x00_fw_version_str, |
| 1850 | .intr_handler = qla2300_intr_handler, |
| 1851 | .enable_intrs = qla2x00_enable_intrs, |
| 1852 | .disable_intrs = qla2x00_disable_intrs, |
| 1853 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1854 | .target_reset = qla2x00_abort_target, |
| 1855 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1856 | .fabric_login = qla2x00_login_fabric, |
| 1857 | .fabric_logout = qla2x00_fabric_logout, |
| 1858 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1859 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1860 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1861 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1862 | .read_nvram = qla2x00_read_nvram_data, |
| 1863 | .write_nvram = qla2x00_write_nvram_data, |
| 1864 | .fw_dump = qla2300_fw_dump, |
| 1865 | .beacon_on = qla2x00_beacon_on, |
| 1866 | .beacon_off = qla2x00_beacon_off, |
| 1867 | .beacon_blink = qla2x00_beacon_blink, |
| 1868 | .read_optrom = qla2x00_read_optrom_data, |
| 1869 | .write_optrom = qla2x00_write_optrom_data, |
| 1870 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1871 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1872 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1873 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1874 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1875 | }; |
| 1876 | |
| 1877 | static struct isp_operations qla24xx_isp_ops = { |
| 1878 | .pci_config = qla24xx_pci_config, |
| 1879 | .reset_chip = qla24xx_reset_chip, |
| 1880 | .chip_diag = qla24xx_chip_diag, |
| 1881 | .config_rings = qla24xx_config_rings, |
| 1882 | .reset_adapter = qla24xx_reset_adapter, |
| 1883 | .nvram_config = qla24xx_nvram_config, |
| 1884 | .update_fw_options = qla24xx_update_fw_options, |
| 1885 | .load_risc = qla24xx_load_risc, |
| 1886 | .pci_info_str = qla24xx_pci_info_str, |
| 1887 | .fw_version_str = qla24xx_fw_version_str, |
| 1888 | .intr_handler = qla24xx_intr_handler, |
| 1889 | .enable_intrs = qla24xx_enable_intrs, |
| 1890 | .disable_intrs = qla24xx_disable_intrs, |
| 1891 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1892 | .target_reset = qla24xx_abort_target, |
| 1893 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1894 | .fabric_login = qla24xx_login_fabric, |
| 1895 | .fabric_logout = qla24xx_fabric_logout, |
| 1896 | .calc_req_entries = NULL, |
| 1897 | .build_iocbs = NULL, |
| 1898 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1899 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1900 | .read_nvram = qla24xx_read_nvram_data, |
| 1901 | .write_nvram = qla24xx_write_nvram_data, |
| 1902 | .fw_dump = qla24xx_fw_dump, |
| 1903 | .beacon_on = qla24xx_beacon_on, |
| 1904 | .beacon_off = qla24xx_beacon_off, |
| 1905 | .beacon_blink = qla24xx_beacon_blink, |
| 1906 | .read_optrom = qla24xx_read_optrom_data, |
| 1907 | .write_optrom = qla24xx_write_optrom_data, |
| 1908 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1909 | .start_scsi = qla24xx_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1910 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1911 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1912 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1913 | }; |
| 1914 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1915 | static struct isp_operations qla25xx_isp_ops = { |
| 1916 | .pci_config = qla25xx_pci_config, |
| 1917 | .reset_chip = qla24xx_reset_chip, |
| 1918 | .chip_diag = qla24xx_chip_diag, |
| 1919 | .config_rings = qla24xx_config_rings, |
| 1920 | .reset_adapter = qla24xx_reset_adapter, |
| 1921 | .nvram_config = qla24xx_nvram_config, |
| 1922 | .update_fw_options = qla24xx_update_fw_options, |
| 1923 | .load_risc = qla24xx_load_risc, |
| 1924 | .pci_info_str = qla24xx_pci_info_str, |
| 1925 | .fw_version_str = qla24xx_fw_version_str, |
| 1926 | .intr_handler = qla24xx_intr_handler, |
| 1927 | .enable_intrs = qla24xx_enable_intrs, |
| 1928 | .disable_intrs = qla24xx_disable_intrs, |
| 1929 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1930 | .target_reset = qla24xx_abort_target, |
| 1931 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1932 | .fabric_login = qla24xx_login_fabric, |
| 1933 | .fabric_logout = qla24xx_fabric_logout, |
| 1934 | .calc_req_entries = NULL, |
| 1935 | .build_iocbs = NULL, |
| 1936 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1937 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1938 | .read_nvram = qla25xx_read_nvram_data, |
| 1939 | .write_nvram = qla25xx_write_nvram_data, |
| 1940 | .fw_dump = qla25xx_fw_dump, |
| 1941 | .beacon_on = qla24xx_beacon_on, |
| 1942 | .beacon_off = qla24xx_beacon_off, |
| 1943 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 1944 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1945 | .write_optrom = qla24xx_write_optrom_data, |
| 1946 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1947 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1948 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1949 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1950 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1951 | }; |
| 1952 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1953 | static struct isp_operations qla81xx_isp_ops = { |
| 1954 | .pci_config = qla25xx_pci_config, |
| 1955 | .reset_chip = qla24xx_reset_chip, |
| 1956 | .chip_diag = qla24xx_chip_diag, |
| 1957 | .config_rings = qla24xx_config_rings, |
| 1958 | .reset_adapter = qla24xx_reset_adapter, |
| 1959 | .nvram_config = qla81xx_nvram_config, |
| 1960 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 1961 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1962 | .pci_info_str = qla24xx_pci_info_str, |
| 1963 | .fw_version_str = qla24xx_fw_version_str, |
| 1964 | .intr_handler = qla24xx_intr_handler, |
| 1965 | .enable_intrs = qla24xx_enable_intrs, |
| 1966 | .disable_intrs = qla24xx_disable_intrs, |
| 1967 | .abort_command = qla24xx_abort_command, |
| 1968 | .target_reset = qla24xx_abort_target, |
| 1969 | .lun_reset = qla24xx_lun_reset, |
| 1970 | .fabric_login = qla24xx_login_fabric, |
| 1971 | .fabric_logout = qla24xx_fabric_logout, |
| 1972 | .calc_req_entries = NULL, |
| 1973 | .build_iocbs = NULL, |
| 1974 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1975 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 1976 | .read_nvram = NULL, |
| 1977 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1978 | .fw_dump = qla81xx_fw_dump, |
| 1979 | .beacon_on = qla24xx_beacon_on, |
| 1980 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1981 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1982 | .read_optrom = qla25xx_read_optrom_data, |
| 1983 | .write_optrom = qla24xx_write_optrom_data, |
| 1984 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 1985 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1986 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1987 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1988 | .initialize_adapter = qla2x00_initialize_adapter, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1989 | }; |
| 1990 | |
| 1991 | static struct isp_operations qla82xx_isp_ops = { |
| 1992 | .pci_config = qla82xx_pci_config, |
| 1993 | .reset_chip = qla82xx_reset_chip, |
| 1994 | .chip_diag = qla24xx_chip_diag, |
| 1995 | .config_rings = qla82xx_config_rings, |
| 1996 | .reset_adapter = qla24xx_reset_adapter, |
| 1997 | .nvram_config = qla81xx_nvram_config, |
| 1998 | .update_fw_options = qla24xx_update_fw_options, |
| 1999 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 2000 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2001 | .fw_version_str = qla24xx_fw_version_str, |
| 2002 | .intr_handler = qla82xx_intr_handler, |
| 2003 | .enable_intrs = qla82xx_enable_intrs, |
| 2004 | .disable_intrs = qla82xx_disable_intrs, |
| 2005 | .abort_command = qla24xx_abort_command, |
| 2006 | .target_reset = qla24xx_abort_target, |
| 2007 | .lun_reset = qla24xx_lun_reset, |
| 2008 | .fabric_login = qla24xx_login_fabric, |
| 2009 | .fabric_logout = qla24xx_fabric_logout, |
| 2010 | .calc_req_entries = NULL, |
| 2011 | .build_iocbs = NULL, |
| 2012 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2013 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2014 | .read_nvram = qla24xx_read_nvram_data, |
| 2015 | .write_nvram = qla24xx_write_nvram_data, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2016 | .fw_dump = qla82xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 2017 | .beacon_on = qla82xx_beacon_on, |
| 2018 | .beacon_off = qla82xx_beacon_off, |
| 2019 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2020 | .read_optrom = qla82xx_read_optrom_data, |
| 2021 | .write_optrom = qla82xx_write_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2022 | .get_flash_version = qla82xx_get_flash_version, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2023 | .start_scsi = qla82xx_start_scsi, |
| 2024 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2025 | .iospace_config = qla82xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2026 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2027 | }; |
| 2028 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2029 | static struct isp_operations qla8044_isp_ops = { |
| 2030 | .pci_config = qla82xx_pci_config, |
| 2031 | .reset_chip = qla82xx_reset_chip, |
| 2032 | .chip_diag = qla24xx_chip_diag, |
| 2033 | .config_rings = qla82xx_config_rings, |
| 2034 | .reset_adapter = qla24xx_reset_adapter, |
| 2035 | .nvram_config = qla81xx_nvram_config, |
| 2036 | .update_fw_options = qla24xx_update_fw_options, |
| 2037 | .load_risc = qla82xx_load_risc, |
| 2038 | .pci_info_str = qla24xx_pci_info_str, |
| 2039 | .fw_version_str = qla24xx_fw_version_str, |
| 2040 | .intr_handler = qla8044_intr_handler, |
| 2041 | .enable_intrs = qla82xx_enable_intrs, |
| 2042 | .disable_intrs = qla82xx_disable_intrs, |
| 2043 | .abort_command = qla24xx_abort_command, |
| 2044 | .target_reset = qla24xx_abort_target, |
| 2045 | .lun_reset = qla24xx_lun_reset, |
| 2046 | .fabric_login = qla24xx_login_fabric, |
| 2047 | .fabric_logout = qla24xx_fabric_logout, |
| 2048 | .calc_req_entries = NULL, |
| 2049 | .build_iocbs = NULL, |
| 2050 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2051 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2052 | .read_nvram = NULL, |
| 2053 | .write_nvram = NULL, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2054 | .fw_dump = qla8044_fw_dump, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2055 | .beacon_on = qla82xx_beacon_on, |
| 2056 | .beacon_off = qla82xx_beacon_off, |
| 2057 | .beacon_blink = NULL, |
Saurav Kashyap | 888e639 | 2014-02-26 04:15:13 -0500 | [diff] [blame] | 2058 | .read_optrom = qla8044_read_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2059 | .write_optrom = qla8044_write_optrom_data, |
| 2060 | .get_flash_version = qla82xx_get_flash_version, |
| 2061 | .start_scsi = qla82xx_start_scsi, |
| 2062 | .abort_isp = qla8044_abort_isp, |
| 2063 | .iospace_config = qla82xx_iospace_config, |
| 2064 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2065 | }; |
| 2066 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2067 | static struct isp_operations qla83xx_isp_ops = { |
| 2068 | .pci_config = qla25xx_pci_config, |
| 2069 | .reset_chip = qla24xx_reset_chip, |
| 2070 | .chip_diag = qla24xx_chip_diag, |
| 2071 | .config_rings = qla24xx_config_rings, |
| 2072 | .reset_adapter = qla24xx_reset_adapter, |
| 2073 | .nvram_config = qla81xx_nvram_config, |
| 2074 | .update_fw_options = qla81xx_update_fw_options, |
| 2075 | .load_risc = qla81xx_load_risc, |
| 2076 | .pci_info_str = qla24xx_pci_info_str, |
| 2077 | .fw_version_str = qla24xx_fw_version_str, |
| 2078 | .intr_handler = qla24xx_intr_handler, |
| 2079 | .enable_intrs = qla24xx_enable_intrs, |
| 2080 | .disable_intrs = qla24xx_disable_intrs, |
| 2081 | .abort_command = qla24xx_abort_command, |
| 2082 | .target_reset = qla24xx_abort_target, |
| 2083 | .lun_reset = qla24xx_lun_reset, |
| 2084 | .fabric_login = qla24xx_login_fabric, |
| 2085 | .fabric_logout = qla24xx_fabric_logout, |
| 2086 | .calc_req_entries = NULL, |
| 2087 | .build_iocbs = NULL, |
| 2088 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2089 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2090 | .read_nvram = NULL, |
| 2091 | .write_nvram = NULL, |
| 2092 | .fw_dump = qla83xx_fw_dump, |
| 2093 | .beacon_on = qla24xx_beacon_on, |
| 2094 | .beacon_off = qla24xx_beacon_off, |
| 2095 | .beacon_blink = qla83xx_beacon_blink, |
| 2096 | .read_optrom = qla25xx_read_optrom_data, |
| 2097 | .write_optrom = qla24xx_write_optrom_data, |
| 2098 | .get_flash_version = qla24xx_get_flash_version, |
| 2099 | .start_scsi = qla24xx_dif_start_scsi, |
| 2100 | .abort_isp = qla2x00_abort_isp, |
| 2101 | .iospace_config = qla83xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2102 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2103 | }; |
| 2104 | |
| 2105 | static struct isp_operations qlafx00_isp_ops = { |
| 2106 | .pci_config = qlafx00_pci_config, |
| 2107 | .reset_chip = qlafx00_soft_reset, |
| 2108 | .chip_diag = qlafx00_chip_diag, |
| 2109 | .config_rings = qlafx00_config_rings, |
| 2110 | .reset_adapter = qlafx00_soft_reset, |
| 2111 | .nvram_config = NULL, |
| 2112 | .update_fw_options = NULL, |
| 2113 | .load_risc = NULL, |
| 2114 | .pci_info_str = qlafx00_pci_info_str, |
| 2115 | .fw_version_str = qlafx00_fw_version_str, |
| 2116 | .intr_handler = qlafx00_intr_handler, |
| 2117 | .enable_intrs = qlafx00_enable_intrs, |
| 2118 | .disable_intrs = qlafx00_disable_intrs, |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2119 | .abort_command = qla24xx_async_abort_command, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2120 | .target_reset = qlafx00_abort_target, |
| 2121 | .lun_reset = qlafx00_lun_reset, |
| 2122 | .fabric_login = NULL, |
| 2123 | .fabric_logout = NULL, |
| 2124 | .calc_req_entries = NULL, |
| 2125 | .build_iocbs = NULL, |
| 2126 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2127 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2128 | .read_nvram = qla24xx_read_nvram_data, |
| 2129 | .write_nvram = qla24xx_write_nvram_data, |
| 2130 | .fw_dump = NULL, |
| 2131 | .beacon_on = qla24xx_beacon_on, |
| 2132 | .beacon_off = qla24xx_beacon_off, |
| 2133 | .beacon_blink = NULL, |
| 2134 | .read_optrom = qla24xx_read_optrom_data, |
| 2135 | .write_optrom = qla24xx_write_optrom_data, |
| 2136 | .get_flash_version = qla24xx_get_flash_version, |
| 2137 | .start_scsi = qlafx00_start_scsi, |
| 2138 | .abort_isp = qlafx00_abort_isp, |
| 2139 | .iospace_config = qlafx00_iospace_config, |
| 2140 | .initialize_adapter = qlafx00_initialize_adapter, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2141 | }; |
| 2142 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2143 | static struct isp_operations qla27xx_isp_ops = { |
| 2144 | .pci_config = qla25xx_pci_config, |
| 2145 | .reset_chip = qla24xx_reset_chip, |
| 2146 | .chip_diag = qla24xx_chip_diag, |
| 2147 | .config_rings = qla24xx_config_rings, |
| 2148 | .reset_adapter = qla24xx_reset_adapter, |
| 2149 | .nvram_config = qla81xx_nvram_config, |
| 2150 | .update_fw_options = qla81xx_update_fw_options, |
| 2151 | .load_risc = qla81xx_load_risc, |
| 2152 | .pci_info_str = qla24xx_pci_info_str, |
| 2153 | .fw_version_str = qla24xx_fw_version_str, |
| 2154 | .intr_handler = qla24xx_intr_handler, |
| 2155 | .enable_intrs = qla24xx_enable_intrs, |
| 2156 | .disable_intrs = qla24xx_disable_intrs, |
| 2157 | .abort_command = qla24xx_abort_command, |
| 2158 | .target_reset = qla24xx_abort_target, |
| 2159 | .lun_reset = qla24xx_lun_reset, |
| 2160 | .fabric_login = qla24xx_login_fabric, |
| 2161 | .fabric_logout = qla24xx_fabric_logout, |
| 2162 | .calc_req_entries = NULL, |
| 2163 | .build_iocbs = NULL, |
| 2164 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2165 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2166 | .read_nvram = NULL, |
| 2167 | .write_nvram = NULL, |
| 2168 | .fw_dump = qla27xx_fwdump, |
| 2169 | .beacon_on = qla24xx_beacon_on, |
| 2170 | .beacon_off = qla24xx_beacon_off, |
| 2171 | .beacon_blink = qla83xx_beacon_blink, |
| 2172 | .read_optrom = qla25xx_read_optrom_data, |
| 2173 | .write_optrom = qla24xx_write_optrom_data, |
| 2174 | .get_flash_version = qla24xx_get_flash_version, |
| 2175 | .start_scsi = qla24xx_dif_start_scsi, |
| 2176 | .abort_isp = qla2x00_abort_isp, |
| 2177 | .iospace_config = qla83xx_iospace_config, |
| 2178 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2179 | }; |
| 2180 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2181 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2182 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2183 | { |
| 2184 | ha->device_type = DT_EXTENDED_IDS; |
| 2185 | switch (ha->pdev->device) { |
| 2186 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2187 | ha->isp_type |= DT_ISP2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2188 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2189 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2190 | break; |
| 2191 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2192 | ha->isp_type |= DT_ISP2200; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2193 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2194 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2195 | break; |
| 2196 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2197 | ha->isp_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2198 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2199 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2200 | break; |
| 2201 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2202 | ha->isp_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2203 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2204 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2205 | break; |
| 2206 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2207 | ha->isp_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2208 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2209 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2210 | ha->pdev->subsystem_device == 0x0170) |
| 2211 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2212 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2213 | break; |
| 2214 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2215 | ha->isp_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2216 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2217 | break; |
| 2218 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2219 | ha->isp_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2220 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2221 | break; |
| 2222 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2223 | ha->isp_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2224 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2225 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2226 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2227 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2228 | break; |
| 2229 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2230 | ha->isp_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2231 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2232 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2233 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2234 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2235 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2236 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2237 | ha->isp_type |= DT_ISP8432; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2238 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2239 | ha->device_type |= DT_FWI2; |
| 2240 | ha->device_type |= DT_IIDMA; |
| 2241 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2242 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2243 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2244 | ha->isp_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2245 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2246 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2247 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2248 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2249 | ha->isp_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2250 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2251 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2252 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2253 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2254 | ha->isp_type |= DT_ISP2532; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2255 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2256 | ha->device_type |= DT_FWI2; |
| 2257 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2258 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2259 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2260 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2261 | ha->isp_type |= DT_ISP8001; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2262 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2263 | ha->device_type |= DT_FWI2; |
| 2264 | ha->device_type |= DT_IIDMA; |
| 2265 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2266 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2267 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2268 | ha->isp_type |= DT_ISP8021; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2269 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2270 | ha->device_type |= DT_FWI2; |
| 2271 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2272 | /* Initialize 82XX ISP flags */ |
| 2273 | qla82xx_init_flags(ha); |
| 2274 | break; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2275 | case PCI_DEVICE_ID_QLOGIC_ISP8044: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2276 | ha->isp_type |= DT_ISP8044; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2277 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2278 | ha->device_type |= DT_FWI2; |
| 2279 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2280 | /* Initialize 82XX ISP flags */ |
| 2281 | qla82xx_init_flags(ha); |
| 2282 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2283 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2284 | ha->isp_type |= DT_ISP2031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2285 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2286 | ha->device_type |= DT_FWI2; |
| 2287 | ha->device_type |= DT_IIDMA; |
| 2288 | ha->device_type |= DT_T10_PI; |
| 2289 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2290 | break; |
| 2291 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2292 | ha->isp_type |= DT_ISP8031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2293 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2294 | ha->device_type |= DT_FWI2; |
| 2295 | ha->device_type |= DT_IIDMA; |
| 2296 | ha->device_type |= DT_T10_PI; |
| 2297 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2298 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2299 | case PCI_DEVICE_ID_QLOGIC_ISPF001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2300 | ha->isp_type |= DT_ISPFX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2301 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2302 | case PCI_DEVICE_ID_QLOGIC_ISP2071: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2303 | ha->isp_type |= DT_ISP2071; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2304 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2305 | ha->device_type |= DT_FWI2; |
| 2306 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2307 | ha->device_type |= DT_T10_PI; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2308 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2309 | break; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2310 | case PCI_DEVICE_ID_QLOGIC_ISP2271: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2311 | ha->isp_type |= DT_ISP2271; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2312 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2313 | ha->device_type |= DT_FWI2; |
| 2314 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2315 | ha->device_type |= DT_T10_PI; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2316 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2317 | break; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2318 | case PCI_DEVICE_ID_QLOGIC_ISP2261: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2319 | ha->isp_type |= DT_ISP2261; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2320 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2321 | ha->device_type |= DT_FWI2; |
| 2322 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2323 | ha->device_type |= DT_T10_PI; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2324 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2325 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2326 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2327 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2328 | if (IS_QLA82XX(ha)) |
Saurav Kashyap | 43a9c38 | 2014-02-26 04:15:16 -0500 | [diff] [blame] | 2329 | ha->port_no = ha->portnum & 1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2330 | else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2331 | /* Get adapter physical port no from interrupt pin register. */ |
| 2332 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2333 | if (IS_QLA27XX(ha)) |
| 2334 | ha->port_no--; |
| 2335 | else |
| 2336 | ha->port_no = !(ha->port_no & 1); |
| 2337 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2338 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2339 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2340 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2341 | ha->device_type, ha->port_no, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2342 | } |
| 2343 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2344 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2345 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2346 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2347 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2348 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2349 | if (vha->hw->flags.running_gold_fw) |
| 2350 | return; |
| 2351 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2352 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2353 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2354 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2355 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2356 | } |
| 2357 | |
| 2358 | static int |
| 2359 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2360 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2361 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2362 | |
Bill Kuzeja | a5dd506e | 2016-10-21 16:45:27 -0400 | [diff] [blame] | 2363 | if (test_bit(UNLOADING, &vha->dpc_flags)) |
| 2364 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2365 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2366 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2367 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2368 | return 1; |
| 2369 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2370 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2371 | } |
| 2372 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2373 | /* |
| 2374 | * PCI driver interface |
| 2375 | */ |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 2376 | static int |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2377 | 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] | 2378 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2379 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2380 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2381 | scsi_qla_host_t *base_vha = NULL; |
| 2382 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2383 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2384 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2385 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2386 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2387 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2388 | struct req_que *req = NULL; |
| 2389 | struct rsp_que *rsp = NULL; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2390 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2391 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2392 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2393 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2394 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2395 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2396 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2397 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2398 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2399 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2400 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2401 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031 || |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2402 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISPF001 || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2403 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8044 || |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2404 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2071 || |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2405 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271 || |
| 2406 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2261) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2407 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2408 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2409 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2410 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2411 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2412 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2413 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2414 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2415 | if (mem_only) { |
| 2416 | if (pci_enable_device_mem(pdev)) |
| 2417 | goto probe_out; |
| 2418 | } else { |
| 2419 | if (pci_enable_device(pdev)) |
| 2420 | goto probe_out; |
| 2421 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2422 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2423 | /* This may fail but that's ok */ |
| 2424 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2425 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2426 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2427 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2428 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2429 | "Unable to allocate memory for ha.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2430 | goto probe_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2431 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2432 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2433 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2434 | ha->pdev = pdev; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2435 | ha->tgt.enable_class_2 = ql2xenableclass2; |
Quinn Tran | 33e7997 | 2014-09-25 06:14:55 -0400 | [diff] [blame] | 2436 | INIT_LIST_HEAD(&ha->tgt.q_full_list); |
| 2437 | spin_lock_init(&ha->tgt.q_full_lock); |
Quinn Tran | 7560151 | 2015-12-17 14:57:04 -0500 | [diff] [blame] | 2438 | spin_lock_init(&ha->tgt.sess_lock); |
Quinn Tran | 2f424b9 | 2015-12-17 14:57:07 -0500 | [diff] [blame] | 2439 | spin_lock_init(&ha->tgt.atio_lock); |
| 2440 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2441 | |
| 2442 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2443 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2444 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2445 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2446 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f722 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2447 | mutex_init(&ha->selflogin_lock); |
Chad Dupuis | 7a8ab9c | 2014-02-26 04:14:56 -0500 | [diff] [blame] | 2448 | mutex_init(&ha->optrom_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2449 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2450 | /* Set ISP-type information. */ |
| 2451 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2452 | |
| 2453 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2454 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2455 | IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2456 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2457 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2458 | ha->prev_topology = 0; |
| 2459 | ha->init_cb_size = sizeof(init_cb_t); |
| 2460 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2461 | ha->optrom_size = OPTROM_SIZE_2300; |
| 2462 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2463 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2464 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2465 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2466 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2467 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2468 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2469 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2470 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2471 | ha->flash_conf_off = ~0; |
| 2472 | ha->flash_data_off = ~0; |
| 2473 | ha->nvram_conf_off = ~0; |
| 2474 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2475 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2476 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2477 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2478 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2479 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2480 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2481 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2482 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2483 | ha->flash_conf_off = ~0; |
| 2484 | ha->flash_data_off = ~0; |
| 2485 | ha->nvram_conf_off = ~0; |
| 2486 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2487 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2488 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2489 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2490 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2491 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2492 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2493 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2494 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2495 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2496 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2497 | ha->flash_conf_off = ~0; |
| 2498 | ha->flash_data_off = ~0; |
| 2499 | ha->nvram_conf_off = ~0; |
| 2500 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2501 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2502 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2503 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2504 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2505 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2506 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2507 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2508 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2509 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2510 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2511 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2512 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2513 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2514 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2515 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2516 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2517 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2518 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2519 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2520 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2521 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2522 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2523 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2524 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2525 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2526 | ha->gid_list_info_size = 8; |
| 2527 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2528 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2529 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2530 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2531 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2532 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2533 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2534 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2535 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2536 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2537 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2538 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 2539 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2540 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2541 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2542 | ha->gid_list_info_size = 8; |
| 2543 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2544 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2545 | ha->isp_ops = &qla81xx_isp_ops; |
| 2546 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2547 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2548 | ha->nvram_conf_off = ~0; |
| 2549 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2550 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2551 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2552 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2553 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2554 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2555 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2556 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2557 | ha->gid_list_info_size = 8; |
| 2558 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2559 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2560 | ha->isp_ops = &qla82xx_isp_ops; |
| 2561 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2562 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2563 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2564 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2565 | } else if (IS_QLA8044(ha)) { |
| 2566 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2567 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2568 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2569 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2570 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2571 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2572 | ha->gid_list_info_size = 8; |
| 2573 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2574 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2575 | ha->isp_ops = &qla8044_isp_ops; |
| 2576 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2577 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2578 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2579 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2580 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2581 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2582 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2583 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Saurav Kashyap | f2ea653 | 2014-09-25 06:14:54 -0400 | [diff] [blame] | 2584 | req_length = REQUEST_ENTRY_CNT_83XX; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2585 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Arun Easi | b8aa4bd | 2013-01-30 03:34:40 -0500 | [diff] [blame] | 2586 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2587 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2588 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2589 | ha->gid_list_info_size = 8; |
| 2590 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2591 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2592 | ha->isp_ops = &qla83xx_isp_ops; |
| 2593 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2594 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2595 | ha->nvram_conf_off = ~0; |
| 2596 | ha->nvram_data_off = ~0; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2597 | } else if (IS_QLAFX00(ha)) { |
| 2598 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_FX00; |
| 2599 | ha->mbx_count = MAILBOX_REGISTER_COUNT_FX00; |
| 2600 | ha->aen_mbx_count = AEN_MAILBOX_REGISTER_COUNT_FX00; |
| 2601 | req_length = REQUEST_ENTRY_CNT_FX00; |
| 2602 | rsp_length = RESPONSE_ENTRY_CNT_FX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2603 | ha->isp_ops = &qlafx00_isp_ops; |
| 2604 | ha->port_down_retry_count = 30; /* default value */ |
| 2605 | ha->mr.fw_hbt_cnt = QLAFX00_HEARTBEAT_INTERVAL; |
| 2606 | ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; |
Armen Baloyan | 71e5600 | 2013-08-27 01:37:38 -0400 | [diff] [blame] | 2607 | ha->mr.fw_critemp_timer_tick = QLAFX00_CRITEMP_INTERVAL; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2608 | ha->mr.fw_hbt_en = 1; |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 2609 | ha->mr.host_info_resend = false; |
| 2610 | ha->mr.hinfo_resend_timer_tick = QLAFX00_HINFO_RESEND_INTERVAL; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2611 | } else if (IS_QLA27XX(ha)) { |
| 2612 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
| 2613 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2614 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2615 | req_length = REQUEST_ENTRY_CNT_83XX; |
| 2616 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 2617 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2618 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2619 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2620 | ha->gid_list_info_size = 8; |
| 2621 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2622 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2623 | ha->isp_ops = &qla27xx_isp_ops; |
| 2624 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2625 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2626 | ha->nvram_conf_off = ~0; |
| 2627 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2628 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2629 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2630 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 2631 | "mbx_count=%d, req_length=%d, " |
| 2632 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2633 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 2634 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2635 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 2636 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2637 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2638 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 2639 | "isp_ops=%p, flash_conf_off=%d, " |
| 2640 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 2641 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 2642 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2643 | |
| 2644 | /* Configure PCI I/O space */ |
| 2645 | ret = ha->isp_ops->iospace_config(ha); |
| 2646 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2647 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2648 | |
| 2649 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 2650 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 2651 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 2652 | mutex_init(&ha->vport_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2653 | init_completion(&ha->mbx_cmd_comp); |
| 2654 | complete(&ha->mbx_cmd_comp); |
| 2655 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 2656 | init_completion(&ha->dcbx_comp); |
Chad Dupuis | f356bef | 2013-02-08 01:58:04 -0500 | [diff] [blame] | 2657 | init_completion(&ha->lb_portup_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2658 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2659 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2660 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 2661 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2662 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 2663 | "64 Bit addressing is %s.\n", |
| 2664 | ha->flags.enable_64bit_addressing ? "enable" : |
| 2665 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2666 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 2667 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2668 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 2669 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2670 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2671 | goto probe_hw_failed; |
| 2672 | } |
| 2673 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2674 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2675 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2676 | req->max_q_depth = ql2xmaxqdepth; |
| 2677 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2678 | |
| 2679 | base_vha = qla2x00_create_host(sht, ha); |
| 2680 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2681 | ret = -ENOMEM; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2682 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2683 | qla2x00_free_req_que(ha, req); |
| 2684 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2685 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2686 | } |
| 2687 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2688 | pci_set_drvdata(pdev, base_vha); |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 2689 | set_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2690 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2691 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2692 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2693 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2694 | base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2695 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2696 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 2697 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2698 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2699 | /* Setup fcport template structure. */ |
| 2700 | ha->mr.fcport.vha = base_vha; |
| 2701 | ha->mr.fcport.port_type = FCT_UNKNOWN; |
| 2702 | ha->mr.fcport.loop_id = FC_NO_LOOP_ID; |
| 2703 | qla2x00_set_fcport_state(&ha->mr.fcport, FCS_UNCONFIGURED); |
| 2704 | ha->mr.fcport.supported_classes = FC_COS_UNSPECIFIED; |
| 2705 | ha->mr.fcport.scan_state = 1; |
| 2706 | |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2707 | /* Set the SG table size based on ISP type */ |
| 2708 | if (!IS_FWI2_CAPABLE(ha)) { |
| 2709 | if (IS_QLA2100(ha)) |
| 2710 | host->sg_tablesize = 32; |
| 2711 | } else { |
| 2712 | if (!IS_QLA82XX(ha)) |
| 2713 | host->sg_tablesize = QLA_SG_ALL; |
| 2714 | } |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2715 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2716 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 2717 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2718 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2719 | host->max_cmd_len = 32; |
| 2720 | else |
| 2721 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 2722 | host->max_channel = MAX_BUSES - 1; |
Hannes Reinecke | 755f516 | 2014-06-03 10:58:54 +0200 | [diff] [blame] | 2723 | /* Older HBAs support only 16-bit LUNs */ |
| 2724 | if (!IS_QLAFX00(ha) && !IS_FWI2_CAPABLE(ha) && |
| 2725 | ql2xmaxlun > 0xffff) |
| 2726 | host->max_lun = 0xffff; |
| 2727 | else |
| 2728 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2729 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2730 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2731 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2732 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 2733 | "max_id=%d this_id=%d " |
| 2734 | "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] | 2735 | "max_lun=%llu transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2736 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 2737 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 2738 | host->transportt, sht->vendor_id); |
| 2739 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2740 | que_init: |
| 2741 | /* Alloc arrays of request and response ring ptrs */ |
| 2742 | if (!qla2x00_alloc_queues(ha, req, rsp)) { |
| 2743 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 2744 | "Failed to allocate memory for queue pointers..." |
| 2745 | "aborting.\n"); |
| 2746 | goto probe_init_failed; |
| 2747 | } |
| 2748 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2749 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2750 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2751 | /* Set up the irqs */ |
| 2752 | ret = qla2x00_request_irqs(ha, rsp); |
| 2753 | if (ret) |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2754 | goto probe_init_failed; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2755 | |
| 2756 | pci_save_state(pdev); |
| 2757 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2758 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2759 | rsp->req = req; |
| 2760 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2761 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2762 | if (IS_QLAFX00(ha)) { |
| 2763 | ha->rsp_q_map[0] = rsp; |
| 2764 | ha->req_q_map[0] = req; |
| 2765 | set_bit(0, ha->req_qid_map); |
| 2766 | set_bit(0, ha->rsp_qid_map); |
| 2767 | } |
| 2768 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2769 | /* FWI2-capable only. */ |
| 2770 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 2771 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 2772 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 2773 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2774 | if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2775 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 2776 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 2777 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 2778 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 2779 | } |
| 2780 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2781 | if (IS_QLAFX00(ha)) { |
| 2782 | req->req_q_in = &ha->iobase->ispfx00.req_q_in; |
| 2783 | req->req_q_out = &ha->iobase->ispfx00.req_q_out; |
| 2784 | rsp->rsp_q_in = &ha->iobase->ispfx00.rsp_q_in; |
| 2785 | rsp->rsp_q_out = &ha->iobase->ispfx00.rsp_q_out; |
| 2786 | } |
| 2787 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2788 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2789 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 2790 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 2791 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 2792 | } |
| 2793 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2794 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 2795 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2796 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2797 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 2798 | "req->req_q_in=%p req->req_q_out=%p " |
| 2799 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2800 | req->req_q_in, req->req_q_out, |
| 2801 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 2802 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 2803 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2804 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2805 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 2806 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2807 | 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] | 2808 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2809 | if (ha->isp_ops->initialize_adapter(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2810 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 2811 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 2812 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2813 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2814 | if (IS_QLA82XX(ha)) { |
| 2815 | qla82xx_idc_lock(ha); |
| 2816 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2817 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2818 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2819 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 2820 | "HW State: FAILED.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2821 | } else if (IS_QLA8044(ha)) { |
| 2822 | qla8044_idc_lock(ha); |
| 2823 | qla8044_wr_direct(base_vha, |
| 2824 | QLA8044_CRB_DEV_STATE_INDEX, |
| 2825 | QLA8XXX_DEV_FAILED); |
| 2826 | qla8044_idc_unlock(ha); |
| 2827 | ql_log(ql_log_fatal, base_vha, 0x0150, |
| 2828 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2829 | } |
| 2830 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2831 | ret = -ENODEV; |
| 2832 | goto probe_failed; |
| 2833 | } |
| 2834 | |
Chad Dupuis | 3b1bef6 | 2014-02-26 04:15:04 -0500 | [diff] [blame] | 2835 | if (IS_QLAFX00(ha)) |
| 2836 | host->can_queue = QLAFX00_MAX_CANQUEUE; |
| 2837 | else |
| 2838 | host->can_queue = req->num_outstanding_cmds - 10; |
| 2839 | |
| 2840 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 2841 | "can_queue=%d, req=%p, mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 2842 | host->can_queue, base_vha->req, |
| 2843 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
| 2844 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2845 | if (ha->mqenable) { |
| 2846 | if (qla25xx_setup_mode(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2847 | ql_log(ql_log_warn, base_vha, 0x00ec, |
| 2848 | "Failed to create queues, falling back to single queue mode.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2849 | goto que_init; |
| 2850 | } |
| 2851 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2852 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2853 | if (ha->flags.running_gold_fw) |
| 2854 | goto skip_dpc; |
| 2855 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2856 | /* |
| 2857 | * Startup the kernel thread for this host adapter |
| 2858 | */ |
| 2859 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2860 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2861 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2862 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 2863 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2864 | ret = PTR_ERR(ha->dpc_thread); |
| 2865 | goto probe_failed; |
| 2866 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2867 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 2868 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2869 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2870 | /* |
| 2871 | * If we're not coming up in initiator mode, we might sit for |
| 2872 | * a while without waking up the dpc thread, which leads to a |
| 2873 | * stuck process warning. So just kick the dpc once here and |
| 2874 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 2875 | */ |
| 2876 | qla2xxx_wake_dpc(base_vha); |
| 2877 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 2878 | INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); |
| 2879 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 2880 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 2881 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 2882 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 2883 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 2884 | |
| 2885 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 2886 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 2887 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 2888 | INIT_WORK(&ha->idc_state_handler, |
| 2889 | qla83xx_idc_state_handler_work); |
| 2890 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 2891 | qla83xx_nic_core_unrecoverable_work); |
| 2892 | } |
| 2893 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2894 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2895 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 2896 | base_vha->host->irq = ha->pdev->irq; |
| 2897 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2898 | /* Initialized the timer */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2899 | qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2900 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 2901 | "Started qla2x00_timer with " |
| 2902 | "interval=%d.\n", WATCH_INTERVAL); |
| 2903 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 2904 | "Detected hba at address=%p.\n", |
| 2905 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2906 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2907 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2908 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2909 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2910 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2911 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 2912 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2913 | if (ql2xenabledif == 1) |
| 2914 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2915 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2916 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2917 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2918 | | SHOST_DIF_TYPE3_PROTECTION |
| 2919 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2920 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2921 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2922 | |
| 2923 | guard = SHOST_DIX_GUARD_CRC; |
| 2924 | |
| 2925 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 2926 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 2927 | guard |= SHOST_DIX_GUARD_IP; |
| 2928 | |
| 2929 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2930 | } else |
| 2931 | base_vha->flags.difdix_supported = 0; |
| 2932 | } |
| 2933 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2934 | ha->isp_ops->enable_intrs(ha); |
| 2935 | |
Armen Baloyan | 1fe19ee | 2013-08-27 01:37:41 -0400 | [diff] [blame] | 2936 | if (IS_QLAFX00(ha)) { |
| 2937 | ret = qlafx00_fx_disc(base_vha, |
| 2938 | &base_vha->hw->mr.fcport, FXDISC_GET_CONFIG_INFO); |
| 2939 | host->sg_tablesize = (ha->mr.extended_io_enabled) ? |
| 2940 | QLA_SG_ALL : 128; |
| 2941 | } |
| 2942 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2943 | ret = scsi_add_host(host, &pdev->dev); |
| 2944 | if (ret) |
| 2945 | goto probe_failed; |
| 2946 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 2947 | base_vha->flags.init_done = 1; |
| 2948 | base_vha->flags.online = 1; |
Saurav Kashyap | edaa5c7 | 2014-04-11 16:54:14 -0400 | [diff] [blame] | 2949 | ha->prev_minidump_failed = 0; |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 2950 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2951 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 2952 | "Init done and hba is online.\n"); |
| 2953 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2954 | if (qla_ini_mode_enabled(base_vha)) |
| 2955 | scsi_scan_host(host); |
| 2956 | else |
| 2957 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 2958 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2959 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2960 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2961 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2962 | if (IS_QLAFX00(ha)) { |
| 2963 | ret = qlafx00_fx_disc(base_vha, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2964 | &base_vha->hw->mr.fcport, FXDISC_GET_PORT_INFO); |
| 2965 | |
| 2966 | /* Register system information */ |
| 2967 | ret = qlafx00_fx_disc(base_vha, |
| 2968 | &base_vha->hw->mr.fcport, FXDISC_REG_HOST_INFO); |
| 2969 | } |
| 2970 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2971 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2972 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2973 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2974 | |
Armen Baloyan | 03eb912 | 2013-10-30 03:38:22 -0400 | [diff] [blame] | 2975 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 2976 | "QLogic %s - %s.\n", ha->model_number, ha->model_desc); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2977 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 2978 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 2979 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 2980 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 2981 | base_vha->host_no, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2982 | 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] | 2983 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2984 | qlt_add_target(ha, base_vha); |
| 2985 | |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 2986 | clear_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 2987 | |
| 2988 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 2989 | return -ENODEV; |
| 2990 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2991 | return 0; |
| 2992 | |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2993 | probe_init_failed: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2994 | qla2x00_free_req_que(ha, req); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2995 | ha->req_q_map[0] = NULL; |
| 2996 | clear_bit(0, ha->req_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2997 | qla2x00_free_rsp_que(ha, rsp); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2998 | ha->rsp_q_map[0] = NULL; |
| 2999 | clear_bit(0, ha->rsp_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3000 | ha->max_req_queues = ha->max_rsp_queues = 0; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 3001 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3002 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3003 | if (base_vha->timer_active) |
| 3004 | qla2x00_stop_timer(base_vha); |
| 3005 | base_vha->flags.online = 0; |
| 3006 | if (ha->dpc_thread) { |
| 3007 | struct task_struct *t = ha->dpc_thread; |
| 3008 | |
| 3009 | ha->dpc_thread = NULL; |
| 3010 | kthread_stop(t); |
| 3011 | } |
| 3012 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3013 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3014 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3015 | scsi_host_put(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3016 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3017 | probe_hw_failed: |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 3018 | qla2x00_clear_drv_active(ha); |
| 3019 | |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3020 | iospace_config_failed: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3021 | if (IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3022 | if (!ha->nx_pcibase) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3023 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3024 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3025 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3026 | } else { |
| 3027 | if (ha->iobase) |
| 3028 | iounmap(ha->iobase); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3029 | if (ha->cregbase) |
| 3030 | iounmap(ha->cregbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3031 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3032 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3033 | kfree(ha); |
| 3034 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3035 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3036 | probe_out: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3037 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3038 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3039 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3040 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 3041 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3042 | qla2x00_shutdown(struct pci_dev *pdev) |
| 3043 | { |
| 3044 | scsi_qla_host_t *vha; |
| 3045 | struct qla_hw_data *ha; |
| 3046 | |
Masanari Iida | 552f3f9 | 2013-02-08 01:57:44 -0500 | [diff] [blame] | 3047 | if (!atomic_read(&pdev->enable_cnt)) |
| 3048 | return; |
| 3049 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3050 | vha = pci_get_drvdata(pdev); |
| 3051 | ha = vha->hw; |
| 3052 | |
Armen Baloyan | 4247934 | 2013-08-27 01:37:37 -0400 | [diff] [blame] | 3053 | /* Notify ISPFX00 firmware */ |
| 3054 | if (IS_QLAFX00(ha)) |
| 3055 | qlafx00_driver_shutdown(vha, 20); |
| 3056 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3057 | /* Turn-off FCE trace */ |
| 3058 | if (ha->flags.fce_enabled) { |
| 3059 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 3060 | ha->flags.fce_enabled = 0; |
| 3061 | } |
| 3062 | |
| 3063 | /* Turn-off EFT trace */ |
| 3064 | if (ha->eft) |
| 3065 | qla2x00_disable_eft_trace(vha); |
| 3066 | |
| 3067 | /* Stop currently executing firmware. */ |
| 3068 | qla2x00_try_to_stop_firmware(vha); |
| 3069 | |
| 3070 | /* Turn adapter off line */ |
| 3071 | vha->flags.online = 0; |
| 3072 | |
| 3073 | /* turn-off interrupts on the card */ |
| 3074 | if (ha->interrupts_on) { |
| 3075 | vha->flags.init_done = 0; |
| 3076 | ha->isp_ops->disable_intrs(ha); |
| 3077 | } |
| 3078 | |
| 3079 | qla2x00_free_irqs(vha); |
| 3080 | |
| 3081 | qla2x00_free_fw_dump(ha); |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3082 | |
| 3083 | pci_disable_pcie_error_reporting(pdev); |
| 3084 | pci_disable_device(pdev); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3085 | } |
| 3086 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3087 | /* Deletes all the virtual ports for a given ha */ |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3088 | static void |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3089 | 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] | 3090 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3091 | scsi_qla_host_t *vha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3092 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3093 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3094 | mutex_lock(&ha->vport_lock); |
| 3095 | while (ha->cur_vport_count) { |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3096 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3097 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3098 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 3099 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 3100 | 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] | 3101 | scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3102 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3103 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3104 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3105 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3106 | fc_vport_terminate(vha->fc_vport); |
| 3107 | scsi_host_put(vha->host); |
| 3108 | |
| 3109 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3110 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3111 | mutex_unlock(&ha->vport_lock); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3112 | } |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3113 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3114 | /* Stops all deferred work threads */ |
| 3115 | static void |
| 3116 | qla2x00_destroy_deferred_work(struct qla_hw_data *ha) |
| 3117 | { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3118 | /* Flush the work queue and remove it */ |
| 3119 | if (ha->wq) { |
| 3120 | flush_workqueue(ha->wq); |
| 3121 | destroy_workqueue(ha->wq); |
| 3122 | ha->wq = NULL; |
| 3123 | } |
| 3124 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3125 | /* Cancel all work and destroy DPC workqueues */ |
| 3126 | if (ha->dpc_lp_wq) { |
| 3127 | cancel_work_sync(&ha->idc_aen); |
| 3128 | destroy_workqueue(ha->dpc_lp_wq); |
| 3129 | ha->dpc_lp_wq = NULL; |
| 3130 | } |
| 3131 | |
| 3132 | if (ha->dpc_hp_wq) { |
| 3133 | cancel_work_sync(&ha->nic_core_reset); |
| 3134 | cancel_work_sync(&ha->idc_state_handler); |
| 3135 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 3136 | destroy_workqueue(ha->dpc_hp_wq); |
| 3137 | ha->dpc_hp_wq = NULL; |
| 3138 | } |
| 3139 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3140 | /* Kill the kernel thread for this host */ |
| 3141 | if (ha->dpc_thread) { |
| 3142 | struct task_struct *t = ha->dpc_thread; |
| 3143 | |
| 3144 | /* |
| 3145 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 3146 | * so we need to zero it out. |
| 3147 | */ |
| 3148 | ha->dpc_thread = NULL; |
| 3149 | kthread_stop(t); |
| 3150 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3151 | } |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3152 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3153 | static void |
| 3154 | qla2x00_unmap_iobases(struct qla_hw_data *ha) |
| 3155 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3156 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 3157 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3158 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3159 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3160 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3161 | } else { |
| 3162 | if (ha->iobase) |
| 3163 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3164 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3165 | if (ha->cregbase) |
| 3166 | iounmap(ha->cregbase); |
| 3167 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3168 | if (ha->mqiobase) |
| 3169 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3170 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3171 | if ((IS_QLA83XX(ha) || IS_QLA27XX(ha)) && ha->msixbase) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3172 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3173 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3174 | } |
| 3175 | |
| 3176 | static void |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3177 | qla2x00_clear_drv_active(struct qla_hw_data *ha) |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3178 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3179 | if (IS_QLA8044(ha)) { |
| 3180 | qla8044_idc_lock(ha); |
Saurav Kashyap | c41afc9 | 2013-11-07 02:54:56 -0500 | [diff] [blame] | 3181 | qla8044_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3182 | qla8044_idc_unlock(ha); |
| 3183 | } else if (IS_QLA82XX(ha)) { |
| 3184 | qla82xx_idc_lock(ha); |
| 3185 | qla82xx_clear_drv_active(ha); |
| 3186 | qla82xx_idc_unlock(ha); |
| 3187 | } |
| 3188 | } |
| 3189 | |
| 3190 | static void |
| 3191 | qla2x00_remove_one(struct pci_dev *pdev) |
| 3192 | { |
| 3193 | scsi_qla_host_t *base_vha; |
| 3194 | struct qla_hw_data *ha; |
| 3195 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3196 | base_vha = pci_get_drvdata(pdev); |
| 3197 | ha = base_vha->hw; |
| 3198 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3199 | /* Indicate device removal to prevent future board_disable and wait |
| 3200 | * until any pending board_disable has completed. */ |
| 3201 | set_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags); |
| 3202 | cancel_work_sync(&ha->board_disable); |
| 3203 | |
| 3204 | /* |
| 3205 | * If the PCI device is disabled then there was a PCI-disconnect and |
| 3206 | * qla2x00_disable_board_on_pci_error has taken care of most of the |
| 3207 | * resources. |
| 3208 | */ |
| 3209 | if (!atomic_read(&pdev->enable_cnt)) { |
| 3210 | scsi_host_put(base_vha->host); |
| 3211 | kfree(ha); |
| 3212 | pci_set_drvdata(pdev, NULL); |
| 3213 | return; |
| 3214 | } |
| 3215 | |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 3216 | qla2x00_wait_for_hba_ready(base_vha); |
| 3217 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 3218 | /* if UNLOAD flag is already set, then continue unload, |
| 3219 | * where it was set first. |
| 3220 | */ |
| 3221 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3222 | return; |
| 3223 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3224 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 3225 | |
| 3226 | if (IS_QLAFX00(ha)) |
| 3227 | qlafx00_driver_shutdown(base_vha, 20); |
| 3228 | |
| 3229 | qla2x00_delete_all_vps(ha, base_vha); |
| 3230 | |
| 3231 | if (IS_QLA8031(ha)) { |
| 3232 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 3233 | "Clearing fcoe driver presence.\n"); |
| 3234 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 3235 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 3236 | "Error while clearing DRV-Presence.\n"); |
| 3237 | } |
| 3238 | |
| 3239 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 3240 | |
| 3241 | qla2x00_dfs_remove(base_vha); |
| 3242 | |
| 3243 | qla84xx_put_chip(base_vha); |
| 3244 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 3245 | /* Laser should be disabled only for ISP2031 */ |
| 3246 | if (IS_QLA2031(ha)) |
| 3247 | qla83xx_disable_laser(base_vha); |
| 3248 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3249 | /* Disable timer */ |
| 3250 | if (base_vha->timer_active) |
| 3251 | qla2x00_stop_timer(base_vha); |
| 3252 | |
| 3253 | base_vha->flags.online = 0; |
| 3254 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3255 | /* free DMA memory */ |
| 3256 | if (ha->exlogin_buf) |
| 3257 | qla2x00_free_exlogin_buffer(ha); |
| 3258 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3259 | /* free DMA memory */ |
| 3260 | if (ha->exchoffld_buf) |
| 3261 | qla2x00_free_exchoffld_buffer(ha); |
| 3262 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3263 | qla2x00_destroy_deferred_work(ha); |
| 3264 | |
| 3265 | qlt_remove_target(ha, base_vha); |
| 3266 | |
| 3267 | qla2x00_free_sysfs_attr(base_vha, true); |
| 3268 | |
| 3269 | fc_remove_host(base_vha->host); |
| 3270 | |
| 3271 | scsi_remove_host(base_vha->host); |
| 3272 | |
| 3273 | qla2x00_free_device(base_vha); |
| 3274 | |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3275 | qla2x00_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3276 | |
Arun Easi | d2749ff | 2014-09-25 05:16:51 -0400 | [diff] [blame] | 3277 | scsi_host_put(base_vha->host); |
| 3278 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3279 | qla2x00_unmap_iobases(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3280 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3281 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3282 | kfree(ha); |
| 3283 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3284 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3285 | pci_disable_pcie_error_reporting(pdev); |
| 3286 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 3287 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3288 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3289 | |
| 3290 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3291 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3292 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3293 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3294 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3295 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 3296 | |
| 3297 | /* Disable timer */ |
| 3298 | if (vha->timer_active) |
| 3299 | qla2x00_stop_timer(vha); |
| 3300 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3301 | qla25xx_delete_queues(vha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3302 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3303 | if (ha->flags.fce_enabled) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3304 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3305 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3306 | if (ha->eft) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3307 | qla2x00_disable_eft_trace(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3308 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3309 | /* Stop currently executing firmware. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3310 | qla2x00_try_to_stop_firmware(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3311 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3312 | vha->flags.online = 0; |
| 3313 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3314 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3315 | if (ha->interrupts_on) { |
| 3316 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 3317 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3318 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3319 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3320 | qla2x00_free_irqs(vha); |
| 3321 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3322 | qla2x00_free_fcports(vha); |
| 3323 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3324 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3325 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 3326 | qla82xx_md_free(vha); |
| 3327 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3328 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3329 | } |
| 3330 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3331 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 3332 | { |
| 3333 | fc_port_t *fcport, *tfcport; |
| 3334 | |
| 3335 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 3336 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3337 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3338 | kfree(fcport); |
| 3339 | fcport = NULL; |
| 3340 | } |
| 3341 | } |
| 3342 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3343 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3344 | 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] | 3345 | int defer) |
| 3346 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3347 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3348 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3349 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3350 | |
| 3351 | if (!fcport->rport) |
| 3352 | return; |
| 3353 | |
| 3354 | rport = fcport->rport; |
| 3355 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3356 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3357 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3358 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3359 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3360 | qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3361 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 3362 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3363 | } else { |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3364 | int now; |
Alexei Potashnik | d20ed91 | 2015-07-14 16:00:47 -0400 | [diff] [blame] | 3365 | if (rport) |
| 3366 | fc_remote_port_delete(rport); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3367 | qlt_do_generation_tick(vha, &now); |
| 3368 | qlt_fc_port_deleted(vha, fcport, now); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3369 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3370 | } |
| 3371 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3372 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3373 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 3374 | * |
| 3375 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 3376 | * |
| 3377 | * Return: None. |
| 3378 | * |
| 3379 | * Context: |
| 3380 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3381 | 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] | 3382 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3383 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3384 | if (IS_QLAFX00(vha->hw)) { |
| 3385 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
| 3386 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3387 | return; |
| 3388 | } |
| 3389 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3390 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3391 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3392 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3393 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3394 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3395 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3396 | * We may need to retry the login, so don't change the state of the |
| 3397 | * port but do the retries. |
| 3398 | */ |
| 3399 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3400 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3401 | |
| 3402 | if (!do_login) |
| 3403 | return; |
| 3404 | |
Arun Easi | a1d0285 | 2015-08-04 13:38:02 -0400 | [diff] [blame] | 3405 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 3406 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3407 | if (fcport->login_retry == 0) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3408 | fcport->login_retry = vha->hw->login_retry_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3409 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3410 | ql_dbg(ql_dbg_disc, vha, 0x2067, |
Oleksandr Khoshaba | 7b83355 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 3411 | "Port login retry %8phN, id = 0x%04x retry cnt=%d.\n", |
| 3412 | fcport->port_name, fcport->loop_id, fcport->login_retry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3413 | } |
| 3414 | } |
| 3415 | |
| 3416 | /* |
| 3417 | * qla2x00_mark_all_devices_lost |
| 3418 | * Updates fcport state when device goes offline. |
| 3419 | * |
| 3420 | * Input: |
| 3421 | * ha = adapter block pointer. |
| 3422 | * fcport = port structure pointer. |
| 3423 | * |
| 3424 | * Return: |
| 3425 | * None. |
| 3426 | * |
| 3427 | * Context: |
| 3428 | */ |
| 3429 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3430 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3431 | { |
| 3432 | fc_port_t *fcport; |
| 3433 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3434 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3435 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3436 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3437 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3438 | /* |
| 3439 | * No point in marking the device as lost, if the device is |
| 3440 | * already DEAD. |
| 3441 | */ |
| 3442 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3443 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3444 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3445 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3446 | if (defer) |
| 3447 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3448 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3449 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3450 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3451 | } |
| 3452 | } |
| 3453 | |
| 3454 | /* |
| 3455 | * qla2x00_mem_alloc |
| 3456 | * Allocates adapter memory. |
| 3457 | * |
| 3458 | * Returns: |
| 3459 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3460 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3461 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3462 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3463 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3464 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3465 | { |
| 3466 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3467 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3468 | 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] | 3469 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3470 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3471 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3472 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3473 | if (qlt_mem_alloc(ha) < 0) |
| 3474 | goto fail_free_init_cb; |
| 3475 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3476 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3477 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3478 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3479 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3480 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3481 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3482 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3483 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3484 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3485 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3486 | /* Allocate cache for CT6 Ctx. */ |
| 3487 | if (!ctx_cachep) { |
| 3488 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3489 | sizeof(struct ct6_dsd), 0, |
| 3490 | SLAB_HWCACHE_ALIGN, NULL); |
| 3491 | if (!ctx_cachep) |
Quinn Tran | beecb1e | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3492 | goto fail_free_srb_mempool; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3493 | } |
| 3494 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3495 | ctx_cachep); |
| 3496 | if (!ha->ctx_mempool) |
| 3497 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3498 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3499 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3500 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3501 | } |
| 3502 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3503 | /* Get memory for cached NVRAM */ |
| 3504 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3505 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3506 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3507 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3508 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3509 | ha->pdev->device); |
| 3510 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3511 | DMA_POOL_SIZE, 8, 0); |
| 3512 | if (!ha->s_dma_pool) |
| 3513 | goto fail_free_nvram; |
| 3514 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3515 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3516 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3517 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3518 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3519 | if (IS_P3P_TYPE(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3520 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3521 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3522 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3523 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3524 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3525 | goto fail_s_dma_pool; |
| 3526 | } |
| 3527 | |
| 3528 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3529 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3530 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3531 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3532 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3533 | goto fail_dl_dma_pool; |
| 3534 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3535 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3536 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3537 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3538 | } |
| 3539 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3540 | /* Allocate memory for SNS commands */ |
| 3541 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3542 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3543 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3544 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3545 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3546 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3547 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 3548 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3549 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3550 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3551 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3552 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3553 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3554 | goto fail_dma_pool; |
| 3555 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3556 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3557 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3558 | if (!ha->ct_sns) |
| 3559 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3560 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 3561 | "ms_iocb=%p ct_sns=%p.\n", |
| 3562 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3563 | } |
| 3564 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3565 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3566 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 3567 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3568 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 3569 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3570 | goto fail_req; |
| 3571 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3572 | (*req)->length = req_len; |
| 3573 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3574 | ((*req)->length + 1) * sizeof(request_t), |
| 3575 | &(*req)->dma, GFP_KERNEL); |
| 3576 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3577 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 3578 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3579 | goto fail_req_ring; |
| 3580 | } |
| 3581 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3582 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 3583 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3584 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 3585 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3586 | goto fail_rsp; |
| 3587 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3588 | (*rsp)->hw = ha; |
| 3589 | (*rsp)->length = rsp_len; |
| 3590 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3591 | ((*rsp)->length + 1) * sizeof(response_t), |
| 3592 | &(*rsp)->dma, GFP_KERNEL); |
| 3593 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3594 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 3595 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3596 | goto fail_rsp_ring; |
| 3597 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3598 | (*req)->rsp = *rsp; |
| 3599 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3600 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 3601 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 3602 | "rsp->length=%d rsp->ring=%p.\n", |
| 3603 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 3604 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3605 | /* Allocate memory for NVRAM data for vports */ |
| 3606 | if (ha->nvram_npiv_size) { |
| 3607 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3608 | ha->nvram_npiv_size, GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3609 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3610 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 3611 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3612 | goto fail_npiv_info; |
| 3613 | } |
| 3614 | } else |
| 3615 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3616 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3617 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3618 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3619 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3620 | &ha->ex_init_cb_dma); |
| 3621 | if (!ha->ex_init_cb) |
| 3622 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3623 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 3624 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3625 | } |
| 3626 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3627 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 3628 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3629 | /* Get consistent memory allocated for Async Port-Database. */ |
| 3630 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3631 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3632 | &ha->async_pd_dma); |
| 3633 | if (!ha->async_pd) |
| 3634 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3635 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 3636 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3637 | } |
| 3638 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3639 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3640 | |
| 3641 | /* Allocate memory for our loop_id bitmap */ |
| 3642 | ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), |
| 3643 | GFP_KERNEL); |
| 3644 | if (!ha->loop_id_map) |
Quinn Tran | beecb1e | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3645 | goto fail_loop_id_map; |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3646 | else { |
| 3647 | qla2x00_set_reserved_loop_ids(ha); |
| 3648 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3649 | "loop_id_map=%p.\n", ha->loop_id_map); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3650 | } |
| 3651 | |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3652 | return 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3653 | |
Quinn Tran | beecb1e | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3654 | fail_loop_id_map: |
| 3655 | 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] | 3656 | fail_async_pd: |
| 3657 | 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] | 3658 | fail_ex_init_cb: |
| 3659 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3660 | fail_npiv_info: |
| 3661 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 3662 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 3663 | (*rsp)->ring = NULL; |
| 3664 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3665 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3666 | kfree(*rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3667 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3668 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 3669 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 3670 | (*req)->ring = NULL; |
| 3671 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3672 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3673 | kfree(*req); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3674 | fail_req: |
| 3675 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 3676 | ha->ct_sns, ha->ct_sns_dma); |
| 3677 | ha->ct_sns = NULL; |
| 3678 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3679 | fail_free_ms_iocb: |
| 3680 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3681 | ha->ms_iocb = NULL; |
| 3682 | ha->ms_iocb_dma = 0; |
Quinn Tran | beecb1e | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3683 | |
| 3684 | if (ha->sns_cmd) |
| 3685 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
| 3686 | ha->sns_cmd, ha->sns_cmd_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3687 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3688 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3689 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3690 | ha->fcp_cmnd_dma_pool = NULL; |
| 3691 | } |
| 3692 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3693 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3694 | dma_pool_destroy(ha->dl_dma_pool); |
| 3695 | ha->dl_dma_pool = NULL; |
| 3696 | } |
| 3697 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3698 | dma_pool_destroy(ha->s_dma_pool); |
| 3699 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3700 | fail_free_nvram: |
| 3701 | kfree(ha->nvram); |
| 3702 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3703 | fail_free_ctx_mempool: |
Quinn Tran | beecb1e | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3704 | if (ha->ctx_mempool) |
| 3705 | mempool_destroy(ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3706 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3707 | fail_free_srb_mempool: |
Quinn Tran | beecb1e | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3708 | if (ha->srb_mempool) |
| 3709 | mempool_destroy(ha->srb_mempool); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3710 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3711 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3712 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3713 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3714 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3715 | ha->gid_list = NULL; |
| 3716 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3717 | fail_free_tgt_mem: |
| 3718 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3719 | fail_free_init_cb: |
| 3720 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 3721 | ha->init_cb_dma); |
| 3722 | ha->init_cb = NULL; |
| 3723 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3724 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3725 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 3726 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3727 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3728 | } |
| 3729 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3730 | int |
| 3731 | qla2x00_set_exlogins_buffer(scsi_qla_host_t *vha) |
| 3732 | { |
| 3733 | int rval; |
| 3734 | uint16_t size, max_cnt, temp; |
| 3735 | struct qla_hw_data *ha = vha->hw; |
| 3736 | |
| 3737 | /* Return if we don't need to alloacate any extended logins */ |
| 3738 | if (!ql2xexlogins) |
| 3739 | return QLA_SUCCESS; |
| 3740 | |
| 3741 | ql_log(ql_log_info, vha, 0xd021, "EXLOGIN count: %d.\n", ql2xexlogins); |
| 3742 | max_cnt = 0; |
| 3743 | rval = qla_get_exlogin_status(vha, &size, &max_cnt); |
| 3744 | if (rval != QLA_SUCCESS) { |
| 3745 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd029, |
| 3746 | "Failed to get exlogin status.\n"); |
| 3747 | return rval; |
| 3748 | } |
| 3749 | |
| 3750 | temp = (ql2xexlogins > max_cnt) ? max_cnt : ql2xexlogins; |
| 3751 | ha->exlogin_size = (size * temp); |
| 3752 | ql_log(ql_log_info, vha, 0xd024, |
| 3753 | "EXLOGIN: max_logins=%d, portdb=0x%x, total=%d.\n", |
| 3754 | max_cnt, size, temp); |
| 3755 | |
| 3756 | ql_log(ql_log_info, vha, 0xd025, "EXLOGIN: requested size=0x%x\n", |
| 3757 | ha->exlogin_size); |
| 3758 | |
| 3759 | /* Get consistent memory for extended logins */ |
| 3760 | ha->exlogin_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 3761 | ha->exlogin_size, &ha->exlogin_buf_dma, GFP_KERNEL); |
| 3762 | if (!ha->exlogin_buf) { |
| 3763 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd02a, |
| 3764 | "Failed to allocate memory for exlogin_buf_dma.\n"); |
| 3765 | return -ENOMEM; |
| 3766 | } |
| 3767 | |
| 3768 | /* Now configure the dma buffer */ |
| 3769 | rval = qla_set_exlogin_mem_cfg(vha, ha->exlogin_buf_dma); |
| 3770 | if (rval) { |
| 3771 | ql_log(ql_log_fatal, vha, 0x00cf, |
| 3772 | "Setup extended login buffer ****FAILED****.\n"); |
| 3773 | qla2x00_free_exlogin_buffer(ha); |
| 3774 | } |
| 3775 | |
| 3776 | return rval; |
| 3777 | } |
| 3778 | |
| 3779 | /* |
| 3780 | * qla2x00_free_exlogin_buffer |
| 3781 | * |
| 3782 | * Input: |
| 3783 | * ha = adapter block pointer |
| 3784 | */ |
| 3785 | void |
| 3786 | qla2x00_free_exlogin_buffer(struct qla_hw_data *ha) |
| 3787 | { |
| 3788 | if (ha->exlogin_buf) { |
| 3789 | dma_free_coherent(&ha->pdev->dev, ha->exlogin_size, |
| 3790 | ha->exlogin_buf, ha->exlogin_buf_dma); |
| 3791 | ha->exlogin_buf = NULL; |
| 3792 | ha->exlogin_size = 0; |
| 3793 | } |
| 3794 | } |
| 3795 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3796 | int |
| 3797 | qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) |
| 3798 | { |
| 3799 | int rval; |
| 3800 | uint16_t size, max_cnt, temp; |
| 3801 | struct qla_hw_data *ha = vha->hw; |
| 3802 | |
| 3803 | /* Return if we don't need to alloacate any extended logins */ |
| 3804 | if (!ql2xexchoffld) |
| 3805 | return QLA_SUCCESS; |
| 3806 | |
| 3807 | ql_log(ql_log_info, vha, 0xd014, |
| 3808 | "Exchange offload count: %d.\n", ql2xexlogins); |
| 3809 | |
| 3810 | max_cnt = 0; |
| 3811 | rval = qla_get_exchoffld_status(vha, &size, &max_cnt); |
| 3812 | if (rval != QLA_SUCCESS) { |
| 3813 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd012, |
| 3814 | "Failed to get exlogin status.\n"); |
| 3815 | return rval; |
| 3816 | } |
| 3817 | |
| 3818 | temp = (ql2xexchoffld > max_cnt) ? max_cnt : ql2xexchoffld; |
| 3819 | ha->exchoffld_size = (size * temp); |
| 3820 | ql_log(ql_log_info, vha, 0xd016, |
| 3821 | "Exchange offload: max_count=%d, buffers=0x%x, total=%d.\n", |
| 3822 | max_cnt, size, temp); |
| 3823 | |
| 3824 | ql_log(ql_log_info, vha, 0xd017, |
| 3825 | "Exchange Buffers requested size = 0x%x\n", ha->exchoffld_size); |
| 3826 | |
| 3827 | /* Get consistent memory for extended logins */ |
| 3828 | ha->exchoffld_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 3829 | ha->exchoffld_size, &ha->exchoffld_buf_dma, GFP_KERNEL); |
| 3830 | if (!ha->exchoffld_buf) { |
| 3831 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
| 3832 | "Failed to allocate memory for exchoffld_buf_dma.\n"); |
| 3833 | return -ENOMEM; |
| 3834 | } |
| 3835 | |
| 3836 | /* Now configure the dma buffer */ |
| 3837 | rval = qla_set_exchoffld_mem_cfg(vha, ha->exchoffld_buf_dma); |
| 3838 | if (rval) { |
| 3839 | ql_log(ql_log_fatal, vha, 0xd02e, |
| 3840 | "Setup exchange offload buffer ****FAILED****.\n"); |
| 3841 | qla2x00_free_exchoffld_buffer(ha); |
| 3842 | } |
| 3843 | |
| 3844 | return rval; |
| 3845 | } |
| 3846 | |
| 3847 | /* |
| 3848 | * qla2x00_free_exchoffld_buffer |
| 3849 | * |
| 3850 | * Input: |
| 3851 | * ha = adapter block pointer |
| 3852 | */ |
| 3853 | void |
| 3854 | qla2x00_free_exchoffld_buffer(struct qla_hw_data *ha) |
| 3855 | { |
| 3856 | if (ha->exchoffld_buf) { |
| 3857 | dma_free_coherent(&ha->pdev->dev, ha->exchoffld_size, |
| 3858 | ha->exchoffld_buf, ha->exchoffld_buf_dma); |
| 3859 | ha->exchoffld_buf = NULL; |
| 3860 | ha->exchoffld_size = 0; |
| 3861 | } |
| 3862 | } |
| 3863 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3864 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3865 | * qla2x00_free_fw_dump |
| 3866 | * Frees fw dump stuff. |
| 3867 | * |
| 3868 | * Input: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3869 | * ha = adapter block pointer |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3870 | */ |
| 3871 | static void |
| 3872 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 3873 | { |
| 3874 | if (ha->fce) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3875 | dma_free_coherent(&ha->pdev->dev, |
| 3876 | FCE_SIZE, ha->fce, ha->fce_dma); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3877 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3878 | if (ha->eft) |
| 3879 | dma_free_coherent(&ha->pdev->dev, |
| 3880 | EFT_SIZE, ha->eft, ha->eft_dma); |
| 3881 | |
| 3882 | if (ha->fw_dump) |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3883 | vfree(ha->fw_dump); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3884 | if (ha->fw_dump_template) |
| 3885 | vfree(ha->fw_dump_template); |
| 3886 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3887 | ha->fce = NULL; |
| 3888 | ha->fce_dma = 0; |
| 3889 | ha->eft = NULL; |
| 3890 | ha->eft_dma = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3891 | ha->fw_dumped = 0; |
Hiral Patel | 61f098d | 2014-04-11 16:54:21 -0400 | [diff] [blame] | 3892 | ha->fw_dump_cap_flags = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3893 | ha->fw_dump_reading = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3894 | ha->fw_dump = NULL; |
| 3895 | ha->fw_dump_len = 0; |
| 3896 | ha->fw_dump_template = NULL; |
| 3897 | ha->fw_dump_template_len = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3898 | } |
| 3899 | |
| 3900 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3901 | * qla2x00_mem_free |
| 3902 | * Frees all adapter allocated memory. |
| 3903 | * |
| 3904 | * Input: |
| 3905 | * ha = adapter block pointer. |
| 3906 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 3907 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3908 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3909 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3910 | qla2x00_free_fw_dump(ha); |
| 3911 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3912 | if (ha->mctp_dump) |
| 3913 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 3914 | ha->mctp_dump_dma); |
| 3915 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3916 | if (ha->srb_mempool) |
| 3917 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3918 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 3919 | if (ha->dcbx_tlv) |
| 3920 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 3921 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 3922 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 3923 | if (ha->xgmac_data) |
| 3924 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 3925 | ha->xgmac_data, ha->xgmac_data_dma); |
| 3926 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3927 | if (ha->sns_cmd) |
| 3928 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3929 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3930 | |
| 3931 | if (ha->ct_sns) |
| 3932 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3933 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3934 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3935 | if (ha->sfp_data) |
| 3936 | dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); |
| 3937 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3938 | if (ha->ms_iocb) |
| 3939 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3940 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3941 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3942 | dma_pool_free(ha->s_dma_pool, |
| 3943 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3944 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3945 | if (ha->async_pd) |
| 3946 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 3947 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3948 | if (ha->s_dma_pool) |
| 3949 | dma_pool_destroy(ha->s_dma_pool); |
| 3950 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3951 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3952 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3953 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3954 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3955 | if (IS_QLA82XX(ha)) { |
| 3956 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 3957 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 3958 | |
| 3959 | /* clean up allocated prev pool */ |
| 3960 | list_for_each_entry_safe(dsd_ptr, |
| 3961 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 3962 | dma_pool_free(ha->dl_dma_pool, |
| 3963 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 3964 | list_del(&dsd_ptr->list); |
| 3965 | kfree(dsd_ptr); |
| 3966 | } |
| 3967 | } |
| 3968 | } |
| 3969 | |
| 3970 | if (ha->dl_dma_pool) |
| 3971 | dma_pool_destroy(ha->dl_dma_pool); |
| 3972 | |
| 3973 | if (ha->fcp_cmnd_dma_pool) |
| 3974 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3975 | |
| 3976 | if (ha->ctx_mempool) |
| 3977 | mempool_destroy(ha->ctx_mempool); |
| 3978 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3979 | qlt_mem_free(ha); |
| 3980 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3981 | if (ha->init_cb) |
| 3982 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3983 | ha->init_cb, ha->init_cb_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3984 | vfree(ha->optrom_buffer); |
| 3985 | kfree(ha->nvram); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3986 | kfree(ha->npiv_info); |
Andrew Vasquez | 7a67735 | 2012-02-09 11:15:56 -0800 | [diff] [blame] | 3987 | kfree(ha->swl); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3988 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3989 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3990 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3991 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3992 | ha->sns_cmd = NULL; |
| 3993 | ha->sns_cmd_dma = 0; |
| 3994 | ha->ct_sns = NULL; |
| 3995 | ha->ct_sns_dma = 0; |
| 3996 | ha->ms_iocb = NULL; |
| 3997 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3998 | ha->init_cb = NULL; |
| 3999 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4000 | ha->ex_init_cb = NULL; |
| 4001 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4002 | ha->async_pd = NULL; |
| 4003 | ha->async_pd_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4004 | |
| 4005 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4006 | ha->dl_dma_pool = NULL; |
| 4007 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4008 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4009 | ha->gid_list = NULL; |
| 4010 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4011 | |
| 4012 | ha->tgt.atio_ring = NULL; |
| 4013 | ha->tgt.atio_dma = 0; |
| 4014 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4015 | } |
| 4016 | |
| 4017 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 4018 | struct qla_hw_data *ha) |
| 4019 | { |
| 4020 | struct Scsi_Host *host; |
| 4021 | struct scsi_qla_host *vha = NULL; |
| 4022 | |
| 4023 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
| 4024 | if (host == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4025 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 4026 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4027 | goto fail; |
| 4028 | } |
| 4029 | |
| 4030 | /* Clear our data area */ |
| 4031 | vha = shost_priv(host); |
| 4032 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 4033 | |
| 4034 | vha->host = host; |
| 4035 | vha->host_no = host->host_no; |
| 4036 | vha->hw = ha; |
| 4037 | |
| 4038 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 4039 | INIT_LIST_HEAD(&vha->work_list); |
| 4040 | INIT_LIST_HEAD(&vha->list); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4041 | INIT_LIST_HEAD(&vha->qla_cmd_list); |
| 4042 | INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list); |
Alexei Potashnik | 71cdc07 | 2015-12-17 14:57:01 -0500 | [diff] [blame] | 4043 | INIT_LIST_HEAD(&vha->logo_list); |
Alexei Potashnik | b7bd104 | 2015-12-17 14:57:02 -0500 | [diff] [blame] | 4044 | INIT_LIST_HEAD(&vha->plogi_ack_list); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4045 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4046 | spin_lock_init(&vha->work_lock); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4047 | spin_lock_init(&vha->cmd_list_lock); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4048 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4049 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4050 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 4051 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 4052 | vha->host, vha->hw, vha, |
| 4053 | dev_name(&(ha->pdev->dev))); |
| 4054 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4055 | return vha; |
| 4056 | |
| 4057 | fail: |
| 4058 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4059 | } |
| 4060 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 4061 | static struct qla_work_evt * |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4062 | 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] | 4063 | { |
| 4064 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4065 | uint8_t bail; |
| 4066 | |
| 4067 | QLA_VHA_MARK_BUSY(vha, bail); |
| 4068 | if (bail) |
| 4069 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4070 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4071 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4072 | if (!e) { |
| 4073 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4074 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4075 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4076 | |
| 4077 | INIT_LIST_HEAD(&e->list); |
| 4078 | e->type = type; |
| 4079 | e->flags = QLA_EVT_FLAG_FREE; |
| 4080 | return e; |
| 4081 | } |
| 4082 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 4083 | static int |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4084 | 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] | 4085 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4086 | unsigned long flags; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4087 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4088 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4089 | list_add_tail(&e->list, &vha->work_list); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4090 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4091 | qla2xxx_wake_dpc(vha); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4092 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4093 | return QLA_SUCCESS; |
| 4094 | } |
| 4095 | |
| 4096 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4097 | 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] | 4098 | u32 data) |
| 4099 | { |
| 4100 | struct qla_work_evt *e; |
| 4101 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4102 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4103 | if (!e) |
| 4104 | return QLA_FUNCTION_FAILED; |
| 4105 | |
| 4106 | e->u.aen.code = code; |
| 4107 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4108 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4109 | } |
| 4110 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4111 | int |
| 4112 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 4113 | { |
| 4114 | struct qla_work_evt *e; |
| 4115 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4116 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4117 | if (!e) |
| 4118 | return QLA_FUNCTION_FAILED; |
| 4119 | |
| 4120 | memcpy(e->u.idc_ack.mb, mb, QLA_IDC_ACK_REGS * sizeof(uint16_t)); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4121 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4122 | } |
| 4123 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4124 | #define qla2x00_post_async_work(name, type) \ |
| 4125 | int qla2x00_post_async_##name##_work( \ |
| 4126 | struct scsi_qla_host *vha, \ |
| 4127 | fc_port_t *fcport, uint16_t *data) \ |
| 4128 | { \ |
| 4129 | struct qla_work_evt *e; \ |
| 4130 | \ |
| 4131 | e = qla2x00_alloc_work(vha, type); \ |
| 4132 | if (!e) \ |
| 4133 | return QLA_FUNCTION_FAILED; \ |
| 4134 | \ |
| 4135 | e->u.logio.fcport = fcport; \ |
| 4136 | if (data) { \ |
| 4137 | e->u.logio.data[0] = data[0]; \ |
| 4138 | e->u.logio.data[1] = data[1]; \ |
| 4139 | } \ |
| 4140 | return qla2x00_post_work(vha, e); \ |
| 4141 | } |
| 4142 | |
| 4143 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
| 4144 | qla2x00_post_async_work(login_done, QLA_EVT_ASYNC_LOGIN_DONE); |
| 4145 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 4146 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4147 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 4148 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4149 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4150 | int |
| 4151 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 4152 | { |
| 4153 | struct qla_work_evt *e; |
| 4154 | |
| 4155 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 4156 | if (!e) |
| 4157 | return QLA_FUNCTION_FAILED; |
| 4158 | |
| 4159 | e->u.uevent.code = code; |
| 4160 | return qla2x00_post_work(vha, e); |
| 4161 | } |
| 4162 | |
| 4163 | static void |
| 4164 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 4165 | { |
| 4166 | char event_string[40]; |
| 4167 | char *envp[] = { event_string, NULL }; |
| 4168 | |
| 4169 | switch (code) { |
| 4170 | case QLA_UEVENT_CODE_FW_DUMP: |
| 4171 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 4172 | vha->host_no); |
| 4173 | break; |
| 4174 | default: |
| 4175 | /* do nothing */ |
| 4176 | break; |
| 4177 | } |
| 4178 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 4179 | } |
| 4180 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4181 | int |
| 4182 | qlafx00_post_aenfx_work(struct scsi_qla_host *vha, uint32_t evtcode, |
| 4183 | uint32_t *data, int cnt) |
| 4184 | { |
| 4185 | struct qla_work_evt *e; |
| 4186 | |
| 4187 | e = qla2x00_alloc_work(vha, QLA_EVT_AENFX); |
| 4188 | if (!e) |
| 4189 | return QLA_FUNCTION_FAILED; |
| 4190 | |
| 4191 | e->u.aenfx.evtcode = evtcode; |
| 4192 | e->u.aenfx.count = cnt; |
| 4193 | memcpy(e->u.aenfx.mbx, data, sizeof(*data) * cnt); |
| 4194 | return qla2x00_post_work(vha, e); |
| 4195 | } |
| 4196 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4197 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4198 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4199 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4200 | struct qla_work_evt *e, *tmp; |
| 4201 | unsigned long flags; |
| 4202 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4203 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4204 | spin_lock_irqsave(&vha->work_lock, flags); |
| 4205 | list_splice_init(&vha->work_list, &work); |
| 4206 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 4207 | |
| 4208 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4209 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4210 | |
| 4211 | switch (e->type) { |
| 4212 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4213 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4214 | e->u.aen.code, e->u.aen.data); |
| 4215 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4216 | case QLA_EVT_IDC_ACK: |
| 4217 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 4218 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4219 | case QLA_EVT_ASYNC_LOGIN: |
| 4220 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 4221 | e->u.logio.data); |
| 4222 | break; |
| 4223 | case QLA_EVT_ASYNC_LOGIN_DONE: |
| 4224 | qla2x00_async_login_done(vha, e->u.logio.fcport, |
| 4225 | e->u.logio.data); |
| 4226 | break; |
| 4227 | case QLA_EVT_ASYNC_LOGOUT: |
| 4228 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 4229 | break; |
| 4230 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 4231 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 4232 | e->u.logio.data); |
| 4233 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4234 | case QLA_EVT_ASYNC_ADISC: |
| 4235 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 4236 | e->u.logio.data); |
| 4237 | break; |
| 4238 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 4239 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 4240 | e->u.logio.data); |
| 4241 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4242 | case QLA_EVT_UEVENT: |
| 4243 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 4244 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4245 | case QLA_EVT_AENFX: |
| 4246 | qlafx00_process_aen(vha, e); |
| 4247 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4248 | } |
| 4249 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 4250 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4251 | |
| 4252 | /* For each work completed decrement vha ref count */ |
| 4253 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4254 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4255 | } |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4256 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4257 | /* Relogins all the fcports of a vport |
| 4258 | * Context: dpc thread |
| 4259 | */ |
| 4260 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 4261 | { |
| 4262 | fc_port_t *fcport; |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 4263 | int status; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4264 | uint16_t next_loopid = 0; |
| 4265 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4266 | uint16_t data[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4267 | |
| 4268 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 4269 | /* |
| 4270 | * If the port is not ONLINE then try to login |
| 4271 | * to it if we haven't run out of retries. |
| 4272 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4273 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
| 4274 | fcport->login_retry && !(fcport->flags & FCF_ASYNC_SENT)) { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4275 | fcport->login_retry--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4276 | if (fcport->flags & FCF_FABRIC_DEVICE) { |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 4277 | if (fcport->flags & FCF_FCP2_DEVICE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4278 | ha->isp_ops->fabric_logout(vha, |
| 4279 | fcport->loop_id, |
| 4280 | fcport->d_id.b.domain, |
| 4281 | fcport->d_id.b.area, |
| 4282 | fcport->d_id.b.al_pa); |
| 4283 | |
Joe Carnuccio | 03bcfb5 | 2011-03-30 11:46:27 -0700 | [diff] [blame] | 4284 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
| 4285 | fcport->loop_id = next_loopid = |
| 4286 | ha->min_external_loopid; |
| 4287 | status = qla2x00_find_new_loop_id( |
| 4288 | vha, fcport); |
| 4289 | if (status != QLA_SUCCESS) { |
| 4290 | /* Ran out of IDs to use */ |
| 4291 | break; |
| 4292 | } |
| 4293 | } |
| 4294 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4295 | if (IS_ALOGIO_CAPABLE(ha)) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4296 | fcport->flags |= FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4297 | data[0] = 0; |
| 4298 | data[1] = QLA_LOGIO_LOGIN_RETRIED; |
| 4299 | status = qla2x00_post_async_login_work( |
| 4300 | vha, fcport, data); |
| 4301 | if (status == QLA_SUCCESS) |
| 4302 | continue; |
| 4303 | /* Attempt a retry. */ |
| 4304 | status = 1; |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4305 | } else { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4306 | status = qla2x00_fabric_login(vha, |
| 4307 | fcport, &next_loopid); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4308 | if (status == QLA_SUCCESS) { |
| 4309 | int status2; |
| 4310 | uint8_t opts; |
| 4311 | |
| 4312 | opts = 0; |
| 4313 | if (fcport->flags & |
| 4314 | FCF_FCP2_DEVICE) |
| 4315 | opts |= BIT_1; |
Saurav Kashyap | 0300396 | 2012-11-21 02:40:31 -0500 | [diff] [blame] | 4316 | status2 = |
| 4317 | qla2x00_get_port_database( |
| 4318 | vha, fcport, opts); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4319 | if (status2 != QLA_SUCCESS) |
| 4320 | status = 1; |
| 4321 | } |
| 4322 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4323 | } else |
| 4324 | status = qla2x00_local_device_login(vha, |
| 4325 | fcport); |
| 4326 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4327 | if (status == QLA_SUCCESS) { |
| 4328 | fcport->old_loop_id = fcport->loop_id; |
| 4329 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4330 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 4331 | "Port login OK: logged in ID 0x%x.\n", |
| 4332 | fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4333 | |
| 4334 | qla2x00_update_fcport(vha, fcport); |
| 4335 | |
| 4336 | } else if (status == 1) { |
| 4337 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 4338 | /* retry the login again */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4339 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 4340 | "Retrying %d login again loop_id 0x%x.\n", |
| 4341 | fcport->login_retry, fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4342 | } else { |
| 4343 | fcport->login_retry = 0; |
| 4344 | } |
| 4345 | |
| 4346 | if (fcport->login_retry == 0 && status != QLA_SUCCESS) |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4347 | qla2x00_clear_loop_id(fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4348 | } |
| 4349 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 4350 | break; |
| 4351 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4352 | } |
| 4353 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4354 | /* Schedule work on any of the dpc-workqueues */ |
| 4355 | void |
| 4356 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 4357 | { |
| 4358 | struct qla_hw_data *ha = base_vha->hw; |
| 4359 | |
| 4360 | switch (work_code) { |
| 4361 | case MBA_IDC_AEN: /* 0x8200 */ |
| 4362 | if (ha->dpc_lp_wq) |
| 4363 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 4364 | break; |
| 4365 | |
| 4366 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 4367 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4368 | if (ha->dpc_hp_wq) |
| 4369 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 4370 | } else |
| 4371 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 4372 | "NIC Core reset is already active. Skip " |
| 4373 | "scheduling it again.\n"); |
| 4374 | break; |
| 4375 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 4376 | if (ha->dpc_hp_wq) |
| 4377 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 4378 | break; |
| 4379 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 4380 | if (ha->dpc_hp_wq) |
| 4381 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 4382 | break; |
| 4383 | default: |
| 4384 | ql_log(ql_log_warn, base_vha, 0xb05f, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 4385 | "Unknown work-code=0x%x.\n", work_code); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4386 | } |
| 4387 | |
| 4388 | return; |
| 4389 | } |
| 4390 | |
| 4391 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 4392 | void |
| 4393 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 4394 | { |
| 4395 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4396 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4397 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4398 | uint32_t dev_state = 0; |
| 4399 | |
| 4400 | qla83xx_idc_lock(base_vha, 0); |
| 4401 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4402 | qla83xx_reset_ownership(base_vha); |
| 4403 | if (ha->flags.nic_core_reset_owner) { |
| 4404 | ha->flags.nic_core_reset_owner = 0; |
| 4405 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4406 | QLA8XXX_DEV_FAILED); |
| 4407 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 4408 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4409 | } |
| 4410 | qla83xx_idc_unlock(base_vha, 0); |
| 4411 | } |
| 4412 | |
| 4413 | /* Work: Execute IDC state handler */ |
| 4414 | void |
| 4415 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 4416 | { |
| 4417 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4418 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4419 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4420 | uint32_t dev_state = 0; |
| 4421 | |
| 4422 | qla83xx_idc_lock(base_vha, 0); |
| 4423 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4424 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 4425 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 4426 | qla83xx_idc_state_handler(base_vha); |
| 4427 | qla83xx_idc_unlock(base_vha, 0); |
| 4428 | } |
| 4429 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4430 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4431 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 4432 | { |
| 4433 | int rval = QLA_SUCCESS; |
| 4434 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 4435 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 4436 | |
| 4437 | do { |
| 4438 | if (time_after(jiffies, heart_beat_wait)) { |
| 4439 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 4440 | "Nic Core f/w is not alive.\n"); |
| 4441 | rval = QLA_FUNCTION_FAILED; |
| 4442 | break; |
| 4443 | } |
| 4444 | |
| 4445 | qla83xx_idc_lock(base_vha, 0); |
| 4446 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4447 | &heart_beat_counter1); |
| 4448 | qla83xx_idc_unlock(base_vha, 0); |
| 4449 | msleep(100); |
| 4450 | qla83xx_idc_lock(base_vha, 0); |
| 4451 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4452 | &heart_beat_counter2); |
| 4453 | qla83xx_idc_unlock(base_vha, 0); |
| 4454 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 4455 | |
| 4456 | return rval; |
| 4457 | } |
| 4458 | |
| 4459 | /* Work: Perform NIC Core Reset handling */ |
| 4460 | void |
| 4461 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 4462 | { |
| 4463 | struct qla_hw_data *ha = |
| 4464 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 4465 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4466 | uint32_t dev_state = 0; |
| 4467 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4468 | if (IS_QLA2031(ha)) { |
| 4469 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 4470 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 4471 | "Failed to dump mctp\n"); |
| 4472 | return; |
| 4473 | } |
| 4474 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4475 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4476 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 4477 | qla83xx_idc_lock(base_vha, 0); |
| 4478 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4479 | &dev_state); |
| 4480 | qla83xx_idc_unlock(base_vha, 0); |
| 4481 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 4482 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 4483 | "Nic Core f/w is alive.\n"); |
| 4484 | return; |
| 4485 | } |
| 4486 | } |
| 4487 | |
| 4488 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 4489 | if (qla83xx_nic_core_reset(base_vha)) { |
| 4490 | /* NIC Core reset failed. */ |
| 4491 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 4492 | "NIC Core reset failed.\n"); |
| 4493 | } |
| 4494 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 4495 | } |
| 4496 | } |
| 4497 | |
| 4498 | /* Work: Handle 8200 IDC aens */ |
| 4499 | void |
| 4500 | qla83xx_service_idc_aen(struct work_struct *work) |
| 4501 | { |
| 4502 | struct qla_hw_data *ha = |
| 4503 | container_of(work, struct qla_hw_data, idc_aen); |
| 4504 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4505 | uint32_t dev_state, idc_control; |
| 4506 | |
| 4507 | qla83xx_idc_lock(base_vha, 0); |
| 4508 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4509 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 4510 | qla83xx_idc_unlock(base_vha, 0); |
| 4511 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 4512 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 4513 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 4514 | "Application requested NIC Core Reset.\n"); |
| 4515 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4516 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 4517 | QLA_SUCCESS) { |
| 4518 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 4519 | "Other protocol driver requested NIC Core Reset.\n"); |
| 4520 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4521 | } |
| 4522 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 4523 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 4524 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4525 | } |
| 4526 | } |
| 4527 | |
| 4528 | static void |
| 4529 | qla83xx_wait_logic(void) |
| 4530 | { |
| 4531 | int i; |
| 4532 | |
| 4533 | /* Yield CPU */ |
| 4534 | if (!in_interrupt()) { |
| 4535 | /* |
| 4536 | * Wait about 200ms before retrying again. |
| 4537 | * This controls the number of retries for single |
| 4538 | * lock operation. |
| 4539 | */ |
| 4540 | msleep(100); |
| 4541 | schedule(); |
| 4542 | } else { |
| 4543 | for (i = 0; i < 20; i++) |
| 4544 | cpu_relax(); /* This a nop instr on i386 */ |
| 4545 | } |
| 4546 | } |
| 4547 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4548 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4549 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 4550 | { |
| 4551 | int rval; |
| 4552 | uint32_t data; |
| 4553 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 4554 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 4555 | struct qla_hw_data *ha = base_vha->hw; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4556 | ql_dbg(ql_dbg_p3p, base_vha, 0xb086, |
| 4557 | "Trying force recovery of the IDC lock.\n"); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4558 | |
| 4559 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 4560 | if (rval) |
| 4561 | return rval; |
| 4562 | |
| 4563 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 4564 | return QLA_SUCCESS; |
| 4565 | } else { |
| 4566 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 4567 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4568 | data); |
| 4569 | if (rval) |
| 4570 | return rval; |
| 4571 | |
| 4572 | msleep(200); |
| 4573 | |
| 4574 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4575 | &data); |
| 4576 | if (rval) |
| 4577 | return rval; |
| 4578 | |
| 4579 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 4580 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 4581 | ~(idc_lck_rcvry_stage_mask)); |
| 4582 | rval = qla83xx_wr_reg(base_vha, |
| 4583 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 4584 | if (rval) |
| 4585 | return rval; |
| 4586 | |
| 4587 | /* Forcefully perform IDC UnLock */ |
| 4588 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 4589 | &data); |
| 4590 | if (rval) |
| 4591 | return rval; |
| 4592 | /* Clear lock-id by setting 0xff */ |
| 4593 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4594 | 0xff); |
| 4595 | if (rval) |
| 4596 | return rval; |
| 4597 | /* Clear lock-recovery by setting 0x0 */ |
| 4598 | rval = qla83xx_wr_reg(base_vha, |
| 4599 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 4600 | if (rval) |
| 4601 | return rval; |
| 4602 | } else |
| 4603 | return QLA_SUCCESS; |
| 4604 | } |
| 4605 | |
| 4606 | return rval; |
| 4607 | } |
| 4608 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4609 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4610 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 4611 | { |
| 4612 | int rval = QLA_SUCCESS; |
| 4613 | uint32_t o_drv_lockid, n_drv_lockid; |
| 4614 | unsigned long lock_recovery_timeout; |
| 4615 | |
| 4616 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 4617 | retry_lockid: |
| 4618 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 4619 | if (rval) |
| 4620 | goto exit; |
| 4621 | |
| 4622 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 4623 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 4624 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 4625 | return QLA_SUCCESS; |
| 4626 | else |
| 4627 | return QLA_FUNCTION_FAILED; |
| 4628 | } |
| 4629 | |
| 4630 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 4631 | if (rval) |
| 4632 | goto exit; |
| 4633 | |
| 4634 | if (o_drv_lockid == n_drv_lockid) { |
| 4635 | qla83xx_wait_logic(); |
| 4636 | goto retry_lockid; |
| 4637 | } else |
| 4638 | return QLA_SUCCESS; |
| 4639 | |
| 4640 | exit: |
| 4641 | return rval; |
| 4642 | } |
| 4643 | |
| 4644 | void |
| 4645 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4646 | { |
| 4647 | uint16_t options = (requester_id << 15) | BIT_6; |
| 4648 | uint32_t data; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4649 | uint32_t lock_owner; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4650 | struct qla_hw_data *ha = base_vha->hw; |
| 4651 | |
| 4652 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 4653 | retry_lock: |
| 4654 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 4655 | == QLA_SUCCESS) { |
| 4656 | if (data) { |
| 4657 | /* Setting lock-id to our function-number */ |
| 4658 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4659 | ha->portnum); |
| 4660 | } else { |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4661 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4662 | &lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4663 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4664 | "Failed to acquire IDC lock, acquired by %d, " |
| 4665 | "retrying...\n", lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4666 | |
| 4667 | /* Retry/Perform IDC-Lock recovery */ |
| 4668 | if (qla83xx_idc_lock_recovery(base_vha) |
| 4669 | == QLA_SUCCESS) { |
| 4670 | qla83xx_wait_logic(); |
| 4671 | goto retry_lock; |
| 4672 | } else |
| 4673 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 4674 | "IDC Lock recovery FAILED.\n"); |
| 4675 | } |
| 4676 | |
| 4677 | } |
| 4678 | |
| 4679 | return; |
| 4680 | |
| 4681 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 4682 | retry_lock2: |
| 4683 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4684 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 4685 | "Failed to acquire IDC lock. retrying...\n"); |
| 4686 | /* Retry/Perform IDC-Lock recovery */ |
| 4687 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 4688 | qla83xx_wait_logic(); |
| 4689 | goto retry_lock2; |
| 4690 | } else |
| 4691 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 4692 | "IDC Lock recovery FAILED.\n"); |
| 4693 | } |
| 4694 | |
| 4695 | return; |
| 4696 | } |
| 4697 | |
| 4698 | void |
| 4699 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4700 | { |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4701 | #if 0 |
| 4702 | uint16_t options = (requester_id << 15) | BIT_7; |
| 4703 | #endif |
| 4704 | uint16_t retry; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4705 | uint32_t data; |
| 4706 | struct qla_hw_data *ha = base_vha->hw; |
| 4707 | |
| 4708 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 4709 | * remote registers |
| 4710 | */ |
| 4711 | retry = 0; |
| 4712 | retry_unlock: |
| 4713 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 4714 | == QLA_SUCCESS) { |
| 4715 | if (data == ha->portnum) { |
| 4716 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 4717 | /* Clearing lock-id by setting 0xff */ |
| 4718 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 4719 | } else if (retry < 10) { |
| 4720 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 4721 | |
| 4722 | /* Retry for IDC-unlock */ |
| 4723 | qla83xx_wait_logic(); |
| 4724 | retry++; |
| 4725 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 4726 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4727 | goto retry_unlock; |
| 4728 | } |
| 4729 | } else if (retry < 10) { |
| 4730 | /* Retry for IDC-unlock */ |
| 4731 | qla83xx_wait_logic(); |
| 4732 | retry++; |
| 4733 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 4734 | "Failed to read drv-lockid, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4735 | goto retry_unlock; |
| 4736 | } |
| 4737 | |
| 4738 | return; |
| 4739 | |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4740 | #if 0 |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4741 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 4742 | retry = 0; |
| 4743 | retry_unlock2: |
| 4744 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4745 | if (retry < 10) { |
| 4746 | /* Retry for IDC-unlock */ |
| 4747 | qla83xx_wait_logic(); |
| 4748 | retry++; |
| 4749 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 4750 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4751 | goto retry_unlock2; |
| 4752 | } |
| 4753 | } |
| 4754 | |
| 4755 | return; |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4756 | #endif |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4757 | } |
| 4758 | |
| 4759 | int |
| 4760 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4761 | { |
| 4762 | int rval = QLA_SUCCESS; |
| 4763 | struct qla_hw_data *ha = vha->hw; |
| 4764 | uint32_t drv_presence; |
| 4765 | |
| 4766 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4767 | if (rval == QLA_SUCCESS) { |
| 4768 | drv_presence |= (1 << ha->portnum); |
| 4769 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4770 | drv_presence); |
| 4771 | } |
| 4772 | |
| 4773 | return rval; |
| 4774 | } |
| 4775 | |
| 4776 | int |
| 4777 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4778 | { |
| 4779 | int rval = QLA_SUCCESS; |
| 4780 | |
| 4781 | qla83xx_idc_lock(vha, 0); |
| 4782 | rval = __qla83xx_set_drv_presence(vha); |
| 4783 | qla83xx_idc_unlock(vha, 0); |
| 4784 | |
| 4785 | return rval; |
| 4786 | } |
| 4787 | |
| 4788 | int |
| 4789 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4790 | { |
| 4791 | int rval = QLA_SUCCESS; |
| 4792 | struct qla_hw_data *ha = vha->hw; |
| 4793 | uint32_t drv_presence; |
| 4794 | |
| 4795 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4796 | if (rval == QLA_SUCCESS) { |
| 4797 | drv_presence &= ~(1 << ha->portnum); |
| 4798 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4799 | drv_presence); |
| 4800 | } |
| 4801 | |
| 4802 | return rval; |
| 4803 | } |
| 4804 | |
| 4805 | int |
| 4806 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4807 | { |
| 4808 | int rval = QLA_SUCCESS; |
| 4809 | |
| 4810 | qla83xx_idc_lock(vha, 0); |
| 4811 | rval = __qla83xx_clear_drv_presence(vha); |
| 4812 | qla83xx_idc_unlock(vha, 0); |
| 4813 | |
| 4814 | return rval; |
| 4815 | } |
| 4816 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4817 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4818 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 4819 | { |
| 4820 | struct qla_hw_data *ha = vha->hw; |
| 4821 | uint32_t drv_ack, drv_presence; |
| 4822 | unsigned long ack_timeout; |
| 4823 | |
| 4824 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 4825 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 4826 | while (1) { |
| 4827 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 4828 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 4829 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4830 | break; |
| 4831 | |
| 4832 | if (time_after_eq(jiffies, ack_timeout)) { |
| 4833 | ql_log(ql_log_warn, vha, 0xb067, |
| 4834 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 4835 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 4836 | /* |
| 4837 | * The function(s) which did not ack in time are forced |
| 4838 | * to withdraw any further participation in the IDC |
| 4839 | * reset. |
| 4840 | */ |
| 4841 | if (drv_ack != drv_presence) |
| 4842 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4843 | drv_ack); |
| 4844 | break; |
| 4845 | } |
| 4846 | |
| 4847 | qla83xx_idc_unlock(vha, 0); |
| 4848 | msleep(1000); |
| 4849 | qla83xx_idc_lock(vha, 0); |
| 4850 | } |
| 4851 | |
| 4852 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 4853 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 4854 | } |
| 4855 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4856 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4857 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 4858 | { |
| 4859 | int rval = QLA_SUCCESS; |
| 4860 | uint32_t idc_control; |
| 4861 | |
| 4862 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 4863 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 4864 | |
| 4865 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 4866 | __qla83xx_get_idc_control(vha, &idc_control); |
| 4867 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 4868 | __qla83xx_set_idc_control(vha, 0); |
| 4869 | |
| 4870 | qla83xx_idc_unlock(vha, 0); |
| 4871 | rval = qla83xx_restart_nic_firmware(vha); |
| 4872 | qla83xx_idc_lock(vha, 0); |
| 4873 | |
| 4874 | if (rval != QLA_SUCCESS) { |
| 4875 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 4876 | "Failed to restart NIC f/w.\n"); |
| 4877 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 4878 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 4879 | } else { |
| 4880 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 4881 | "Success in restarting nic f/w.\n"); |
| 4882 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 4883 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 4884 | } |
| 4885 | |
| 4886 | return rval; |
| 4887 | } |
| 4888 | |
| 4889 | /* Assumes idc_lock always held on entry */ |
| 4890 | int |
| 4891 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 4892 | { |
| 4893 | struct qla_hw_data *ha = base_vha->hw; |
| 4894 | int rval = QLA_SUCCESS; |
| 4895 | unsigned long dev_init_timeout; |
| 4896 | uint32_t dev_state; |
| 4897 | |
| 4898 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 4899 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 4900 | |
| 4901 | while (1) { |
| 4902 | |
| 4903 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 4904 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 4905 | "Initialization TIMEOUT!\n"); |
| 4906 | /* Init timeout. Disable further NIC Core |
| 4907 | * communication. |
| 4908 | */ |
| 4909 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4910 | QLA8XXX_DEV_FAILED); |
| 4911 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 4912 | "HW State: FAILED.\n"); |
| 4913 | } |
| 4914 | |
| 4915 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4916 | switch (dev_state) { |
| 4917 | case QLA8XXX_DEV_READY: |
| 4918 | if (ha->flags.nic_core_reset_owner) |
| 4919 | qla83xx_idc_audit(base_vha, |
| 4920 | IDC_AUDIT_COMPLETION); |
| 4921 | ha->flags.nic_core_reset_owner = 0; |
| 4922 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 4923 | "Reset_owner reset by 0x%x.\n", |
| 4924 | ha->portnum); |
| 4925 | goto exit; |
| 4926 | case QLA8XXX_DEV_COLD: |
| 4927 | if (ha->flags.nic_core_reset_owner) |
| 4928 | rval = qla83xx_device_bootstrap(base_vha); |
| 4929 | else { |
| 4930 | /* Wait for AEN to change device-state */ |
| 4931 | qla83xx_idc_unlock(base_vha, 0); |
| 4932 | msleep(1000); |
| 4933 | qla83xx_idc_lock(base_vha, 0); |
| 4934 | } |
| 4935 | break; |
| 4936 | case QLA8XXX_DEV_INITIALIZING: |
| 4937 | /* Wait for AEN to change device-state */ |
| 4938 | qla83xx_idc_unlock(base_vha, 0); |
| 4939 | msleep(1000); |
| 4940 | qla83xx_idc_lock(base_vha, 0); |
| 4941 | break; |
| 4942 | case QLA8XXX_DEV_NEED_RESET: |
| 4943 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 4944 | qla83xx_need_reset_handler(base_vha); |
| 4945 | else { |
| 4946 | /* Wait for AEN to change device-state */ |
| 4947 | qla83xx_idc_unlock(base_vha, 0); |
| 4948 | msleep(1000); |
| 4949 | qla83xx_idc_lock(base_vha, 0); |
| 4950 | } |
| 4951 | /* reset timeout value after need reset handler */ |
| 4952 | dev_init_timeout = jiffies + |
| 4953 | (ha->fcoe_dev_init_timeout * HZ); |
| 4954 | break; |
| 4955 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 4956 | /* XXX: DEBUG for now */ |
| 4957 | qla83xx_idc_unlock(base_vha, 0); |
| 4958 | msleep(1000); |
| 4959 | qla83xx_idc_lock(base_vha, 0); |
| 4960 | break; |
| 4961 | case QLA8XXX_DEV_QUIESCENT: |
| 4962 | /* XXX: DEBUG for now */ |
| 4963 | if (ha->flags.quiesce_owner) |
| 4964 | goto exit; |
| 4965 | |
| 4966 | qla83xx_idc_unlock(base_vha, 0); |
| 4967 | msleep(1000); |
| 4968 | qla83xx_idc_lock(base_vha, 0); |
| 4969 | dev_init_timeout = jiffies + |
| 4970 | (ha->fcoe_dev_init_timeout * HZ); |
| 4971 | break; |
| 4972 | case QLA8XXX_DEV_FAILED: |
| 4973 | if (ha->flags.nic_core_reset_owner) |
| 4974 | qla83xx_idc_audit(base_vha, |
| 4975 | IDC_AUDIT_COMPLETION); |
| 4976 | ha->flags.nic_core_reset_owner = 0; |
| 4977 | __qla83xx_clear_drv_presence(base_vha); |
| 4978 | qla83xx_idc_unlock(base_vha, 0); |
| 4979 | qla8xxx_dev_failed_handler(base_vha); |
| 4980 | rval = QLA_FUNCTION_FAILED; |
| 4981 | qla83xx_idc_lock(base_vha, 0); |
| 4982 | goto exit; |
| 4983 | case QLA8XXX_BAD_VALUE: |
| 4984 | qla83xx_idc_unlock(base_vha, 0); |
| 4985 | msleep(1000); |
| 4986 | qla83xx_idc_lock(base_vha, 0); |
| 4987 | break; |
| 4988 | default: |
| 4989 | ql_log(ql_log_warn, base_vha, 0xb071, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 4990 | "Unknown Device State: %x.\n", dev_state); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4991 | qla83xx_idc_unlock(base_vha, 0); |
| 4992 | qla8xxx_dev_failed_handler(base_vha); |
| 4993 | rval = QLA_FUNCTION_FAILED; |
| 4994 | qla83xx_idc_lock(base_vha, 0); |
| 4995 | goto exit; |
| 4996 | } |
| 4997 | } |
| 4998 | |
| 4999 | exit: |
| 5000 | return rval; |
| 5001 | } |
| 5002 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5003 | void |
| 5004 | qla2x00_disable_board_on_pci_error(struct work_struct *work) |
| 5005 | { |
| 5006 | struct qla_hw_data *ha = container_of(work, struct qla_hw_data, |
| 5007 | board_disable); |
| 5008 | struct pci_dev *pdev = ha->pdev; |
| 5009 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5010 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 5011 | /* if UNLOAD flag is already set, then continue unload, |
| 5012 | * where it was set first. |
| 5013 | */ |
| 5014 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5015 | return; |
| 5016 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5017 | ql_log(ql_log_warn, base_vha, 0x015b, |
| 5018 | "Disabling adapter.\n"); |
| 5019 | |
| 5020 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 5021 | |
| 5022 | qla2x00_delete_all_vps(ha, base_vha); |
| 5023 | |
| 5024 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5025 | |
| 5026 | qla2x00_dfs_remove(base_vha); |
| 5027 | |
| 5028 | qla84xx_put_chip(base_vha); |
| 5029 | |
| 5030 | if (base_vha->timer_active) |
| 5031 | qla2x00_stop_timer(base_vha); |
| 5032 | |
| 5033 | base_vha->flags.online = 0; |
| 5034 | |
| 5035 | qla2x00_destroy_deferred_work(ha); |
| 5036 | |
| 5037 | /* |
| 5038 | * Do not try to stop beacon blink as it will issue a mailbox |
| 5039 | * command. |
| 5040 | */ |
| 5041 | qla2x00_free_sysfs_attr(base_vha, false); |
| 5042 | |
| 5043 | fc_remove_host(base_vha->host); |
| 5044 | |
| 5045 | scsi_remove_host(base_vha->host); |
| 5046 | |
| 5047 | base_vha->flags.init_done = 0; |
| 5048 | qla25xx_delete_queues(base_vha); |
| 5049 | qla2x00_free_irqs(base_vha); |
| 5050 | qla2x00_free_fcports(base_vha); |
| 5051 | qla2x00_mem_free(ha); |
| 5052 | qla82xx_md_free(base_vha); |
| 5053 | qla2x00_free_queues(ha); |
| 5054 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5055 | qla2x00_unmap_iobases(ha); |
| 5056 | |
| 5057 | pci_release_selected_regions(ha->pdev, ha->bars); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5058 | pci_disable_pcie_error_reporting(pdev); |
| 5059 | pci_disable_device(pdev); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5060 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 5061 | /* |
| 5062 | * Let qla2x00_remove_one cleanup qla_hw_data on device removal. |
| 5063 | */ |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5064 | } |
| 5065 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5066 | /************************************************************************** |
| 5067 | * qla2x00_do_dpc |
| 5068 | * This kernel thread is a task that is schedule by the interrupt handler |
| 5069 | * to perform the background processing for interrupts. |
| 5070 | * |
| 5071 | * Notes: |
| 5072 | * This task always run in the context of a kernel thread. It |
| 5073 | * is kick-off by the driver's detect code and starts up |
| 5074 | * up one per adapter. It immediately goes to sleep and waits for |
| 5075 | * some fibre event. When either the interrupt handler or |
| 5076 | * the timer routine detects a event it will one of the task |
| 5077 | * bits then wake us up. |
| 5078 | **************************************************************************/ |
| 5079 | static int |
| 5080 | qla2x00_do_dpc(void *data) |
| 5081 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5082 | scsi_qla_host_t *base_vha; |
| 5083 | struct qla_hw_data *ha; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5084 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5085 | ha = (struct qla_hw_data *)data; |
| 5086 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5087 | |
Dongsheng Yang | 8698a74 | 2014-03-11 18:09:12 +0800 | [diff] [blame] | 5088 | set_user_nice(current, MIN_NICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5089 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5090 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5091 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5092 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 5093 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5094 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5095 | schedule(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5096 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5097 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 5098 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5099 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5100 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5101 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 5102 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5103 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5104 | } |
| 5105 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5106 | ha->dpc_active = 1; |
| 5107 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5108 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 5109 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 5110 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5111 | |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 5112 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5113 | break; |
| 5114 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5115 | qla2x00_do_work(base_vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5116 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5117 | if (IS_P3P_TYPE(ha)) { |
| 5118 | if (IS_QLA8044(ha)) { |
| 5119 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5120 | &base_vha->dpc_flags)) { |
| 5121 | qla8044_idc_lock(ha); |
| 5122 | qla8044_wr_direct(base_vha, |
| 5123 | QLA8044_CRB_DEV_STATE_INDEX, |
| 5124 | QLA8XXX_DEV_FAILED); |
| 5125 | qla8044_idc_unlock(ha); |
| 5126 | ql_log(ql_log_info, base_vha, 0x4004, |
| 5127 | "HW State: FAILED.\n"); |
| 5128 | qla8044_device_state_handler(base_vha); |
| 5129 | continue; |
| 5130 | } |
| 5131 | |
| 5132 | } else { |
| 5133 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5134 | &base_vha->dpc_flags)) { |
| 5135 | qla82xx_idc_lock(ha); |
| 5136 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
| 5137 | QLA8XXX_DEV_FAILED); |
| 5138 | qla82xx_idc_unlock(ha); |
| 5139 | ql_log(ql_log_info, base_vha, 0x0151, |
| 5140 | "HW State: FAILED.\n"); |
| 5141 | qla82xx_device_state_handler(base_vha); |
| 5142 | continue; |
| 5143 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5144 | } |
| 5145 | |
| 5146 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 5147 | &base_vha->dpc_flags)) { |
| 5148 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5149 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 5150 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5151 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 5152 | &base_vha->dpc_flags))) { |
| 5153 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 5154 | /* FCoE-ctx reset failed. |
| 5155 | * Escalate to chip-reset |
| 5156 | */ |
| 5157 | set_bit(ISP_ABORT_NEEDED, |
| 5158 | &base_vha->dpc_flags); |
| 5159 | } |
| 5160 | clear_bit(ABORT_ISP_ACTIVE, |
| 5161 | &base_vha->dpc_flags); |
| 5162 | } |
| 5163 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5164 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 5165 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5166 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5167 | } else if (IS_QLAFX00(ha)) { |
| 5168 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5169 | &base_vha->dpc_flags)) { |
| 5170 | ql_dbg(ql_dbg_dpc, base_vha, 0x4020, |
| 5171 | "Firmware Reset Recovery\n"); |
| 5172 | if (qlafx00_reset_initialize(base_vha)) { |
| 5173 | /* Failed. Abort isp later. */ |
| 5174 | if (!test_bit(UNLOADING, |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5175 | &base_vha->dpc_flags)) { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5176 | set_bit(ISP_UNRECOVERABLE, |
| 5177 | &base_vha->dpc_flags); |
| 5178 | ql_dbg(ql_dbg_dpc, base_vha, |
| 5179 | 0x4021, |
| 5180 | "Reset Recovery Failed\n"); |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5181 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5182 | } |
| 5183 | } |
| 5184 | |
| 5185 | if (test_and_clear_bit(FX00_TARGET_SCAN, |
| 5186 | &base_vha->dpc_flags)) { |
| 5187 | ql_dbg(ql_dbg_dpc, base_vha, 0x4022, |
| 5188 | "ISPFx00 Target Scan scheduled\n"); |
| 5189 | if (qlafx00_rescan_isp(base_vha)) { |
| 5190 | if (!test_bit(UNLOADING, |
| 5191 | &base_vha->dpc_flags)) |
| 5192 | set_bit(ISP_UNRECOVERABLE, |
| 5193 | &base_vha->dpc_flags); |
| 5194 | ql_dbg(ql_dbg_dpc, base_vha, 0x401e, |
| 5195 | "ISPFx00 Target Scan Failed\n"); |
| 5196 | } |
| 5197 | ql_dbg(ql_dbg_dpc, base_vha, 0x401f, |
| 5198 | "ISPFx00 Target Scan End\n"); |
| 5199 | } |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 5200 | if (test_and_clear_bit(FX00_HOST_INFO_RESEND, |
| 5201 | &base_vha->dpc_flags)) { |
| 5202 | ql_dbg(ql_dbg_dpc, base_vha, 0x4023, |
| 5203 | "ISPFx00 Host Info resend scheduled\n"); |
| 5204 | qlafx00_fx_disc(base_vha, |
| 5205 | &base_vha->hw->mr.fcport, |
| 5206 | FXDISC_REG_HOST_INFO); |
| 5207 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5208 | } |
| 5209 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5210 | if (test_and_clear_bit(ISP_ABORT_NEEDED, |
| 5211 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5212 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5213 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 5214 | "ISP abort scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5215 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5216 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5217 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5218 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5219 | /* failed. retry later */ |
| 5220 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5221 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5222 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5223 | clear_bit(ABORT_ISP_ACTIVE, |
| 5224 | &base_vha->dpc_flags); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5225 | } |
| 5226 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5227 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 5228 | "ISP abort end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5229 | } |
| 5230 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 5231 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 5232 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5233 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 5234 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 5235 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5236 | if (test_bit(SCR_PENDING, &base_vha->dpc_flags)) { |
| 5237 | int ret; |
| 5238 | ret = qla2x00_send_change_request(base_vha, 0x3, 0); |
| 5239 | if (ret != QLA_SUCCESS) |
| 5240 | ql_log(ql_log_warn, base_vha, 0x121, |
| 5241 | "Failed to enable receiving of RSCN " |
| 5242 | "requests: 0x%x.\n", ret); |
| 5243 | clear_bit(SCR_PENDING, &base_vha->dpc_flags); |
| 5244 | } |
| 5245 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5246 | if (IS_QLAFX00(ha)) |
| 5247 | goto loop_resync_check; |
| 5248 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5249 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5250 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 5251 | "Quiescence mode scheduled.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5252 | if (IS_P3P_TYPE(ha)) { |
| 5253 | if (IS_QLA82XX(ha)) |
| 5254 | qla82xx_device_state_handler(base_vha); |
| 5255 | if (IS_QLA8044(ha)) |
| 5256 | qla8044_device_state_handler(base_vha); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5257 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5258 | &base_vha->dpc_flags); |
| 5259 | if (!ha->flags.quiesce_owner) { |
| 5260 | qla2x00_perform_loop_resync(base_vha); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5261 | if (IS_QLA82XX(ha)) { |
| 5262 | qla82xx_idc_lock(ha); |
| 5263 | qla82xx_clear_qsnt_ready( |
| 5264 | base_vha); |
| 5265 | qla82xx_idc_unlock(ha); |
| 5266 | } else if (IS_QLA8044(ha)) { |
| 5267 | qla8044_idc_lock(ha); |
| 5268 | qla8044_clear_qsnt_ready( |
| 5269 | base_vha); |
| 5270 | qla8044_idc_unlock(ha); |
| 5271 | } |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5272 | } |
| 5273 | } else { |
| 5274 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5275 | &base_vha->dpc_flags); |
| 5276 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5277 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5278 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 5279 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5280 | } |
| 5281 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5282 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5283 | &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5284 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5285 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5286 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 5287 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5288 | qla2x00_rst_aen(base_vha); |
| 5289 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5290 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 5291 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5292 | } |
| 5293 | |
| 5294 | /* Retry each device up to login retry count */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5295 | if ((test_and_clear_bit(RELOGIN_NEEDED, |
| 5296 | &base_vha->dpc_flags)) && |
| 5297 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 5298 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5299 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5300 | ql_dbg(ql_dbg_dpc, base_vha, 0x400d, |
| 5301 | "Relogin scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5302 | qla2x00_relogin(base_vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5303 | ql_dbg(ql_dbg_dpc, base_vha, 0x400e, |
| 5304 | "Relogin end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5305 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5306 | loop_resync_check: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5307 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5308 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5309 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5310 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 5311 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5312 | |
| 5313 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5314 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5315 | |
Bart Van Assche | 52c8282 | 2015-07-09 07:23:26 -0700 | [diff] [blame] | 5316 | qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5317 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5318 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 5319 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5320 | } |
| 5321 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5322 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 5323 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5324 | } |
| 5325 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5326 | if (IS_QLAFX00(ha)) |
| 5327 | goto intr_on_check; |
| 5328 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5329 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 5330 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 5331 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 5332 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 5333 | } |
| 5334 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5335 | intr_on_check: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5336 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 5337 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5338 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5339 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
Himanshu Madani | 90b604f | 2014-04-11 16:54:40 -0400 | [diff] [blame] | 5340 | &base_vha->dpc_flags)) { |
| 5341 | if (ha->beacon_blink_led == 1) |
| 5342 | ha->isp_ops->beacon_blink(base_vha); |
| 5343 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5344 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5345 | if (!IS_QLAFX00(ha)) |
| 5346 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5347 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5348 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5349 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5350 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5351 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5352 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5353 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5354 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 5355 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5356 | |
| 5357 | /* |
| 5358 | * Make sure that nobody tries to wake us up again. |
| 5359 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5360 | ha->dpc_active = 0; |
| 5361 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5362 | /* Cleanup any residual CTX SRBs. */ |
| 5363 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5364 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5365 | return 0; |
| 5366 | } |
| 5367 | |
| 5368 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5369 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5370 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5371 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5372 | struct task_struct *t = ha->dpc_thread; |
| 5373 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5374 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5375 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5376 | } |
| 5377 | |
| 5378 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5379 | * qla2x00_rst_aen |
| 5380 | * Processes asynchronous reset. |
| 5381 | * |
| 5382 | * Input: |
| 5383 | * ha = adapter block pointer. |
| 5384 | */ |
| 5385 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5386 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5387 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5388 | if (vha->flags.online && !vha->flags.reset_active && |
| 5389 | !atomic_read(&vha->loop_down_timer) && |
| 5390 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5391 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5392 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5393 | |
| 5394 | /* |
| 5395 | * Issue marker command only when we are going to start |
| 5396 | * the I/O. |
| 5397 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5398 | vha->marker_needed = 1; |
| 5399 | } while (!atomic_read(&vha->loop_down_timer) && |
| 5400 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5401 | } |
| 5402 | } |
| 5403 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5404 | /************************************************************************** |
| 5405 | * qla2x00_timer |
| 5406 | * |
| 5407 | * Description: |
| 5408 | * One second timer |
| 5409 | * |
| 5410 | * Context: Interrupt |
| 5411 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5412 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5413 | qla2x00_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5414 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5415 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5416 | int start_dpc = 0; |
| 5417 | int index; |
| 5418 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5419 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5420 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5421 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5422 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5423 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5424 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 5425 | "EEH = %d, restarting timer.\n", |
| 5426 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5427 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 5428 | return; |
| 5429 | } |
| 5430 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5431 | /* |
| 5432 | * Hardware read to raise pending EEH errors during mailbox waits. If |
| 5433 | * the read returns -1 then disable the board. |
| 5434 | */ |
| 5435 | if (!pci_channel_offline(ha->pdev)) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5436 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Joe Lawrence | c821e0d | 2014-08-26 17:11:41 -0400 | [diff] [blame] | 5437 | qla2x00_check_reg16_for_disconnect(vha, w); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5438 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5439 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5440 | /* Make sure qla82xx_watchdog is run only for physical port */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5441 | if (!vha->vp_idx && IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5442 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 5443 | start_dpc++; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5444 | if (IS_QLA82XX(ha)) |
| 5445 | qla82xx_watchdog(vha); |
| 5446 | else if (IS_QLA8044(ha)) |
| 5447 | qla8044_watchdog(vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5448 | } |
| 5449 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5450 | if (!vha->vp_idx && IS_QLAFX00(ha)) |
| 5451 | qlafx00_timer_routine(vha); |
| 5452 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5453 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5454 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5455 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 5456 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5457 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5458 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5459 | if (atomic_read(&vha->loop_down_timer) == |
| 5460 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5461 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5462 | ql_log(ql_log_info, vha, 0x6008, |
| 5463 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5464 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5465 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 5466 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5467 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5468 | /* |
| 5469 | * Schedule an ISP abort to return any FCP2-device |
| 5470 | * commands. |
| 5471 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5472 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5473 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5474 | spin_lock_irqsave(&ha->hardware_lock, |
| 5475 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5476 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5477 | for (index = 1; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 5478 | index < req->num_outstanding_cmds; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5479 | index++) { |
| 5480 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 5481 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5482 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5483 | if (!sp) |
| 5484 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 5485 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 5486 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5487 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5488 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5489 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5490 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5491 | if (IS_QLA82XX(ha)) |
| 5492 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5493 | &vha->dpc_flags); |
| 5494 | else |
| 5495 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5496 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5497 | break; |
| 5498 | } |
| 5499 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5500 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5501 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5502 | start_dpc++; |
| 5503 | } |
| 5504 | |
| 5505 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5506 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 5507 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5508 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5509 | "Loop down - aborting ISP.\n"); |
| 5510 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5511 | if (IS_QLA82XX(ha)) |
| 5512 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5513 | &vha->dpc_flags); |
| 5514 | else |
| 5515 | set_bit(ISP_ABORT_NEEDED, |
| 5516 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5517 | } |
| 5518 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5519 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 5520 | "Loop down - seconds remaining %d.\n", |
| 5521 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5522 | } |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5523 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 5524 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5525 | /* There is no beacon_blink function for ISP82xx */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5526 | if (!IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5527 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 5528 | start_dpc++; |
| 5529 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5530 | } |
| 5531 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5532 | /* Process any deferred work. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5533 | if (!list_empty(&vha->work_list)) |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5534 | start_dpc++; |
| 5535 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5536 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5537 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 5538 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 5539 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5540 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5541 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 5542 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5543 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 5544 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5545 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5546 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5547 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 5548 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 5549 | "fcport_update_needed=%d start_dpc=%d " |
| 5550 | "reset_marker_needed=%d", |
| 5551 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 5552 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 5553 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 5554 | start_dpc, |
| 5555 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 5556 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 5557 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 5558 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5559 | "relogin_needed=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5560 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 5561 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 5562 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 5563 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5564 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5565 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5566 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5567 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5568 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5569 | } |
| 5570 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5571 | /* Firmware interface routines. */ |
| 5572 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5573 | #define FW_BLOBS 11 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5574 | #define FW_ISP21XX 0 |
| 5575 | #define FW_ISP22XX 1 |
| 5576 | #define FW_ISP2300 2 |
| 5577 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5578 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5579 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5580 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5581 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5582 | #define FW_ISP2031 8 |
| 5583 | #define FW_ISP8031 9 |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5584 | #define FW_ISP27XX 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5585 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5586 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 5587 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 5588 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 5589 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 5590 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5591 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5592 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5593 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5594 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 5595 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5596 | #define FW_FILE_ISP27XX "ql2700_fw.bin" |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5597 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5598 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5599 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5600 | |
| 5601 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5602 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 5603 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 5604 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 5605 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 5606 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5607 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5608 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5609 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5610 | { .name = FW_FILE_ISP2031, }, |
| 5611 | { .name = FW_FILE_ISP8031, }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5612 | { .name = FW_FILE_ISP27XX, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5613 | }; |
| 5614 | |
| 5615 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5616 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5617 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5618 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5619 | struct fw_blob *blob; |
| 5620 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5621 | if (IS_QLA2100(ha)) { |
| 5622 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 5623 | } else if (IS_QLA2200(ha)) { |
| 5624 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5625 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5626 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5627 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5628 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5629 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5630 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5631 | } else if (IS_QLA25XX(ha)) { |
| 5632 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5633 | } else if (IS_QLA81XX(ha)) { |
| 5634 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5635 | } else if (IS_QLA82XX(ha)) { |
| 5636 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5637 | } else if (IS_QLA2031(ha)) { |
| 5638 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 5639 | } else if (IS_QLA8031(ha)) { |
| 5640 | blob = &qla_fw_blobs[FW_ISP8031]; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5641 | } else if (IS_QLA27XX(ha)) { |
| 5642 | blob = &qla_fw_blobs[FW_ISP27XX]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 5643 | } else { |
| 5644 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5645 | } |
| 5646 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5647 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5648 | if (blob->fw) |
| 5649 | goto out; |
| 5650 | |
| 5651 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5652 | ql_log(ql_log_warn, vha, 0x0063, |
| 5653 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5654 | blob->fw = NULL; |
| 5655 | blob = NULL; |
| 5656 | goto out; |
| 5657 | } |
| 5658 | |
| 5659 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5660 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5661 | return blob; |
| 5662 | } |
| 5663 | |
| 5664 | static void |
| 5665 | qla2x00_release_firmware(void) |
| 5666 | { |
| 5667 | int idx; |
| 5668 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5669 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5670 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 5671 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5672 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5673 | } |
| 5674 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5675 | static pci_ers_result_t |
| 5676 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 5677 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5678 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 5679 | struct qla_hw_data *ha = vha->hw; |
| 5680 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5681 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 5682 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 5683 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5684 | switch (state) { |
| 5685 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5686 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5687 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 5688 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5689 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5690 | /* For ISP82XX complete any pending mailbox cmd */ |
| 5691 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5692 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 5693 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 5694 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5695 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5696 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5697 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 5698 | /* Return back all IOs */ |
| 5699 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5700 | return PCI_ERS_RESULT_NEED_RESET; |
| 5701 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5702 | ha->flags.pci_channel_io_perm_failure = 1; |
| 5703 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5704 | return PCI_ERS_RESULT_DISCONNECT; |
| 5705 | } |
| 5706 | return PCI_ERS_RESULT_NEED_RESET; |
| 5707 | } |
| 5708 | |
| 5709 | static pci_ers_result_t |
| 5710 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 5711 | { |
| 5712 | int risc_paused = 0; |
| 5713 | uint32_t stat; |
| 5714 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5715 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5716 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5717 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 5718 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 5719 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 5720 | if (IS_QLA82XX(ha)) |
| 5721 | return PCI_ERS_RESULT_RECOVERED; |
| 5722 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5723 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 5724 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 5725 | stat = RD_REG_DWORD(®->hccr); |
| 5726 | if (stat & HCCR_RISC_PAUSE) |
| 5727 | risc_paused = 1; |
| 5728 | } else if (IS_QLA23XX(ha)) { |
| 5729 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 5730 | if (stat & HSR_RISC_PAUSED) |
| 5731 | risc_paused = 1; |
| 5732 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 5733 | stat = RD_REG_DWORD(®24->host_status); |
| 5734 | if (stat & HSRX_RISC_PAUSED) |
| 5735 | risc_paused = 1; |
| 5736 | } |
| 5737 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 5738 | |
| 5739 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5740 | ql_log(ql_log_info, base_vha, 0x9003, |
| 5741 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5742 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5743 | |
| 5744 | return PCI_ERS_RESULT_NEED_RESET; |
| 5745 | } else |
| 5746 | return PCI_ERS_RESULT_RECOVERED; |
| 5747 | } |
| 5748 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5749 | static uint32_t |
| 5750 | qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5751 | { |
| 5752 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 5753 | uint32_t drv_active = 0; |
| 5754 | struct qla_hw_data *ha = base_vha->hw; |
| 5755 | int fn; |
| 5756 | struct pci_dev *other_pdev = NULL; |
| 5757 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5758 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 5759 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5760 | |
| 5761 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5762 | |
| 5763 | if (base_vha->flags.online) { |
| 5764 | /* Abort all outstanding commands, |
| 5765 | * so as to be requeued later */ |
| 5766 | qla2x00_abort_isp_cleanup(base_vha); |
| 5767 | } |
| 5768 | |
| 5769 | |
| 5770 | fn = PCI_FUNC(ha->pdev->devfn); |
| 5771 | while (fn > 0) { |
| 5772 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5773 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 5774 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5775 | other_pdev = |
| 5776 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 5777 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 5778 | fn)); |
| 5779 | |
| 5780 | if (!other_pdev) |
| 5781 | continue; |
| 5782 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5783 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 5784 | "Found PCI func available and enable at 0x%x.\n", |
| 5785 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5786 | pci_dev_put(other_pdev); |
| 5787 | break; |
| 5788 | } |
| 5789 | pci_dev_put(other_pdev); |
| 5790 | } |
| 5791 | |
| 5792 | if (!fn) { |
| 5793 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5794 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 5795 | "This devfn is reset owner = 0x%x.\n", |
| 5796 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5797 | qla82xx_idc_lock(ha); |
| 5798 | |
| 5799 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5800 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5801 | |
| 5802 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 5803 | QLA82XX_IDC_VERSION); |
| 5804 | |
| 5805 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5806 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 5807 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5808 | |
| 5809 | qla82xx_idc_unlock(ha); |
| 5810 | /* Reset if device is not already reset |
| 5811 | * drv_active would be 0 if a reset has already been done |
| 5812 | */ |
| 5813 | if (drv_active) |
| 5814 | rval = qla82xx_start_firmware(base_vha); |
| 5815 | else |
| 5816 | rval = QLA_SUCCESS; |
| 5817 | qla82xx_idc_lock(ha); |
| 5818 | |
| 5819 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5820 | ql_log(ql_log_info, base_vha, 0x900b, |
| 5821 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5822 | qla82xx_clear_drv_active(ha); |
| 5823 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5824 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5825 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5826 | ql_log(ql_log_info, base_vha, 0x900c, |
| 5827 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5828 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5829 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5830 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5831 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5832 | rval = qla82xx_restart_isp(base_vha); |
| 5833 | qla82xx_idc_lock(ha); |
| 5834 | /* Clear driver state register */ |
| 5835 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 5836 | qla82xx_set_drv_active(base_vha); |
| 5837 | } |
| 5838 | qla82xx_idc_unlock(ha); |
| 5839 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5840 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 5841 | "This devfn is not reset owner = 0x%x.\n", |
| 5842 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5843 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5844 | QLA8XXX_DEV_READY)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5845 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5846 | rval = qla82xx_restart_isp(base_vha); |
| 5847 | qla82xx_idc_lock(ha); |
| 5848 | qla82xx_set_drv_active(base_vha); |
| 5849 | qla82xx_idc_unlock(ha); |
| 5850 | } |
| 5851 | } |
| 5852 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5853 | |
| 5854 | return rval; |
| 5855 | } |
| 5856 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5857 | static pci_ers_result_t |
| 5858 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 5859 | { |
| 5860 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5861 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5862 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5863 | struct rsp_que *rsp; |
| 5864 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5865 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5866 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 5867 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5868 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5869 | /* Workaround: qla2xxx driver which access hardware earlier |
| 5870 | * needs error state to be pci_channel_io_online. |
| 5871 | * Otherwise mailbox command timesout. |
| 5872 | */ |
| 5873 | pdev->error_state = pci_channel_io_normal; |
| 5874 | |
| 5875 | pci_restore_state(pdev); |
| 5876 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 5877 | /* pci_restore_state() clears the saved_state flag of the device |
| 5878 | * save restored state which resets saved_state flag |
| 5879 | */ |
| 5880 | pci_save_state(pdev); |
| 5881 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 5882 | if (ha->mem_only) |
| 5883 | rc = pci_enable_device_mem(pdev); |
| 5884 | else |
| 5885 | rc = pci_enable_device(pdev); |
| 5886 | |
| 5887 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5888 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5889 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5890 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5891 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5892 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5893 | rsp = ha->rsp_q_map[0]; |
| 5894 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5895 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5896 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5897 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5898 | goto exit_slot_reset; |
| 5899 | |
| 5900 | if (IS_QLA82XX(ha)) { |
| 5901 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 5902 | ret = PCI_ERS_RESULT_RECOVERED; |
| 5903 | goto exit_slot_reset; |
| 5904 | } else |
| 5905 | goto exit_slot_reset; |
| 5906 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5907 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5908 | while (ha->flags.mbox_busy && retries--) |
| 5909 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5910 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5911 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5912 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5913 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5914 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5915 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5916 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5917 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5918 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 5919 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5920 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5921 | return ret; |
| 5922 | } |
| 5923 | |
| 5924 | static void |
| 5925 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 5926 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5927 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5928 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5929 | int ret; |
| 5930 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5931 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 5932 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5933 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5934 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5935 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5936 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 5937 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5938 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5939 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 5940 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 5941 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5942 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5943 | } |
| 5944 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 5945 | static void |
| 5946 | qla83xx_disable_laser(scsi_qla_host_t *vha) |
| 5947 | { |
| 5948 | uint32_t reg, data, fn; |
| 5949 | struct qla_hw_data *ha = vha->hw; |
| 5950 | struct device_reg_24xx __iomem *isp_reg = &ha->iobase->isp24; |
| 5951 | |
| 5952 | /* pci func #/port # */ |
| 5953 | ql_dbg(ql_dbg_init, vha, 0x004b, |
| 5954 | "Disabling Laser for hba: %p\n", vha); |
| 5955 | |
| 5956 | fn = (RD_REG_DWORD(&isp_reg->ctrl_status) & |
| 5957 | (BIT_15|BIT_14|BIT_13|BIT_12)); |
| 5958 | |
| 5959 | fn = (fn >> 12); |
| 5960 | |
| 5961 | if (fn & 1) |
| 5962 | reg = PORT_1_2031; |
| 5963 | else |
| 5964 | reg = PORT_0_2031; |
| 5965 | |
| 5966 | data = LASER_OFF_2031; |
| 5967 | |
| 5968 | qla83xx_wr_reg(vha, reg, data); |
| 5969 | } |
| 5970 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 5971 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5972 | .error_detected = qla2xxx_pci_error_detected, |
| 5973 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 5974 | .slot_reset = qla2xxx_pci_slot_reset, |
| 5975 | .resume = qla2xxx_pci_resume, |
| 5976 | }; |
| 5977 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5978 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5979 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 5980 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 5981 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 5982 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 5983 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 5984 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 5985 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 5986 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 5987 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5988 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5989 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 5990 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5991 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5992 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5993 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5994 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 5995 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5996 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISPF001) }, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5997 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8044) }, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5998 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2071) }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5999 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2271) }, |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 6000 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2261) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6001 | { 0 }, |
| 6002 | }; |
| 6003 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 6004 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6005 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 6006 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 6007 | .driver = { |
| 6008 | .owner = THIS_MODULE, |
| 6009 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6010 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6011 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 6012 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 6013 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6014 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6015 | }; |
| 6016 | |
Al Viro | 75ef9de | 2013-04-04 19:09:41 -0400 | [diff] [blame] | 6017 | static const struct file_operations apidev_fops = { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6018 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 6019 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6020 | }; |
| 6021 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6022 | /** |
| 6023 | * qla2x00_module_init - Module initialization. |
| 6024 | **/ |
| 6025 | static int __init |
| 6026 | qla2x00_module_init(void) |
| 6027 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6028 | int ret = 0; |
| 6029 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6030 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6031 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 6032 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6033 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6034 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 6035 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6036 | return -ENOMEM; |
| 6037 | } |
| 6038 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6039 | /* Initialize target kmem_cache and mem_pools */ |
| 6040 | ret = qlt_init(); |
| 6041 | if (ret < 0) { |
| 6042 | kmem_cache_destroy(srb_cachep); |
| 6043 | return ret; |
| 6044 | } else if (ret > 0) { |
| 6045 | /* |
| 6046 | * If initiator mode is explictly disabled by qlt_init(), |
| 6047 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 6048 | * performing scsi_scan_target() during LOOP UP event. |
| 6049 | */ |
| 6050 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 6051 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 6052 | } |
| 6053 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6054 | /* Derive version string. */ |
| 6055 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 6056 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 6057 | strcat(qla2x00_version_str, "-debug"); |
| 6058 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 6059 | qla2xxx_transport_template = |
| 6060 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6061 | if (!qla2xxx_transport_template) { |
| 6062 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6063 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 6064 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6065 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6066 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6067 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6068 | |
| 6069 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 6070 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6071 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 6072 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6073 | } |
| 6074 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6075 | qla2xxx_transport_vport_template = |
| 6076 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 6077 | if (!qla2xxx_transport_vport_template) { |
| 6078 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6079 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6080 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6081 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 6082 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6083 | return -ENODEV; |
| 6084 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6085 | ql_log(ql_log_info, NULL, 0x0005, |
| 6086 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 6087 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6088 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6089 | if (ret) { |
| 6090 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6091 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6092 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6093 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6094 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 6095 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 6096 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6097 | } |
| 6098 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6099 | } |
| 6100 | |
| 6101 | /** |
| 6102 | * qla2x00_module_exit - Module cleanup. |
| 6103 | **/ |
| 6104 | static void __exit |
| 6105 | qla2x00_module_exit(void) |
| 6106 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6107 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6108 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6109 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6110 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6111 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6112 | if (ctx_cachep) |
| 6113 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6114 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6115 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6116 | } |
| 6117 | |
| 6118 | module_init(qla2x00_module_init); |
| 6119 | module_exit(qla2x00_module_exit); |
| 6120 | |
| 6121 | MODULE_AUTHOR("QLogic Corporation"); |
| 6122 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 6123 | MODULE_LICENSE("GPL"); |
| 6124 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6125 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 6126 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 6127 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 6128 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 6129 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 6130 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |